Moved source code under src folder - massive change

This commit is contained in:
Mark McDowall 2013-10-02 18:01:32 -07:00
commit 5bf0e197ec
1499 changed files with 1054 additions and 1444 deletions

View file

@ -0,0 +1,33 @@
'use strict';
define(
[
'marionette',
'Series/SeriesCollection',
'Series/SeasonCollection',
'SeasonPass/SeriesCollectionView',
'Shared/LoadingView'
], function (Marionette,
SeriesCollection,
SeasonCollection,
SeriesCollectionView,
LoadingView) {
return Marionette.Layout.extend({
template: 'SeasonPass/SeasonPassLayoutTemplate',
regions: {
series: '#x-series'
},
onShow: function () {
var self = this;
this.series.show(new LoadingView());
this.seriesCollection = SeriesCollection;
self.series.show(new SeriesCollectionView({
collection: self.seriesCollection
}));
}
});
});

View file

@ -0,0 +1,11 @@
<div class="row">
<div class="span12">
<div class="alert alert-info">Season Pass allows you to quickly change the monitored status of seasons for all your series in one place</div>
</div>
</div>
<div class="row">
<div class="span12">
<div id="x-series"></div>
</div>
</div>

View file

@ -0,0 +1,10 @@
'use strict';
define(
[
'marionette',
'SeasonPass/SeriesLayout'
], function (Marionette, SeriesLayout) {
return Marionette.CollectionView.extend({
itemView: SeriesLayout
});
});

View file

@ -0,0 +1,158 @@
'use strict';
define(
[
'underscore',
'marionette',
'backgrid',
'Series/SeasonCollection'
], function (_, Marionette, Backgrid, SeasonCollection) {
return Marionette.Layout.extend({
template: 'SeasonPass/SeriesLayoutTemplate',
ui: {
seasonSelect : '.x-season-select',
expander : '.x-expander',
seasonGrid : '.x-season-grid',
seriesMonitored: '.x-series-monitored'
},
events: {
'change .x-season-select' : '_seasonSelected',
'click .x-expander' : '_expand',
'click .x-latest' : '_latest',
'click .x-all' : '_all',
'click .x-monitored' : '_toggleSeasonMonitored',
'click .x-series-monitored': '_toggleSeriesMonitored'
},
regions: {
seasonGrid: '.x-season-grid'
},
initialize: function () {
this.listenTo(this.model, 'sync', this._setSeriesMonitoredState);
this.seasonCollection = new SeasonCollection(this.model.get('seasons'));
this.expanded = false;
},
onRender: function () {
if (!this.expanded) {
this.ui.seasonGrid.hide();
}
this._setExpanderIcon();
this._setSeriesMonitoredState();
},
_seasonSelected: function () {
var seasonNumber = parseInt(this.ui.seasonSelect.val());
if (seasonNumber === -1 || isNaN(seasonNumber)) {
return;
}
this._setSeasonMonitored(seasonNumber);
},
_expand: function () {
if (this.expanded) {
this.ui.seasonGrid.slideUp();
this.expanded = false;
}
else {
this.ui.seasonGrid.slideDown();
this.expanded = true;
}
this._setExpanderIcon();
},
_setExpanderIcon: function () {
if (this.expanded) {
this.ui.expander.removeClass('icon-chevron-right');
this.ui.expander.addClass('icon-chevron-down');
}
else {
this.ui.expander.removeClass('icon-chevron-down');
this.ui.expander.addClass('icon-chevron-right');
}
},
_latest: function () {
var season = _.max(this.model.get('seasons'), function (s) {
return s.seasonNumber;
});
this._setSeasonMonitored(season.seasonNumber);
},
_all: function () {
var minSeasonNotZero = _.min(_.reject(this.model.get('seasons'), { seasonNumber: 0 }), 'seasonNumber');
this._setSeasonMonitored(minSeasonNotZero.seasonNumber);
},
_setSeasonMonitored: function (seasonNumber) {
var self = this;
this.model.setSeasonPass(seasonNumber);
var promise = this.model.save();
promise.done(function (data) {
self.seasonCollection = new SeasonCollection(data);
self.render();
});
},
_toggleSeasonMonitored: function (e) {
var seasonNumber = 0;
var element;
if (e.target.localName === 'i') {
seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'));
element = $(e.target);
}
else {
seasonNumber = parseInt($(e.target).attr('data-season-number'));
element = $(e.target).children('i');
}
this.model.setSeasonMonitored(seasonNumber);
var savePromise =this.model.save()
.always(this.render.bind(this));
element.spinForPromise(savePromise);
},
_afterToggleSeasonMonitored: function () {
this.render();
},
_setSeriesMonitoredState: function () {
var monitored = this.model.get('monitored');
this.ui.seriesMonitored.removeAttr('data-idle-icon');
if (monitored) {
this.ui.seriesMonitored.addClass('icon-nd-monitored');
this.ui.seriesMonitored.removeClass('icon-nd-unmonitored');
}
else {
this.ui.seriesMonitored.addClass('icon-nd-unmonitored');
this.ui.seriesMonitored.removeClass('icon-nd-monitored');
}
},
_toggleSeriesMonitored: function (e) {
var savePromise = this.model.save('monitored', !this.model.get('monitored'), {
wait: true
});
this.ui.seriesMonitored.spinForPromise(savePromise);
}
});
});

View file

@ -0,0 +1,81 @@
<div class="seasonpass-series">
<div class="row">
<div class="span12">
<i class="icon-chevron-right x-expander expander pull-left"/>
<i class="x-series-monitored series-monitor-toggle pull-left" title="Toggle monitored state for entire series"/>
<span class="title span5">
<a href="{{route}}">
{{title}}
</a>
</span>
<span class="span3">
<select class="x-season-select season-select">
<option value="-1">Select season...</option>
{{#each seasons}}
{{#if_eq seasonNumber compare="0"}}
<option value="{{seasonNumber}}">Specials</option>
{{else}}
<option value="{{seasonNumber}}">Season {{seasonNumber}}</option>
{{/if_eq}}
{{/each}}
</select>
<span class="help-inline">
<i class="icon-question-sign" title="Selecting a season will unmonitor all previous seasons"/>
</span>
</span>
<span class="season-pass-button">
<button class="btn x-latest">Latest</button>
<span class="help-inline">
<i class="icon-question-sign" title="Will quickly select the latest season as first monitored"/>
</span>
</span>
<span class="season-pass-button">
<button class="btn x-all">All</button>
<span class="help-inline">
<i class="icon-question-sign" title="Will quickly select all seasons except for specials to be monitored"/>
</span>
</span>
</div>
</div>
<div class="row">
<div class="span11">
<div class="x-season-grid season-grid">
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th class="sortable">Season</th>
</tr>
</thead>
<tbody>
{{#each seasons}}
<tr>
<td class="toggle-cell x-monitored" data-season-number="{{seasonNumber}}">
{{#if monitored}}
<i class="icon-nd-monitored"></i>
{{else}}
<i class="icon-nd-unmonitored"></i>
{{/if}}
</td>
<td>
{{#if_eq seasonNumber compare="0"}}
Specials
{{else}}
Season {{seasonNumber}}
{{/if_eq}}
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
</div>
</div>