1 /*global View render_template panels */
2 var EditorView = View.extend({
3 _className: 'EditorView',
8 init: function(element, model, template) {
9 this._super(element, model, template);
12 this.quickSaveButton = $('#action-quick-save', this.element).bind('click.editorview', this.quickSave.bind(this));
13 this.commitButton = $('#action-commit', this.element).bind('click.editorview', this.commit.bind(this));
14 this.updateButton = $('#action-update', this.element).bind('click.editorview', this.update.bind(this));
15 this.mergeButton = $('#action-merge', this.element).bind('click.editorview', this.merge.bind(this));
17 this.model.addObserver(this, 'state', this.modelStateChanged.bind(this));
18 this.modelStateChanged('state', this.model.get('state'));
21 quickSave: function(event) {
22 this.model.quickSave();
25 commit: function(event) {
28 update: function(event) {
31 merge: function(event) {
34 modelStateChanged: function(property, value) {
35 // Uaktualnia stan przycisków
36 if (value == 'dirty') {
37 this.quickSaveButton.attr('disabled', null);
38 this.commitButton.attr('disabled', null);
39 this.updateButton.attr('disabled', 'disabled');
40 this.mergeButton.attr('disabled', 'disabled');
41 } else if (value == 'synced') {
42 this.quickSaveButton.attr('disabled', 'disabled');
43 this.commitButton.attr('disabled', 'disabled');
44 this.updateButton.attr('disabled', null);
45 this.mergeButton.attr('disabled', null);
46 } else if (value == 'empty') {
47 this.quickSaveButton.attr('disabled', 'disabled');
48 this.commitButton.attr('disabled', 'disabled');
49 this.updateButton.attr('disabled', 'disabled');
50 this.mergeButton.attr('disabled', 'disabled');
55 $('#action-quick-save', this.element).unbind('click.editorview');
56 $('#action-commit', this.element).unbind('click.editorview');
57 $('#action-update', this.element).unbind('click.editorview');
58 $('#action-merge', this.element).unbind('click.editorview');
60 this.model.removeObserver(this);