2013-07-02 08:46:38 +02:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'marionette',
|
|
|
|
|
'Settings/DownloadClient/SabView',
|
|
|
|
|
'Settings/DownloadClient/BlackholeView',
|
|
|
|
|
'Settings/DownloadClient/PneumaticView',
|
|
|
|
|
'Settings/DownloadClient/NzbgetView',
|
|
|
|
|
'Mixins/AsModelBoundView',
|
2013-07-06 23:59:15 +02:00
|
|
|
|
'Mixins/AutoComplete',
|
2013-07-02 08:46:38 +02:00
|
|
|
|
'bootstrap'
|
|
|
|
|
], function (Marionette, SabView, BlackholeView, PneumaticView, NzbgetView, AsModelBoundView) {
|
|
|
|
|
|
|
|
|
|
var view = Marionette.Layout.extend({
|
|
|
|
|
template : 'Settings/DownloadClient/LayoutTemplate',
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
downloadClient: '#download-client-settings-region'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ui: {
|
2013-07-06 23:59:15 +02:00
|
|
|
|
downloadClientSelect: '.x-download-client',
|
|
|
|
|
downloadedEpisodesFolder: '.x-path'
|
2013-07-02 08:46:38 +02:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
'change .x-download-client': 'downloadClientChanged'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onShow: function () {
|
|
|
|
|
this.sabView = new SabView({ model: this.model});
|
|
|
|
|
this.blackholeView = new BlackholeView({ model: this.model});
|
|
|
|
|
this.pneumaticView = new PneumaticView({ model: this.model});
|
|
|
|
|
this.nzbgetView = new NzbgetView({ model: this.model});
|
|
|
|
|
|
2013-07-06 23:59:15 +02:00
|
|
|
|
this.ui.downloadedEpisodesFolder.autoComplete('/directories');
|
|
|
|
|
|
2013-07-02 08:46:38 +02:00
|
|
|
|
var client = this.model.get('downloadClient');
|
|
|
|
|
this.refreshUIVisibility(client);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
downloadClientChanged: function () {
|
|
|
|
|
var clientId = this.ui.downloadClientSelect.val();
|
|
|
|
|
this.refreshUIVisibility(clientId);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
refreshUIVisibility: function (clientId) {
|
|
|
|
|
|
|
|
|
|
if (!clientId) {
|
|
|
|
|
clientId = 'sabnzbd';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (clientId.toString()) {
|
|
|
|
|
case 'sabnzbd':
|
|
|
|
|
this.downloadClient.show(this.sabView);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'blackhole':
|
|
|
|
|
this.downloadClient.show(this.blackholeView);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'pneumatic':
|
|
|
|
|
this.downloadClient.show(this.pneumaticView);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'nzbget':
|
|
|
|
|
this.downloadClient.show(this.nzbgetView);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default :
|
|
|
|
|
throw 'unknown download client id' + clientId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return AsModelBoundView.call(view);
|
|
|
|
|
});
|