1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 02:07:41 +00:00

Added a second "master" toggle to ignoreSeason on Series/Details at the top of the page.

This commit is contained in:
Mark McDowall 2011-08-19 20:02:47 -07:00
parent bf17b63d2b
commit 56da830296
3 changed files with 136 additions and 62 deletions

View file

@ -19,14 +19,16 @@ $(".ignoreEpisode").live("click", function () {
} }
var seasonNumber = 0; var seasonNumber = 0;
//Flip the ignored to the new state (We want the new value moving forward) //Flip the ignored to the new state (We want the new value moving forward)
ignored = !ignored; ignored = !ignored;
if (toggle.hasClass('ignoredEpisodesMaster')) { if (toggle.hasClass('ignoredEpisodesMaster')) {
seasonNumber = toggle.attr('id').replace('master_', ''); //seasonNumber = toggle.attr('id').replace('master_', '');
seasonNumber = toggle.attr('class').split(/\s+/)[2].replace('ignoreSeason_', '');
toggleChildren(seasonNumber, ignored); toggleChildren(seasonNumber, ignored);
toggleMasters(seasonNumber, ignored);
saveSeasonIgnore(seasonNumber, ignored); saveSeasonIgnore(seasonNumber, ignored);
} }
@ -60,16 +62,36 @@ function toggleChildren(seasonNumber, ignored) {
function toggleMaster(seasonNumber) { function toggleMaster(seasonNumber) {
var ignoreEpisodes = $('.ignoreEpisode_' + seasonNumber); var ignoreEpisodes = $('.ignoreEpisode_' + seasonNumber);
var ignoredCount = ignoreEpisodes.filter('.ignored').length; var ignoredCount = ignoreEpisodes.filter('.ignored').length;
var master = $('#master_' + seasonNumber); var masters = $('.ignoreSeason_' + seasonNumber);
if (ignoreEpisodes.length == ignoredCount) { masters.each(function (index) {
master.attr('src', ignoredImage); if (ignoreEpisodes.length == ignoredCount) {
master.addClass('ignored'); $(this).attr('src', ignoredImage);
$(this).addClass('ignored');
}
else {
$(this).attr('src', notIgnoredImage);
$(this).removeClass('ignored');
}
});
}
function toggleMasters(seasonNumber, ignored) {
var masters = $('.ignoreSeason_' + seasonNumber);
if (ignored) {
masters.each(function (index) {
$(this).addClass('ignored');
$(this).attr('src', ignoredImage);
});
} }
else { else {
master.attr('src', notIgnoredImage); masters.each(function (index) {
master.removeClass('ignored'); $(this).removeClass('ignored');
$(this).attr('src', notIgnoredImage);
});
} }
} }
@ -89,28 +111,16 @@ function grid_rowBound(e) {
ignoredIcon.attr('src', notIgnoredImage); ignoredIcon.attr('src', notIgnoredImage);
ignoredIcon.removeClass('ignored'); ignoredIcon.removeClass('ignored');
} }
if (seriesId == 0) if (seriesId == 0)
seriesId = dataItem.SeriesId seriesId = dataItem.SeriesId;
} }
function grid_dataBound(e) { function grid_dataBound(e) {
var id = $(this).attr('id'); var id = $(this).attr('id');
var seasonNumber = id.replace('seasons_', ''); var seasonNumber = id.replace('seasons_', '');
var ignoreEpisodes = $('.ignoreEpisode_' + seasonNumber);
var master = $('#master_' + seasonNumber);
var count = ignoreEpisodes.length;
var ignoredCount = ignoreEpisodes.filter('.ignored').length;
if (ignoredCount == count) { toggleMaster(seasonNumber);
master.attr('src', ignoredImage);
master.addClass('ignored');
}
else {
master.attr('src', notIgnoredImage);
master.removeClass('ignored');
}
} }
function saveSeasonIgnore(seasonNumber, ignored) { function saveSeasonIgnore(seasonNumber, ignored) {

View file

@ -22,6 +22,45 @@
padding-left: 18px; padding-left: 18px;
padding-right: -18px; padding-right: -18px;
} }
.seasonToggleTopGroup
{
overflow: hidden;
width: 50%;
}
.seasonToggleTop
{
@*float: left;
border-width: 1px;
border-style: solid;
border-color: grey;
margin: 5px;
padding: 3px;
padding-top: 0px;
padding-bottom: 0px;*@
background-color: #F1EDED;
background-position: 5px center;
background-repeat: no-repeat;
display: inline-block;
font-size: 15px;
margin: 2px;
padding: 2px 5px;
width: 95px;
}
.seasonToggleLabel
{
margin-left: 5px;
}
.seasonToggleTop .ignoredEpisodesMaster
{
padding-left: 0px;
padding-right: 0px;
margin-bottom: -4px;
}
</style> </style>
@section ActionMenu{ @section ActionMenu{
@ -33,6 +72,18 @@
</ul> </ul>
} }
@section MainContent{ @section MainContent{
<div class="seasonToggleTopGroup">
@foreach (var season in Model.Seasons)
{
var ignoreSeason = "ignoreSeason_" + season;
<div class="seasonToggleTop">
<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode @ignoreSeason' />
<span class="seasonToggleLabel">@(season == 0 ? "Specials" : "Season " + season)</span>
</div>
}
</div>
@foreach (var season in Model.Seasons.Where(s => s > 0).Reverse()) @foreach (var season in Model.Seasons.Where(s => s > 0).Reverse())
{ {
<h3> <h3>
@ -42,24 +93,24 @@
Html.Telerik().Grid<EpisodeModel>().Name("seasons_" + season) Html.Telerik().Grid<EpisodeModel>().Name("seasons_" + season)
.TableHtmlAttributes(new { @class = "Grid" }) .TableHtmlAttributes(new { @class = "Grid" })
.Columns(columns => .Columns(columns =>
{ {
columns.Bound(o => o.Ignored) columns.Bound(o => o.Ignored)
.Title("<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode' id='master_" + season + "' />") .Title("<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode ignoreSeason_" + season + "'/>")
.ClientTemplate( .ClientTemplate(
"<img src='../../Content/Images/ignoredNeutral.png' class='ignoreEpisode ignoreEpisode_" + season + " ignored' id='<#= EpisodeId #>' />") "<img src='../../Content/Images/ignoredNeutral.png' class='ignoreEpisode ignoreEpisode_" + season + " ignored' id='<#= EpisodeId #>' />")
.Width(20) .Width(20)
.HtmlAttributes(new { style = "text-align:center" }); .HtmlAttributes(new { style = "text-align:center" });
columns.Bound(c => c.EpisodeNumber).Width(0).Title("Episode"); columns.Bound(c => c.EpisodeNumber).Width(0).Title("Episode");
columns.Bound(c => c.Title).Title("Title"); columns.Bound(c => c.Title).Title("Title");
columns.Bound(c => c.AirDate).Width(0); columns.Bound(c => c.AirDate).Width(0);
columns.Bound(c => c.Quality).Width(0); columns.Bound(c => c.Quality).Width(0);
columns.Bound(c => c.Status).Width(0); columns.Bound(c => c.Status).Width(0);
columns.Bound(o => o.EpisodeId).Title("") columns.Bound(o => o.EpisodeId).Title("")
.ClientTemplate("<a href='#Search' onClick=\"searchForEpisode('<#= EpisodeId #>'); return false;\">Search</a>" .ClientTemplate("<a href='#Search' onClick=\"searchForEpisode('<#= EpisodeId #>'); return false;\">Search</a>"
+ " | " + + " | " +
"<a href='#Rename' onClick=\"renameEpisode('<#= EpisodeFileId #>'); return false;\">Rename</a>"); "<a href='#Rename' onClick=\"renameEpisode('<#= EpisodeFileId #>'); return false;\">Rename</a>");
}) })
.DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #> </br><#= Path #> </div>")) .DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #> </br><#= Path #> </div>"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.EpisodeNumber).Descending()).Enabled(false)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.EpisodeNumber).Descending()).Enabled(false))
.Footer(true) .Footer(true)
@ -72,10 +123,10 @@
c.Custom().Text("Rename Season").Action("RenameSeason", "Series", new { seasonId = season }) c.Custom().Text("Rename Season").Action("RenameSeason", "Series", new { seasonId = season })
.ButtonType(GridButtonType.Text)) .ButtonType(GridButtonType.Text))
.ClientEvents(clientEvents => .ClientEvents(clientEvents =>
{ {
clientEvents.OnRowDataBound("grid_rowBound"); clientEvents.OnRowDataBound("grid_rowBound");
clientEvents.OnDataBound("grid_dataBound"); clientEvents.OnDataBound("grid_dataBound");
}) })
.Render();} .Render();}
</div> </div>
} }
@ -85,31 +136,36 @@
<h3> <h3>
Specials</h3> Specials</h3>
<div class="grid-container"> <div class="grid-container">
@{Html.Telerik().Grid<EpisodeModel>().Name("seasons_specials") @{Html.Telerik().Grid<EpisodeModel>().Name("seasons_0")
.TableHtmlAttributes(new { @class = "Grid" }) .TableHtmlAttributes(new { @class = "Grid" })
.Columns(columns => .Columns(columns =>
{ {
columns.Bound(o => o.Ignored) columns.Bound(o => o.Ignored)
.Title("<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode' id='master_0' />") .Title("<img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode ignoreSeason_0' />")
.ClientTemplate( .ClientTemplate(
"<img src='../../Content/Images/ignoredNeutral.png' class='ignoreEpisode ignoreEpisode_0 ignored' id='<#= EpisodeId #>' />") "<img src='../../Content/Images/ignoredNeutral.png' class='ignoreEpisode ignoreEpisode_0 ignored' id='<#= EpisodeId #>' />")
.Width(20) .Width(20)
.HtmlAttributes(new { style = "text-align:center" }); .HtmlAttributes(new { style = "text-align:center" });
columns.Bound(c => c.EpisodeNumber).Width(10).Title("Episode"); columns.Bound(c => c.EpisodeNumber).Width(10).Title("Episode");
columns.Bound(c => c.Title).Title("Title").Width(10000); columns.Bound(c => c.Title).Title("Title").Width(10000);
columns.Bound(c => c.AirDate).Width(10); columns.Bound(c => c.AirDate).Width(10);
columns.Bound(c => c.Quality).Width(10); columns.Bound(c => c.Quality).Width(10);
columns.Bound(c => c.Status).Width(10); columns.Bound(c => c.Status).Width(10);
}) })
.DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #> </br><#= Path #> </div>")) .DetailView(detailView => detailView.ClientTemplate("<div><#= Overview #> </br><#= Path #> </div>"))
.Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.EpisodeNumber).Descending()).Enabled(false)) .Sortable(rows => rows.OrderBy(epSort => epSort.Add(c => c.EpisodeNumber).Descending()).Enabled(false))
.Footer(true) .Footer(true)
.DataBinding( .DataBinding(
d => d =>
d.Ajax().Select("_AjaxSeasonGrid", "Series", d.Ajax().Select("_AjaxSeasonGrid", "Series",
new RouteValueDictionary { { "seriesId", Model.SeriesId }, { "seasonNumber", 0 } } new RouteValueDictionary { { "seriesId", Model.SeriesId }, { "seasonNumber", 0 } }))
)).Render(); } .ClientEvents(clientEvents =>
{
clientEvents.OnRowDataBound("grid_rowBound");
clientEvents.OnDataBound("grid_dataBound");
})
.Render(); }
</div> </div>
} }
} }

View file

@ -1 +1,9 @@
 <img src='../../Content/Images/ignoredNeutral.png' class='ignoredEpisodesMaster ignoreEpisode' id='master' value='10'/>
<script>
$(".ignoreEpisode").live("click", function () {
var toggle = $(this);
var value = $(this).attr('value');
var test = 0;
});
</script>