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