diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-24 21:27:43 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-03-24 21:27:43 +0100 |
commit | 7b4c75f0dd755e28fcffc0e4fdd05452458a3b09 (patch) | |
tree | 43ef5fe76ff5ff235cc52b79f16b9a8b6047bca8 /module/web/static/js/views/queryModal.js | |
parent | Merge remote-tracking branch 'origin/stable' (diff) | |
download | pyload-7b4c75f0dd755e28fcffc0e4fdd05452458a3b09.tar.xz |
added view type for input fields
Diffstat (limited to 'module/web/static/js/views/queryModal.js')
-rw-r--r-- | module/web/static/js/views/queryModal.js | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/module/web/static/js/views/queryModal.js b/module/web/static/js/views/queryModal.js index 5d1585a0d..86fd5b78b 100644 --- a/module/web/static/js/views/queryModal.js +++ b/module/web/static/js/views/queryModal.js @@ -1,15 +1,18 @@ -define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/default/queryDialog.html'], - function($, _, App, modalView, template) { +define(['jquery', 'underscore', 'app', 'views/abstract/modalView', './input/inputLoader', 'text!tpl/default/queryDialog.html'], + function($, _, App, modalView, load_input, template) { return modalView.extend({ events: { 'click .btn-success': 'submit', 'submit form': 'submit' }, + template: _.compile(template), - model: null, + // the notificationView parent: null, - template: _.compile(template), + + model: null, + input: null, initialize: function() { // Inherit parent events @@ -23,32 +26,42 @@ define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/def description: this.model.get('description') }; + var input = this.model.get('input').data; if (this.model.isCaptcha()) { - var input = this.model.get('input').data; 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: different input types // TODO: load next task - this.model.set('result', this.$('input').val()); + this.model.set('result', this.input.getVal()); var self = this; this.model.save({success: function() { self.hide(); }}); - this.$('input').val(''); + this.input.clear(); }, onShow: function() { - this.$('input').focus(); - } + this.input.focus(); + }, + onHide: function() { + this.input.destroy(); + } }); });
\ No newline at end of file |