From 7ca154e613329050885b7c6a799488475266218e Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 24 Mar 2013 15:51:30 +0100 Subject: enter captchas on webui --- module/web/static/js/views/queryModal.js | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 module/web/static/js/views/queryModal.js (limited to 'module/web/static/js/views/queryModal.js') diff --git a/module/web/static/js/views/queryModal.js b/module/web/static/js/views/queryModal.js new file mode 100644 index 000000000..5d1585a0d --- /dev/null +++ b/module/web/static/js/views/queryModal.js @@ -0,0 +1,54 @@ +define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/default/queryDialog.html'], + function($, _, App, modalView, template) { + return modalView.extend({ + + events: { + 'click .btn-success': 'submit', + 'submit form': 'submit' + }, + + model: null, + parent: null, + template: _.compile(template), + + 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') + }; + + if (this.model.isCaptcha()) { + var input = this.model.get('input').data; + data.captcha = input[0]; + data.type = input[1]; + } + + return data; + }, + + submit: function(e) { + e.stopPropagation(); + // TODO: different input types + // TODO: load next task + + this.model.set('result', this.$('input').val()); + var self = this; + this.model.save({success: function() { + self.hide(); + }}); + + this.$('input').val(''); + }, + + onShow: function() { + this.$('input').focus(); + } + + }); + }); \ No newline at end of file -- cgit v1.2.3