2013-04-19 02:14:08 +03:00
|
|
|
"use strict";
|
|
|
|
define([
|
2013-03-04 03:09:43 +03:00
|
|
|
'app',
|
|
|
|
'Settings/Naming/NamingView',
|
2013-03-07 11:01:18 +03:00
|
|
|
'Settings/Quality/QualityLayout',
|
2013-05-01 03:01:54 +03:00
|
|
|
'Settings/Indexers/CollectionView',
|
2013-03-04 03:09:43 +03:00
|
|
|
'Settings/DownloadClient/DownloadClientView',
|
2013-05-20 07:19:54 +03:00
|
|
|
'Settings/Notifications/CollectionView',
|
2013-05-23 08:12:01 +03:00
|
|
|
'Settings/General/GeneralView',
|
|
|
|
'Settings/General/GeneralSettingsModel',
|
2013-03-04 03:09:43 +03:00
|
|
|
'Settings/Misc/MiscView'
|
|
|
|
],
|
2013-04-19 02:14:08 +03:00
|
|
|
function () {
|
2013-03-04 03:09:43 +03:00
|
|
|
NzbDrone.Settings.SettingsLayout = Backbone.Marionette.Layout.extend({
|
|
|
|
template: 'Settings/SettingsLayoutTemplate',
|
|
|
|
|
|
|
|
regions: {
|
2013-03-30 02:28:58 +03:00
|
|
|
naming : '#naming',
|
|
|
|
quality : '#quality',
|
|
|
|
indexers : '#indexers',
|
2013-03-04 03:09:43 +03:00
|
|
|
downloadClient: '#download-client',
|
2013-03-30 02:28:58 +03:00
|
|
|
notifications : '#notifications',
|
2013-05-23 08:12:01 +03:00
|
|
|
general : '#general',
|
2013-03-30 02:28:58 +03:00
|
|
|
misc : '#misc'
|
2013-03-04 03:09:43 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
ui: {
|
2013-03-30 02:28:58 +03:00
|
|
|
namingTab : '.x-naming-tab',
|
|
|
|
qualityTab : '.x-quality-tab',
|
|
|
|
indexersTab : '.x-indexers-tab',
|
2013-03-04 03:09:43 +03:00
|
|
|
downloadClientTab: '.x-download-client-tab',
|
2013-03-30 02:28:58 +03:00
|
|
|
notificationsTab : '.x-notifications-tab',
|
2013-05-23 08:12:01 +03:00
|
|
|
generalTab : '.x-general-tab',
|
2013-03-30 02:28:58 +03:00
|
|
|
miscTab : '.x-misc-tab'
|
2013-03-04 03:09:43 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
2013-03-30 02:28:58 +03:00
|
|
|
'click .x-naming-tab' : 'showNaming',
|
|
|
|
'click .x-quality-tab' : 'showQuality',
|
|
|
|
'click .x-indexers-tab' : 'showIndexers',
|
2013-03-04 03:09:43 +03:00
|
|
|
'click .x-download-client-tab': 'showDownloadClient',
|
2013-03-30 02:28:58 +03:00
|
|
|
'click .x-notifications-tab' : 'showNotifications',
|
2013-05-23 08:12:01 +03:00
|
|
|
'click .x-general-tab' : 'showGeneral',
|
2013-03-30 02:28:58 +03:00
|
|
|
'click .x-misc-tab' : 'showMisc',
|
|
|
|
'click .x-save-settings' : 'save'
|
2013-03-04 03:09:43 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
showNaming: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ui.namingTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/naming');
|
|
|
|
},
|
|
|
|
|
|
|
|
showQuality: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ui.qualityTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/quality');
|
|
|
|
},
|
|
|
|
|
|
|
|
showIndexers: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ui.indexersTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/indexers');
|
|
|
|
},
|
|
|
|
|
|
|
|
showDownloadClient: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ui.downloadClientTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/downloadclient');
|
|
|
|
},
|
|
|
|
|
|
|
|
showNotifications: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ui.notificationsTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/notifications');
|
|
|
|
},
|
|
|
|
|
2013-05-23 08:12:01 +03:00
|
|
|
showGeneral: function (e) {
|
2013-03-04 03:09:43 +03:00
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
2013-05-23 08:12:01 +03:00
|
|
|
this.ui.generalTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/general');
|
2013-03-04 03:09:43 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
showMisc: function (e) {
|
|
|
|
if (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.ui.miscTab.tab('show');
|
|
|
|
NzbDrone.Router.navigate('settings/misc');
|
|
|
|
},
|
|
|
|
|
2013-04-19 02:14:08 +03:00
|
|
|
initialize: function (options) {
|
2013-05-14 06:21:37 +03:00
|
|
|
this.settings = new NzbDrone.Settings.SettingsModel();
|
|
|
|
this.settings.fetch();
|
|
|
|
|
2013-05-23 08:12:01 +03:00
|
|
|
this.generalSettings = new NzbDrone.Settings.General.GeneralSettingsModel();
|
|
|
|
this.generalSettings.fetch();
|
|
|
|
|
2013-04-26 18:31:56 +03:00
|
|
|
this.namingSettings = new NzbDrone.Settings.Naming.NamingModel();
|
|
|
|
this.namingSettings.fetch();
|
|
|
|
|
2013-05-01 03:01:54 +03:00
|
|
|
this.indexerSettings = new NzbDrone.Settings.Indexers.Collection();
|
|
|
|
this.indexerSettings.fetch();
|
|
|
|
|
2013-05-20 07:19:54 +03:00
|
|
|
this.notificationSettings = new NzbDrone.Settings.Notifications.Collection();
|
|
|
|
this.notificationSettings.fetch();
|
|
|
|
|
2013-04-19 02:14:08 +03:00
|
|
|
if (options.action) {
|
|
|
|
this.action = options.action.toLowerCase();
|
2013-03-04 03:09:43 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onRender: function () {
|
2013-04-26 18:31:56 +03:00
|
|
|
this.naming.show(new NzbDrone.Settings.Naming.NamingView());
|
2013-03-07 11:01:18 +03:00
|
|
|
this.quality.show(new NzbDrone.Settings.Quality.QualityLayout({settings: this.settings}));
|
2013-05-01 03:01:54 +03:00
|
|
|
this.indexers.show(new NzbDrone.Settings.Indexers.CollectionView({collection: this.indexerSettings}));
|
2013-03-04 03:09:43 +03:00
|
|
|
this.downloadClient.show(new NzbDrone.Settings.DownloadClient.DownloadClientView({model: this.settings}));
|
2013-05-20 07:19:54 +03:00
|
|
|
this.notifications.show(new NzbDrone.Settings.Notifications.CollectionView({collection: this.notificationSettings}));
|
2013-05-23 08:12:01 +03:00
|
|
|
this.general.show(new NzbDrone.Settings.General.GeneralView({model: this.generalSettings}));
|
2013-03-04 03:09:43 +03:00
|
|
|
this.misc.show(new NzbDrone.Settings.Misc.MiscView({model: this.settings}));
|
|
|
|
},
|
|
|
|
|
|
|
|
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 08:12:01 +03:00
|
|
|
case 'general':
|
|
|
|
this.showGeneral();
|
2013-03-04 03:09:43 +03:00
|
|
|
break;
|
|
|
|
case 'misc':
|
|
|
|
this.showMisc();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
this.showNaming();
|
|
|
|
}
|
2013-03-05 09:50:42 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
save: function () {
|
2013-04-25 07:27:49 +03:00
|
|
|
|
|
|
|
NzbDrone.vent.trigger(NzbDrone.Commands.SaveSettings);
|
|
|
|
|
2013-06-14 02:19:24 +03:00
|
|
|
this.settings.saveIfChanged(undefined, NzbDrone.Settings.SyncNotificaiton.callback({
|
|
|
|
successMessage: 'Settings saved',
|
|
|
|
errorMessage: "Failed to save settings"
|
|
|
|
}));
|
2013-03-04 03:09:43 +03:00
|
|
|
}
|
2013-06-14 02:19:24 +03:00
|
|
|
});
|
|
|
|
});
|
2013-03-04 03:09:43 +03:00
|
|
|
|