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