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">
 
  13                 var panel = self.contentDiv;
 
  15         var textareaId = 'xmleditor-' + Math.ceil(Math.random() * 1000000000);
 
  16                 $('textarea', panel).attr('id', textareaId);
 
  18                 var texteditor = CodeMirror.fromTextArea(textareaId, {
 
  19             parserfile: 'parsexml.js',
 
  20             path: "/static/js/codemirror/",
 
  21             stylesheet: "/static/css/xmlcolors.css",
 
  22             parserConfig: {useHTMLKludges: false},
 
  23             onChange: function() {
 
  24                                 panel.trigger('panel:contentChanged', self);
 
  26             initCallback: function(editor) {
 
  28                 $('.toolbar-tabs li', panel).click(function() {
 
  29                     var id = $(this).attr('p:button-list');
 
  30                     $('.toolbar-tabs li', panel).removeClass('active');
 
  31                     $(this).addClass('active');
 
  32                     if (!$('.' + id, panel).is(':visible')) {
 
  33                         $('.toolbar-buttons ol', panel).not('#' + id).hide();
 
  34                         $('.' + id, panel).show();
 
  39                 $('.toolbar-buttons li', panel).each(function() {
 
  40                     var tag = $(this).attr('p:tag');
 
  41                     var handler = function() {
 
  42                         var text = texteditor.selection();
 
  43                         editor.replaceSelection('<' + tag + '>' + text + '</' + tag + '>');
 
  44                         if (text.length == 0) {
 
  45                             var pos = texteditor.cursorPosition();
 
  46                             texteditor.selectLines(pos.line, pos.character + tag.length + 2);
 
  48                         $(document).trigger('panel:contentChanged', self);
 
  50                     if ($(this).attr('p:key')) {
 
  51                         keys[$(this).attr('p:key')] = handler;
 
  53                     $(this).click(handler)
 
  56                 texteditor.grabKeys(function(event) { 
 
  57                     if (keys[event.keyCode]) {
 
  58                         keys[event.keyCode]();
 
  60                 }, function(event) { return event.altKey && keys[event.keyCode]; });
 
  64         $(texteditor.frame).css({width: '100%', height: '100%'});
 
  66         $('#toolbar-buttons li').wTooltip({
 
  69                 border: "1px solid #7F7D67",
 
  71                 background: "#FBFBC6", 
 
  77                 this.texteditor = texteditor;
 
  81                 this.texteditor = null;
 
  89         saveInfo: function(saveInfo) {
 
  91                         url: "{% url file_xml fpath %}", 
 
  93                                 content: this.texteditor.getCode()
 
  96                 $.extend(saveInfo, myInfo);