includes/clientside/static/tinymce-init.js
author Dan
Tue, 24 Jun 2008 23:37:23 -0400
changeset 582 a38876c0793c
child 588 20484deb89cd
permissions -rw-r--r--
Majorly reworked Javascript runtime stuff to use on-demand loading. - Runtime reduced to only AJAX library + very common functions, ~50K total - Almost all specific functionality loaded on demand using synchronous XHR - Crypto functions consolidated into crypto.js - Much testing still to be done - ACL editor known not working under firefox - Some other components (autofill, theme/rank managers) not ported yet
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     1
// init TinyMCE
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     2
var head = document.getElementsByTagName('head')[0];
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     3
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     4
if ( document.getElementById('mdgCss') )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     5
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     6
  var css_url = document.getElementById('mdgCss').href;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     7
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     8
else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
     9
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    10
  var css_url = scriptPath + '/includes/clientside/css/enano_shared.css';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    11
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    12
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    13
var do_popups = ( is_Safari ) ? '' : ',inlinepopups';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    14
var _skin = ( typeof(tinymce_skin) == 'string' ) ? tinymce_skin : 'default';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    15
var tinymce_initted = false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    16
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    17
var enano_tinymce_options = {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    18
  mode : "none",
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    19
  plugins : 'table,save,safari,pagebreak,style,layer,advhr,insertdatetime,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras' + do_popups,
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    20
  theme : 'advanced',
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    21
  skin : _skin,
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    22
  theme_advanced_resize_horizontal : false,
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    23
  theme_advanced_resizing : true,
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    24
  theme_advanced_toolbar_location : "top",
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    25
  theme_advanced_toolbar_align : "left",
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    26
  theme_advanced_buttons1 : "save,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,forecolor,backcolor,|,formatselect,|,fontselect,fontsizeselect",
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    27
  theme_advanced_buttons3_add_before : "tablecontrols,separator",
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    28
  theme_advanced_buttons3_add_after : "|,fullscreen",
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    29
  theme_advanced_statusbar_location : 'bottom',
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    30
  noneditable_noneditable_class : 'mce_readonly',
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    31
  content_css : css_url
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    32
};
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    33
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    34
var enano_tinymce_gz_options = {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    35
	plugins : 'table,save,safari,pagebreak,style,layer,advhr,insertdatetime,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras' + do_popups,
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    36
	themes : 'advanced',
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    37
	languages : 'en',
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    38
	disk_cache : true,
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    39
	debug : false
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    40
};
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    41
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    42
if ( !KILL_SWITCH && !DISABLE_MCE )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    43
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    44
  // load MCE with XHR
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    45
  var ajax = ajaxMakeXHR();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    46
  var uri = scriptPath + '/includes/clientside/tinymce/tiny_mce_gzip.js';
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    47
  ajax.open('GET', uri, false);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    48
  ajax.send(null);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    49
  if ( ajax.readyState == 4 && ajax.status == 200 )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    50
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    51
    eval_global(ajax.responseText);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    52
    tinyMCE_GZ.init(enano_tinymce_gz_options);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    53
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    54
  else
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    55
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    56
    console.error('TinyMCE load failed');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    57
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    58
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    59
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    60
// Check tinyMCE to make sure its init is finished
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    61
window.tinymce_preinit_check = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    62
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    63
  if ( typeof(tinyMCE.init) != 'function' )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    64
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    65
  if ( typeof(tinymce.DOM) != 'object' )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    66
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    67
  if ( typeof(tinymce.DOM.get) != 'function' )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    68
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    69
  if ( typeof(enano_tinymce_gz_options) != 'object' )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    70
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    71
  return true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    72
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    73
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    74
var initTinyMCE = function(e)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    75
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    76
  if ( typeof(tinyMCE) == 'object' )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    77
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    78
    if ( !KILL_SWITCH && !DISABLE_MCE )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    79
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    80
      if ( !tinymce_preinit_check() )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    81
      {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    82
        setTimeout('initTinyMCE(false);', 200);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    83
        return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    84
      }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    85
      tinyMCE.init(enano_tinymce_options);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    86
      tinymce_initted = true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    87
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    88
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
diff changeset
    89
};