summaryrefslogtreecommitdiffstats
path: root/module/web/static/js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-02-24 17:47:51 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-02-24 17:47:51 +0100
commitb4fa3cd44d7b6827ca385f60e72d4f7798a3e02f (patch)
treefbf63ffade6444c19902337320a71f803b1e60ba /module/web/static/js
parentparse category from addons (diff)
downloadpyload-b4fa3cd44d7b6827ca385f60e72d4f7798a3e02f.tar.xz
added confirm dialogs
Diffstat (limited to 'module/web/static/js')
-rw-r--r--module/web/static/js/app.js1
-rw-r--r--module/web/static/js/utils/dialogs.js15
-rw-r--r--module/web/static/js/views/abstract/modalView.js31
-rw-r--r--module/web/static/js/views/selectionView.js5
4 files changed, 47 insertions, 5 deletions
diff --git a/module/web/static/js/app.js b/module/web/static/js/app.js
index dcc9594af..e3fad4ea1 100644
--- a/module/web/static/js/app.js
+++ b/module/web/static/js/app.js
@@ -12,6 +12,7 @@ define([
'utils/initHB',
'utils/animations',
'utils/lazyRequire',
+ 'utils/dialogs',
'wreqr',
'bootstrap',
'animate'
diff --git a/module/web/static/js/utils/dialogs.js b/module/web/static/js/utils/dialogs.js
new file mode 100644
index 000000000..13478ff88
--- /dev/null
+++ b/module/web/static/js/utils/dialogs.js
@@ -0,0 +1,15 @@
+// Loads all helper and set own handlebars rules
+define(['jquery', 'underscore', 'views/abstract/modalView'], function($, _, modal) {
+
+ // Shows the confirm dialog for given context
+ // on success executes func with context
+ _.confirm = function(template, func, context) {
+ template = "text!tpl/" + template;
+ _.requireOnce([template], function(html) {
+ var template = _.compile(html);
+ var dialog = new modal(template, _.bind(func, context));
+ dialog.show();
+ });
+
+ };
+}); \ No newline at end of file
diff --git a/module/web/static/js/views/abstract/modalView.js b/module/web/static/js/views/abstract/modalView.js
index 56c060a42..e0542d552 100644
--- a/module/web/static/js/views/abstract/modalView.js
+++ b/module/web/static/js/views/abstract/modalView.js
@@ -3,6 +3,7 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
return Backbone.View.extend({
events: {
+ 'click .btn-confirm': 'confirm',
'click .btn-close': 'hide',
'click .close': 'hide'
},
@@ -10,12 +11,22 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
template: null,
dialog: null,
- initialize: function() {
+ onHideDestroy: false,
+ confirmCallback: null,
+
+ initialize: function(template, confirm) {
+ this.confirmCallback = confirm;
var self = this;
if (this.template === null) {
- require(['text!tpl/default/modal.html'], function(template) {
- self.template = template;
- });
+ if (template) {
+ this.template = template;
+ // When template was provided this is a temporary dialog
+ this.onHideDestroy = true;
+ }
+ else
+ require(['text!tpl/default/modal.html'], function(template) {
+ self.template = template;
+ });
}
},
@@ -26,6 +37,8 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
this.$el.css({opacity: 0, scale: 0.7});
$("body").append(this.el);
+ var self = this;
+
this.dialog = this.$el.omniWindow({
overlay: {
selector: '#modal-overlay',
@@ -34,6 +47,8 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
hide: function(subjects, internalCallback) {
subjects.overlay.transition({opacity: 'hide', delay: 100}, 300, function() {
internalCallback(subjects);
+ if (self.onHideDestroy)
+ self.destroy();
});
},
show: function(subjects, internalCallback) {
@@ -74,9 +89,17 @@ define(['jquery', 'backbone', 'underscore', 'omniwindow'], function($, Backbone,
this.dialog.trigger('hide');
},
+ confirm: function() {
+ if (this.confirmCallback)
+ this.confirmCallback.apply();
+
+ this.hide();
+ },
+
destroy: function() {
this.$el.remove();
this.dialog = null;
+ this.remove();
}
});
diff --git a/module/web/static/js/views/selectionView.js b/module/web/static/js/views/selectionView.js
index 8dbd069bd..6d346b6ee 100644
--- a/module/web/static/js/views/selectionView.js
+++ b/module/web/static/js/views/selectionView.js
@@ -80,7 +80,10 @@ define(['jquery', 'backbone', 'underscore', 'app'],
},
pause: function() {
- // TODO
+ _.confirm('default/confirmDialog.html', function() {
+ alert("Not implemented yet");
+ this.deselect();
+ }, this);
},
trash: function() {