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'));
20 // Inicjalizacja okien jQuery Modal
21 $('#commit-dialog', this.element).
24 onShow: this.loadRelatedIssues.bind(this)
27 $('#commit-dialog-cancel-button', this.element).click(function() {
28 $('#commit-dialog-error-empty-message').hide();
29 $('#commit-dialog').jqmHide();
32 // $('#split-dialog').jqm({
34 // onShow: $.fbind(self, self.loadSplitDialog)
36 // jqmAddClose('button.dialog-close-button');
39 quickSave: function(event) {
40 this.model.saveDirtyContentModel();
43 commit: function(event) {
44 $('#commit-dialog', this.element).jqmShow({callback: this.doCommit.bind(this)});
47 doCommit: function(message) {
48 this.model.saveDirtyContentModel(message);
51 update: function(event) {
55 merge: function(event) {
56 $('#commit-dialog', this.element).jqmShow({callback: this.doMerge.bind(this)});
59 doMerge: function(message) {
60 this.model.merge(message);
63 loadRelatedIssues: function(hash) {
65 var c = $('#commit-dialog-related-issues');
67 $('#commit-dialog-save-button').click(function(event, data)
69 if ($('#commit-dialog-message').val().match(/^\s*$/)) {
70 $('#commit-dialog-error-empty-message').fadeIn();
72 $('#commit-dialog-error-empty-message').hide();
73 $('#commit-dialog').jqmHide();
75 var message = $('#commit-dialog-message').val();
76 $('#commit-dialog-related-issues input:checked')
77 .each(function() { message += ' refs #' + $(this).val(); });
78 console.log("COMMIT APROVED", hash.t);
79 hash.t.callback(message);
84 $("div.loading-box", c).show();
85 $("div.fatal-error-box", c).hide();
86 $("div.container-box", c).hide();
88 $.getJSON(c.attr('ui:ajax-src') + '?callback=?',
89 function(data, status)
92 $(data).each( function() {
93 fmt += '<label><input type="checkbox" checked="checked"';
94 fmt += ' value="' + this.id + '" />' + this.subject +'</label>\n';
96 $("div.container-box", c).html(fmt);
97 $("div.loading-box", c).hide();
98 $("div.container-box", c).show();
104 modelStateChanged: function(property, value) {
105 // Uaktualnia stan przycisków
106 if (value == 'dirty') {
107 this.quickSaveButton.attr('disabled', null);
108 this.commitButton.attr('disabled', null);
109 this.updateButton.attr('disabled', 'disabled');
110 this.mergeButton.attr('disabled', 'disabled');
111 } else if (value == 'synced') {
112 this.quickSaveButton.attr('disabled', 'disabled');
113 this.commitButton.attr('disabled', 'disabled');
114 this.updateButton.attr('disabled', null);
115 this.mergeButton.attr('disabled', null);
116 } else if (value == 'empty') {
117 this.quickSaveButton.attr('disabled', 'disabled');
118 this.commitButton.attr('disabled', 'disabled');
119 this.updateButton.attr('disabled', 'disabled');
120 this.mergeButton.attr('disabled', 'disabled');
124 dispose: function() {
125 $('#action-quick-save', this.element).unbind('click.editorview');
126 $('#action-commit', this.element).unbind('click.editorview');
127 $('#action-update', this.element).unbind('click.editorview');
128 $('#action-merge', this.element).unbind('click.editorview');
130 this.model.removeObserver(this);