X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/889882b4d84fb826afc834040b203dff2fb4a224..acfc09bd38e71bffb09f0d78ca1fa24888a471d8:/project/static/js/editor.js?ds=sidebyside diff --git a/project/static/js/editor.js b/project/static/js/editor.js index fa796dba..79b7fa90 100644 --- a/project/static/js/editor.js +++ b/project/static/js/editor.js @@ -92,7 +92,8 @@ Panel.prototype.unload = function(event, data) { $(this.contentDiv).html(''); // disconnect the toolbar - $('div.panel-toolbar span.panel-toolbar-extra', this.wrap).empty(); + $('div.panel-toolbar span.panel-toolbar-extra', this.wrap).html( + ''); this.callHook('unload'); this.hooks = null; // flush the hooks @@ -149,12 +150,9 @@ Panel.prototype.connectToolbar = function() if(toolbar.length === 0) return; // move the extra - var extra_buttons = $('span.panel-toolbar-extra', toolbar); - var placeholder = $('div.panel-toolbar span.panel-toolbar-extra', this.wrap); - placeholder.replaceWith(extra_buttons); - placeholder.hide(); - - var action_buttons = $('button', extra_buttons); + var extra_buttons = $('span.panel-toolbar-extra button', toolbar); + var placeholder = $('div.panel-toolbar span.panel-toolbar-extra > span', this.wrap); + placeholder.replaceWith(extra_buttons); // connect group-switch buttons var group_buttons = $('*.toolbar-tabs-container button', toolbar); @@ -185,7 +183,7 @@ Panel.prototype.connectToolbar = function() }); // connect action buttons - var allbuttons = $.makeArray(action_buttons); + var allbuttons = $.makeArray(extra_buttons); $.merge(allbuttons, $.makeArray($('*.toolbar-button-groups-container button', toolbar)) ); @@ -253,7 +251,9 @@ Panel.prototype.isHotkey = function(event) { if(event.ctrlKey) code = code | 0x200; if(event.shiftKey) code = code | 0x400; - if(this.hotkeys[code] !== null) { + $.log(event.character, this.hotkeys[code]); + + if(this.hotkeys[code]) { return true; } return false; @@ -301,6 +301,10 @@ Editor.prototype.loadConfig = function() { this.fileOptions = this.options; var self = this; + + if(!this.options.recentFiles) + this.options.recentFiles = []; + $.each(this.options.recentFiles, function(index) { if (fileId == self.options.recentFiles[index].fileId) { $.log('Found options for', fileId); @@ -378,7 +382,7 @@ Editor.prototype.saveToBranch = function(msg) var self = this; $.log('Saving to local branch - panel:', changed_panel); - if(!msg) msg = "Zapis z edytora platformy."; + if(!msg) msg = "Szybki zapis z edytora platformy."; if( changed_panel.length === 0) { $.log('Nothing to save.'); @@ -419,7 +423,7 @@ Editor.prototype.saveToBranch = function(msg) if(self.autosaveTimer) { clearTimeout(self.autosaveTimer); } - if (data.warnings === null) { + if (data.warnings === null || data.warning === undefined) { self.showPopup('save-successful'); } else { self.showPopup('save-warn', data.warnings[0]); @@ -450,9 +454,8 @@ Editor.prototype.autoSave = function() Editor.prototype.onContentChanged = function(event, data) { var self = this; - $('#toolbar-button-save').removeAttr('disabled'); - $('#toolbar-button-commit').attr('disabled', 'disabled'); - $('#toolbar-button-update').attr('disabled', 'disabled'); + $('button.provides-save').removeAttr('disabled'); + $('button.requires-save').attr('disabled', 'disabled'); if(this.autosaveTimer) return; this.autosaveTimer = setTimeout( function() { @@ -495,9 +498,8 @@ Editor.prototype.sendMergeRequest = function (message) { alert("There are unsaved changes - can't commit."); } - var self = this; - $.log('URL !: ', $('#commit-dialog form').attr('action')); - + var self = this; + $.ajax({ url: $('#commit-dialog form').attr('action'), dataType: 'json',