summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/views
diff options
context:
space:
mode:
Diffstat (limited to 'module/web/static/js/views')
-rw-r--r--module/web/static/js/views/abstract/modalView.js4
-rw-r--r--module/web/static/js/views/headerView.js7
-rw-r--r--module/web/static/js/views/linkGrabberModal.js4
-rw-r--r--module/web/static/js/views/notificationView.js23
-rw-r--r--module/web/static/js/views/queryModal.js54
5 files changed, 82 insertions, 10 deletions
diff --git a/module/web/static/js/views/abstract/modalView.js b/module/web/static/js/views/abstract/modalView.js
index 8f5a7ed0c..d3ac34bd6 100644
--- a/module/web/static/js/views/abstract/modalView.js
+++ b/module/web/static/js/views/abstract/modalView.js
@@ -32,7 +32,7 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
},
render: function() {
- this.$el.html(this.template({ content: this.renderContent().html()}));
+ this.$el.html(this.template(this.renderContent()));
this.$el.addClass('modal hide');
this.$el.css({opacity: 0, scale: 0.7});
$("body").append(this.el);
@@ -73,7 +73,7 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
return this;
},
renderContent: function() {
- return $('<h1>Content!</h1>');
+ return {content: $('<h1>Content!</h1>').html()};
},
show: function() {
diff --git a/module/web/static/js/views/headerView.js b/module/web/static/js/views/headerView.js
index b5b4a9d24..25127a337 100644
--- a/module/web/static/js/views/headerView.js
+++ b/module/web/static/js/views/headerView.js
@@ -158,6 +158,13 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/ServerStatus', 'colle
if (data['@class'] === "ServerStatus") {
// TODO: load interaction when none available
this.status.set(data);
+
+ // There tasks at the server, but not in queue: so fetch them
+ // or there are tasks in our queue but not on the server
+ if (this.status.get('notifications') && !this.notificationView.tasks.hasTaskWaiting() ||
+ !this.status.get('notifications') && this.notificationView.tasks.hasTaskWaiting())
+ this.notificationView.tasks.fetch();
+
this.speeds = this.speeds.slice(1);
this.speeds.push([this.speeds[this.speeds.length - 1][0] + 1, Math.floor(data.speed / 1024)]);
diff --git a/module/web/static/js/views/linkGrabberModal.js b/module/web/static/js/views/linkGrabberModal.js
index 3d9a886db..e2b6e985d 100644
--- a/module/web/static/js/views/linkGrabberModal.js
+++ b/module/web/static/js/views/linkGrabberModal.js
@@ -15,10 +15,6 @@ define(['jquery', 'underscore', 'app', 'views/abstract/modalView', 'text!tpl/def
this.events = _.extend({}, modalView.prototype.events, this.events);
},
- renderContent: function() {
- return $('<h1>Content!</h1>');
- },
-
addOnEnter: function(e) {
if (e.keyCode != 13) return;
this.addPackage(e);
diff --git a/module/web/static/js/views/notificationView.js b/module/web/static/js/views/notificationView.js
index 22c727304..afb542eed 100644
--- a/module/web/static/js/views/notificationView.js
+++ b/module/web/static/js/views/notificationView.js
@@ -1,5 +1,5 @@
define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'],
- function($, Backbone, _, App, InteractionList) {
+ function($, Backbone, _, App, InteractionList, queryModal) {
// Renders context actions for selection packages and files
return Backbone.View.extend({
@@ -12,10 +12,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'
},
tasks: null,
- // current open task
- current: null,
// area is slided out
visible: false,
+ // the dialog
+ modal: null,
initialize: function() {
this.tasks = new InteractionList();
@@ -40,7 +40,10 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'
},
render: function() {
- this.$el.html(this.template(this.tasks.toJSON()));
+
+ // only render when it will be visible
+ if (this.tasks.length > 0)
+ this.$el.html(this.template(this.tasks.toJSON()));
if (this.tasks.length > 0 && !this.visible) {
this.$el.slideOut();
@@ -55,6 +58,18 @@ define(['jquery', 'backbone', 'underscore', 'app', 'collections/InteractionList'
},
openQuery: function() {
+ var self = this;
+
+ _.requireOnce(['views/queryModal'], function(modalView) {
+ if (self.modal === null) {
+ self.modal = new modalView();
+ self.modal.parent = self;
+ }
+
+ self.modal.model = self.tasks.at(0);
+ self.modal.render();
+ self.modal.show();
+ });
},
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