tiny_mce_gzip.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. init : function(s, cb, sc) {
  12. var t = this, n, i, nl = document.getElementsByTagName('script');
  13. for (n in s)
  14. t.settings[n] = s[n];
  15. s = t.settings;
  16. if (window.tinyMCEPreInit) {
  17. t.baseURL = tinyMCEPreInit.base;
  18. } else {
  19. for (i=0; i<nl.length; i++) {
  20. n = nl[i];
  21. if (n.src && n.src.indexOf('tiny_mce') != -1)
  22. t.baseURL = n.src.substring(0, n.src.lastIndexOf('/'));
  23. }
  24. }
  25. if (!t.coreLoaded)
  26. t.loadScripts(1, s.themes, s.plugins, s.languages, cb, sc);
  27. },
  28. loadScripts : function(co, th, pl, la, cb, sc) {
  29. var t = this, x, w = window, q, c = 0, ti, s = t.settings;
  30. function get(s) {
  31. x = 0;
  32. try {
  33. x = new ActiveXObject(s);
  34. } catch (s) {
  35. }
  36. return x;
  37. };
  38. // Build query string
  39. 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);
  40. if (co)
  41. t.coreLoaded = 1;
  42. // Send request
  43. x = w.XMLHttpRequest ? new XMLHttpRequest() : get('Msxml2.XMLHTTP') || get('Microsoft.XMLHTTP');
  44. x.overrideMimeType && x.overrideMimeType('text/javascript');
  45. x.open('GET', t.baseURL + '/' + s.page_name + '?' + q, !!cb);
  46. // x.setRequestHeader('Content-Type', 'text/javascript');
  47. x.send('');
  48. // Handle asyncronous loading
  49. if (cb) {
  50. // Wait for response
  51. ti = w.setInterval(function() {
  52. if (x.readyState == 4 || c++ > 10000) {
  53. w.clearInterval(ti);
  54. if (c < 10000 && x.status == 200) {
  55. t.loaded = 1;
  56. t.eval(x.responseText);
  57. tinymce.dom.Event.domLoaded = true;
  58. cb.call(sc || t, x);
  59. }
  60. ti = x = null;
  61. }
  62. }, 10);
  63. } else
  64. t.eval(x.responseText);
  65. },
  66. start : function() {
  67. var t = this, each = tinymce.each, s = t.settings, ln = s.languages.split(',');
  68. tinymce.suffix = s.suffix;
  69. function load(u) {
  70. tinymce.ScriptLoader.markDone(tinyMCE.baseURI.toAbsolute(u));
  71. };
  72. // Add core languages
  73. each(ln, function(c) {
  74. if (c)
  75. load('langs/' + c + '.js');
  76. });
  77. // Add themes with languages
  78. each(s.themes.split(','), function(n) {
  79. if (n) {
  80. load('themes/' + n + '/editor_template' + s.suffix + '.js');
  81. each (ln, function(c) {
  82. if (c)
  83. load('themes/' + n + '/langs/' + c + '.js');
  84. });
  85. }
  86. });
  87. // Add plugins with languages
  88. each(s.plugins.split(','), function(n) {
  89. if (n) {
  90. load('plugins/' + n + '/editor_plugin' + s.suffix + '.js');
  91. each(ln, function(c) {
  92. if (c)
  93. load('plugins/' + n + '/langs/' + c + '.js');
  94. });
  95. }
  96. });
  97. },
  98. end : function() {
  99. },
  100. eval : function(co) {
  101. var se = document.createElement('script');
  102. // Create script
  103. se.type = 'text/javascript';
  104. se.text = co;
  105. // Add it to evaluate it and remove it
  106. (document.getElementsByTagName('head')[0] || document.documentElement).appendChild(se);
  107. se.parentNode.removeChild(se);
  108. }
  109. };