From: Ɓukasz Rekucki Date: Fri, 28 Aug 2009 14:23:18 +0000 (+0200) Subject: Merge branch 'master' of git@stigma:platforma X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/12e7b7cbf07c8633f3093df7b4898156cca768f6?hp=-c Merge branch 'master' of git@stigma:platforma --- 12e7b7cbf07c8633f3093df7b4898156cca768f6 diff --combined project/static/js/editor.js index 131c8632,0f56fa79..7b145626 --- a/project/static/js/editor.js +++ b/project/static/js/editor.js @@@ -23,14 -23,15 +23,14 @@@ Panel.prototype.callHook = function() args = $.makeArray(arguments) var hookName = args.splice(0,1)[0] var noHookAction = args.splice(0,1)[0] + var result = false; $.log('calling hook: ', hookName, 'with args: ', args); if(this.hooks && this.hooks[hookName]) - { - return this.hooks[hookName].apply(this, args); - } - else if (noHookAction instanceof Function) - return noHookAction(args); - else return false; + result = this.hooks[hookName].apply(this, args); + else if (noHookAction instanceof Function) + result = noHookAction(args); + return result; } Panel.prototype.load = function (url) { @@@ -68,10 -69,9 +68,10 @@@ Panel.prototype.unload = function(event } Panel.prototype.refresh = function(event, data) { + var self = this; reload = function() { - $.log('hard reload for panel ', this.current_url); - this.load(this.current_url); + $.log('hard reload for panel ', self.current_url); + self.load(self.current_url); return true; } @@@ -86,8 -86,7 +86,7 @@@ Panel.prototype.otherPanelChanged = fun } Panel.prototype.markChanged = function () { - if(!this.wrap.hasClass('changed') ) // TODO: is this needed ? - this.wrap.addClass('changed'); + this.wrap.addClass('changed'); } Panel.prototype.changed = function () { @@@ -130,10 -129,11 +129,10 @@@ Editor.prototype.setupUI = function() }); }); - $(document).bind('panel:contentChanged', function(event, data) { - $('#toolbar-button-save').removeAttr('disabled'); - }); + $(document).bind('panel:contentChanged', function() { self.onContentChanged.apply(self, arguments) }); $('#toolbar-button-save').click( function (event, data) { self.saveToBranch(); } ); + $('#toolbar-button-commit').click( function (event, data) { self.sendPullRequest(); } ); self.rootDiv.bind('stopResize', function() { self.savePanelOptions() }); } @@@ -222,11 -222,9 +221,11 @@@ Editor.prototype.saveToBranch = functio success: function(data, textStatus) { if (data.result != 'ok') $.log('save errors: ', data.errors) - else + else { self.refreshPanels(changed_panel); - $('#toolbar-button-save').attr('disabled', 'disabled'); + $('#toolbar-button-save').attr('disabled', 'disabled'); + $('#toolbar-button-commit').removeAttr('disabled'); + } }, error: function(rq, tstat, err) { $.log('save error', rq, tstat, err); @@@ -236,18 -234,13 +235,18 @@@ }); }; +Editor.prototype.onContentChanged = function(event, data) { + $('#toolbar-button-save').removeAttr('disabled'); + $('#toolbar-button-commit').attr('disabled', 'disabled'); +}; + Editor.prototype.refreshPanels = function(goodPanel) { var self = this; var panels = $('#' + self.rootDiv.attr('id') +' > *.panel-wrap', self.rootDiv.parent()); panels.each(function() { var panel = $(this).data('ctrl'); - $.log(this, panel); + $.log('Refreshing: ', this, panel); if ( panel.changed() ) panel.unmarkChanged(); else @@@ -255,25 -248,6 +254,25 @@@ }); }; + +Editor.prototype.sendPullRequest = function () { + if( $('.panel-wrap.changed').length != 0) + alert("There are unsaved changes - can't make a pull request."); + + $.ajax({ + url: '/pull-request', + dataType: 'json', + success: function(data, textStatus) { + $.log('data: ' + data); + }, + error: function(rq, tstat, err) { + $.log('commit error', rq, tstat, err); + }, + type: 'POST', + data: {} + }); +} + $(function() { editor = new Editor(); diff --combined project/templates/explorer/panels/xmleditor.html index f93e6eaa,90771a1a..2253609c --- a/project/templates/explorer/panels/xmleditor.html +++ b/project/templates/explorer/panels/xmleditor.html @@@ -1,6 -1,10 +1,10 @@@ {% load toolbar_tags %} {% toolbar %} +
+
A-
+
A+
+
@@@ -74,6 -78,18 +78,18 @@@ panel_hooks = } }); + $('.decrease-font-size', panel).click(function() { + var frameBody = $('body', $(texteditor.frame).contents()); + console.log(frameBody.css('font-size')); + frameBody.css('font-size', parseInt(frameBody.css('font-size')) - 2); + }); + + $('.increase-font-size', panel).click(function() { + var frameBody = $('body', $(texteditor.frame).contents()); + console.log(frameBody.css('font-size')); + frameBody.css('font-size', parseInt(frameBody.css('font-size')) + 2); + }); + this.texteditor = texteditor; }, @@@ -82,7 -98,9 +98,7 @@@ }, - refresh: function() { - return false; - }, + //refresh: function() { }, // no support for refresh saveInfo: function(saveInfo) { var myInfo = {