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.updateDirtyContentModel();
43 commit: function(event) {
44 $('#commit-dialog', this.element).jqmShow({callback: this.doCommit.bind(this)});
47 doCommit: function(message) {
48 this.model.updateDirtyContentModel(message);
51 loadRelatedIssues: function(hash) {
53 var c = $('#commit-dialog-related-issues');
55 $('#commit-dialog-save-button').click(function(event, data)
57 if ($('#commit-dialog-message').val().match(/^\s*$/)) {
58 $('#commit-dialog-error-empty-message').fadeIn();
60 $('#commit-dialog-error-empty-message').hide();
61 $('#commit-dialog').jqmHide();
63 var message = $('#commit-dialog-message').val();
64 $('#commit-dialog-related-issues input:checked')
65 .each(function() { message += ' refs #' + $(this).val(); });
66 console.log("COMMIT APROVED", hash.t);
67 hash.t.callback(message);
72 $("div.loading-box", c).show();
73 $("div.fatal-error-box", c).hide();
74 $("div.container-box", c).hide();
76 // $.getJSON(c.attr('ui:ajax-src') + '?callback=?',
77 // function(data, status)
80 // $(data).each( function() {
81 // fmt += '<label><input type="checkbox" checked="checked"'
82 // fmt += ' value="' + this.id + '" />' + this.subject +'</label>\n'
84 // $("div.container-box", c).html(fmt);
85 // $("div.loading-box", c).hide();
86 // $("div.container-box", c).show();
92 update: function(event) {
95 merge: function(event) {
98 modelStateChanged: function(property, value) {
99 // Uaktualnia stan przycisków
100 if (value == 'dirty') {
101 this.quickSaveButton.attr('disabled', null);
102 this.commitButton.attr('disabled', null);
103 this.updateButton.attr('disabled', 'disabled');
104 this.mergeButton.attr('disabled', 'disabled');
105 } else if (value == 'synced') {
106 this.quickSaveButton.attr('disabled', 'disabled');
107 this.commitButton.attr('disabled', 'disabled');
108 this.updateButton.attr('disabled', null);
109 this.mergeButton.attr('disabled', null);
110 } else if (value == 'empty') {
111 this.quickSaveButton.attr('disabled', 'disabled');
112 this.commitButton.attr('disabled', 'disabled');
113 this.updateButton.attr('disabled', 'disabled');
114 this.mergeButton.attr('disabled', 'disabled');
118 dispose: function() {
119 $('#action-quick-save', this.element).unbind('click.editorview');
120 $('#action-commit', this.element).unbind('click.editorview');
121 $('#action-update', this.element).unbind('click.editorview');
122 $('#action-merge', this.element).unbind('click.editorview');
124 this.model.removeObserver(this);