FIX: Skrypt jquery.loggin.js nie działał w Safari 4.
[redakcja.git] / project / templates / explorer / panels / xmleditor.html
index 89990a4..dfe9477 100644 (file)
@@ -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>