2 'libs/text!./templates/restoreDialog.html',
5 ], function(restoreDialogTemplate, _, Backbone) {
10 var DialogView = Backbone.View.extend({
11 template: _.template(restoreDialogTemplate),
13 'click .restore-btn': 'onSave',
14 'click .cancel-btn': 'close',
15 'click .close': 'close'
17 initialize: function() {
19 this.actionsDisabled = false;
22 this.setElement(this.template());
23 this.$el.modal({backdrop: 'static'});
24 this.$el.modal('show');
25 this.$('textarea').focus();
30 this.trigger('restore', {
31 data: {description: view.$el.find('textarea').val()},
32 success: function() { view.actionsDisabled = false; view.close(); },
33 error: function() { view.actionsDisabled = false; view.close(); },
40 if(!this.actionsDisabled) {
41 this.$el.modal('hide');
45 toggleButtons: function(toggle) {
46 this.$('.btn, button').toggleClass('disabled', !toggle);
47 this.$('textarea').attr('disabled', !toggle);
48 this.actionsDisabled = !toggle;
54 return new DialogView();