Poprawki do file upload i toolbar.
[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                 
39
40 /*                texteditor.grabKeys(function(event) { 
41                     if (keys[event.keyCode]) {
42                         keys[event.keyCode]();
43                     }
44                 }, function(event) { return event.altKey && keys[event.keyCode]; }); */
45             }
46         })
47         
48         $(texteditor.frame).css({width: '100%', height: '100%'});
49         
50         $('#toolbar-buttons li').wTooltip({
51             delay: 1000, 
52             style: {
53                 border: "1px solid #7F7D67",
54                 opacity: 0.9, 
55                 background: "#FBFBC6", 
56                 padding: "1px",
57                 fontSize: "12px"
58             }
59         });
60
61         $('.decrease-font-size', panel).click(function() {
62             var frameBody = $('body', $(texteditor.frame).contents());
63             console.log(frameBody.css('font-size'));
64             frameBody.css('font-size', parseInt(frameBody.css('font-size')) - 2);
65         });
66         
67         $('.increase-font-size', panel).click(function() {
68             var frameBody = $('body', $(texteditor.frame).contents());
69             console.log(frameBody.css('font-size'));
70             frameBody.css('font-size', parseInt(frameBody.css('font-size')) + 2);
71         });        
72         this.texteditor = texteditor;
73     },
74
75         unload: function() { 
76                 this.texteditor = null;
77         },
78
79
80         //refresh: function() { }, // no support for refresh
81
82         saveInfo: function(saveInfo) {
83                 var myInfo = {
84                         url: "{% url file_xml fpath %}", 
85                         postData: {
86                                 content: this.texteditor.getCode()
87                         } 
88                 };
89                 $.extend(saveInfo, myInfo);
90         }               
91 };
92
93 </script>