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>
8 <div class="iframe-container" style="position: absolute; top: 48px; left:0px; right:0px; bottom: 0px;">
9 <textarea name="text">{{ text }}</textarea>
12 <script type="text/javascript" charset="utf-8">
17 var panel = self.contentDiv;
19 var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
20 $('textarea', panel).attr('id', textareaId);
22 var texteditor = CodeMirror.fromTextArea(textareaId, {
23 parserfile: 'parsexml.js',
24 path: "/static/js/codemirror/",
25 stylesheet: "/static/css/xmlcolors.css",
26 parserConfig: {useHTMLKludges: false},
27 onChange: function() {
28 panel.trigger('panel:contentChanged', self);
30 initCallback: function(editor) {
32 $('.toolbar-tabs li', panel).click(function() {
33 var id = $(this).attr('p:button-list');
34 $('.toolbar-tabs li', panel).removeClass('active');
35 $(this).addClass('active');
36 if (!$('.' + id, panel).is(':visible')) {
37 $('.toolbar-buttons ol', panel).not('#' + id).hide();
38 $('.' + id, panel).show();
43 $('.toolbar-buttons li', panel).each(function() {
44 var tag = $(this).attr('p:tag');
45 var handler = function() {
46 var text = texteditor.selection();
47 editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
48 if (text.length == 0) {
49 var pos = texteditor.cursorPosition();
50 texteditor.selectLines(pos.line, pos.character + tag.length + 2);
52 $(document).trigger('panel:contentChanged', self);
54 if ($(this).attr('p:key')) {
55 keys[$(this).attr('p:key')] = handler;
57 $(this).click(handler)
60 texteditor.grabKeys(function(event) {
61 if (keys[event.keyCode]) {
62 keys[event.keyCode]();
64 }, function(event) { return event.altKey && keys[event.keyCode]; });
68 $(texteditor.frame).css({width: '100%', height: '100%'});
70 $('#toolbar-buttons li').wTooltip({
73 border: "1px solid #7F7D67",
75 background: "#FBFBC6",
81 $('.decrease-font-size', panel).click(function() {
82 var frameBody = $('body', $(texteditor.frame).contents());
83 console.log(frameBody.css('font-size'));
84 frameBody.css('font-size', parseInt(frameBody.css('font-size')) - 2);
87 $('.increase-font-size', panel).click(function() {
88 var frameBody = $('body', $(texteditor.frame).contents());
89 console.log(frameBody.css('font-size'));
90 frameBody.css('font-size', parseInt(frameBody.css('font-size')) + 2);
93 this.texteditor = texteditor;
97 this.texteditor = null;
101 refresh: function() {
105 saveInfo: function(saveInfo) {
107 url: "{% url file_xml fpath %}",
109 content: this.texteditor.getCode()
112 $.extend(saveInfo, myInfo);