2013-06-22 09:24:24 +03:00
|
|
|
'use strict';
|
2013-06-25 02:41:59 +03:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'marionette',
|
|
|
|
'Episode/Summary/View',
|
|
|
|
'Episode/Search/Layout',
|
|
|
|
'Release/Collection',
|
|
|
|
'Shared/SpinnerView'
|
|
|
|
], function (Marionette, SummaryView, SearchLayout, ReleaseCollection, SpinnerView) {
|
2013-05-15 04:17:24 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
return Marionette.Layout.extend({
|
|
|
|
template: 'Episode/LayoutTemplate',
|
2013-05-21 03:17:33 +03:00
|
|
|
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
regions: {
|
|
|
|
summary : '#episode-summary',
|
|
|
|
activity: '#episode-activity',
|
|
|
|
search : '#episode-search'
|
|
|
|
},
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
ui: {
|
|
|
|
summary : '.x-episode-summary',
|
|
|
|
activity: '.x-episode-activity',
|
|
|
|
search : '.x-episode-search'
|
|
|
|
},
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
events: {
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
'click .x-episode-summary' : 'showSummary',
|
|
|
|
'click .x-episode-activity': 'showActivity',
|
|
|
|
'click .x-episode-search' : 'showSearch'
|
|
|
|
},
|
2013-05-21 03:17:33 +03:00
|
|
|
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
onShow: function () {
|
|
|
|
this.showSummary();
|
|
|
|
this._releaseSearchActivated = false;
|
|
|
|
},
|
2013-05-21 03:17:33 +03:00
|
|
|
|
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
showSummary: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
this.ui.summary.tab('show');
|
|
|
|
this.summary.show(new SummaryView({model: this.model}));
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
},
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
showActivity: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
this.ui.activity.tab('show');
|
|
|
|
},
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
showSearch: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
2013-05-21 03:17:33 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
if (this._releaseSearchActivated) {
|
|
|
|
return;
|
|
|
|
}
|
2013-06-07 03:17:57 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
var self = this;
|
2013-06-07 03:17:57 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
this.ui.search.tab('show');
|
|
|
|
this.search.show(new SpinnerView());
|
2013-06-07 03:17:57 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
var releases = new ReleaseCollection();
|
|
|
|
var promise = releases.fetchEpisodeReleases(this.model.id);
|
2013-06-07 03:17:57 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
promise.done(function () {
|
|
|
|
if (!self.isClosed) {
|
|
|
|
self.search.show(new SearchLayout({collection: releases}));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-05-15 04:17:24 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
});
|
2013-05-15 04:17:24 +03:00
|
|
|
|
2013-06-25 02:41:59 +03:00
|
|
|
});
|