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.
85 lines
2.4 KiB
85 lines
2.4 KiB
12 years ago
|
'use strict';
|
||
12 years ago
|
define(
|
||
|
[
|
||
12 years ago
|
'app',
|
||
12 years ago
|
'marionette',
|
||
12 years ago
|
'Episode/Search/ButtonsView',
|
||
12 years ago
|
'Episode/Search/ManualLayout',
|
||
|
'Release/Collection',
|
||
11 years ago
|
'Series/SeriesCollection',
|
||
11 years ago
|
'Commands/CommandController',
|
||
|
'Shared/LoadingView'
|
||
|
], function (App, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
|
||
12 years ago
|
|
||
12 years ago
|
return Marionette.Layout.extend({
|
||
11 years ago
|
template: 'Episode/Search/EpisodeSearchLayoutTemplate',
|
||
12 years ago
|
|
||
12 years ago
|
regions: {
|
||
12 years ago
|
main: '#episode-search-region'
|
||
12 years ago
|
},
|
||
12 years ago
|
|
||
12 years ago
|
events: {
|
||
12 years ago
|
'click .x-search-auto' : '_searchAuto',
|
||
|
'click .x-search-manual': '_searchManual',
|
||
|
'click .x-search-back' : '_showButtons'
|
||
|
},
|
||
|
|
||
|
initialize: function () {
|
||
|
this.mainView = new ButtonsView();
|
||
12 years ago
|
},
|
||
12 years ago
|
|
||
|
onShow: function () {
|
||
11 years ago
|
if (this.startManualSearch) {
|
||
|
this._searchManual();
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
this._showMainView();
|
||
|
}
|
||
12 years ago
|
},
|
||
|
|
||
|
_searchAuto: function (e) {
|
||
|
if (e) {
|
||
|
e.preventDefault();
|
||
|
}
|
||
|
|
||
11 years ago
|
CommandController.Execute('episodeSearch', {
|
||
|
episodeId: this.model.get('id')
|
||
12 years ago
|
});
|
||
|
|
||
12 years ago
|
App.vent.trigger(App.Commands.CloseModalCommand);
|
||
12 years ago
|
},
|
||
|
|
||
|
_searchManual: function (e) {
|
||
|
if (e) {
|
||
|
e.preventDefault();
|
||
12 years ago
|
}
|
||
12 years ago
|
|
||
|
var self = this;
|
||
|
|
||
11 years ago
|
this.mainView = new LoadingView();
|
||
12 years ago
|
this._showMainView();
|
||
12 years ago
|
|
||
|
var releases = new ReleaseCollection();
|
||
|
var promise = releases.fetchEpisodeReleases(this.model.id);
|
||
|
|
||
|
promise.done(function () {
|
||
|
if (!self.isClosed) {
|
||
12 years ago
|
self.mainView = new ManualSearchLayout({collection: releases});
|
||
|
self._showMainView();
|
||
12 years ago
|
}
|
||
|
});
|
||
12 years ago
|
},
|
||
|
|
||
|
_showMainView: function () {
|
||
|
this.main.show(this.mainView);
|
||
|
},
|
||
|
|
||
|
_showButtons: function () {
|
||
|
this.mainView = new ButtonsView();
|
||
|
this._showMainView();
|
||
12 years ago
|
}
|
||
12 years ago
|
});
|
||
12 years ago
|
|
||
12 years ago
|
});
|