1 {% load toolbar_tags %}
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>
9 <div class="iframe-container" style="position: absolute; top: 41pt; left:0px; right:0px; bottom: 0px;">
10 <textarea name="text">{{ text }}</textarea>
16 <script type="text/javascript" charset="utf-8">
21 var panel = self.contentDiv;
23 var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
24 $('textarea', panel).attr('id', textareaId);
26 var texteditor = CodeMirror.fromTextArea(textareaId, {
27 parserfile: 'parsexml.js',
28 path: "/static/js/codemirror/",
29 stylesheet: "/static/css/xmlcolors.css",
30 parserConfig: {useHTMLKludges: false},
31 onChange: function() {
32 panel.trigger('panel:contentChanged', self);
34 initCallback: function(editor) {
36 // Buttons are connected
37 // register callbacks for actions
38 $(document).bind("ui:action:INSERT_TAG", function(event, 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);
47 $(document).trigger('panel:contentChanged', self);
50 /* texteditor.grabKeys(function(event) {
51 if (keys[event.keyCode]) {
52 keys[event.keyCode]();
54 }, function(event) { return event.altKey && keys[event.keyCode]; }); */
58 $(texteditor.frame).css({width: '100%', height: '100%'});
60 $('#toolbar-buttons li').wTooltip({
63 border: "1px solid #7F7D67",
65 background: "#FBFBC6",
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);
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);
83 this.texteditor = texteditor;
87 this.texteditor = null;
91 //refresh: function() { }, // no support for refresh
93 saveInfo: function(saveInfo) {
95 url: "{% url file_xml fpath %}",
97 content: this.texteditor.getCode()
100 $.extend(saveInfo, myInfo);