2 'libs/text!./saveDialog.html',
5 'libs/jquery-1.9.1.min'
6 ], function(saveDialogTemplate, _, Backbone, $) {
8 var DialogView = Backbone.View.extend({
9 template: _.template(saveDialogTemplate),
11 'click .save-btn': 'onSave',
12 'click .cancel-btn': 'close',
13 'click .close': 'close'
15 initialize: function() {
17 this.actionsDisabled = false;
20 this.setElement(this.template());
21 this.$el.modal({backdrop: 'static'});
22 this.$el.modal('show');
23 this.$('textarea').focus();
29 this.trigger('save', {
30 data: {description: view.$el.find('textarea').val()},
31 success: function() { view.actionsDisabled = false; view.close(); },
32 error: function() { view.actionsDisabled = false; view.close(); },
38 if(!this.actionsDisabled) {
39 this.$el.modal('hide');
43 toggleButtons: function(toggle) {
44 this.$('.btn, button').toggleClass('disabled', !toggle);
45 this.$('textarea').attr('disabled', !toggle);
46 this.actionsDisabled = !toggle;
52 return new DialogView();