2 'libs/text!./saveDialog.html',
5 ], function(saveDialogTemplate, _, Backbone) {
9 var DialogView = Backbone.View.extend({
10 template: _.template(saveDialogTemplate),
12 'click .save-btn': 'onSave',
13 'click .cancel-btn': 'close',
14 'click .close': 'close'
16 initialize: function() {
18 this.actionsDisabled = false;
21 this.setElement(this.template());
22 this.$el.modal({backdrop: 'static'});
23 this.$el.modal('show');
24 this.$('textarea').focus();
30 this.trigger('save', {
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();