2013-06-25 01:41:59 +02:00
|
|
|
|
'use strict';
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'app',
|
|
|
|
|
'marionette',
|
|
|
|
|
'Settings/SettingsModel',
|
|
|
|
|
'Settings/General/GeneralSettingsModel',
|
2013-07-05 05:26:07 +02:00
|
|
|
|
'Settings/MediaManagement/Naming/Model',
|
|
|
|
|
'Settings/MediaManagement/Layout',
|
2013-06-25 01:41:59 +02:00
|
|
|
|
'Settings/Quality/QualityLayout',
|
|
|
|
|
'Settings/Indexers/CollectionView',
|
|
|
|
|
'Settings/Indexers/Collection',
|
2013-07-02 08:46:38 +02:00
|
|
|
|
'Settings/DownloadClient/Layout',
|
2013-06-25 01:41:59 +02:00
|
|
|
|
'Settings/Notifications/CollectionView',
|
|
|
|
|
'Settings/Notifications/Collection',
|
|
|
|
|
'Settings/General/GeneralView',
|
2013-07-02 08:46:38 +02:00
|
|
|
|
'Settings/Misc/MiscView',
|
|
|
|
|
'Shared/LoadingView'
|
|
|
|
|
], function (App,
|
|
|
|
|
Marionette,
|
|
|
|
|
SettingsModel,
|
|
|
|
|
GeneralSettingsModel,
|
|
|
|
|
NamingModel,
|
2013-07-05 05:26:07 +02:00
|
|
|
|
MediaManagementLayout,
|
2013-07-02 08:46:38 +02:00
|
|
|
|
QualityLayout,
|
|
|
|
|
IndexerCollectionView,
|
|
|
|
|
IndexerCollection,
|
|
|
|
|
DownloadClientLayout,
|
|
|
|
|
NotificationCollectionView,
|
|
|
|
|
NotificationCollection,
|
|
|
|
|
GeneralView,
|
|
|
|
|
MiscView,
|
|
|
|
|
LoadingView) {
|
2013-06-19 03:02:23 +02:00
|
|
|
|
return Marionette.Layout.extend({
|
2013-03-04 01:09:43 +01:00
|
|
|
|
template: 'Settings/SettingsLayoutTemplate',
|
|
|
|
|
|
|
|
|
|
regions: {
|
2013-07-05 05:26:07 +02:00
|
|
|
|
mediaManagement : '#media-management',
|
|
|
|
|
quality : '#quality',
|
|
|
|
|
indexers : '#indexers',
|
|
|
|
|
downloadClient : '#download-client',
|
|
|
|
|
notifications : '#notifications',
|
|
|
|
|
general : '#general',
|
|
|
|
|
misc : '#misc',
|
|
|
|
|
loading : '#loading-region'
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ui: {
|
2013-07-05 05:26:07 +02:00
|
|
|
|
mediaManagementTab : '.x-media-management-tab',
|
|
|
|
|
qualityTab : '.x-quality-tab',
|
|
|
|
|
indexersTab : '.x-indexers-tab',
|
|
|
|
|
downloadClientTab : '.x-download-client-tab',
|
|
|
|
|
notificationsTab : '.x-notifications-tab',
|
|
|
|
|
generalTab : '.x-general-tab',
|
|
|
|
|
miscTab : '.x-misc-tab'
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-07-05 05:26:07 +02:00
|
|
|
|
'click .x-media-management-tab' : '_showMediaManagement',
|
|
|
|
|
'click .x-quality-tab' : '_showQuality',
|
|
|
|
|
'click .x-indexers-tab' : '_showIndexers',
|
|
|
|
|
'click .x-download-client-tab' : '_showDownloadClient',
|
|
|
|
|
'click .x-notifications-tab' : '_showNotifications',
|
|
|
|
|
'click .x-general-tab' : '_showGeneral',
|
|
|
|
|
'click .x-misc-tab' : '_showMisc',
|
|
|
|
|
'click .x-save-settings' : '_save'
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showMediaManagement: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this.ui.mediaManagementTab.tab('show');
|
|
|
|
|
this._navigate('settings/mediamanagement');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showQuality: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.qualityTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/quality');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showIndexers: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.indexersTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/indexers');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showDownloadClient: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.downloadClientTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/downloadclient');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showNotifications: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.notificationsTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/notifications');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showGeneral: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-23 07:12:01 +02:00
|
|
|
|
this.ui.generalTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/general');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_showMisc: function (e) {
|
2013-03-04 01:09:43 +01:00
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.miscTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/misc');
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_navigate:function(route){
|
|
|
|
|
require(['Router'], function(){
|
|
|
|
|
App.Router.navigate(route);
|
|
|
|
|
});
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-04-19 01:14:08 +02:00
|
|
|
|
initialize: function (options) {
|
|
|
|
|
if (options.action) {
|
|
|
|
|
this.action = options.action.toLowerCase();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
2013-07-02 08:46:38 +02:00
|
|
|
|
this.loading.show(new LoadingView());
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
this.settings = new SettingsModel();
|
|
|
|
|
this.generalSettings = new GeneralSettingsModel();
|
|
|
|
|
this.namingSettings = new NamingModel();
|
|
|
|
|
this.indexerSettings = new IndexerCollection();
|
|
|
|
|
this.notificationSettings = new NotificationCollection();
|
|
|
|
|
|
|
|
|
|
$.when(this.settings.fetch(),
|
|
|
|
|
this.generalSettings.fetch(),
|
|
|
|
|
this.namingSettings.fetch(),
|
|
|
|
|
this.indexerSettings.fetch(),
|
|
|
|
|
this.notificationSettings.fetch()
|
|
|
|
|
).done(function () {
|
|
|
|
|
self.loading.$el.hide();
|
2013-07-05 05:26:07 +02:00
|
|
|
|
self.mediaManagement.show(new MediaManagementLayout({ settings: self.settings, namingSettings: self.namingSettings }));
|
2013-07-02 08:46:38 +02:00
|
|
|
|
self.quality.show(new QualityLayout({settings: self.settings}));
|
|
|
|
|
self.indexers.show(new IndexerCollectionView({collection: self.indexerSettings}));
|
|
|
|
|
self.downloadClient.show(new DownloadClientLayout({model: self.settings}));
|
|
|
|
|
self.notifications.show(new NotificationCollectionView({collection: self.notificationSettings}));
|
|
|
|
|
self.general.show(new GeneralView({model: self.generalSettings}));
|
|
|
|
|
self.misc.show(new MiscView({model: self.settings}));
|
|
|
|
|
});
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
switch (this.action) {
|
|
|
|
|
case 'quality':
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showQuality();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
|
|
|
|
case 'indexers':
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showIndexers();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
|
|
|
|
case 'downloadclient':
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showDownloadClient();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
|
|
|
|
case 'notifications':
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showNotifications();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
2013-05-23 07:12:01 +02:00
|
|
|
|
case 'general':
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showGeneral();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
|
|
|
|
case 'misc':
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showMisc();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2013-07-05 05:26:07 +02:00
|
|
|
|
this._showMediaManagement();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
}
|
2013-03-05 07:50:42 +01:00
|
|
|
|
},
|
|
|
|
|
|
2013-07-05 05:26:07 +02:00
|
|
|
|
_save: function () {
|
2013-06-19 03:02:23 +02:00
|
|
|
|
App.vent.trigger(App.Commands.SaveSettings);
|
2013-03-04 01:09:43 +01:00
|
|
|
|
}
|
2013-06-14 01:19:24 +02:00
|
|
|
|
});
|
|
|
|
|
});
|
2013-03-04 01:09:43 +01:00
|
|
|
|
|