From: zuber Date: Tue, 29 Sep 2009 11:57:02 +0000 (+0200) Subject: Działający przycisk "Commit". X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/d1582246fb727ec53bb984b432a3a59ce86ea772?hp=--cc Działający przycisk "Commit". --- d1582246fb727ec53bb984b432a3a59ce86ea772 diff --git a/project/static/js/models.js b/project/static/js/models.js index 8ea488e1..0402e6dd 100644 --- a/project/static/js/models.js +++ b/project/static/js/models.js @@ -230,7 +230,7 @@ Editor.DocumentModel = Editor.Model.extend({ } }, - quickSave: function(message) { + updateDirtyContentModel: function(message) { for (var key in this.contentModels) { if (this.contentModels[key].get('state') == 'dirty') { this.contentModels[key].update(message); diff --git a/project/static/js/views/editor.js b/project/static/js/views/editor.js index 1e39ca56..49b5e022 100644 --- a/project/static/js/views/editor.js +++ b/project/static/js/views/editor.js @@ -16,13 +16,77 @@ 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.updateDirtyContentModel(); }, commit: function(event) { + $('#commit-dialog', this.element).jqmShow({callback: this.doCommit.bind(this)}); + }, + + doCommit: function(message) { + this.model.updateDirtyContentModel(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(); }, update: function(event) { diff --git a/project/templates/explorer/editor.html b/project/templates/explorer/editor.html index d0756788..3a64e8d3 100644 --- a/project/templates/explorer/editor.html +++ b/project/templates/explorer/editor.html @@ -1,12 +1,16 @@ {% extends "base.html" %} {% block extrahead %} + + - + {# Libraries #} + + {# Scriptlets #} @@ -85,7 +89,7 @@ {% endblock %} {% block header-toolbar %} - + {% endblock %} {% block maincontent %} @@ -95,35 +99,35 @@ - {#
#} - {#
#} - {# #} - {# #} - {#

Wiadomość nie może być pusta.

#} - {# #} - {#

#} - {# #} - {# #} - {#

#} - {#
#} - {#
#} - {# #} - {#
#} - {#
#} - {# #} - {# #} - {#
#} + + + {% endblock maincontent %}