X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/bb42027c8fd9ed17234381d3c366c387a20592f0..a398f2a96740ebe6dd60559d90e74c648e7009af:/modules/documentHistory/restoreDialog.js diff --git a/modules/documentHistory/restoreDialog.js b/modules/documentHistory/restoreDialog.js index 97ea2af..a9de353 100644 --- a/modules/documentHistory/restoreDialog.js +++ b/modules/documentHistory/restoreDialog.js @@ -1,55 +1,55 @@ -define([ -'libs/text!./templates/restoreDialog.html', -'libs/underscore-min', -'libs/backbone-min', -'libs/jquery-1.9.1.min' -], function(restoreDialogTemplate, _, Backbone, $) { - - var DialogView = Backbone.View.extend({ - template: _.template(restoreDialogTemplate), - events: { - 'click .restore-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('restore', { - 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!./templates/restoreDialog.html', +'libs/underscore-min', +'libs/backbone-min', +'libs/jquery-1.9.1.min' +], function(restoreDialogTemplate, _, Backbone, $) { + + var DialogView = Backbone.View.extend({ + template: _.template(restoreDialogTemplate), + events: { + 'click .restore-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('restore', { + 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