X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/36ea564aabce5f15b890fabaa06faf34d7bd1044..4af60771b6c6a164465057e08bdbc2de583410a8:/project/templates/explorer/panels/xmleditor.html diff --git a/project/templates/explorer/panels/xmleditor.html b/project/templates/explorer/panels/xmleditor.html index 89990a4a..dfe94774 100644 --- a/project/templates/explorer/panels/xmleditor.html +++ b/project/templates/explorer/panels/xmleditor.html @@ -7,28 +7,32 @@ <script type="text/javascript" charset="utf-8"> (function() { - function xmleditor_onload(event, me) { + + function xmleditor_onload(event, panel) { var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000); - $('textarea', me).attr('id', textareaId); + $('textarea', panel).attr('id', textareaId); var editor = CodeMirror.fromTextArea(textareaId, { parserfile: 'parsexml.js', path: "/static/js/codemirror/", stylesheet: "/static/css/xmlcolors.css", parserConfig: {useHTMLKludges: false}, - initCallback: function() { + onChange: function() { + $(document).trigger('panel:contentChanged', panel); + }, + initCallback: function(editor) { // Toolbar - $('#toolbar-tabs li', panel).click(function() { + $('.toolbar-tabs li', panel).click(function() { var id = $(this).attr('p:button-list'); - $('#toolbar-tabs li', panel).removeClass('active'); + $('.toolbar-tabs li', panel).removeClass('active'); $(this).addClass('active'); - if (!$('#' + id).is(':visible')) { - $('#toolbar-buttons ol', panel).not('#' + id).hide(); - $('#' + id, panel).show(); + if (!$('.' + id, panel).is(':visible')) { + $('.toolbar-buttons ol', panel).not('#' + id).hide(); + $('.' + id, panel).show(); } }) var keys = {}; - $('#toolbar-buttons li', panel).each(function() { + $('.toolbar-buttons li', panel).each(function() { var tag = $(this).attr('p:tag'); var handler = function() { var text = editor.selection(); @@ -37,6 +41,7 @@ var pos = editor.cursorPosition(); editor.selectLines(pos.line, pos.character + tag.length + 2); } + $(document).trigger('panel:contentChanged', panel); } if ($(this).attr('p:key')) { keys[$(this).attr('p:key')] = handler; @@ -66,8 +71,7 @@ }); }; - function xmleditor_onunload(event, me) {} - - panel(xmleditor_onload, xmleditor_onunload); + // define the callback + load_callback = xmleditor_onload; })(); </script>