2013-06-25 01:41:59 +02:00
|
|
|
|
'use strict';
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'app',
|
|
|
|
|
'marionette',
|
|
|
|
|
'Settings/SettingsModel',
|
|
|
|
|
'Settings/General/GeneralSettingsModel',
|
|
|
|
|
'Settings/Naming/NamingModel',
|
|
|
|
|
'Settings/Naming/NamingView',
|
|
|
|
|
'Settings/Quality/QualityLayout',
|
|
|
|
|
'Settings/Indexers/CollectionView',
|
|
|
|
|
'Settings/Indexers/Collection',
|
|
|
|
|
'Settings/DownloadClient/DownloadClientView',
|
|
|
|
|
'Settings/Notifications/CollectionView',
|
|
|
|
|
'Settings/Notifications/Collection',
|
|
|
|
|
'Settings/General/GeneralView',
|
|
|
|
|
'Settings/Misc/MiscView'
|
|
|
|
|
], function (App, Marionette, SettingsModel, GeneralSettingsModel,NamingModel, NamingView, QualityLayout, IndexerCollectionView, IndexerCollection, DownloadClientView,
|
|
|
|
|
NotificationCollectionView, NotificationCollection, GeneralView, MiscView) {
|
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-03-30 00:28:58 +01:00
|
|
|
|
naming : '#naming',
|
|
|
|
|
quality : '#quality',
|
|
|
|
|
indexers : '#indexers',
|
2013-03-04 01:09:43 +01:00
|
|
|
|
downloadClient: '#download-client',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
notifications : '#notifications',
|
2013-05-23 07:12:01 +02:00
|
|
|
|
general : '#general',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
misc : '#misc'
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ui: {
|
2013-03-30 00:28:58 +01:00
|
|
|
|
namingTab : '.x-naming-tab',
|
|
|
|
|
qualityTab : '.x-quality-tab',
|
|
|
|
|
indexersTab : '.x-indexers-tab',
|
2013-03-04 01:09:43 +01:00
|
|
|
|
downloadClientTab: '.x-download-client-tab',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
notificationsTab : '.x-notifications-tab',
|
2013-05-23 07:12:01 +02:00
|
|
|
|
generalTab : '.x-general-tab',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
miscTab : '.x-misc-tab'
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-03-30 00:28:58 +01:00
|
|
|
|
'click .x-naming-tab' : 'showNaming',
|
|
|
|
|
'click .x-quality-tab' : 'showQuality',
|
|
|
|
|
'click .x-indexers-tab' : 'showIndexers',
|
2013-03-04 01:09:43 +01:00
|
|
|
|
'click .x-download-client-tab': 'showDownloadClient',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
'click .x-notifications-tab' : 'showNotifications',
|
2013-05-23 07:12:01 +02:00
|
|
|
|
'click .x-general-tab' : 'showGeneral',
|
2013-03-30 00:28:58 +01:00
|
|
|
|
'click .x-misc-tab' : 'showMisc',
|
|
|
|
|
'click .x-save-settings' : 'save'
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showNaming: function (e) {
|
|
|
|
|
if (e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.ui.namingTab.tab('show');
|
2013-06-25 01:41:59 +02:00
|
|
|
|
this._navigate('settings/naming');
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showQuality: function (e) {
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showIndexers: function (e) {
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showDownloadClient: function (e) {
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showNotifications: function (e) {
|
|
|
|
|
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-05-23 07:12:01 +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
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showMisc: function (e) {
|
|
|
|
|
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) {
|
2013-06-19 03:02:23 +02:00
|
|
|
|
this.settings = new SettingsModel();
|
2013-05-14 05:21:37 +02:00
|
|
|
|
this.settings.fetch();
|
|
|
|
|
|
2013-06-19 03:02:23 +02:00
|
|
|
|
this.generalSettings = new GeneralSettingsModel();
|
2013-05-23 07:12:01 +02:00
|
|
|
|
this.generalSettings.fetch();
|
|
|
|
|
|
2013-06-19 03:02:23 +02:00
|
|
|
|
this.namingSettings = new NamingModel();
|
2013-04-26 17:31:56 +02:00
|
|
|
|
this.namingSettings.fetch();
|
|
|
|
|
|
2013-06-19 03:02:23 +02:00
|
|
|
|
this.indexerSettings = new IndexerCollection();
|
2013-05-01 02:01:54 +02:00
|
|
|
|
this.indexerSettings.fetch();
|
|
|
|
|
|
2013-06-19 03:02:23 +02:00
|
|
|
|
this.notificationSettings = new NotificationCollection();
|
2013-05-20 06:19:54 +02:00
|
|
|
|
this.notificationSettings.fetch();
|
|
|
|
|
|
2013-04-19 01:14:08 +02:00
|
|
|
|
if (options.action) {
|
|
|
|
|
this.action = options.action.toLowerCase();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
2013-06-19 03:02:23 +02:00
|
|
|
|
this.naming.show(new NamingView());
|
|
|
|
|
this.quality.show(new QualityLayout({settings: this.settings}));
|
|
|
|
|
this.indexers.show(new IndexerCollectionView({collection: this.indexerSettings}));
|
|
|
|
|
this.downloadClient.show(new DownloadClientView({model: this.settings}));
|
|
|
|
|
this.notifications.show(new NotificationCollectionView({collection: this.notificationSettings}));
|
|
|
|
|
this.general.show(new GeneralView({model: this.generalSettings}));
|
|
|
|
|
this.misc.show(new MiscView({model: this.settings}));
|
2013-03-04 01:09:43 +01:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
switch (this.action) {
|
|
|
|
|
case 'quality':
|
|
|
|
|
this.showQuality();
|
|
|
|
|
break;
|
|
|
|
|
case 'indexers':
|
|
|
|
|
this.showIndexers();
|
|
|
|
|
break;
|
|
|
|
|
case 'downloadclient':
|
|
|
|
|
this.showDownloadClient();
|
|
|
|
|
break;
|
|
|
|
|
case 'notifications':
|
|
|
|
|
this.showNotifications();
|
|
|
|
|
break;
|
2013-05-23 07:12:01 +02:00
|
|
|
|
case 'general':
|
|
|
|
|
this.showGeneral();
|
2013-03-04 01:09:43 +01:00
|
|
|
|
break;
|
|
|
|
|
case 'misc':
|
|
|
|
|
this.showMisc();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
this.showNaming();
|
|
|
|
|
}
|
2013-03-05 07:50:42 +01: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
|
|
|
|
|