includes/clientside/static/tinymce-init.js
changeset 582 a38876c0793c
child 588 20484deb89cd
equal deleted inserted replaced
581:5e8fd89c02ea 582:a38876c0793c
       
     1 // init TinyMCE
       
     2 var head = document.getElementsByTagName('head')[0];
       
     3 
       
     4 if ( document.getElementById('mdgCss') )
       
     5 {
       
     6   var css_url = document.getElementById('mdgCss').href;
       
     7 }
       
     8 else
       
     9 {
       
    10   var css_url = scriptPath + '/includes/clientside/css/enano_shared.css';
       
    11 }
       
    12 
       
    13 var do_popups = ( is_Safari ) ? '' : ',inlinepopups';
       
    14 var _skin = ( typeof(tinymce_skin) == 'string' ) ? tinymce_skin : 'default';
       
    15 var tinymce_initted = false;
       
    16 
       
    17 var enano_tinymce_options = {
       
    18   mode : "none",
       
    19   plugins : 'table,save,safari,pagebreak,style,layer,advhr,insertdatetime,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras' + do_popups,
       
    20   theme : 'advanced',
       
    21   skin : _skin,
       
    22   theme_advanced_resize_horizontal : false,
       
    23   theme_advanced_resizing : true,
       
    24   theme_advanced_toolbar_location : "top",
       
    25   theme_advanced_toolbar_align : "left",
       
    26   theme_advanced_buttons1 : "save,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor,|,formatselect,|,fontselect,fontsizeselect",
       
    27   theme_advanced_buttons3_add_before : "tablecontrols,separator",
       
    28   theme_advanced_buttons3_add_after : "|,fullscreen",
       
    29   theme_advanced_statusbar_location : 'bottom',
       
    30   noneditable_noneditable_class : 'mce_readonly',
       
    31   content_css : css_url
       
    32 };
       
    33 
       
    34 var enano_tinymce_gz_options = {
       
    35 	plugins : 'table,save,safari,pagebreak,style,layer,advhr,insertdatetime,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras' + do_popups,
       
    36 	themes : 'advanced',
       
    37 	languages : 'en',
       
    38 	disk_cache : true,
       
    39 	debug : false
       
    40 };
       
    41 
       
    42 if ( !KILL_SWITCH && !DISABLE_MCE )
       
    43 {
       
    44   // load MCE with XHR
       
    45   var ajax = ajaxMakeXHR();
       
    46   var uri = scriptPath + '/includes/clientside/tinymce/tiny_mce_gzip.js';
       
    47   ajax.open('GET', uri, false);
       
    48   ajax.send(null);
       
    49   if ( ajax.readyState == 4 && ajax.status == 200 )
       
    50   {
       
    51     eval_global(ajax.responseText);
       
    52     tinyMCE_GZ.init(enano_tinymce_gz_options);
       
    53   }
       
    54   else
       
    55   {
       
    56     console.error('TinyMCE load failed');
       
    57   }
       
    58 }
       
    59 
       
    60 // Check tinyMCE to make sure its init is finished
       
    61 window.tinymce_preinit_check = function()
       
    62 {
       
    63   if ( typeof(tinyMCE.init) != 'function' )
       
    64     return false;
       
    65   if ( typeof(tinymce.DOM) != 'object' )
       
    66     return false;
       
    67   if ( typeof(tinymce.DOM.get) != 'function' )
       
    68     return false;
       
    69   if ( typeof(enano_tinymce_gz_options) != 'object' )
       
    70     return false;
       
    71   return true;
       
    72 }
       
    73 
       
    74 var initTinyMCE = function(e)
       
    75 {
       
    76   if ( typeof(tinyMCE) == 'object' )
       
    77   {
       
    78     if ( !KILL_SWITCH && !DISABLE_MCE )
       
    79     {
       
    80       if ( !tinymce_preinit_check() )
       
    81       {
       
    82         setTimeout('initTinyMCE(false);', 200);
       
    83         return false;
       
    84       }
       
    85       tinyMCE.init(enano_tinymce_options);
       
    86       tinymce_initted = true;
       
    87     }
       
    88   }
       
    89 };