Poprawka błędu jquery.logging.js w Firefox.
[redakcja.git] / project / templates / explorer / panels / xmleditor.html
1 {% load toolbar_tags %}
2
3 {% toolbar %}
4 <div class="iframe-container" style="position: absolute; top: 48px; left:0px; right:0px; bottom: 0px;">
5         <textarea name="text">{{ text }}</textarea>
6 </div>
7
8 <script type="text/javascript" charset="utf-8">
9 (function() {
10     function xmleditor_onload(event, panel) {
11         var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
12         $('textarea', panel).attr('id', textareaId);
13         var editor = CodeMirror.fromTextArea(textareaId, {
14             parserfile: 'parsexml.js',
15             path: "/static/js/codemirror/",
16             stylesheet: "/static/css/xmlcolors.css",
17             parserConfig: {useHTMLKludges: false},
18             onChange: function() {
19                 $(document).trigger('panel:contentChanged', panel);
20             },
21             initCallback: function(editor) {
22                 // Toolbar
23                 $('.toolbar-tabs li', panel).click(function() {
24                     var id = $(this).attr('p:button-list');
25                     $('.toolbar-tabs li', panel).removeClass('active');
26                     $(this).addClass('active');
27                     if (!$('.' + id, panel).is(':visible')) {
28                         $('.toolbar-buttons ol', panel).not('#' + id).hide();
29                         $('.' + id, panel).show();
30                     }
31                 })
32                 
33                 var keys = {};
34                 $('.toolbar-buttons li', panel).each(function() {
35                     var tag = $(this).attr('p:tag');
36                     var handler = function() {
37                         var text = editor.selection();
38                         editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
39                         if (text.length == 0) {
40                             var pos = editor.cursorPosition();
41                             editor.selectLines(pos.line, pos.character + tag.length + 2);
42                         }
43                         $(document).trigger('panel:contentChanged', panel);
44                     }
45                     if ($(this).attr('p:key')) {
46                         keys[$(this).attr('p:key')] = handler;
47                     }
48                     $(this).click(handler)
49                 });
50
51                 editor.grabKeys(function(event) { 
52                     if (keys[event.keyCode]) {
53                         keys[event.keyCode]();
54                     }
55                 }, function(event) { return event.altKey && keys[event.keyCode]; });
56             }
57         })
58         
59         $(editor.frame).css({width: '100%', height: '100%'});
60         
61         $('#toolbar-buttons li').wTooltip({
62             delay: 1000, 
63             style: {
64                 border: "1px solid #7F7D67",
65                 opacity: 0.9, 
66                 background: "#FBFBC6", 
67                 padding: "1px",
68                 fontSize: "12px",
69             }
70         });
71     };
72     
73     function xmleditor_onunload(event, panel) {}
74     
75     panel(xmleditor_onload, xmleditor_onunload);
76 })();
77 </script>