diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-09-18 17:59:50 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-09-18 17:59:50 +0200 |
commit | 6130a2377ca6754fee88773097ce220abef1aa47 (patch) | |
tree | 76bea0d76393100fcf393c164c96d34f286aba7a /module/web/static/js/views/modal/modalView.js | |
parent | Added DuckcryptInfo decrypter, smaller fixes (diff) | |
parent | dropdowns in navbar (diff) | |
download | pyload-6130a2377ca6754fee88773097ce220abef1aa47.tar.xz |
merged stable into default
Diffstat (limited to 'module/web/static/js/views/modal/modalView.js')
-rw-r--r-- | module/web/static/js/views/modal/modalView.js | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/module/web/static/js/views/modal/modalView.js b/module/web/static/js/views/modal/modalView.js new file mode 100644 index 000000000..b20aab57d --- /dev/null +++ b/module/web/static/js/views/modal/modalView.js @@ -0,0 +1,84 @@ +define(['jquery', 'backbone', 'underscore', 'text!tpl/default/modal.html', 'omniwindow'], function($, Backbone, _, template) { + + return Backbone.View.extend({ + + events: { + 'click .btn-close': 'hide', + 'click .close': 'hide' + }, + + template: _.template(template), + + dialog: null, + + initialize: function() { + + }, + + render: function() { + this.$el.html(this.template({ content: this.renderContent().html(), header: this.getHeader()})); + this.$el.addClass('modal hide'); + this.$el.css({opacity: 0, scale: 0.7}); + $("body").append(this.el); + + this.dialog = this.$el.omniWindow({ + overlay: { + selector: '#modal-overlay', + hideClass: 'hide', + animations: { + hide: function(subjects, internalCallback) { + subjects.overlay.fadeOut(400, function() { + internalCallback(subjects); + }); + }, + show: function(subjects, internalCallback) { + subjects.overlay.fadeIn(250, function() { + internalCallback(subjects); + }); + }}}, + modal: { + hideClass: 'hide', + animations: { + hide: function(subjects, internalCallback) { + subjects.modal.transition({opacity: 'hide', scale: 0.7}, 250, function() { + internalCallback(subjects); + }); + }, + + show: function(subjects, internalCallback) { + subjects.modal.transition({opacity: 'show', scale: 1}, 250, function() { + internalCallback(subjects); + }); + }} + }}); + + return this; + }, + renderContent: function() { + return $('<h1>Content!</h1>'); + }, + + getHeader: function() { + return 'Dialog'; + }, + + show: function() { + if (this.dialog === null) + this.render(); + + this.dialog.trigger('show'); + + // TODO: set focus on first element + }, + + hide: function() { + this.dialog.trigger('hide'); + }, + + destroy: function() { + this.$el.remove(); + this.dialog = null; + } + + }); +});
\ No newline at end of file |