From 4bcd5ce5c6aa1adb8b626b1e95bacf933a3c4830 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Wed, 4 Sep 2013 22:01:22 -0700 Subject: [PATCH] Removed season menu in favour of minimizing seasons --- UI/Content/theme.less | 4 +- UI/Series/Details/SeasonLayout.js | 76 +++++++++++++--- UI/Series/Details/SeasonLayoutTemplate.html | 13 ++- .../Details/SeasonMenu/CollectionView.js | 31 ------- UI/Series/Details/SeasonMenu/ItemView.js | 88 ------------------- .../Details/SeasonMenu/ItemViewTemplate.html | 14 --- UI/Series/Details/SeriesDetailsLayout.js | 8 -- UI/Series/Details/SeriesDetailsTemplate.html | 3 - UI/Series/Index/EpisodeProgressPartial.html | 6 +- UI/Series/series.less | 26 ++---- 10 files changed, 91 insertions(+), 178 deletions(-) delete mode 100644 UI/Series/Details/SeasonMenu/CollectionView.js delete mode 100644 UI/Series/Details/SeasonMenu/ItemView.js delete mode 100644 UI/Series/Details/SeasonMenu/ItemViewTemplate.html diff --git a/UI/Content/theme.less b/UI/Content/theme.less index 4c8c3a1e8..5e94c3bd3 100644 --- a/UI/Content/theme.less +++ b/UI/Content/theme.less @@ -12,7 +12,7 @@ @import "../Shared/Styles/clickable"; @import "../Shared/Styles/card"; -.progress { +.progress.episode-progress { width : 125px; position : relative; margin-bottom : 2px; @@ -21,6 +21,7 @@ font-size : 11.844px; font-weight : bold; text-align : center; + cursor : default; } .progressbar-back-text { @@ -33,6 +34,7 @@ display : block; width : 125px; } + .bar { position : absolute; overflow : hidden; diff --git a/UI/Series/Details/SeasonLayout.js b/UI/Series/Details/SeasonLayout.js index b5281541f..621223a98 100644 --- a/UI/Series/Details/SeasonLayout.js +++ b/UI/Series/Details/SeasonLayout.js @@ -8,8 +8,9 @@ define( 'Cells/EpisodeTitleCell', 'Cells/RelativeDateCell', 'Cells/EpisodeStatusCell', - 'Shared/Actioneer' - ], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, Actioneer) { + 'Shared/Actioneer', + 'moment' + ], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, Actioneer, Moment) { return Marionette.Layout.extend({ template: 'Series/Details/SeasonLayoutTemplate', @@ -20,13 +21,15 @@ define( }, events: { - 'click .x-season-search' : '_seasonSearch', - 'click .x-season-monitored': '_seasonMonitored', - 'click .x-season-rename' : '_seasonRename' + 'click .x-season-search' : '_seasonSearch', + 'click .x-season-monitored' : '_seasonMonitored', + 'click .x-season-rename' : '_seasonRename', + 'click .x-show-hide-episodes' : '_showHideEpisodes', + 'dblclick .series-season h2' : '_showHideEpisodes' }, regions: { - episodeGrid: '#x-episode-grid' + episodeGrid: '.x-episode-grid' }, columns: @@ -67,6 +70,8 @@ define( } ], + templateHelpers: {}, + initialize: function (options) { if (!options.episodeCollection) { @@ -76,6 +81,9 @@ define( this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber')); this.series = options.series; + this.showingEpisodes = this._shouldShowEpisodes(); + this.templateHelpers.showingEpisodes = this.showingEpisodes; + this.listenTo(this.model, 'sync', function () { this._afterSeasonMonitored(); }, this); @@ -86,11 +94,9 @@ define( }, onRender: function () { - this.episodeGrid.show(new Backgrid.Grid({ - columns : this.columns, - collection: this.episodeCollection, - className : 'table table-hover season-grid' - })); + if (this.showingEpisodes) { + this._showEpisodes(); + } this._setSeasonMonitoredState(); }, @@ -159,6 +165,54 @@ define( _afterRename: function () { App.vent.trigger(App.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') }); + }, + + _showEpisodes: function () { + this.episodeGrid.show(new Backgrid.Grid({ + columns : this.columns, + collection: this.episodeCollection, + className : 'table table-hover season-grid' + })); + }, + + _shouldShowEpisodes: function () { + var startDate = Moment().add('month', -1); + var endDate = Moment().add('year', 1); + + var result = this.episodeCollection.some(function(episode) { + + var airDate = episode.get('airDateUtc'); + + if (airDate) + { + var airDateMoment = Moment(airDate); + + if (airDateMoment.isAfter(startDate) && airDateMoment.isBefore(endDate)) { + return true; + } + } + + return false; + }); + + return result; + }, + + _showHideEpisodes: function () { + if (this.showingEpisodes) { + this.showingEpisodes = false; + this.episodeGrid.$el.slideUp(); + this.episodeGrid.close(); + } + + else { + this.showingEpisodes = true; + this._showEpisodes(); + this.episodeGrid.$el.slideDown(); + } + + this.templateHelpers.showingEpisodes = this.showingEpisodes; + this.render(); } }); }); diff --git a/UI/Series/Details/SeasonLayoutTemplate.html b/UI/Series/Details/SeasonLayoutTemplate.html index eb02bf938..372caf157 100644 --- a/UI/Series/Details/SeasonLayoutTemplate.html +++ b/UI/Series/Details/SeasonLayoutTemplate.html @@ -1,15 +1,26 @@ 

+ {{#if seasonNumber}} Season {{seasonNumber}} {{else}} Specials {{/if}} +

-
+
+
+

+ {{#if showingEpisodes}} +