1 var tinyMCE_GZ = { |
1 var tinyMCE_GZ={settings:{themes:"",plugins:"",languages:"",disk_cache:true,page_name:"tiny_mce_gzip.php",debug:false,suffix:""},init:function(E,A,F){var D=this,G,C,B=document.getElementsByTagName("script");for(G in E){D.settings[G]=E[G]}E=D.settings;for(C=0;C<B.length;C++){G=B[C];if(G.src&&G.src.indexOf("tiny_mce")!=-1){D.baseURL=G.src.substring(0,G.src.lastIndexOf("/"))}}if(!D.coreLoaded){D.loadScripts(1,E.themes,E.plugins,E.languages,A,F)}},loadScripts:function(co,th,pl,la,cb,sc){var t=this,x,w=window,q,c=0,ti,s=t.settings;function get(s){x=0;try{x=new ActiveXObject(s)}catch(s){}return x}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);if(co){t.coreLoaded=1}x=w.XMLHttpRequest?new XMLHttpRequest():get("Msxml2.XMLHTTP")||get("Microsoft.XMLHTTP");x.overrideMimeType&&x.overrideMimeType("text/javascript");x.open("GET",t.baseURL+"/"+s.page_name+"?"+q,!!cb);x.send("");if(cb){ti=w.setInterval(function(){if(x.readyState==4||c++>10000){w.clearInterval(ti);if(c<10000&&x.status==200){t.loaded=1;t.eval(x.responseText);tinymce.dom.Event.domLoaded=true;cb.call(sc||t,x)}ti=x=null}},10)}else{t.eval(x.responseText)}},start:function(){var B=this,F=tinymce.each,C=B.settings,A,D=C.languages.split(",");tinymce.suffix=C.suffix;tinymce.create("tinymce.compressor.ScriptLoader:tinymce.dom.ScriptLoader",{loadScripts:function(M,G,J){var I=this,K=[],H=[],L=[];F(M,function(O){var N=O.url;if((!I.lookup[N]||I.lookup[N].state!=2)&&N.indexOf(B.baseURL)===0){if(N.indexOf("editor_template")!=-1){K.push(/\/themes\/([^\/]+)/.exec(N)[1]);E(N,1)}if(N.indexOf("editor_plugin")!=-1){H.push(/\/plugins\/([^\/]+)/.exec(N)[1]);E(N,1)}if(N.indexOf("/langs/")!=-1){L.push(/\/langs\/([^.]+)/.exec(N)[1]);E(N,1)}}});if(K.length+H.length+L.length>0){if(A.settings.strict_mode){B.loadScripts(0,K.join(","),H.join(","),L.join(","),G,J);return }else{B.loadScripts(0,K.join(","),H.join(","),L.join(","),G,J)}}return I.parent(M,G,J)}});A=tinymce.ScriptLoader=new tinymce.compressor.ScriptLoader();function E(G,H){var I;if(!H){G=B.baseURL+G}I={url:G,state:2};A.queue.push(I);A.lookup[I.url]=I}F(D,function(G){if(G){E("/langs/"+G+".js")}});F(C.themes.split(","),function(G){if(G){E("/themes/"+G+"/editor_template"+C.suffix+".js");F(D,function(H){if(H){E("/themes/"+G+"/langs/"+H+".js")}})}});F(C.plugins.split(","),function(G){if(G){E("/plugins/"+G+"/editor_plugin"+C.suffix+".js");F(D,function(H){if(H){E("/plugins/"+G+"/langs/"+H+".js")}})}})},end:function(){},eval:function(co){var w=window;if(!w.execScript){if(/Gecko/.test(navigator.userAgent)){eval(co,w)}else{eval.call(w,co)}}else{w.execScript(co)}}}; |
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 if (/Gecko/.test(navigator.userAgent)) |
|
179 eval(co, w); // Firefox 3.0 |
|
180 else |
|
181 eval.call(w, co); |
|
182 } else |
|
183 w.execScript(co); // IE |
|
184 } |
|
185 }; |
|