You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
115 lines
3.6 KiB
115 lines
3.6 KiB
12 years ago
|
'use strict';
|
||
12 years ago
|
define(
|
||
|
[
|
||
|
'marionette',
|
||
11 years ago
|
'Episode/Summary/EpisodeSummaryLayout',
|
||
11 years ago
|
'Episode/Search/EpisodeSearchLayout',
|
||
11 years ago
|
'Series/SeriesCollection'
|
||
|
], function (Marionette, SummaryLayout, SearchLayout, SeriesCollection) {
|
||
12 years ago
|
|
||
12 years ago
|
return Marionette.Layout.extend({
|
||
11 years ago
|
template: 'Episode/EpisodeDetailsLayoutTemplate',
|
||
12 years ago
|
|
||
12 years ago
|
regions: {
|
||
|
summary : '#episode-summary',
|
||
|
activity: '#episode-activity',
|
||
|
search : '#episode-search'
|
||
|
},
|
||
12 years ago
|
|
||
12 years ago
|
ui: {
|
||
11 years ago
|
summary : '.x-episode-summary',
|
||
|
activity : '.x-episode-activity',
|
||
|
search : '.x-episode-search',
|
||
|
monitored: '.x-episode-monitored'
|
||
12 years ago
|
},
|
||
12 years ago
|
|
||
12 years ago
|
events: {
|
||
12 years ago
|
|
||
11 years ago
|
'click .x-episode-summary' : '_showSummary',
|
||
|
'click .x-episode-activity' : '_showActivity',
|
||
|
'click .x-episode-search' : '_showSearch',
|
||
|
'click .x-episode-monitored': '_toggleMonitored'
|
||
12 years ago
|
},
|
||
12 years ago
|
|
||
11 years ago
|
templateHelpers: {},
|
||
|
|
||
|
initialize: function (options) {
|
||
|
this.templateHelpers.hideSeriesLink = options.hideSeriesLink;
|
||
|
|
||
11 years ago
|
this.series = SeriesCollection.find({ id: this.model.get('seriesId') });
|
||
|
this.templateHelpers.series = this.series.toJSON();
|
||
11 years ago
|
this.openingTab = options.openingTab || 'summary'
|
||
11 years ago
|
},
|
||
|
|
||
12 years ago
|
onShow: function () {
|
||
12 years ago
|
this.searchLayout = new SearchLayout({ model: this.model });
|
||
11 years ago
|
|
||
|
if (this.openingTab === 'search') {
|
||
|
this.searchLayout.startManualSearch = true;
|
||
|
this._showSearch();
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
this._showSummary();
|
||
|
}
|
||
|
|
||
11 years ago
|
this._setMonitoredState();
|
||
12 years ago
|
},
|
||
12 years ago
|
|
||
12 years ago
|
_showSummary: function (e) {
|
||
12 years ago
|
if (e) {
|
||
|
e.preventDefault();
|
||
|
}
|
||
12 years ago
|
|
||
12 years ago
|
this.ui.summary.tab('show');
|
||
11 years ago
|
this.summary.show(new SummaryLayout({model: this.model, series: this.series}));
|
||
12 years ago
|
},
|
||
12 years ago
|
|
||
12 years ago
|
_showActivity: function (e) {
|
||
12 years ago
|
if (e) {
|
||
|
e.preventDefault();
|
||
|
}
|
||
12 years ago
|
|
||
12 years ago
|
this.ui.activity.tab('show');
|
||
|
},
|
||
12 years ago
|
|
||
12 years ago
|
_showSearch: function (e) {
|
||
12 years ago
|
if (e) {
|
||
|
e.preventDefault();
|
||
|
}
|
||
12 years ago
|
|
||
12 years ago
|
this.ui.search.tab('show');
|
||
12 years ago
|
this.search.show(this.searchLayout);
|
||
11 years ago
|
},
|
||
|
|
||
|
_toggleMonitored: function () {
|
||
|
var self = this;
|
||
|
var name = 'monitored';
|
||
|
this.model.set(name, !this.model.get(name), { silent: true });
|
||
|
|
||
|
this.ui.monitored.addClass('icon-spinner icon-spin');
|
||
|
|
||
|
var promise = this.model.save();
|
||
|
|
||
|
promise.always(function () {
|
||
|
self._setMonitoredState();
|
||
|
});
|
||
|
},
|
||
|
|
||
|
_setMonitoredState: function () {
|
||
|
var monitored = this.model.get('monitored');
|
||
|
|
||
|
this.ui.monitored.removeClass('icon-spin icon-spinner');
|
||
|
|
||
|
if (this.model.get('monitored')) {
|
||
|
this.ui.monitored.addClass('icon-bookmark');
|
||
|
this.ui.monitored.removeClass('icon-bookmark-empty');
|
||
|
}
|
||
|
else {
|
||
|
this.ui.monitored.addClass('icon-bookmark-empty');
|
||
|
this.ui.monitored.removeClass('icon-bookmark');
|
||
|
}
|
||
12 years ago
|
}
|
||
|
});
|
||
|
});
|