X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/320fd24b68185b73f1180c425271e037331baa46..a695f4ce2259e5758e56f36727ef0e0507b58f81:/project/static/js/views/editor.js diff --git a/project/static/js/views/editor.js b/project/static/js/views/editor.js index 1e39ca56..e9e62e99 100644 --- a/project/static/js/views/editor.js +++ b/project/static/js/views/editor.js @@ -16,19 +16,89 @@ var EditorView = View.extend({ this.model.addObserver(this, 'state', this.modelStateChanged.bind(this)); this.modelStateChanged('state', this.model.get('state')); + + // Inicjalizacja okien jQuery Modal + $('#commit-dialog', this.element). + jqm({ + modal: true, + onShow: this.loadRelatedIssues.bind(this) + }); + + $('#commit-dialog-cancel-button', this.element).click(function() { + $('#commit-dialog-error-empty-message').hide(); + $('#commit-dialog').jqmHide(); + }); + + // $('#split-dialog').jqm({ + // modal: true, + // onShow: $.fbind(self, self.loadSplitDialog) + // }). + // jqmAddClose('button.dialog-close-button'); }, quickSave: function(event) { - this.model.quickSave(); + this.model.saveDirtyContentModel(); }, commit: function(event) { + $('#commit-dialog', this.element).jqmShow({callback: this.doCommit.bind(this)}); + }, + + doCommit: function(message) { + this.model.saveDirtyContentModel(message); }, update: function(event) { + this.model.update(); }, merge: function(event) { + $('#commit-dialog', this.element).jqmShow({callback: this.doMerge.bind(this)}); + }, + + doMerge: function(message) { + this.model.merge(message); + }, + + loadRelatedIssues: function(hash) { + var self = this; + var c = $('#commit-dialog-related-issues'); + + $('#commit-dialog-save-button').click(function(event, data) + { + if ($('#commit-dialog-message').val().match(/^\s*$/)) { + $('#commit-dialog-error-empty-message').fadeIn(); + } else { + $('#commit-dialog-error-empty-message').hide(); + $('#commit-dialog').jqmHide(); + + var message = $('#commit-dialog-message').val(); + $('#commit-dialog-related-issues input:checked') + .each(function() { message += ' refs #' + $(this).val(); }); + console.log("COMMIT APROVED", hash.t); + hash.t.callback(message); + } + return false; + }); + + $("div.loading-box", c).show(); + $("div.fatal-error-box", c).hide(); + $("div.container-box", c).hide(); + + $.getJSON(c.attr('ui:ajax-src') + '?callback=?', + function(data, status) + { + var fmt = ''; + $(data).each( function() { + fmt += '\n'; + }); + $("div.container-box", c).html(fmt); + $("div.loading-box", c).hide(); + $("div.container-box", c).show(); + }); + + hash.w.show(); }, modelStateChanged: function(property, value) {