summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/views/queryModal.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:22 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-06-09 18:10:23 +0200
commit16af85004c84d0d6c626b4f8424ce9647669a0c1 (patch)
tree025d479862d376dbc17e934f4ed20031c8cd97d1 /pyload/web/app/scripts/views/queryModal.js
parentadapted to jshint config (diff)
downloadpyload-16af85004c84d0d6c626b4f8424ce9647669a0c1.tar.xz
moved everything from module to pyload
Diffstat (limited to 'pyload/web/app/scripts/views/queryModal.js')
-rw-r--r--pyload/web/app/scripts/views/queryModal.js69
1 files changed, 69 insertions, 0 deletions
diff --git a/pyload/web/app/scripts/views/queryModal.js b/pyload/web/app/scripts/views/queryModal.js
new file mode 100644
index 000000000..7c6439b49
--- /dev/null
+++ b/pyload/web/app/scripts/views/queryModal.js
@@ -0,0 +1,69 @@
+define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inputLoader', 'text!tpl/default/queryDialog.html'],
+ function($, _, App, modalView, load_input, template) {
+ 'use strict';
+ return modalView.extend({
+
+ // TODO: submit on enter reloads the page sometimes
+ events: {
+ 'click .btn-success': 'submit',
+ 'submit form': 'submit'
+ },
+ template: _.compile(template),
+
+ // the notificationView
+ parent: null,
+
+ model: null,
+ input: null,
+
+ initialize: function() {
+ // Inherit parent events
+ this.events = _.extend({}, modalView.prototype.events, this.events);
+ },
+
+ renderContent: function() {
+ var data = {
+ title: this.model.get('title'),
+ plugin: this.model.get('plugin'),
+ description: this.model.get('description')
+ };
+
+ var input = this.model.get('input').data;
+ if (this.model.isCaptcha()) {
+ data.captcha = input[0];
+ data.type = input[1];
+ }
+ return data;
+ },
+
+ onRender: function() {
+ // instantiate the input
+ var input = this.model.get('input');
+ var InputView = load_input(input);
+ this.input = new InputView(input);
+ // only renders after wards
+ this.$('#inputField').append(this.input.render().el);
+ },
+
+ submit: function(e) {
+ e.stopPropagation();
+ // TODO: load next task
+
+ this.model.set('result', this.input.getVal());
+ var self = this;
+ this.model.save({success: function() {
+ self.hide();
+ }});
+
+ this.input.clear();
+ },
+
+ onShow: function() {
+ this.input.focus();
+ },
+
+ onHide: function() {
+ this.input.destroy();
+ }
+ });
+ }); \ No newline at end of file