includes/clientside/tinymce/switcher.js
changeset 1 fe660c52c48f
equal deleted inserted replaced
0:902822492a68 1:fe660c52c48f
       
     1 function readCookie(name) {var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i < ca.length;i++){var c = ca[i];while (c.charAt(0)==' ') c = c.substring(1,c.length);if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);}return null;}
       
     2 function createCookie(name,value,days){if (days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";document.cookie = name+"="+value+expires+"; path=/";}
       
     3 function eraseCookie(name) {createCookie(name,"",-1);}
       
     4 
       
     5 function initSwitcher()
       
     6 {
       
     7   if(readCookie('tmce_demo_mode') == 'tinymce')
       
     8   {
       
     9     switchToMCE();
       
    10   }
       
    11 }
       
    12 
       
    13 function switchToMCE()
       
    14 {
       
    15   elem = document.getElementById('tMceEditor');
       
    16   tinyMCE.addMCEControl(elem, 'content', document);
       
    17   createCookie('tmce_demo_mode', 'tinymce', 365);
       
    18 }
       
    19 
       
    20 function switchToText()
       
    21 {
       
    22   elem = document.getElementById('tMceEditor');
       
    23   tinyMCE.removeMCEControl('content');
       
    24   createCookie('tmce_demo_mode', 'text', 365);
       
    25 }
       
    26 
       
    27 function switchEditor()
       
    28 {
       
    29   if(readCookie('tmce_demo_mode') == 'tinymce')
       
    30   {
       
    31     switchToText();
       
    32   }
       
    33   else
       
    34   {
       
    35     switchToMCE();
       
    36   }
       
    37 }
       
    38 
       
    39 window.onload = initSwitcher;
       
    40 
       
    41 tinyMCE.init({
       
    42       mode : "exact",
       
    43       elements : '',
       
    44       theme_advanced_resize_horizontal : false,
       
    45       theme_advanced_resizing : true,
       
    46       theme_advanced_toolbar_location : "top",
       
    47       theme_advanced_toolbar_align : "left",
       
    48       theme_advanced_buttons1_add : "fontselect,fontsizeselect",
       
    49       theme_advanced_statusbar_location : 'bottom'
       
    50   });
       
    51