1 {% load toolbar_tags %}
4 <div class="iframe-container" style="position: absolute; top: 48px; left:0px; right:0px; bottom: 0px;">
5 <textarea name="text">{{ text }}</textarea>
8 <script type="text/javascript" charset="utf-8">
10 function xmleditor_onload(event, panel) {
11 var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
12 $('textarea', panel).attr('id', textareaId);
13 var editor = CodeMirror.fromTextArea(textareaId, {
14 parserfile: 'parsexml.js',
15 path: "/static/js/codemirror/",
16 stylesheet: "/static/css/xmlcolors.css",
17 parserConfig: {useHTMLKludges: false},
18 initCallback: function() {
20 $('.toolbar-tabs li', panel).click(function() {
21 var id = $(this).attr('p:button-list');
22 $('.toolbar-tabs li', panel).removeClass('active');
23 $(this).addClass('active');
24 if (!$('.' + id, panel).is(':visible')) {
25 $('.toolbar-buttons ol', panel).not('#' + id).hide();
26 $('.' + id, panel).show();
31 $('.toolbar-buttons li', panel).each(function() {
32 var tag = $(this).attr('p:tag');
33 var handler = function() {
34 var text = editor.selection();
35 console.log(editor, editor.frame);
36 editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
37 if (text.length == 0) {
38 var pos = editor.cursorPosition();
39 editor.selectLines(pos.line, pos.character + tag.length + 2);
42 if ($(this).attr('p:key')) {
43 keys[$(this).attr('p:key')] = handler;
45 $(this).click(handler)
48 editor.grabKeys(function(event) {
49 if (keys[event.keyCode]) {
50 keys[event.keyCode]();
52 }, function(event) { return event.altKey && keys[event.keyCode]; });
56 $(editor.frame).css({width: '100%', height: '100%'});
58 $('#toolbar-buttons li').wTooltip({
61 border: "1px solid #7F7D67",
63 background: "#FBFBC6",
70 function xmleditor_onunload(event, panel) {}
72 panel(xmleditor_onload, xmleditor_onunload);