1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-21 01:49:57 +02:00
Sonarr/UI/Episode/Search/Layout.js

79 lines
2.2 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03:00
'use strict';
define(
[
'app',
'marionette',
'Episode/Search/ButtonsView',
'Episode/Search/ManualLayout',
'Release/Collection',
'Series/SeriesCollection',
2013-09-11 09:33:47 +03:00
'Commands/CommandController',
'Shared/LoadingView'
], function (App, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Search/LayoutTemplate',
regions: {
main: '#episode-search-region'
},
2013-06-10 05:16:48 +03:00
events: {
'click .x-search-auto' : '_searchAuto',
'click .x-search-manual': '_searchManual',
'click .x-search-back' : '_showButtons'
},
initialize: function () {
this.mainView = new ButtonsView();
},
onShow: function () {
this._showMainView();
},
_searchAuto: function (e) {
if (e) {
e.preventDefault();
}
2013-09-11 09:33:47 +03:00
CommandController.Execute('episodeSearch', {
episodeId: this.model.get('id')
});
2013-07-24 04:15:58 +03:00
App.vent.trigger(App.Commands.CloseModalCommand);
},
_searchManual: function (e) {
if (e) {
e.preventDefault();
}
var self = this;
2013-08-22 07:04:03 +03:00
this.mainView = new LoadingView();
this._showMainView();
var releases = new ReleaseCollection();
var promise = releases.fetchEpisodeReleases(this.model.id);
promise.done(function () {
if (!self.isClosed) {
self.mainView = new ManualSearchLayout({collection: releases});
self._showMainView();
}
});
},
_showMainView: function () {
this.main.show(this.mainView);
},
_showButtons: function () {
this.mainView = new ButtonsView();
this._showMainView();
}
});
});