[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/editors/mostlyce/jscripts/tiny_mce/ -> tiny_mce_gzip.js (source)

   1  var tinyMCE_GZ = {
   2      settings : {
   3          themes : '',
   4          plugins : '',
   5          languages : '',
   6          disk_cache : true,
   7          page_name : 'tiny_mce_gzip.php',
   8          debug : false,
   9          suffix : ''
  10      },
  11  
  12      init : function(s, cb, sc) {
  13          var t = this, n, i, nl = document.getElementsByTagName('script');
  14  
  15          for (n in s)
  16              t.settings[n] = s[n];
  17  
  18          s = t.settings;
  19  
  20          for (i=0; i<nl.length; i++) {
  21              n = nl[i];
  22  
  23              if (n.src && n.src.indexOf('tiny_mce') != -1)
  24                  t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
  25          }
  26  
  27          if (!t.coreLoaded)
  28              t.loadScripts(1, s.themes, s.plugins, s.languages, cb, sc);
  29      },
  30  
  31      loadScripts : function(co, th, pl, la, cb, sc) {
  32          var t = this, x, w = window, q, c = 0, ti, s = t.settings;
  33  
  34  		function get(s) {
  35              x = 0;
  36  
  37              try {
  38                  x = new ActiveXObject(s);
  39              } catch (s) {
  40              }
  41  
  42              return x;
  43          };
  44  
  45          // Build query string

  46          q = 'js=true&diskcache=' + (s.disk_cache ? 'true' : 'false') + '&core=' + (co ? 'true' : 'false') + '&suffix=' + escape(s.suffix) + '&themes=' + escape(th) + '&plugins=' + escape(pl) + '&languages=' + escape(la);
  47  
  48          if (co)
  49              t.coreLoaded = 1;
  50  
  51          // Send request

  52          x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Msxml2.XMLHTTP') || get('Microsoft.XMLHTTP');
  53          x.overrideMimeType && x.overrideMimeType('text/javascript');
  54          x.open('GET', t.baseURL + '/' + s.page_name + '?' + q, !!cb);
  55  //        x.setRequestHeader('Content-Type', 'text/javascript');

  56          x.send('');
  57  
  58          // Handle asyncronous loading

  59          if (cb) {
  60              // Wait for response

  61              ti = w.setInterval(function() {
  62                  if (x.readyState == 4 || c++ > 10000) {
  63                      w.clearInterval(ti);
  64  
  65                      if (c < 10000 && x.status == 200) {
  66                          t.loaded = 1;
  67                          t.eval(x.responseText);
  68                          tinymce.dom.Event.domLoaded = true;
  69                          cb.call(sc || t, x);
  70                      }
  71  
  72                      ti = x = null;
  73                  }
  74              }, 10);
  75          } else
  76              t.eval(x.responseText);
  77      },
  78  
  79      start : function() {
  80          var t = this, each = tinymce.each, s = t.settings, sl, ln = s.languages.split(',');
  81  
  82          tinymce.suffix = s.suffix;
  83  
  84          // Extend script loader

  85          tinymce.create('tinymce.compressor.ScriptLoader:tinymce.dom.ScriptLoader', {
  86              loadScripts : function(sc, cb, s) {
  87                  var ti = this, th = [], pl = [], la = [];
  88  
  89                  each(sc, function(o) {
  90                      var u = o.url;
  91  
  92                      if ((!ti.lookup[u] || ti.lookup[u].state != 2) && u.indexOf(t.baseURL) === 0) {
  93                          // Collect theme

  94                          if (u.indexOf('editor_template') != -1) {
  95                              th.push(/\/themes\/([^\/]+)/.exec(u)[1]);
  96                              load(u, 1);
  97                          }
  98  
  99                          // Collect plugin

 100                          if (u.indexOf('editor_plugin') != -1) {
 101                              pl.push(/\/plugins\/([^\/]+)/.exec(u)[1]);
 102                              load(u, 1);
 103                          }
 104  
 105                          // Collect language

 106                          if (u.indexOf('/langs/') != -1) {
 107                              la.push(/\/langs\/([^.]+)/.exec(u)[1]);
 108                              load(u, 1);
 109                          }
 110                      }
 111                  });
 112  
 113                  if (th.length + pl.length + la.length > 0) {
 114                      if (sl.settings.strict_mode) {
 115                          // Async

 116                          t.loadScripts(0, th.join(','), pl.join(','), la.join(','), cb, s);
 117                          return;
 118                      } else
 119                          t.loadScripts(0, th.join(','), pl.join(','), la.join(','), cb, s);
 120                  }
 121  
 122                  return ti.parent(sc, cb, s);
 123              }
 124          });
 125  
 126          sl = tinymce.ScriptLoader = new tinymce.compressor.ScriptLoader();
 127  
 128  		function load(u, sp) {
 129              var o;
 130  
 131              if (!sp)
 132                  u = t.baseURL + u;
 133  
 134              o = {url : u, state : 2};
 135              sl.queue.push(o);
 136              sl.lookup[o.url] = o;
 137          };
 138  
 139          // Add core languages

 140          each (ln, function(c) {
 141              if (c)
 142                  load('/langs/' + c + '.js');
 143          });
 144  
 145          // Add themes with languages

 146          each(s.themes.split(','), function(n) {
 147              if (n) {
 148                  load('/themes/' + n + '/editor_template' + s.suffix + '.js');
 149  
 150                  each (ln, function(c) {
 151                      if (c)
 152                          load('/themes/' + n + '/langs/' + c + '.js');
 153                  });
 154              }
 155          });
 156  
 157          // Add plugins with languages

 158          each(s.plugins.split(','), function(n) {
 159              if (n) {
 160                  load('/plugins/' + n + '/editor_plugin' + s.suffix + '.js');
 161  
 162                  each (ln, function(c) {
 163                      if (c)
 164                          load('/plugins/' + n + '/langs/' + c + '.js');
 165                  });
 166              }
 167          });
 168      },
 169  
 170      end : function() {
 171      },
 172  
 173      eval : function(co) {
 174          var w = window;
 175  
 176          // Evaluate script

 177          if (!w.execScript) {
 178              try {
 179                  eval.call(w, co);
 180              } catch (ex) {
 181                  eval(co, w); // Firefox 3.0a8

 182              }
 183          } else
 184              w.execScript(co); // IE

 185      }
 186  };