Panele posiadaja teraz obiekt kontroller, który trzyma ich stan. TODO: lepsza inicjal...
[redakcja.git] / project / templates / explorer / panels / xmleditor.html
index f2a6d73..dfe9477 100644 (file)
@@ -7,6 +7,7 @@
 
 <script type="text/javascript" charset="utf-8">
 (function() {
 
 <script type="text/javascript" charset="utf-8">
 (function() {
+
     function xmleditor_onload(event, panel) {
         var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
         $('textarea', panel).attr('id', textareaId);
     function xmleditor_onload(event, panel) {
         var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
         $('textarea', panel).attr('id', textareaId);
             path: "/static/js/codemirror/",
             stylesheet: "/static/css/xmlcolors.css",
             parserConfig: {useHTMLKludges: false},
             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() {
                     var id = $(this).attr('p:button-list');
                 // Toolbar
                 $('.toolbar-tabs li', panel).click(function() {
                     var id = $(this).attr('p:button-list');
                     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();
-                        console.log(editor, editor.frame);
                         editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
                         if (text.length == 0) {
                             var pos = editor.cursorPosition();
                             editor.selectLines(pos.line, pos.character + tag.length + 2);
                         }
                         editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
                         if (text.length == 0) {
                             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;
@@ -67,8 +71,7 @@
         });
     };
     
         });
     };
     
-    function xmleditor_onunload(event, panel) {}
-    
-    panel(xmleditor_onload, xmleditor_onunload);
+       // define the callback
+       load_callback = xmleditor_onload;
 })();
 </script>
 })();
 </script>