X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/0da45be34c7019ee362d1892e92dd53e743933b6..d00fdcaf7bba586060d69f3526347dc19d711a19:/project/static/js/editor.ui.js?ds=inline diff --git a/project/static/js/editor.ui.js b/project/static/js/editor.ui.js index 41025fa0..8932b4e6 100755 --- a/project/static/js/editor.ui.js +++ b/project/static/js/editor.ui.js @@ -15,6 +15,11 @@ Editor.prototype.setupUI = function() { var resize_changed = function(event) { var old_width = parseInt(event.data.overlay.css('width')); var delta = event.pageX + event.data.hotspot_x - old_width; + + if(old_width + delta < 12) delta = 12 - old_width; + if(old_width + delta > $(window).width()) + delta = $(window).width() - old_width; + event.data.overlay.css({ 'width': old_width + delta }); @@ -135,18 +140,20 @@ Editor.prototype.setupUI = function() { $(document).bind('panel:contentChanged', function() { self.onContentChanged.apply(self, arguments) - }); - - + }); /* * Connect various buttons */ - $('#toolbar-button-save').click( function (event, data) { + $('#toolbar-button-quick-save').click( function (event, data) { self.saveToBranch(); } ); + $('#toolbar-button-save').click( function (event, data) { + $('#commit-dialog').jqmShow( {callback: $.fbind(self, self.saveToBranch)} ); + } ); + $('#toolbar-button-update').click( function (event, data) { if (self.updateUserBranch()) { // commit/update can be called only after proper, save @@ -160,15 +167,36 @@ Editor.prototype.setupUI = function() { $('#commit-dialog'). jqm({ modal: true, - trigger: '#toolbar-button-commit' + onShow: $.fbind(self, self.loadRelatedIssues) }); + $('#toolbar-button-commit').click( function (event, data) { + $('#commit-dialog').jqmShow( {callback: $.fbind(self, self.sendMergeRequest)} ); + } ); + + /* STATIC BINDS */ $('#commit-dialog-cancel-button').click(function() { $('#commit-dialog-error-empty-message').hide(); $('#commit-dialog').jqmHide(); - }); + }); + + + /* SPLIT DIALOG */ + $('#split-dialog').jqm({ + modal: true, + onShow: $.fbind(self, self.loadSplitDialog) + }). + jqmAddClose('button.dialog-close-button'); + +// $('#split-dialog'). +} + +Editor.prototype.loadRelatedIssues = function(hash) +{ + var self = this; + var c = $('#commit-dialog-related-issues'); - $('#commit-dialog-save-button').click( function (event, data) + $('#commit-dialog-save-button').click( function (event, data) { if( $('#commit-dialog-message').val().match(/^\s*$/)) { $('#commit-dialog-error-empty-message').fadeIn(); @@ -176,20 +204,35 @@ Editor.prototype.setupUI = function() { else { $('#commit-dialog-error-empty-message').hide(); $('#commit-dialog').jqmHide(); - self.sendMergeRequest($('#commit-dialog-message').val() ); - } - - return false; - }); - /* SPLIT DIALOG */ - $('#split-dialog').jqm({ - modal: true, - onShow: $.fbind(self, self.loadSplitDialog) - }). - jqmAddClose('button.dialog-close-button'); + var message = $('#commit-dialog-message').val(); + $('#commit-dialog-related-issues input:checked'). + each(function() { message += ' refs #' + $(this).val(); }); + $.log("COMMIT APROVED", hash.t); + hash.t.callback(message); + } -// $('#split-dialog'). + 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(); } Editor.prototype.loadSplitDialog = function(hash) @@ -270,9 +313,8 @@ Editor.prototype.refreshPanels = function() { panel.refresh(); }); - $('#toolbar-button-save').attr('disabled', 'disabled'); - $('#toolbar-button-commit').removeAttr('disabled'); - $('#toolbar-button-update').removeAttr('disabled'); + $('button.provides-save').attr('disabled', 'disabled'); + $('button.requires-save').removeAttr('disabled'); }; /*