2013-03-04 00:09:43 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
define([
|
2013-06-19 01:02:23 +00:00
|
|
|
|
'app', 'marionette', 'Mixins/AsModelBoundView', 'bootstrap'
|
2013-03-04 00:09:43 +00:00
|
|
|
|
|
2013-06-19 01:02:23 +00:00
|
|
|
|
], function (App, Marionette, AsModelBoundView) {
|
2013-03-04 00:09:43 +00:00
|
|
|
|
|
2013-06-19 01:02:23 +00:00
|
|
|
|
var view = Marionette.ItemView.extend({
|
2013-03-29 23:28:58 +00:00
|
|
|
|
template : 'Settings/DownloadClient/DownloadClientTemplate',
|
2013-03-14 00:26:30 +00:00
|
|
|
|
className: 'form-horizontal',
|
|
|
|
|
|
|
|
|
|
ui: {
|
2013-06-19 01:02:23 +00:00
|
|
|
|
bsSwitch : '.switch',
|
2013-04-01 07:24:18 +00:00
|
|
|
|
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-14 00:26:30 +00:00
|
|
|
|
},
|
2013-03-04 00:09:43 +00:00
|
|
|
|
|
|
|
|
|
onRender: function () {
|
2013-03-16 00:33:04 +00:00
|
|
|
|
this.ui.pathInput.autoComplete('/directories');
|
2013-04-01 07:24:18 +00:00
|
|
|
|
this.refreshUIVisibility(this.model.get('downloadClient'));
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
downloadClientChanged: function () {
|
|
|
|
|
var clientId = this.ui.downloadClientSelect.val();
|
|
|
|
|
this.refreshUIVisibility(clientId);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
refreshUIVisibility: function (clientId) {
|
|
|
|
|
|
|
|
|
|
if (!clientId) {
|
2013-06-22 06:24:24 +00:00
|
|
|
|
clientId = 'sabnzbd';
|
2013-04-01 07:24:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (clientId.toString()) {
|
2013-06-22 06:24:24 +00:00
|
|
|
|
case 'sabnzbd':
|
2013-04-01 07:24:18 +00:00
|
|
|
|
this.ui.sabConfig.show();
|
|
|
|
|
this.ui.blackholeConfig.hide();
|
|
|
|
|
this.ui.pneumaticConfig.hide();
|
|
|
|
|
this.ui.nzbGetConfig.hide();
|
|
|
|
|
break;
|
|
|
|
|
|
2013-06-22 06:24:24 +00:00
|
|
|
|
case 'blackhole':
|
2013-04-01 07:24:18 +00:00
|
|
|
|
this.ui.sabConfig.hide();
|
|
|
|
|
this.ui.blackholeConfig.show();
|
|
|
|
|
this.ui.pneumaticConfig.hide();
|
|
|
|
|
this.ui.nzbGetConfig.hide();
|
|
|
|
|
break;
|
|
|
|
|
|
2013-06-22 06:24:24 +00:00
|
|
|
|
case 'pneumatic':
|
2013-04-01 07:24:18 +00:00
|
|
|
|
this.ui.sabConfig.hide();
|
|
|
|
|
this.ui.blackholeConfig.hide();
|
|
|
|
|
this.ui.pneumaticConfig.show();
|
|
|
|
|
this.ui.nzbGetConfig.hide();
|
|
|
|
|
break;
|
|
|
|
|
|
2013-06-22 06:24:24 +00:00
|
|
|
|
case 'nzbget':
|
2013-04-01 07:24:18 +00:00
|
|
|
|
this.ui.sabConfig.hide();
|
|
|
|
|
this.ui.blackholeConfig.hide();
|
|
|
|
|
this.ui.pneumaticConfig.hide();
|
|
|
|
|
this.ui.nzbGetConfig.show();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default :
|
2013-06-22 06:24:24 +00:00
|
|
|
|
throw 'unknown download client id' + clientId;
|
2013-04-01 07:24:18 +00:00
|
|
|
|
}
|
2013-03-04 00:09:43 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2013-06-19 01:02:23 +00:00
|
|
|
|
|
|
|
|
|
return AsModelBoundView.call(view);
|
2013-03-04 00:09:43 +00:00
|
|
|
|
});
|