Sonarr/UI/Settings/DownloadClient/DownloadClientView.js

80 lines
2.5 KiB
JavaScript
Raw Normal View History

2013-03-04 00:09:43 +00:00
'use strict';
define([
'app', 'Settings/SettingsModel','bootstrap'
2013-03-04 00:09:43 +00:00
], function () {
NzbDrone.Settings.DownloadClient.DownloadClientView = Backbone.Marionette.ItemView.extend({
template : 'Settings/DownloadClient/DownloadClientTemplate',
className: 'form-horizontal',
ui: {
bsSwitch : '.switch',
tooltip : '.help-inline i',
pathInput : '.x-path',
sabConfig : '.x-sab-config',
blackholeConfig : '.x-blackhole-config',
pneumaticConfig : '.x-pneumatic-config',
nzbGetConfig : '.x-nzbget-config',
downloadClientSelect: '.x-download-client'
},
events: {
'change .x-download-client': 'downloadClientChanged'
},
2013-03-04 00:09:43 +00:00
onRender: function () {
this.ui.tooltip.tooltip({ placement: 'right', html: true });
this.ui.pathInput.autoComplete('/directories');
this.refreshUIVisibility(this.model.get('downloadClient'));
},
downloadClientChanged: function () {
var clientId = this.ui.downloadClientSelect.val();
this.refreshUIVisibility(clientId);
},
refreshUIVisibility: function (clientId) {
if (!clientId) {
2013-05-30 15:29:43 +00:00
clientId = "sabnzbd";
}
switch (clientId.toString()) {
2013-05-30 15:29:43 +00:00
case "sabnzbd":
this.ui.sabConfig.show();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
2013-05-30 15:29:43 +00:00
case "blackhole":
this.ui.sabConfig.hide();
this.ui.blackholeConfig.show();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.hide();
break;
2013-05-30 15:29:43 +00:00
case "pneumatic":
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.show();
this.ui.nzbGetConfig.hide();
break;
2013-05-30 15:29:43 +00:00
case "nzbget":
this.ui.sabConfig.hide();
this.ui.blackholeConfig.hide();
this.ui.pneumaticConfig.hide();
this.ui.nzbGetConfig.show();
break;
default :
throw "unknown download client id" + clientId;
}
2013-03-04 00:09:43 +00:00
}
});
});