Merge branch 'master' of git@stigma:platforma
[redakcja.git] / project / templates / explorer / panels / xmleditor.html
index 89990a4..0c8724f 100644 (file)
@@ -7,28 +7,31 @@
 
 <script type="text/javascript" charset="utf-8">
 (function() {
 
 <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);
         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},
         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
-                $('#toolbar-tabs li', panel).click(function() {
+                $('.toolbar-tabs li', panel).click(function() {
                     var id = $(this).attr('p:button-list');
                     var id = $(this).attr('p:button-list');
-                    $('#toolbar-tabs li', panel).removeClass('active');
+                    $('.toolbar-tabs li', panel).removeClass('active');
                     $(this).addClass('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 = {};
                     }
                 })
                 
                 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();
                     var tag = $(this).attr('p:tag');
                     var handler = function() {
                         var text = editor.selection();
@@ -37,6 +40,7 @@
                             var pos = editor.cursorPosition();
                             editor.selectLines(pos.line, pos.character + tag.length + 2);
                         }
                             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;
                     }
                     if ($(this).attr('p:key')) {
                         keys[$(this).attr('p:key')] = handler;
@@ -66,7 +70,7 @@
         });
     };
     
         });
     };
     
-    function xmleditor_onunload(event, me) {}
+    function xmleditor_onunload(event, panel) {}
     
     panel(xmleditor_onload, xmleditor_onunload);
 })();
     
     panel(xmleditor_onload, xmleditor_onunload);
 })();