X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/dcbcc948a5d3044fee2839dbe508ab1eb4ba54dc..72dfc92f908add69b4d862e9b6c3107e2a8acd21:/modules/data/saveDialog.js?ds=sidebyside diff --git a/modules/data/saveDialog.js b/modules/data/saveDialog.js index 2108276..d0049d5 100644 --- a/modules/data/saveDialog.js +++ b/modules/data/saveDialog.js @@ -1,56 +1,56 @@ -define([ -'libs/text!./saveDialog.html', -'libs/underscore-min', -'libs/backbone-min', -'libs/jquery-1.9.1.min' -], function(saveDialogTemplate, _, Backbone, $) { - - var DialogView = Backbone.View.extend({ - template: _.template(saveDialogTemplate), - events: { - 'click .save-btn': 'onSave', - 'click .cancel-btn': 'close', - 'click .close': 'close' - }, - initialize: function() { - _.bindAll(this); - this.actionsDisabled = false; - }, - show: function() { - this.setElement(this.template()); - this.$el.modal({backdrop: 'static'}); - this.$el.modal('show'); - this.$('textarea').focus(); - - }, - onSave: function(e) { - e.preventDefault(); - var view = this; - this.trigger('save', { - data: {description: view.$el.find('textarea').val()}, - success: function() { view.actionsDisabled = false; view.close(); }, - error: function() { view.actionsDisabled = false; view.close(); }, - }) - }, - close: function(e) { - if(e) - e.preventDefault(); - if(!this.actionsDisabled) { - this.$el.modal('hide'); - this.$el.remove(); - } - }, - toggleButtons: function(toggle) { - this.$('.btn, button').toggleClass('disabled', !toggle); - this.$('textarea').attr('disabled', !toggle); - this.actionsDisabled = !toggle; - } - }); - - return { - create: function() { - return new DialogView(); - } - } - +define([ +'libs/text!./saveDialog.html', +'libs/underscore-min', +'libs/backbone-min', +'libs/jquery-1.9.1.min' +], function(saveDialogTemplate, _, Backbone, $) { + + var DialogView = Backbone.View.extend({ + template: _.template(saveDialogTemplate), + events: { + 'click .save-btn': 'onSave', + 'click .cancel-btn': 'close', + 'click .close': 'close' + }, + initialize: function() { + _.bindAll(this); + this.actionsDisabled = false; + }, + show: function() { + this.setElement(this.template()); + this.$el.modal({backdrop: 'static'}); + this.$el.modal('show'); + this.$('textarea').focus(); + + }, + onSave: function(e) { + e.preventDefault(); + var view = this; + this.trigger('save', { + data: {description: view.$el.find('textarea').val()}, + success: function() { view.actionsDisabled = false; view.close(); }, + error: function() { view.actionsDisabled = false; view.close(); }, + }); + }, + close: function(e) { + if(e) + e.preventDefault(); + if(!this.actionsDisabled) { + this.$el.modal('hide'); + this.$el.remove(); + } + }, + toggleButtons: function(toggle) { + this.$('.btn, button').toggleClass('disabled', !toggle); + this.$('textarea').attr('disabled', !toggle); + this.actionsDisabled = !toggle; + } + }); + + return { + create: function() { + return new DialogView(); + } + }; + }); \ No newline at end of file