Advertisement
Guest User

Edit to make plugin work when visual editor disabled

a guest
Apr 25th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function runEditorHighlighter(el) {
  2.     fullscreen.switchmode('html');
  3.                
  4.     // <edit>
  5.     var visualEditorEnabled;
  6.  
  7.     if (document.getElementById("content-tmce") != null)
  8.         visualEditorEnabled = true;
  9.     else visualEditorEnabled = false;
  10.  
  11.     if (visualEditorEnabled)
  12.         switchEditors.switchto(document.getElementById("content-html"));
  13.     // </edit>
  14.  
  15.     var editor = CodeMirror.fromTextArea(document.getElementById(el), {
  16.         mode: "text/html",
  17.         tabMode: "indent",
  18.         lineNumbers: true,
  19.         matchBrackets: true,
  20.         indentUnit: 4,
  21.         indentWithTabs: true,
  22.         enterMode: "keep",
  23.         lineWrapping: true,
  24.         onCursorActivity: function() {
  25.             editor.setLineClass(hlLine, null, null);
  26.             hlLine = editor.setLineClass(editor.getCursor().line, null, "activeline");
  27.             },
  28.             onChange: function(){
  29.                 editor.save();
  30.             }
  31.         });
  32.         var hlLine = editor.setLineClass(0, "activeline");
  33.                
  34.         // <edit>
  35.         if (visualEditorEnabled) {
  36.             document.getElementById("content-tmce").onclick = function(e){
  37.                 editor.toTextArea();
  38.                 switchEditors.switchto(document.getElementById("content-tmce"));
  39.                 document.getElementById("content-html").onclick = function(e){
  40.                 runEditorHighlighter("content");
  41.                 }
  42.             }
  43.             }
  44.             // </edit>
  45.                
  46.             document.getElementById("qt_content_fullscreen").onclick = function(e){
  47.                 editor.toTextArea();
  48.                 fullscreen.switchmode('html');
  49.                 setTimeout('runEditorHighlighter("wp_mce_fullscreen")', 2000);
  50.                 document.getElementById("wp-fullscreen-close").onclick = function(e){
  51.                 fullscreen.off();
  52.                 runEditorHighlighter("content");
  53.                 return false;
  54.                 }
  55.             }
  56.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement