summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-30 15:39:56 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-03-30 15:39:56 +0100
commit76f760fe029303ba2ff203759a8332a628a9a7ec (patch)
tree1ce40a9de659b540b602d98af0ec3998604ac868 /module/web/static/js/views
parentfix in update file info, moved recaptcha back (diff)
downloadpyload-76f760fe029303ba2ff203759a8332a628a9a7ec.tar.xz
plugin chooser for settings
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r--module/web/static/js/views/abstract/modalView.js2
-rw-r--r--module/web/static/js/views/dashboard/fileView.js6
-rw-r--r--module/web/static/js/views/settings/configSectionView.js (renamed from module/web/static/js/views/configSectionView.js)2
-rw-r--r--module/web/static/js/views/settings/pluginChooserModal.js66
-rw-r--r--module/web/static/js/views/settings/settingsView.js (renamed from module/web/static/js/views/settingsView.js)29
5 files changed, 94 insertions, 11 deletions
diff --git a/module/web/static/js/views/abstract/modalView.js b/module/web/static/js/views/abstract/modalView.js
index 1e45e942b..170681f06 100644
--- a/module/web/static/js/views/abstract/modalView.js
+++ b/module/web/static/js/views/abstract/modalView.js
@@ -83,7 +83,7 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
},
renderContent: function() {
- return {content: $('<h1>Content!</h1>').html()};
+ return {};
},
show: function() {
diff --git a/module/web/static/js/views/dashboard/fileView.js b/module/web/static/js/views/dashboard/fileView.js
index c673041b5..5d687a111 100644
--- a/module/web/static/js/views/dashboard/fileView.js
+++ b/module/web/static/js/views/dashboard/fileView.js
@@ -77,7 +77,7 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abst
},
progress_changed: function() {
- if(!this.model.isDownload())
+ if (!this.model.isDownload())
return;
if (this.model.get('download').status === Api.DownloadStatus.Downloading) {
@@ -89,6 +89,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'utils/apitypes', 'views/abst
bar.width(this.model.get('progress') + '%');
bar.html('&nbsp;&nbsp;' + formatTime(this.model.get('eta')));
+ } else if (this.model.get('download').status === Api.DownloadStatus.Waiting) {
+ this.$('.second').html(
+ "<i class='iconf-time'></i>&nbsp;" + formatTime(this.model.get('eta')));
+
} else // Every else state can be renderred normally
this.render();
diff --git a/module/web/static/js/views/configSectionView.js b/module/web/static/js/views/settings/configSectionView.js
index 949493731..79f314309 100644
--- a/module/web/static/js/views/configSectionView.js
+++ b/module/web/static/js/views/settings/configSectionView.js
@@ -1,4 +1,4 @@
-define(['jquery', 'underscore', 'backbone', 'app', './abstract/itemView', './input/inputLoader'],
+define(['jquery', 'underscore', 'backbone', 'app', '../abstract/itemView', '../input/inputLoader'],
function($, _, Backbone, App, itemView, load_input) {
// Renders settings over view page
diff --git a/module/web/static/js/views/settings/pluginChooserModal.js b/module/web/static/js/views/settings/pluginChooserModal.js
new file mode 100644
index 000000000..c7cdce244
--- /dev/null
+++ b/module/web/static/js/views/settings/pluginChooserModal.js
@@ -0,0 +1,66 @@
+define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/default/pluginChooserDialog.html', 'select2'],
+ function($, _, App, modalView, template) {
+ return modalView.extend({
+
+ events: {
+ 'click .btn-add': 'add'
+ },
+ template: _.compile(template),
+ plugins: null,
+ select: null,
+
+ initialize: function() {
+ // Inherit parent events
+ this.events = _.extend({}, modalView.prototype.events, this.events);
+ var self = this;
+ $.ajax(App.apiRequest('getAvailablePlugins', null, {success: function(data) {
+ self.plugins = data;
+ self.render();
+ }
+ }));
+ },
+
+ onRender: function() {
+ // TODO: could be a seperate input type if needed on multiple pages
+ if (this.plugins)
+ this.select = this.$('#pluginSelect').select2({
+ escapeMarkup: function(m) {
+ return m;
+ },
+ formatResult: this.format,
+ formatSelection: this.formatSelection,
+ data: {results: this.plugins, text: function(item) {
+ return item.label;
+ }},
+ id: function(item) {
+ return item.name;
+ }
+ });
+ },
+
+ onShow: function() {
+ },
+
+ onHide: function() {
+ },
+
+ format: function(data) {
+ var s = '<div class="plugin-select" style="background-image: url(icons/' + data.name + '">' + data.label;
+ s += "<br><span>" + data.description + "<span></div>";
+ return s;
+ },
+
+ formatSelection: function(data) {
+ return '<img class="logo-select" src="icons/' + data.name + '"> ' + data.label;
+ },
+
+ add: function(e) {
+ e.stopPropagation();
+ if (this.select) {
+ var plugin = this.select.val();
+ App.settingsView.openConfig(plugin);
+ this.hide();
+ }
+ }
+ });
+ }); \ No newline at end of file
diff --git a/module/web/static/js/views/settingsView.js b/module/web/static/js/views/settings/settingsView.js
index 3b8308f19..58507f51a 100644
--- a/module/web/static/js/views/settingsView.js
+++ b/module/web/static/js/views/settings/settingsView.js
@@ -4,18 +4,20 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con
// Renders settings over view page
return Backbone.View.extend({
- el: "#content",
+ el: "body",
templateMenu: _.compile($("#template-menu").html()),
events: {
- 'click .settings-menu li > a': 'change_section'
+ 'click .settings-menu li > a': 'change_section',
+ 'click .btn-add': 'choosePlugin'
},
menu: null,
content: null,
+ modal: null,
- core_config: null, // It seems models are not needed
- plugin_config: null,
+ coreConfig: null, // It seems collections are not needed
+ pluginConfig: null,
// currently open configHolder
config: null,
@@ -36,19 +38,19 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con
refresh: function() {
var self = this;
$.ajax(App.apiRequest("getCoreConfig", null, {success: function(data) {
- self.core_config = data;
+ self.coreConfig = data;
self.render();
}}));
$.ajax(App.apiRequest("getPluginConfig", null, {success: function(data) {
- self.plugin_config = data;
+ self.pluginConfig = data;
self.render();
}}));
},
render: function() {
this.menu.html(this.templateMenu({
- core: this.core_config,
- plugin: this.plugin_config
+ core: this.coreConfig,
+ plugin: this.pluginConfig
}));
},
@@ -113,6 +115,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con
change_section: function(e) {
// TODO check for changes
+ // TODO move this into render?
var el = $(e.target).parent();
var name = el.data("name");
@@ -121,6 +124,16 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ConfigHolder', './con
this.menu.find("li.active").removeClass("active");
el.addClass("active");
e.preventDefault();
+ },
+
+ choosePlugin: function(e){
+ var self = this;
+ _.requireOnce(['views/settings/pluginChooserModal'], function(Modal) {
+ if (self.modal === null)
+ self.modal = new Modal();
+
+ self.modal.show();
+ });
}
});