76018ca717ff377324f5696b9e0986b8c0ddb628
[redakcja.git] / project / templates / explorer / panels / xmleditor.html
1 {% load toolbar_tags %}
2
3 <div class="iframe-container" style="position: absolute; top: 41pt; left:0px; right:0px; bottom: 0px;">
4         <textarea name="text">{{ text }}</textarea>
5 </div>
6
7 {% toolbar %}
8
9 <script type="text/javascript" charset="utf-8">
10
11 panel_hooks = {
12         load: function () {
13                 var self = this;
14                 var panel = self.contentDiv;
15
16         var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
17                 $('textarea', panel).attr('id', textareaId);
18
19         var texteditor = CodeMirror.fromTextArea(textareaId, {
20             parserfile: 'parsexml.js',
21             path: "{{STATIC_URL}}js/codemirror/",
22             stylesheet: "{{STATIC_URL}}css/xmlcolors.css",
23             parserConfig: {useHTMLKludges: false},
24             onChange: function() {
25                 self.fireEvent('contentChanged');
26             },
27             initCallback: function(editor) {
28                 // Editor is loaded
29                 // Buttons are connected
30                 // register callbacks for actions
31                 texteditor.grabKeys(
32                     $.fbind(self, self.hotkeyPressed),
33                     $.fbind(self, self.isHotkey) );
34             }
35         })
36
37         $(texteditor.frame).css({width: '100%', height: '100%'});    
38         this.texteditor = texteditor;
39     },
40
41         unload: function() { 
42                 this.texteditor = null;
43         },
44
45
46         //refresh: function() { }, // no support for refresh
47
48         saveInfo: function(saveInfo) {
49                 var myInfo = {
50                         url: "{% url file_xml fpath %}", 
51                         postData: {
52                                 content: this.texteditor.getCode()
53                         } 
54                 };
55                 $.extend(saveInfo, myInfo);
56         }               
57 };
58
59 </script>