Templaty używają teraz ścieżek z konfiguracji dal plików statycznych.
[redakcja.git] / project / templates / explorer / panels / xmleditor.html
1 {% load toolbar_tags %}
2
3
4 <div class="change-font-size" style="">
5     <div class="decrease-font-size">A<sup>-</sup></div>
6     <div class="increase-font-size">A<sup>+</sup></div>
7 </div>
8
9 <div class="iframe-container" style="position: absolute; top: 41pt; left:0px; right:0px; bottom: 0px;">
10         <textarea name="text">{{ text }}</textarea>
11 </div>
12
13
14 {% toolbar %}
15
16 <script type="text/javascript" charset="utf-8">
17
18 panel_hooks = {
19         load: function () {
20                 var self = this;
21                 var panel = self.contentDiv;
22
23         var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
24                 $('textarea', panel).attr('id', textareaId);
25
26                 var texteditor = CodeMirror.fromTextArea(textareaId, {
27             parserfile: 'parsexml.js',
28             path: "{{STATIC_URL}}js/codemirror/",
29             stylesheet: "{{STATIC_URL}}css/xmlcolors.css",
30             parserConfig: {useHTMLKludges: false},
31             onChange: function() {
32                                 panel.trigger('panel:contentChanged', self);
33             },
34             initCallback: function(editor) {
35                 // Editor is loaded
36                 // Buttons are connected
37                 // register callbacks for actions
38                 $(document).bind("ui:action:INSERT_TAG", function(event, data) {
39                     var tag = data;
40                     var text = texteditor.selection();
41                     editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
42                     if (text.length == 0) {
43                         var pos = texteditor.cursorPosition();
44                         texteditor.selectLines(pos.line, pos.character + tag.length + 2);
45                     }
46                     
47                     $(document).trigger('panel:contentChanged', self);
48                 });
49
50 /*                texteditor.grabKeys(function(event) { 
51                     if (keys[event.keyCode]) {
52                         keys[event.keyCode]();
53                     }
54                 }, function(event) { return event.altKey && keys[event.keyCode]; }); */
55             }
56         })
57         
58         $(texteditor.frame).css({width: '100%', height: '100%'});
59         
60         $('#toolbar-buttons li').wTooltip({
61             delay: 1000, 
62             style: {
63                 border: "1px solid #7F7D67",
64                 opacity: 0.9, 
65                 background: "#FBFBC6", 
66                 padding: "1px",
67                 fontSize: "12px"
68             }
69         });
70
71         $('.decrease-font-size', panel).click(function() {
72             var frameBody = $('body', $(texteditor.frame).contents());
73             console.log(frameBody.css('font-size'));
74             frameBody.css('font-size', parseInt(frameBody.css('font-size')) - 2);
75         });
76         
77         $('.increase-font-size', panel).click(function() {
78             var frameBody = $('body', $(texteditor.frame).contents());
79             console.log(frameBody.css('font-size'));
80             frameBody.css('font-size', parseInt(frameBody.css('font-size')) + 2);
81         });
82         
83                 this.texteditor = texteditor;
84     },
85
86         unload: function() { 
87                 this.texteditor = null;
88         },
89
90
91         //refresh: function() { }, // no support for refresh
92
93         saveInfo: function(saveInfo) {
94                 var myInfo = {
95                         url: "{% url file_xml fpath %}", 
96                         postData: {
97                                 content: this.texteditor.getCode()
98                         } 
99                 };
100                 $.extend(saveInfo, myInfo);
101         }               
102 };
103
104 </script>