2 /* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
4 function TinyMCE_Engine() {
7 this.majorVersion = "2";
8 this.minorVersion = "1.3";
9 this.releaseDate = "2007-11-27";
12 this.switchClassCache = [];
14 this.loadedFiles = [];
15 this.pendingFiles = [];
16 this.loadingIndex = 0;
18 this.currentConfig = 0;
19 this.eventHandlers = [];
23 this.typingUndoIndex = -1;
27 ua = navigator.userAgent;
28 this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
29 this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
30 this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
31 this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1);
32 this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari
33 this.isSafari = ua.indexOf('Safari') != -1;
34 this.isOpera = window['opera'] && opera.buildNumber ? true : false;
35 this.isMac = ua.indexOf('Mac') != -1;
36 this.isNS7 = ua.indexOf('Netscape/7') != -1;
37 this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
38 this.dialogCounter = 0;
42 this.loadedPlugins = [];
44 this.isLoaded = false;
46 // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those
50 this.isSafari = false;
53 this.isIE = this.isMSIE;
54 this.isRealIE = this.isMSIE && !this.isOpera;
56 // TinyMCE editor id instance counter
60 TinyMCE_Engine.prototype = {
61 init : function(settings) {
62 var theme, nl, baseHREF = "", i, cssPath, entities, h, p, src, elements = [], head;
64 // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry.
68 this.settings = settings;
70 // Check if valid browser has execcommand support
71 if (typeof(document.execCommand) == 'undefined')
74 // Get script base path
75 if (!tinyMCE.baseURL) {
76 // Search through head
77 head = document.getElementsByTagName('head')[0];
80 for (i=0, nl = head.getElementsByTagName('script'); i<nl.length; i++)
84 // Search through rest of document
85 for (i=0, nl = document.getElementsByTagName('script'); i<nl.length; i++)
88 // If base element found, add that infront of baseURL
89 nl = document.getElementsByTagName('base');
90 for (i=0; i<nl.length; i++) {
92 baseHREF = nl[i].href;
95 for (i=0; i<elements.length; i++) {
96 if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_dev.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
97 src = elements[i].src;
99 tinyMCE.srcMode = (src.indexOf('_src') != -1 || src.indexOf('_dev') != -1) ? '_src' : '';
100 tinyMCE.gzipMode = src.indexOf('_gzip') != -1;
101 src = src.substring(0, src.lastIndexOf('/'));
103 if (settings.exec_mode == "src" || settings.exec_mode == "normal")
104 tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
106 // Force it absolute if page has a base href
107 if (baseHREF !== '' && src.indexOf('://') == -1)
108 tinyMCE.baseURL = baseHREF + src;
110 tinyMCE.baseURL = src;
117 // Get document base path
118 this.documentBasePath = document.location.href;
119 if (this.documentBasePath.indexOf('?') != -1)
120 this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));
121 this.documentURL = this.documentBasePath;
122 this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));
124 // If not HTTP absolute
125 if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {
127 tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;
130 // Set default values on settings
131 this._def("mode", "none");
132 this._def("theme", "advanced");
133 this._def("plugins", "", true);
134 this._def("language", "en");
135 this._def("docs_language", this.settings.language);
136 this._def("elements", "");
137 this._def("textarea_trigger", "mce_editable");
138 this._def("editor_selector", "");
139 this._def("editor_deselector", "mceNoEditor");
140 this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],#td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang],cite[title|id|class|style|dir|lang],abbr[title|id|class|style|dir|lang],acronym[title|id|class|style|dir|lang],del[title|id|class|style|dir|lang|datetime|cite],ins[title|id|class|style|dir|lang|datetime|cite]");
141 this._def("extended_valid_elements", "");
142 this._def("invalid_elements", "");
143 this._def("encoding", "");
144 this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL"));
145 this._def("save_callback", "");
146 this._def("force_br_newlines", false);
147 this._def("force_p_newlines", true);
148 this._def("add_form_submit_trigger", true);
149 this._def("relative_urls", true);
150 this._def("remove_script_host", true);
151 this._def("focus_alert", true);
152 this._def("document_base_url", this.documentURL);
153 this._def("visual", true);
154 this._def("visual_table_class", "mceVisualAid");
155 this._def("setupcontent_callback", "");
156 this._def("fix_content_duplication", true);
157 this._def("custom_undo_redo", true);
158 this._def("custom_undo_redo_levels", -1);
159 this._def("custom_undo_redo_keyboard_shortcuts", true);
160 this._def("custom_undo_redo_restore_selection", true);
161 this._def("custom_undo_redo_global", false);
162 this._def("verify_html", true);
163 this._def("apply_source_formatting", false);
164 this._def("directionality", "ltr");
165 this._def("cleanup_on_startup", false);
166 this._def("inline_styles", false);
167 this._def("convert_newlines_to_brs", false);
168 this._def("auto_reset_designmode", true);
169 this._def("entities", "39,#39,160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true);
170 this._def("entity_encoding", "named");
171 this._def("cleanup_callback", "");
172 this._def("add_unload_trigger", true);
173 this._def("ask", false);
174 this._def("nowrap", false);
175 this._def("auto_resize", false);
176 this._def("auto_focus", false);
177 this._def("cleanup", true);
178 this._def("remove_linebreaks", true);
179 this._def("button_tile_map", false);
180 this._def("submit_patch", true);
181 this._def("browsers", "msie,safari,gecko,opera", true);
182 this._def("dialog_type", "window");
183 this._def("accessibility_warnings", true);
184 this._def("accessibility_focus", true);
185 this._def("merge_styles_invalid_parents", "");
186 this._def("force_hex_style_colors", true);
187 this._def("trim_span_elements", true);
188 this._def("convert_fonts_to_spans", false);
189 this._def("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
190 this._def("font_size_classes", '');
191 this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true);
192 this._def("event_elements", 'a,img', true);
193 this._def("convert_urls", true);
194 this._def("table_inline_editing", false);
195 this._def("object_resizing", true);
196 this._def("custom_shortcuts", true);
197 this._def("convert_on_click", false);
198 this._def("content_css", '');
199 this._def("fix_list_elements", true);
200 this._def("fix_table_elements", false);
201 this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
202 this._def("hidden_tab_class", '');
203 this._def("display_tab_class", '');
204 this._def("gecko_spellcheck", false);
205 this._def("hide_selects_on_submit", true);
206 this._def("forced_root_block", false);
207 this._def("remove_trailing_nbsp", false);
208 this._def("save_on_tinymce_forms", false);
210 // Force strict loading mode to false on non Gecko browsers
211 if (this.isMSIE && !this.isOpera)
212 this.settings.strict_loading_mode = false;
215 if (this.isMSIE && this.settings.browsers.indexOf('msie') == -1)
218 // Browser check Gecko
219 if (this.isGecko && this.settings.browsers.indexOf('gecko') == -1)
222 // Browser check Safari
223 if (this.isSafari && this.settings.browsers.indexOf('safari') == -1)
226 // Browser check Opera
227 if (this.isOpera && this.settings.browsers.indexOf('opera') == -1)
230 // If not super absolute make it so
231 baseHREF = tinyMCE.settings.document_base_url;
232 h = document.location.href;
233 p = h.indexOf('://');
234 if (p > 0 && document.location.protocol != "file:") {
235 p = h.indexOf('/', p + 3);
236 h = h.substring(0, p);
238 if (baseHREF.indexOf('://') == -1)
239 baseHREF = h + baseHREF;
241 tinyMCE.settings.document_base_url = baseHREF;
242 tinyMCE.settings.document_base_prefix = h;
245 // Trim away query part
246 if (baseHREF.indexOf('?') != -1)
247 baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
249 this.settings.base_href = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
251 theme = this.settings.theme;
252 this.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';
253 this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';
254 this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
255 this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
256 this.posKeyCodes = [13,45,36,35,33,34,37,38,39,40];
257 this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL
258 this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
259 this.callbacks = ['onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance'];
262 this.settings.theme_href = tinyMCE.baseURL + "/themes/" + theme;
264 if (!tinyMCE.isIE || tinyMCE.isOpera)
265 this.settings.force_br_newlines = false;
267 if (tinyMCE.getParam("popups_css", false)) {
268 cssPath = tinyMCE.getParam("popups_css", "");
271 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
272 this.settings.popups_css = this.documentBasePath + "/" + cssPath;
274 this.settings.popups_css = cssPath;
276 this.settings.popups_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
278 if (tinyMCE.getParam("editor_css", false)) {
279 cssPath = tinyMCE.getParam("editor_css", "");
282 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
283 this.settings.editor_css = this.documentBasePath + "/" + cssPath;
285 this.settings.editor_css = cssPath;
287 if (this.settings.editor_css !== '')
288 this.settings.editor_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
292 if (this.configs.length == 0) {
293 if (typeof(TinyMCECompressed) == "undefined") {
294 tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
296 if (tinyMCE.isRealIE) {
298 tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
300 tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad);
303 tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad);
304 tinyMCE._addUnloadEvents();
308 this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings.theme + '/editor_template' + tinyMCE.srcMode + '.js');
309 this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings.language + '.js');
310 this.loadCSS(this.settings.editor_css);
313 p = tinyMCE.getParam('plugins', '', true, ',');
315 for (i=0; i<p.length; i++) {
316 if (p[i].charAt(0) != '-')
317 this.loadScript(tinyMCE.baseURL + '/plugins/' + p[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');
322 if (tinyMCE.getParam('entity_encoding') == 'named') {
323 settings.cleanup_entities = [];
324 entities = tinyMCE.getParam('entities', '', true, ',');
325 for (i=0; i<entities.length; i+=2)
326 settings.cleanup_entities['c' + entities[i]] = entities[i+1];
329 // Save away this config
330 settings.index = this.configs.length;
331 this.configs[this.configs.length] = settings;
333 // Start loading first one in chain
334 this.loadNextScript();
336 // Force flicker free CSS backgrounds in IE
337 if (this.isIE && !this.isOpera) {
339 document.execCommand('BackgroundImageCache', false, true);
345 // Setup XML encoding regexps
346 this.xmlEncodeRe = new RegExp('[<>&"]', 'g');
349 _addUnloadEvents : function() {
350 var st = tinyMCE.settings.add_unload_trigger;
354 tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
355 tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler);
359 tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);});
363 _def : function(key, def_val, t) {
364 var v = tinyMCE.getParam(key, def_val);
366 v = t ? v.replace(/\s+/g, "") : v;
368 this.settings[key] = v;
371 hasPlugin : function(n) {
372 return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
375 addPlugin : function(n, p) {
376 var op = this.plugins[n];
378 // Use the previous plugin object base URL used when loading external plugins
379 p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n;
382 this.loadNextScript();
385 setPluginBaseURL : function(n, u) {
386 var op = this.plugins[n];
391 this.plugins[n] = {baseURL : u};
394 loadPlugin : function(n, u) {
395 u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u;
396 u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u;
397 this.plugins[n] = {baseURL : u};
398 this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js");
401 hasTheme : function(n) {
402 return typeof(this.themes[n]) != "undefined" && this.themes[n] != null;
405 addTheme : function(n, t) {
408 this.loadNextScript();
411 addMenu : function(n, m) {
415 hasMenu : function(n) {
416 return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
419 loadScript : function(url) {
422 for (i=0; i<this.loadedFiles.length; i++) {
423 if (this.loadedFiles[i] == url)
427 if (tinyMCE.settings.strict_loading_mode)
428 this.pendingFiles[this.pendingFiles.length] = url;
430 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
432 this.loadedFiles[this.loadedFiles.length] = url;
435 loadNextScript : function() {
436 var d = document, se;
438 if (!tinyMCE.settings.strict_loading_mode)
441 if (this.loadingIndex < this.pendingFiles.length) {
442 se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script');
443 se.setAttribute('language', 'javascript');
444 se.setAttribute('type', 'text/javascript');
445 se.setAttribute('src', this.pendingFiles[this.loadingIndex++]);
447 d.getElementsByTagName("head")[0].appendChild(se);
449 this.loadingIndex = -1; // Done with loading
452 loadCSS : function(url) {
453 var ar = url.replace(/\s+/, '').split(',');
454 var lflen = 0, csslen = 0, skip = false;
455 var x = 0, i = 0, nl, le;
457 for (x = 0,csslen = ar.length; x<csslen; x++) {
458 if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) {
459 /* Make sure it doesn't exist. */
460 for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) {
461 if (this.loadedFiles[i] == ar[x]) {
468 if (tinyMCE.settings.strict_loading_mode) {
469 nl = document.getElementsByTagName("head");
471 le = document.createElement('link');
472 le.setAttribute('href', ar[x]);
473 le.setAttribute('rel', 'stylesheet');
474 le.setAttribute('type', 'text/css');
476 nl[0].appendChild(le);
478 document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />');
480 this.loadedFiles[this.loadedFiles.length] = ar[x];
486 importCSS : function(doc, css) {
487 var css_ary = css.replace(/\s+/, '').split(',');
488 var csslen, elm, headArr, x, css_file;
490 for (x = 0, csslen = css_ary.length; x<csslen; x++) {
491 css_file = css_ary[x];
493 if (css_file != null && css_file != 'null' && css_file.length > 0) {
494 // Is relative, make absolute
495 if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/')
496 css_file = this.documentBasePath + "/" + css_file;
498 if (typeof(doc.createStyleSheet) == "undefined") {
499 elm = doc.createElement("link");
501 elm.rel = "stylesheet";
504 if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
505 headArr[0].appendChild(elm);
507 doc.createStyleSheet(css_file);
512 confirmAdd : function(e, settings) {
513 var elm = tinyMCE.isIE ? event.srcElement : e.target;
514 var elementId = elm.name ? elm.name : elm.id;
516 tinyMCE.settings = settings;
518 if (tinyMCE.settings.convert_on_click || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang.lang_edit_confirm)))
519 tinyMCE.addMCEControl(elm, elementId);
521 elm.setAttribute('mce_noask', 'true');
524 updateContent : function(form_element_name) {
525 var formElement, n, inst, doc;
527 // Find MCE instance linked to given form element and copy it's value
528 formElement = document.getElementById(form_element_name);
529 for (n in tinyMCE.instances) {
530 inst = tinyMCE.instances[n];
532 if (!tinyMCE.isInstance(inst))
535 inst.switchSettings();
537 if (inst.formElement == formElement) {
540 tinyMCE._setHTML(doc, inst.formElement.value);
543 doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
548 addMCEControl : function(replace_element, form_element_name, target_document) {
549 var id = "mce_editor_" + tinyMCE.idCounter++;
550 var inst = new TinyMCE_Control(tinyMCE.settings);
553 this.instances[id] = inst;
555 inst._onAdd(replace_element, form_element_name, target_document);
558 removeInstance : function(ti) {
561 // Remove from instances
562 for (n in tinyMCE.instances) {
563 i = tinyMCE.instances[n];
565 if (tinyMCE.isInstance(i) && ti != i)
569 tinyMCE.instances = t;
571 // Remove from global undo/redo
573 t = tinyMCE.undoLevels;
575 for (i=0; i<t.length; i++) {
580 tinyMCE.undoLevels = n;
581 tinyMCE.undoIndex = n.length;
583 // Dispatch remove instance call
584 tinyMCE.dispatchCallback(ti, 'remove_instance_callback', 'removeInstance', ti);
589 removeMCEControl : function(editor_id) {
590 var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn, n;
593 inst.switchSettings();
595 editor_id = inst.editorId;
596 h = tinyMCE.getContent(editor_id);
598 this.removeInstance(inst);
600 tinyMCE.selectedElement = null;
601 tinyMCE.selectedInstance = null;
603 tinyMCE.selectedElement = null;
604 tinyMCE.selectedInstance = null;
606 // Try finding an instance
607 for (n in tinyMCE.instances) {
608 if (!tinyMCE.isInstance(tinyMCE.instances[n]))
611 tinyMCE.selectedInstance = tinyMCE.instances[n];
616 re = document.getElementById(editor_id + "_parent");
617 ot = inst.oldTargetElement;
618 tn = ot.nodeName.toLowerCase();
620 if (tn == "textarea" || tn == "input") {
621 re.parentNode.removeChild(re);
622 ot.style.display = "inline";
626 ot.style.display = 'block';
627 re.parentNode.insertBefore(ot, re);
628 re.parentNode.removeChild(re);
633 triggerSave : function(skip_cleanup, skip_callback) {
637 if (typeof(skip_cleanup) == "undefined")
638 skip_cleanup = false;
641 if (typeof(skip_callback) == "undefined")
642 skip_callback = false;
644 // Cleanup and set all form fields
645 for (n in tinyMCE.instances) {
646 inst = tinyMCE.instances[n];
648 if (!tinyMCE.isInstance(inst))
651 inst.triggerSave(skip_cleanup, skip_callback);
655 resetForm : function(form_index) {
656 var i, inst, n, formObj = document.forms[form_index];
658 for (n in tinyMCE.instances) {
659 inst = tinyMCE.instances[n];
661 if (!tinyMCE.isInstance(inst))
664 inst.switchSettings();
666 for (i=0; i<formObj.elements.length; i++) {
667 if (inst.formTargetElementId == formObj.elements[i].name)
668 inst.getBody().innerHTML = inst.startContent;
673 execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
674 var inst = tinyMCE.getInstanceById(editor_id), r;
677 r = inst.selection.getRng();
679 if (typeof(focus) == "undefined")
682 // IE bug lost focus on images in absolute divs Bug #1534575
683 if (focus && (!r || !r.item))
684 inst.contentWindow.focus();
686 // Reset design mode if lost
687 inst.autoResetDesignMode();
689 this.selectedElement = inst.getFocusElement();
691 tinyMCE.execCommand(command, user_interface, value);
693 // Cancel event so it doesn't call onbeforeonunlaod
694 if (tinyMCE.isIE && window.event != null)
695 tinyMCE.cancelEvent(window.event);
699 execCommand : function(command, user_interface, value) {
700 var inst = tinyMCE.selectedInstance, n, pe, te;
703 user_interface = user_interface ? user_interface : false;
704 value = value ? value : null;
707 inst.switchSettings();
711 if (this.getParam('custom_undo_redo_global')) {
712 if (this.undoIndex > 0) {
713 tinyMCE.nextUndoRedoAction = 'Undo';
714 inst = this.undoLevels[--this.undoIndex];
717 if (!tinyMCE.nextUndoRedoInstanceId)
718 inst.execCommand('Undo');
721 inst.execCommand('Undo');
725 if (this.getParam('custom_undo_redo_global')) {
726 if (this.undoIndex <= this.undoLevels.length - 1) {
727 tinyMCE.nextUndoRedoAction = 'Redo';
728 inst = this.undoLevels[this.undoIndex++];
731 if (!tinyMCE.nextUndoRedoInstanceId)
732 inst.execCommand('Redo');
735 inst.execCommand('Redo');
740 inst = tinyMCE.getInstanceById(value);
743 inst.getWin().focus();
746 case "mceAddControl":
748 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
751 case "mceAddFrameControl":
752 tinyMCE.addMCEControl(tinyMCE._getElementById(value.element, value.document), value.element, value.document);
755 case "mceRemoveControl":
756 case "mceRemoveEditor":
757 tinyMCE.removeMCEControl(value);
760 case "mceToggleEditor":
761 inst = tinyMCE.getInstanceById(value);
764 pe = document.getElementById(inst.editorId + '_parent');
765 te = inst.oldTargetElement;
767 if (typeof(inst.enabled) == 'undefined')
770 inst.enabled = !inst.enabled;
773 pe.style.display = 'none';
775 if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT')
776 te.value = inst.getHTML();
778 te.innerHTML = inst.getHTML();
780 te.style.display = inst.oldTargetDisplay;
781 tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst);
783 pe.style.display = 'block';
784 te.style.display = 'none';
786 if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT')
787 inst.setHTML(te.value);
789 inst.setHTML(te.innerHTML);
792 tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst);
795 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
799 case "mceResetDesignMode":
800 // Resets the designmode state of the editors in Gecko
801 if (tinyMCE.isGecko) {
802 for (n in tinyMCE.instances) {
803 if (!tinyMCE.isInstance(tinyMCE.instances[n]))
807 tinyMCE.instances[n].getDoc().designMode = "off";
808 tinyMCE.instances[n].getDoc().designMode = "on";
809 tinyMCE.instances[n].useCSS = false;
820 inst.execCommand(command, user_interface, value);
821 } else if (tinyMCE.settings.focus_alert)
822 alert(tinyMCELang.lang_focus_alert);
825 _createIFrame : function(replace_element, doc, win) {
826 var iframe, id = replace_element.getAttribute("id");
829 if (typeof(doc) == "undefined")
832 if (typeof(win) == "undefined")
835 iframe = doc.createElement("iframe");
837 aw = "" + tinyMCE.settings.area_width;
838 ah = "" + tinyMCE.settings.area_height;
840 if (aw.indexOf('%') == -1) {
842 aw = (isNaN(aw) || aw < 0) ? 300 : aw;
846 if (ah.indexOf('%') == -1) {
848 ah = (isNaN(ah) || ah < 0) ? 240 : ah;
852 iframe.setAttribute("id", id);
853 iframe.setAttribute("name", id);
854 iframe.setAttribute("class", "mceEditorIframe");
855 iframe.setAttribute("border", "0");
856 iframe.setAttribute("frameBorder", "0");
857 iframe.setAttribute("marginWidth", "0");
858 iframe.setAttribute("marginHeight", "0");
859 iframe.setAttribute("leftMargin", "0");
860 iframe.setAttribute("topMargin", "0");
861 iframe.setAttribute("width", aw);
862 iframe.setAttribute("height", ah);
863 iframe.setAttribute("allowtransparency", "true");
864 iframe.className = 'mceEditorIframe';
866 if (tinyMCE.settings.auto_resize)
867 iframe.setAttribute("scrolling", "no");
869 // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
870 if (tinyMCE.isRealIE)
871 iframe.setAttribute("src", this.settings.default_document);
873 iframe.style.width = aw;
874 iframe.style.height = ah;
876 // Ugly hack for Gecko problem in strict mode
877 if (tinyMCE.settings.strict_loading_mode)
878 iframe.style.marginBottom = '-5px';
881 if (tinyMCE.isRealIE)
882 replace_element.outerHTML = iframe.outerHTML;
884 replace_element.parentNode.replaceChild(iframe, replace_element);
886 if (tinyMCE.isRealIE)
887 return win.frames[id];
892 setupContent : function(editor_id) {
893 var inst = tinyMCE.instances[editor_id], i, doc = inst.getDoc(), head = doc.getElementsByTagName('head').item(0);
894 var content = inst.startContent, contentElement, body;
896 // HTML values get XML encoded in strict mode
897 if (tinyMCE.settings.strict_loading_mode) {
898 content = content.replace(/</g, '<');
899 content = content.replace(/>/g, '>');
900 content = content.replace(/"/g, '"');
901 content = content.replace(/&/g, '&');
904 tinyMCE.selectedInstance = inst;
905 inst.switchSettings();
907 // Not loaded correctly hit it again, Mozilla bug #997860
908 if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
909 // This part will remove the designMode status
910 // Failes first time in Firefox 1.5b2 on Mac
911 try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
912 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);
916 // Wait for it to load
917 if (!head || !doc.body) {
918 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);
922 // Import theme specific content CSS the user specific
923 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings.theme + "/css/editor_content.css");
924 tinyMCE.importCSS(inst.getDoc(), inst.settings.content_css);
925 tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst);
927 // Setup keyboard shortcuts
928 if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) {
929 inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo');
930 inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
933 // BlockFormat shortcuts keys
935 inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, '<h' + i + '>');
937 inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '<p>');
938 inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '<div>');
939 inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '<address>');
941 // Add default shortcuts for gecko
942 if (tinyMCE.isGecko) {
943 inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
944 inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic');
945 inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline');
949 if (tinyMCE.getParam("convert_fonts_to_spans"))
950 inst.getBody().setAttribute('id', 'mceSpanFonts');
952 if (tinyMCE.settings.nowrap)
953 doc.body.style.whiteSpace = "nowrap";
955 doc.body.dir = this.settings.directionality;
956 doc.editorId = editor_id;
958 // Add on document element in Mozilla
960 doc.documentElement.editorId = editor_id;
962 inst.setBaseHREF(tinyMCE.settings.base_href);
964 // Replace new line characters to BRs
965 if (tinyMCE.settings.convert_newlines_to_brs) {
966 content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
967 content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
968 content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
971 // Open closed anchors
972 // content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
974 // Call custom cleanup code
975 content = tinyMCE.storeAwayURLs(content);
976 content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
980 window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
982 if (tinyMCE.settings.force_br_newlines)
983 doc.styleSheets[0].addRule("p", "margin: 0;");
985 body = inst.getBody();
986 body.editorId = editor_id;
989 content = tinyMCE.cleanupHTMLCode(content);
991 // Fix for bug #958637
993 contentElement = inst.getDoc().createElement("body");
996 contentElement.innerHTML = content;
998 if (tinyMCE.settings.cleanup_on_startup)
999 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
1001 tinyMCE.setInnerHTML(inst.getBody(), content);
1003 tinyMCE.convertAllRelativeURLs(inst.getBody());
1005 if (tinyMCE.settings.cleanup_on_startup) {
1006 tinyMCE._setHTML(inst.getDoc(), content);
1008 // Produces permission denied error in MSIE 5.5
1010 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));
1015 tinyMCE._setHTML(inst.getDoc(), content);
1018 // Fix for bug #957681
1019 //inst.getDoc().designMode = inst.getDoc().designMode;
1021 tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings.visual, inst);
1022 tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
1024 // Re-add design mode on mozilla
1026 tinyMCE.addEventHandlers(inst);
1030 tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
1031 tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
1033 // Workaround for drag drop/copy paste base href bug
1034 if (!tinyMCE.isOpera) {
1035 tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove);
1036 tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch);
1037 tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch);
1041 // Trigger node change, this call locks buttons for tables and so forth
1043 tinyMCE.selectedElement = inst.contentWindow.document.body;
1045 // Call custom DOM cleanup
1046 tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
1047 tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
1048 tinyMCE._setEventsEnabled(inst.getBody(), false);
1049 tinyMCE.cleanupAnchors(inst.getDoc());
1051 if (tinyMCE.getParam("convert_fonts_to_spans"))
1052 tinyMCE.convertSpansToFonts(inst.getDoc());
1054 inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
1055 inst.undoRedo.add({ content : inst.startContent });
1057 // Cleanup any mess left from storyAwayURLs
1058 if (tinyMCE.isGecko) {
1059 // Remove mce_src from textnodes and comments
1060 tinyMCE.selectNodes(inst.getBody(), function(n) {
1061 if (n.nodeType == 3 || n.nodeType == 8)
1062 n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
1068 // Remove Gecko spellchecking
1069 if (tinyMCE.isGecko)
1070 inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck");
1072 // Cleanup any mess left from storyAwayURLs
1073 tinyMCE._removeInternal(inst.getBody());
1076 tinyMCE.triggerNodeChange(false, true);
1079 storeAwayURLs : function(s) {
1080 // Remove all mce_src, mce_href and replace them with new ones
1081 // s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
1082 // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
1084 if (!s.match(/(mce_src|mce_href)/gi, s)) {
1085 s = s.replace(new RegExp('src\\s*=\\s*[\"\']([^ >\"]*)[\"\']', 'gi'), 'src="$1" mce_src="$1"');
1086 s = s.replace(new RegExp('href\\s*=\\s*[\"\']([^ >\"]*)[\"\']', 'gi'), 'href="$1" mce_href="$1"');
1092 _removeInternal : function(n) {
1093 if (tinyMCE.isGecko) {
1094 // Remove mce_src from textnodes and comments
1095 tinyMCE.selectNodes(n, function(n) {
1096 if (n.nodeType == 3 || n.nodeType == 8)
1097 n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
1104 removeTinyMCEFormElements : function(form_obj) {
1107 // Skip form element removal
1108 if (!tinyMCE.getParam('hide_selects_on_submit'))
1111 // Check if form is valid
1112 if (typeof(form_obj) == "undefined" || form_obj == null)
1115 // If not a form, find the form
1116 if (form_obj.nodeName != "FORM") {
1118 form_obj = form_obj.form;
1120 form_obj = tinyMCE.getParentElement(form_obj, "form");
1124 if (form_obj == null)
1127 // Disable all UI form elements that TinyMCE created
1128 for (i=0; i<form_obj.elements.length; i++) {
1129 elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
1131 if (elementId.indexOf('mce_editor_') == 0)
1132 form_obj.elements[i].disabled = true;
1136 handleEvent : function(e) {
1137 var inst = tinyMCE.selectedInstance, i, elm, keys;
1139 // Remove odd, error
1140 if (typeof(tinyMCE) == "undefined")
1143 //tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""));
1145 if (tinyMCE.executeCallback(tinyMCE.selectedInstance, 'handle_event_callback', 'handleEvent', e))
1149 case "beforedeactivate": // Was added due to bug #1439953
1151 if (tinyMCE.selectedInstance)
1152 tinyMCE.selectedInstance.execCommand('mceEndTyping');
1154 tinyMCE.hideMenus();
1158 // Workaround for drag drop/copy paste base href bug
1161 /* if (tinyMCE.selectedInstance)
1162 tinyMCE.selectedInstance.setBaseHREF(null);
1164 // Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks
1165 // This logic forces the width/height to be in pixels while the user is drag/dropping
1166 // NOTE: This has been disabled for now since it messes up copy/paste that is far more important than image drag
1167 if (tinyMCE.isRealIE) {
1168 var ife = tinyMCE.selectedInstance.iframeElement;
1170 if (ife.style.height.indexOf('%') != -1) {
1171 ife._oldHeight = ife.style.height;
1172 ife.style.height = ife.clientHeight;
1176 window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings.base_href);tinyMCE._resetIframeHeight();", 1);
1181 tinyMCE.formSubmit(tinyMCE.isMSIE ? window.event.srcElement : e.target);
1185 var formObj = tinyMCE.isIE ? window.event.srcElement : e.target;
1187 for (i=0; i<document.forms.length; i++) {
1188 if (document.forms[i] == formObj)
1189 window.setTimeout('tinyMCE.resetForm(' + i + ');', 10);
1195 if (inst && inst.handleShortcut(e))
1198 if (e.target.editorId) {
1199 tinyMCE.instances[e.target.editorId].select();
1201 if (e.target.ownerDocument.editorId)
1202 tinyMCE.instances[e.target.ownerDocument.editorId].select();
1205 if (tinyMCE.selectedInstance)
1206 tinyMCE.selectedInstance.switchSettings();
1209 if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings.force_p_newlines && e.keyCode == 13 && !e.shiftKey) {
1210 // Insert P element instead of BR
1211 if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) {
1213 tinyMCE.execCommand("mceAddUndoLevel");
1214 return tinyMCE.cancelEvent(e);
1219 if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
1220 // Insert P element instead of BR
1221 if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
1223 tinyMCE.execCommand("mceAddUndoLevel");
1224 return tinyMCE.cancelEvent(e);
1228 // Return key pressed
1229 if (tinyMCE.isIE && tinyMCE.settings.force_br_newlines && e.keyCode == 13) {
1230 if (e.target.editorId)
1231 tinyMCE.instances[e.target.editorId].select();
1233 if (tinyMCE.selectedInstance) {
1234 var sel = tinyMCE.selectedInstance.getDoc().selection;
1235 var rng = sel.createRange();
1237 if (tinyMCE.getParentElement(rng.parentElement(), "li") != null)
1241 e.returnValue = false;
1242 e.cancelBubble = true;
1244 // Insert BR element
1245 rng.pasteHTML("<br />");
1246 rng.collapse(false);
1249 tinyMCE.execCommand("mceAddUndoLevel");
1250 tinyMCE.triggerNodeChange(false);
1255 // Backspace or delete
1256 if (e.keyCode == 8 || e.keyCode == 46) {
1257 tinyMCE.selectedElement = e.target;
1258 tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
1259 tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
1260 tinyMCE.triggerNodeChange(false);
1267 tinyMCE.hideMenus();
1268 tinyMCE.hasMouseMoved = false;
1270 if (inst && inst.handleShortcut(e))
1273 inst._fixRootBlocks();
1275 if (inst.settings.remove_trailing_nbsp)
1276 inst._fixTrailingNbsp();
1278 if (e.target.editorId)
1279 tinyMCE.instances[e.target.editorId].select();
1281 if (tinyMCE.selectedInstance)
1282 tinyMCE.selectedInstance.switchSettings();
1284 inst = tinyMCE.selectedInstance;
1287 if (tinyMCE.isGecko && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
1288 // Insert P element instead of BR
1289 if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
1291 tinyMCE.execCommand("mceAddUndoLevel");
1297 tinyMCE.selectedElement = null;
1298 tinyMCE.selectedNode = null;
1299 elm = tinyMCE.selectedInstance.getFocusElement();
1300 tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
1301 tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
1302 tinyMCE.selectedElement = elm;
1304 // Update visualaids on tabs
1305 if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
1306 tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings.visual, tinyMCE.selectedInstance);
1308 // Fix empty elements on return/enter, check where enter occured
1309 if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13)
1310 tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
1312 // Fix empty elements on return/enter
1313 if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) {
1314 elm = tinyMCE.enterKeyElement;
1316 var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
1317 var dre = new RegExp('^H[1-6]$','g'); // Add double on these
1319 if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
1320 if (dre.test(elm.nodeName))
1321 elm.innerHTML = " ";
1323 elm.innerHTML = " ";
1328 // Check if it's a position key
1329 keys = tinyMCE.posKeyCodes;
1331 for (i=0; i<keys.length; i++) {
1332 if (keys[i] == e.keyCode) {
1338 // MSIE custom key handling
1339 if (tinyMCE.isIE && tinyMCE.settings.custom_undo_redo) {
1340 keys = [8, 46]; // Backspace,Delete
1342 for (i=0; i<keys.length; i++) {
1343 if (keys[i] == e.keyCode) {
1344 if (e.type == "keyup")
1345 tinyMCE.triggerNodeChange(false);
1351 if (e.keyCode == 17)
1354 // Handle Undo/Redo when typing content
1356 if (tinyMCE.isGecko) {
1357 // Start typing (not a position key or ctrl key, but ctrl+x and ctrl+p is ok)
1358 if (!posKey && e.type == "keyup" && !e.ctrlKey || (e.ctrlKey && (e.keyCode == 86 || e.keyCode == 88)))
1359 tinyMCE.execCommand("mceStartTyping");
1361 // IE seems to be working better with this setting
1362 if (!posKey && e.type == "keyup")
1363 tinyMCE.execCommand("mceStartTyping");
1366 // Store undo bookmark
1367 if (e.type == "keydown" && (posKey || e.ctrlKey) && inst)
1368 inst.undoBookmark = inst.selection.getBookmark();
1370 // End typing (position key) or some Ctrl event
1371 if (e.type == "keyup" && (posKey || e.ctrlKey))
1372 tinyMCE.execCommand("mceEndTyping");
1374 if (posKey && e.type == "keyup")
1375 tinyMCE.triggerNodeChange(false);
1377 if (tinyMCE.isIE && e.ctrlKey)
1378 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
1386 tinyMCE.hideMenus();
1388 if (tinyMCE.selectedInstance) {
1389 tinyMCE.selectedInstance.switchSettings();
1390 tinyMCE.selectedInstance.isFocused = true;
1393 // Check instance event trigged on
1394 var targetBody = tinyMCE.getParentElement(e.target, "html");
1395 for (var instanceName in tinyMCE.instances) {
1396 if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
1399 inst = tinyMCE.instances[instanceName];
1401 // Reset design mode if lost (on everything just in case)
1402 inst.autoResetDesignMode();
1404 // Use HTML element since users might click outside of body element
1405 if (inst.getBody().parentNode == targetBody) {
1407 tinyMCE.selectedElement = e.target;
1408 tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
1409 tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
1414 // Add first bookmark location
1415 if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark && (e.type == "mouseup" || e.type == "dblclick"))
1416 tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
1418 // Reset selected node
1419 if (e.type != "focus")
1420 tinyMCE.selectedNode = null;
1422 tinyMCE.triggerNodeChange(false);
1423 tinyMCE.execCommand("mceEndTyping");
1425 if (e.type == "mouseup")
1426 tinyMCE.execCommand("mceAddUndoLevel");
1429 if (!tinyMCE.selectedInstance && e.target.editorId)
1430 tinyMCE.instances[e.target.editorId].select();
1436 getButtonHTML : function(id, lang, img, cmd, ui, val) {
1437 var h = '', m, x, io = '';
1439 cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
1441 if (typeof(ui) != "undefined" && ui != null)
1444 if (typeof(val) != "undefined" && val != null)
1445 cmd += ",'" + val + "'";
1449 // Patch for IE7 bug with hover out not restoring correctly
1450 if (tinyMCE.isRealIE)
1451 io = 'onmouseover="tinyMCE.lastHover = this;"';
1453 // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
1454 if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
1456 x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
1457 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceTiledButton mceButtonNormal" target="_self">';
1458 h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" alt="{$'+lang+'}" title="{$' + lang + '}" />';
1462 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">';
1463 h += '<img src="' + img + '" alt="{$'+lang+'}" title="{$' + lang + '}" />';
1470 getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) {
1473 mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');';
1474 cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
1476 if (typeof(ui) != "undefined" && ui != null)
1479 if (typeof(val) != "undefined" && val != null)
1480 cmd += ",'" + val + "'";
1484 // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
1485 if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
1486 x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
1488 if (tinyMCE.isRealIE)
1489 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
1491 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
1493 h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceMenuButtonNormal" target="_self">';
1494 h += '<img src="{$themeurl}/images/spacer.gif" style="width: 20px; height: 20px; background-position: ' + x + 'px 0" title="{$' + lang + '}" /></a>';
1495 h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
1498 if (tinyMCE.isRealIE)
1499 h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
1501 h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">';
1503 h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
1504 h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
1505 h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
1512 _menuButtonEvent : function(e, o) {
1513 if (o.className == 'mceMenuButtonFocus')
1517 o.className = o.className + ' mceMenuHover';
1519 o.className = o.className.replace(/\s.*$/, '');
1522 addButtonMap : function(m) {
1523 var i, a = m.replace(/\s+/, '').split(',');
1525 for (i=0; i<a.length; i++)
1526 this.buttonMap[a[i]] = i;
1529 formSubmit : function(f, p) {
1530 var n, inst, found = false;
1535 // Is it a form that has a TinyMCE instance
1536 if (tinyMCE.getParam('save_on_tinymce_forms')) {
1537 for (n in tinyMCE.instances) {
1538 inst = tinyMCE.instances[n];
1540 if (!tinyMCE.isInstance(inst))
1543 if (inst.formElement) {
1544 if (f == inst.formElement.form) {
1546 inst.isNotDirty = true;
1555 tinyMCE.removeTinyMCEFormElements(f);
1556 tinyMCE.triggerSave();
1560 if (f.mceOldSubmit && p)
1564 submitPatch : function() {
1565 tinyMCE.formSubmit(this, true);
1568 onLoad : function() {
1569 var r, i, c, mode, trigger, elements, element, settings, elementId, elm;
1570 var selector, deselector, elementRefAr, form;
1572 // Wait for everything to be loaded first
1573 if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) {
1574 window.setTimeout('tinyMCE.onLoad();', 1);
1578 if (tinyMCE.isRealIE && window.event.type == "readystatechange" && document.readyState != "complete")
1581 if (tinyMCE.isLoaded)
1584 tinyMCE.isLoaded = true;
1586 // IE produces JS error if TinyMCE is placed in a frame
1587 // It seems to have something to do with the selection not beeing
1588 // correctly initialized in IE so this hack solves the problem
1589 if (tinyMCE.isRealIE && document.body && window.location.href != window.top.location.href) {
1590 r = document.body.createTextRange();
1595 tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad');
1597 for (c=0; c<tinyMCE.configs.length; c++) {
1598 tinyMCE.settings = tinyMCE.configs[c];
1600 selector = tinyMCE.getParam("editor_selector");
1601 deselector = tinyMCE.getParam("editor_deselector");
1604 // Add submit triggers
1605 if (document.forms && tinyMCE.settings.add_form_submit_trigger && !tinyMCE.submitTriggers) {
1606 for (i=0; i<document.forms.length; i++) {
1607 form = document.forms[i];
1609 tinyMCE.addEvent(form, "submit", TinyMCE_Engine.prototype.handleEvent);
1610 tinyMCE.addEvent(form, "reset", TinyMCE_Engine.prototype.handleEvent);
1611 tinyMCE.submitTriggers = true; // Do it only once
1613 // Patch the form.submit function
1614 if (tinyMCE.settings.submit_patch) {
1616 form.mceOldSubmit = form.submit;
1617 form.submit = TinyMCE_Engine.prototype.submitPatch;
1625 // Add editor instances based on mode
1626 mode = tinyMCE.settings.mode;
1629 elements = tinyMCE.getParam('elements', '', true, ',');
1631 for (i=0; i<elements.length; i++) {
1632 element = tinyMCE._getElementById(elements[i]);
1633 trigger = element ? element.getAttribute(tinyMCE.settings.textarea_trigger) : "";
1635 if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class")))
1638 if (trigger == "false")
1641 if ((tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) && element) {
1642 elementRefAr[elementRefAr.length] = element;
1647 tinyMCE.addMCEControl(element, elements[i]);
1651 case "specific_textareas":
1653 elements = document.getElementsByTagName("textarea");
1655 for (i=0; i<elements.length; i++) {
1656 elm = elements.item(i);
1657 trigger = elm.getAttribute(tinyMCE.settings.textarea_trigger);
1659 if (selector !== '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
1662 if (selector !== '')
1663 trigger = selector !== '' ? "true" : "";
1665 if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
1668 if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))
1669 elementRefAr[elementRefAr.length] = elm;
1674 for (i=0; i<elementRefAr.length; i++) {
1675 element = elementRefAr[i];
1676 elementId = element.name ? element.name : element.id;
1678 if (tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) {
1679 // Focus breaks in Mozilla
1680 if (tinyMCE.isGecko) {
1681 settings = tinyMCE.settings;
1683 tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
1685 if (element.nodeName != "TEXTAREA" && element.nodeName != "INPUT")
1686 tinyMCE.addEvent(element, "click", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
1687 // tinyMCE.addEvent(element, "mouseover", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
1689 settings = tinyMCE.settings;
1691 tinyMCE.addEvent(element, "focus", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
1692 tinyMCE.addEvent(element, "click", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
1693 // tinyMCE.addEvent(element, "mouseenter", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
1696 tinyMCE.addMCEControl(element, elementId);
1699 // Handle auto focus
1700 if (tinyMCE.settings.auto_focus) {
1701 window.setTimeout(function () {
1702 var inst = tinyMCE.getInstanceById(tinyMCE.settings.auto_focus);
1703 inst.selection.selectNode(inst.getBody(), true, true);
1704 inst.contentWindow.focus();
1708 tinyMCE.dispatchCallback(null, 'oninit', 'onInit');
1712 isInstance : function(o) {
1713 return o != null && typeof(o) == "object" && o.isTinyMCE_Control;
1716 getParam : function(name, default_value, strip_whitespace, split_chr) {
1717 var i, outArray, value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
1720 if (value == "true" || value == "false")
1721 return (value == "true");
1723 if (strip_whitespace)
1724 value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "");
1726 if (typeof(split_chr) != "undefined" && split_chr != null) {
1727 value = value.split(split_chr);
1730 for (i=0; i<value.length; i++) {
1731 if (value[i] && value[i] !== '')
1732 outArray[outArray.length] = value[i];
1741 getLang : function(name, default_value, parse_entities, va) {
1742 var v = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name], n;
1745 v = tinyMCE.entityDecode(v);
1749 v = this.replaceVar(v, n, va[n]);
1755 entityDecode : function(s) {
1756 var e = document.createElement("div");
1760 return !e.firstChild ? s : e.firstChild.nodeValue;
1763 addToLang : function(prefix, ar) {
1767 if (typeof(ar[k]) == 'function')
1770 tinyMCELang[(k.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix !== '' ? (prefix + "_") : '') + k] = ar[k];
1773 this.loadNextScript();
1776 triggerNodeChange : function(focus, setup_content) {
1777 var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection, st;
1779 if (tinyMCE.selectedInstance) {
1780 inst = tinyMCE.selectedInstance;
1781 elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
1783 /* if (elm == inst.lastTriggerEl)
1786 inst.lastTriggerEl = elm;*/
1788 editorId = inst.editorId;
1789 st = inst.selection.getSelectedText();
1791 if (tinyMCE.settings.auto_resize)
1792 inst.resizeToContent();
1794 if (setup_content && tinyMCE.isGecko && inst.isHidden())
1795 elm = inst.getBody();
1797 inst.switchSettings();
1798 anySelection = !inst.selection.isCollapsed();
1800 if (tinyMCE.settings.custom_undo_redo) {
1801 undoIndex = inst.undoRedo.undoIndex;
1802 undoLevels = inst.undoRedo.undoLevels.length;
1805 tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
1808 if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
1809 this.selectedInstance.contentWindow.focus();
1812 _customCleanup : function(inst, type, content) {
1813 var pl, po, i, customCleanup;
1815 // Call custom cleanup
1816 customCleanup = tinyMCE.settings.cleanup_callback;
1817 if (customCleanup != '')
1818 content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst);
1820 // Trigger theme cleanup
1821 po = tinyMCE.themes[tinyMCE.settings.theme];
1822 if (po && po.cleanup)
1823 content = po.cleanup(type, content, inst);
1825 // Trigger plugin cleanups
1827 for (i=0; i<pl.length; i++) {
1828 po = tinyMCE.plugins[pl[i]];
1830 if (po && po.cleanup)
1831 content = po.cleanup(type, content, inst);
1837 setContent : function(h) {
1838 if (tinyMCE.selectedInstance) {
1839 tinyMCE.selectedInstance.execCommand('mceSetContent', false, h);
1840 tinyMCE.selectedInstance.repaint();
1844 importThemeLanguagePack : function(name) {
1845 if (typeof(name) == "undefined")
1846 name = tinyMCE.settings.theme;
1848 tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings.language + '.js');
1851 importPluginLanguagePack : function(name) {
1852 var b = tinyMCE.baseURL + '/plugins/' + name;
1854 if (this.plugins[name])
1855 b = this.plugins[name].baseURL;
1857 tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings.language + '.js');
1860 applyTemplate : function(h, ag) {
1861 return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) {
1862 if (s.indexOf('lang_') == 0 && tinyMCELang[s])
1863 return tinyMCELang[s];
1868 if (tinyMCE.settings[s])
1869 return tinyMCE.settings[s];
1871 if (m == 'themeurl')
1872 return tinyMCE.themeURL;
1878 replaceVar : function(h, r, v) {
1879 return h.replace(new RegExp('{\\\$' + r + '}', 'g'), v);
1882 openWindow : function(template, args) {
1883 var html, width, height, x, y, resizable, scrollbars, url, name, win, modal, features;
1885 args = !args ? {} : args;
1887 args.mce_template_file = template.file;
1888 args.mce_width = template.width;
1889 args.mce_height = template.height;
1890 tinyMCE.windowArgs = args;
1892 html = template.html;
1893 if (!(width = parseInt(template.width)))
1896 if (!(height = parseInt(template.height)))
1899 // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
1905 x = parseInt(screen.width / 2.0) - (width / 2.0);
1906 y = parseInt(screen.height / 2.0) - (height / 2.0);
1908 resizable = (args && args.resizable) ? args.resizable : "no";
1909 scrollbars = (args && args.scrollbars) ? args.scrollbars : "no";
1911 if (template.file.charAt(0) != '/' && template.file.indexOf('://') == -1)
1912 url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template.file;
1914 url = template.file;
1916 // Replace all args as variables in URL
1917 for (name in args) {
1918 if (typeof(args[name]) == 'function')
1921 url = tinyMCE.replaceVar(url, name, escape(args[name]));
1925 html = tinyMCE.replaceVar(html, "css", this.settings.popups_css);
1926 html = tinyMCE.applyTemplate(html, args);
1928 win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable);
1930 alert(tinyMCELang.lang_popup_blocked);
1934 win.document.write(html);
1935 win.document.close();
1936 win.resizeTo(width, height);
1939 if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings.dialog_type == "modal") {
1942 features = "resizable:" + resizable + ";scroll:" + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;";
1944 window.showModalDialog(url, window, features);
1946 modal = (resizable == "yes") ? "no" : "yes";
1948 if (tinyMCE.isGecko && tinyMCE.isMac)
1951 if (template.close_previous != "no")
1952 try {tinyMCE.lastWindow.close();} catch (ex) {}
1954 win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable);
1956 alert(tinyMCELang.lang_popup_blocked);
1960 if (template.close_previous != "no")
1961 tinyMCE.lastWindow = win;
1964 win.resizeTo(width, height);
1969 // Make it bigger if statusbar is forced
1970 if (tinyMCE.isGecko && win.document) {
1971 if (win.document.defaultView.statusbar.visible)
1972 win.resizeBy(0, tinyMCE.isMac ? 10 : 24);
1980 closeWindow : function(win) {
1984 getVisualAidClass : function(class_name, state) {
1985 var i, classNames, ar, className, aidClass = tinyMCE.settings.visual_table_class;
1987 if (typeof(state) == "undefined")
1988 state = tinyMCE.settings.visual;
1992 ar = class_name.split(' ');
1993 for (i=0; i<ar.length; i++) {
1994 if (ar[i] == aidClass)
1998 classNames[classNames.length] = ar[i];
2002 classNames[classNames.length] = aidClass;
2006 for (i=0; i<classNames.length; i++) {
2010 className += classNames[i];
2016 handleVisualAid : function(el, deep, state, inst, skip_dispatch) {
2017 var i, x, y, tableElement, anchorName, oldW, oldH, bo, cn;
2023 tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst);
2025 tableElement = null;
2027 switch (el.nodeName) {
2029 oldW = el.style.width;
2030 oldH = el.style.height;
2031 bo = tinyMCE.getAttrib(el, "border");
2033 bo = bo == '' || bo == "0" ? true : false;
2035 tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
2037 el.style.width = oldW;
2038 el.style.height = oldH;
2040 for (y=0; y<el.rows.length; y++) {
2041 for (x=0; x<el.rows[y].cells.length; x++) {
2042 cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);
2043 tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn);
2050 anchorName = tinyMCE.getAttrib(el, "name");
2052 if (anchorName !== '' && state) {
2053 el.title = anchorName;
2054 tinyMCE.addCSSClass(el, 'mceItemAnchor');
2055 } else if (anchorName !== '' && !state)
2061 if (deep && el.hasChildNodes()) {
2062 for (i=0; i<el.childNodes.length; i++)
2063 tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true);
2067 fixGeckoBaseHREFBug : function(m, e, h) {
2070 if (tinyMCE.isGecko) {
2072 h = h.replace(/\ssrc=/gi, " mce_tsrc=");
2073 h = h.replace(/\shref=/gi, " mce_thref=");
2077 // Why bother if there is no src or href broken
2078 if (!new RegExp('(src|href)=', 'g').test(h))
2081 // Restore src and href that gets messed up by Gecko
2082 tinyMCE.selectElements(e, 'A,IMG,SELECT,AREA,IFRAME,BASE,INPUT,SCRIPT,EMBED,OBJECT,LINK', function (n) {
2083 xsrc = tinyMCE.getAttrib(n, "mce_tsrc");
2084 xhref = tinyMCE.getAttrib(n, "mce_thref");
2088 n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, xsrc);
2090 // Ignore, Firefox cast exception if local file wasn't found
2093 n.removeAttribute("mce_tsrc");
2098 n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, xhref);
2100 // Ignore, Firefox cast exception if local file wasn't found
2103 n.removeAttribute("mce_thref");
2109 // Restore text/comment nodes
2110 tinyMCE.selectNodes(e, function(n) {
2111 if (n.nodeType == 3 || n.nodeType == 8) {
2112 n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src=");
2113 n.nodeValue = n.nodeValue.replace(/\smce_thref=/gi, " href=");
2124 _setHTML : function(doc, html_content) {
2125 var i, html, paras, node;
2127 // Force closed anchors open
2128 //html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
2130 html_content = tinyMCE.cleanupHTMLCode(html_content);
2132 // Try innerHTML if it fails use pasteHTML in MSIE
2134 tinyMCE.setInnerHTML(doc.body, html_content);
2137 doc.body.createTextRange().pasteHTML(html_content);
2140 // Content duplication bug fix
2141 if (tinyMCE.isIE && tinyMCE.settings.fix_content_duplication) {
2142 // Remove P elements in P elements
2143 paras = doc.getElementsByTagName("P");
2144 for (i=0; i<paras.length; i++) {
2147 while ((node = node.parentNode) != null) {
2148 if (node.nodeName == "P")
2149 node.outerHTML = node.innerHTML;
2153 // Content duplication bug fix (Seems to be word crap)
2154 html = doc.body.innerHTML;
2156 // Always set the htmlText output
2157 tinyMCE.setInnerHTML(doc.body, html);
2160 tinyMCE.cleanupAnchors(doc);
2162 if (tinyMCE.getParam("convert_fonts_to_spans"))
2163 tinyMCE.convertSpansToFonts(doc);
2166 getEditorId : function(form_element) {
2167 var inst = this.getInstanceById(form_element);
2172 return inst.editorId;
2175 getInstanceById : function(editor_id) {
2176 var inst = this.instances[editor_id], n;
2179 for (n in tinyMCE.instances) {
2180 inst = tinyMCE.instances[n];
2182 if (!tinyMCE.isInstance(inst))
2185 if (inst.formTargetElementId == editor_id)
2194 queryInstanceCommandValue : function(editor_id, command) {
2195 var inst = tinyMCE.getInstanceById(editor_id);
2198 return inst.queryCommandValue(command);
2203 queryInstanceCommandState : function(editor_id, command) {
2204 var inst = tinyMCE.getInstanceById(editor_id);
2207 return inst.queryCommandState(command);
2212 setWindowArg : function(n, v) {
2213 this.windowArgs[n] = v;
2216 getWindowArg : function(n, d) {
2217 return (typeof(this.windowArgs[n]) == "undefined") ? d : this.windowArgs[n];
2220 getCSSClasses : function(editor_id, doc) {
2221 var i, c, x, rule, styles, rules, csses, selectorText, inst = tinyMCE.getInstanceById(editor_id);
2222 var cssClass, addClass, p;
2225 inst = tinyMCE.selectedInstance;
2231 doc = inst.getDoc();
2233 // Is cached, use that
2234 if (inst && inst.cssClasses.length > 0)
2235 return inst.cssClasses;
2240 styles = doc.styleSheets;
2242 if (styles && styles.length > 0) {
2243 for (x=0; x<styles.length; x++) {
2247 csses = tinyMCE.isIE ? doc.styleSheets(x).rules : styles[x].cssRules;
2249 // Just ignore any errors I know this is ugly!!
2255 for (i=0; i<csses.length; i++) {
2256 selectorText = csses[i].selectorText;
2258 // Can be multiple rules per selector
2260 rules = selectorText.split(',');
2261 for (c=0; c<rules.length; c++) {
2264 // Strip spaces between selectors
2265 while (rule.indexOf(' ') == 0)
2266 rule = rule.substring(1);
2269 if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1)
2272 if (rule.indexOf(tinyMCE.settings.visual_table_class) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1)
2276 if (rule.indexOf('.') != -1) {
2277 cssClass = rule.substring(rule.indexOf('.') + 1);
2280 for (p=0; p<inst.cssClasses.length && addClass; p++) {
2281 if (inst.cssClasses[p] == cssClass)
2286 inst.cssClasses[inst.cssClasses.length] = cssClass;
2294 return inst.cssClasses;
2297 regexpReplace : function(in_str, reg_exp, replace_str, opts) {
2303 if (typeof(opts) == "undefined")
2306 re = new RegExp(reg_exp, opts);
2308 return in_str.replace(re, replace_str);
2311 trim : function(s) {
2312 return s.replace(/^\s*|\s*$/g, "");
2315 cleanupEventStr : function(s) {
2317 s = s.replace('function anonymous()\n{\n', '');
2318 s = s.replace('\n}', '');
2319 s = s.replace(/^return true;/gi, ''); // Remove event blocker
2324 getControlHTML : function(c) {
2325 var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl';
2327 l = tinyMCE.plugins;
2331 if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') {
2333 return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>';
2335 return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
2339 o = tinyMCE.themes[tinyMCE.settings.theme];
2340 if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') {
2342 return '<span dir="rtl">' + v + '</span>';
2350 evalFunc : function(f, idx, a, o) {
2351 o = !o ? window : o;
2352 f = typeof(f) == 'function' ? f : o[f];
2354 return f.apply(o, Array.prototype.slice.call(a, idx));
2357 dispatchCallback : function(i, p, n) {
2358 return this.callFunc(i, p, n, 0, this.dispatchCallback.arguments);
2361 executeCallback : function(i, p, n) {
2362 return this.callFunc(i, p, n, 1, this.executeCallback.arguments);
2365 execCommandCallback : function(i, p, n) {
2366 return this.callFunc(i, p, n, 2, this.execCommandCallback.arguments);
2369 callFunc : function(ins, p, n, m, a) {
2370 var l, i, on, o, s, v;
2374 l = tinyMCE.getParam(p, '');
2376 if (l !== '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0)
2380 for (i=0, l = ins.plugins; i<l.length; i++) {
2381 o = tinyMCE.plugins[l[i]];
2383 if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
2392 if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
2399 resolveDots : function(s, o) {
2402 if (typeof(s) == 'string') {
2403 for (i=0, s=s.split('.'); i<s.length; i++)
2411 xmlEncode : function(s) {
2412 return s ? ('' + s).replace(this.xmlEncodeRe, function (c, b) {
2431 add : function(c, m) {
2435 if (m.hasOwnProperty(n))
2436 c.prototype[n] = m[n];
2440 extend : function(p, np) {
2446 if (p.hasOwnProperty(n))
2451 if (np.hasOwnProperty(n))
2458 hideMenus : function() {
2459 var e = tinyMCE.lastSelectedMenuBtn;
2461 if (tinyMCE.lastMenu) {
2462 tinyMCE.lastMenu.hide();
2463 tinyMCE.lastMenu = null;
2467 tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass);
2468 tinyMCE.lastSelectedMenuBtn = null;
2475 var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors
2476 var tinyMCE = new TinyMCE_Engine();
2477 var tinyMCELang = {};
2479 /* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */
2481 function TinyMCE_Control(settings) {
2482 var t, i, tos, fu, p, x, fn, fu, pn, s = settings;
2484 this.undoRedoLevel = true;
2485 this.isTinyMCE_Control = true;
2488 this.enabled = true;
2490 this.settings.theme = tinyMCE.getParam("theme", "default");
2491 this.settings.width = tinyMCE.getParam("width", -1);
2492 this.settings.height = tinyMCE.getParam("height", -1);
2493 this.selection = new TinyMCE_Selection(this);
2494 this.undoRedo = new TinyMCE_UndoRedo(this);
2495 this.cleanup = new TinyMCE_Cleanup();
2496 this.shortcuts = [];
2497 this.hasMouseMoved = false;
2498 this.foreColor = this.backColor = "#999999";
2500 this.cssClasses = [];
2503 valid_elements : s.valid_elements,
2504 extended_valid_elements : s.extended_valid_elements,
2505 valid_child_elements : s.valid_child_elements,
2506 entities : s.entities,
2507 entity_encoding : s.entity_encoding,
2508 debug : s.cleanup_debug,
2509 indent : s.apply_source_formatting,
2510 invalid_elements : s.invalid_elements,
2511 verify_html : s.verify_html,
2512 fix_content_duplication : s.fix_content_duplication,
2513 convert_fonts_to_spans : s.convert_fonts_to_spans
2517 t = this.settings.theme;
2518 if (!tinyMCE.hasTheme(t)) {
2519 fn = tinyMCE.callbacks;
2522 for (i=0; i<fn.length; i++) {
2523 if ((fu = window['TinyMCE_' + t + "_" + fn[i]]))
2527 tinyMCE.addTheme(t, tos);
2532 p = tinyMCE.getParam('plugins', '', true, ',');
2534 for (i=0; i<p.length; i++) {
2537 if (pn.charAt(0) == '-')
2538 pn = pn.substring(1);
2540 if (!tinyMCE.hasPlugin(pn)) {
2541 fn = tinyMCE.callbacks;
2544 for (x=0; x<fn.length; x++) {
2545 if ((fu = window['TinyMCE_' + pn + "_" + fn[x]]))
2549 tinyMCE.addPlugin(pn, tos);
2552 this.plugins[this.plugins.length] = pn;
2557 TinyMCE_Control.prototype = {
2564 getData : function(na) {
2565 var o = this.data[na];
2568 o = this.data[na] = {};
2573 hasPlugin : function(n) {
2576 for (i=0; i<this.plugins.length; i++) {
2577 if (this.plugins[i] == n)
2584 addPlugin : function(n, p) {
2585 if (!this.hasPlugin(n)) {
2586 tinyMCE.addPlugin(n, p);
2587 this.plugins[this.plugins.length] = n;
2591 repaint : function() {
2594 if (tinyMCE.isRealIE)
2599 b = s.getBookmark(true);
2600 this.getBody().style.display = 'none';
2601 this.getDoc().execCommand('selectall', false, null);
2602 this.getSel().collapseToStart();
2603 this.getBody().style.display = 'block';
2604 s.moveToBookmark(b);
2610 switchSettings : function() {
2611 if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings.index) {
2612 tinyMCE.settings = this.settings;
2613 tinyMCE.currentConfig = this.settings.index;
2617 select : function() {
2618 var oldInst = tinyMCE.selectedInstance;
2620 if (oldInst != this) {
2622 oldInst.execCommand('mceEndTyping');
2624 tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst);
2625 tinyMCE.selectedInstance = this;
2629 getBody : function() {
2630 return this.contentBody ? this.contentBody : this.getDoc().body;
2633 getDoc : function() {
2634 // return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ?
2635 return this.contentWindow.document;
2638 getWin : function() {
2639 return this.contentWindow;
2642 getContainerWin : function() {
2643 return this.containerWindow ? this.containerWindow : window;
2646 getViewPort : function() {
2647 return tinyMCE.getViewPort(this.getWin());
2650 getParentNode : function(n, f) {
2651 return tinyMCE.getParentNode(n, f, this.getBody());
2654 getParentElement : function(n, na, f) {
2655 return tinyMCE.getParentElement(n, na, f, this.getBody());
2658 getParentBlockElement : function(n) {
2659 return tinyMCE.getParentBlockElement(n, this.getBody());
2662 resizeToContent : function() {
2663 var d = this.getDoc(), b = d.body, de = d.documentElement;
2665 this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px';
2668 addShortcut : function(m, k, d, cmd, ui, va) {
2669 var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts;
2671 if (!tinyMCE.getParam('custom_shortcuts'))
2674 m = m.toLowerCase();
2675 k = ie && !n ? k.toUpperCase() : k;
2676 c = n ? null : k.charCodeAt(0);
2677 d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d;
2680 alt : m.indexOf('alt') != -1,
2681 ctrl : m.indexOf('ctrl') != -1,
2682 shift : m.indexOf('shift') != -1,
2684 keyCode : n ? k : (ie ? c : null),
2691 for (i=0; i<scl.length; i++) {
2692 if (sc.alt == scl[i].alt && sc.ctrl == scl[i].ctrl && sc.shift == scl[i].shift
2693 && sc.charCode == scl[i].charCode && sc.keyCode == scl[i].keyCode) {
2698 scl[scl.length] = sc;
2703 handleShortcut : function(e) {
2706 // Normal key press, then ignore it
2707 if (!e.altKey && !e.ctrlKey)
2712 for (i=0; i<s.length; i++) {
2715 if (o.alt == e.altKey && o.ctrl == e.ctrlKey && (o.keyCode == e.keyCode || o.charCode == e.charCode)) {
2716 if (o.cmd && (e.type == "keydown" || (e.type == "keypress" && !tinyMCE.isOpera)))
2717 tinyMCE.execCommand(o.cmd, o.ui, o.val);
2719 tinyMCE.cancelEvent(e);
2727 autoResetDesignMode : function() {
2728 // Add fix for tab/style.display none/block problems in Gecko
2729 if (!tinyMCE.isIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
2730 eval('try { this.getDoc().designMode = "On"; this.useCSS = false; } catch(e) {}');
2733 isHidden : function() {
2741 // Weird, wheres that cursor selection?
2742 return (!s || !s.rangeCount || s.rangeCount == 0);
2745 isDirty : function() {
2746 // Is content modified and not in a submit procedure
2747 return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !this.isNotDirty;
2750 _mergeElements : function(scmd, pa, ch, override) {
2751 var st, stc, className, n;
2753 if (scmd == "removeformat") {
2755 pa.style.cssText = "";
2757 ch.style.cssText = "";
2761 st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style"));
2762 stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));
2763 className = tinyMCE.getAttrib(pa, "class");
2765 // Removed class adding due to bug #1478272
2766 className = tinyMCE.getAttrib(ch, "class");
2770 if (typeof(st[n]) == 'function')
2777 if (typeof(stc[n]) == 'function')
2784 tinyMCE.setAttrib(pa, "style", tinyMCE.serializeStyle(st));
2785 tinyMCE.setAttrib(pa, "class", tinyMCE.trim(className));
2787 ch.style.cssText = "";
2788 ch.removeAttribute("class");
2789 ch.removeAttribute("style");
2792 _fixRootBlocks : function() {
2793 var rb, b, ne, be, nx, bm;
2795 rb = tinyMCE.getParam('forced_root_block');
2803 nx = ne.nextSibling;
2805 // If text node or inline element wrap it in a block element
2806 if ((ne.nodeType == 3 && ne.nodeValue.replace(/\s+/g, '') != '') || (ne.nodeType == 1 && !tinyMCE.blockRegExp.test(ne.nodeName))) {
2808 bm = this.selection.getBookmark();
2811 be = this.getDoc().createElement(rb);
2812 be.appendChild(ne.cloneNode(true));
2813 b.replaceChild(be, ne);
2815 be.appendChild(ne.cloneNode(true));
2825 this.selection.moveToBookmark(bm);
2828 _fixTrailingNbsp : function() {
2829 var s = this.selection, e = s.getFocusElement(), bm, v;
2831 if (e && tinyMCE.blockRegExp.test(e.nodeName) && e.firstChild) {
2832 v = e.firstChild.nodeValue;
2834 if (v && v.length > 1 && /(^\u00a0|\u00a0$)/.test(v)) {
2835 e.firstChild.nodeValue = v.replace(/(^\u00a0|\u00a0$)/, '');
2836 s.selectNode(e.firstChild, true, false, false); // Select and collapse
2841 _setUseCSS : function(b) {
2842 var d = this.getDoc();
2844 try {d.execCommand("useCSS", false, !b);} catch (ex) {}
2845 try {d.execCommand("styleWithCSS", false, b);} catch (ex) {}
2847 if (!tinyMCE.getParam("table_inline_editing"))
2848 try {d.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {}
2850 if (!tinyMCE.getParam("object_resizing"))
2851 try {d.execCommand('enableObjectResizing', false, "false");} catch (ex) {}
2854 execCommand : function(command, user_interface, value) {
2855 var i, x, z, align, img, div, doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement();
2857 // Is not a undo specific command
2858 if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command))
2859 this.undoBookmark = null;
2862 if (!tinyMCE.isIE && !this.useCSS) {
2863 this._setUseCSS(false);
2867 //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value);
2868 this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks
2870 // Don't dispatch key commands
2871 if (!/mceStartTyping|mceEndTyping/.test(command)) {
2872 if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value))
2876 // Fix align on images
2877 if (focusElm && focusElm.nodeName == "IMG") {
2878 align = focusElm.getAttribute('align');
2879 img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm;
2883 if (align == 'left') {
2884 img.setAttribute('align', ''); // Needed for IE
2885 img.removeAttribute('align');
2887 img.setAttribute('align', 'left');
2890 div = focusElm.parentNode;
2891 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
2892 div.parentNode.replaceChild(img, div);
2894 this.selection.selectNode(img);
2896 tinyMCE.triggerNodeChange();
2899 case "JustifyCenter":
2900 img.setAttribute('align', ''); // Needed for IE
2901 img.removeAttribute('align');
2904 div = tinyMCE.getParentElement(focusElm, "div");
2905 if (div && div.style.textAlign == "center") {
2907 if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
2908 div.parentNode.replaceChild(img, div);
2911 div = this.getDoc().createElement("div");
2912 div.style.textAlign = 'center';
2913 div.appendChild(img);
2914 focusElm.parentNode.replaceChild(div, focusElm);
2917 this.selection.selectNode(img);
2919 tinyMCE.triggerNodeChange();
2922 case "JustifyRight":
2923 if (align == 'right') {
2924 img.setAttribute('align', ''); // Needed for IE
2925 img.removeAttribute('align');
2927 img.setAttribute('align', 'right');
2930 div = focusElm.parentNode;
2931 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
2932 div.parentNode.replaceChild(img, div);
2934 this.selection.selectNode(img);
2936 tinyMCE.triggerNodeChange();
2941 if (tinyMCE.settings.force_br_newlines) {
2942 var alignValue = "";
2944 if (doc.selection.type != "Control") {
2947 alignValue = "left";
2950 case "JustifyCenter":
2951 alignValue = "center";
2955 alignValue = "justify";
2958 case "JustifyRight":
2959 alignValue = "right";
2963 if (alignValue !== '') {
2964 var rng = doc.selection.createRange();
2966 if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null)
2967 divElm.setAttribute("align", alignValue);
2968 else if (rng.pasteHTML && rng.htmlText.length > 0)
2969 rng.pasteHTML('<div align="' + alignValue + '">' + rng.htmlText + "</div>");
2971 tinyMCE.triggerNodeChange();
2983 case "JustifyCenter":
2985 case "JustifyRight":
2986 var el = tinyMCE.getParentNode(focusElm, function(n) {return tinyMCE.getAttrib(n, 'align');});
2989 el.setAttribute('align', ''); // Needed for IE
2990 el.removeAttribute('align');
2992 this.getDoc().execCommand(command, user_interface, value);
2994 tinyMCE.triggerNodeChange();
2999 // Unlink if caret is inside link
3000 if (tinyMCE.isGecko && this.getSel().isCollapsed) {
3001 focusElm = tinyMCE.getParentElement(focusElm, 'A');
3004 this.selection.selectNode(focusElm, false);
3007 this.getDoc().execCommand(command, user_interface, value);
3009 tinyMCE.isGecko && this.getSel().collapseToEnd();
3011 tinyMCE.triggerNodeChange();
3015 case "InsertUnorderedList":
3016 case "InsertOrderedList":
3017 this.getDoc().execCommand(command, user_interface, value);
3018 tinyMCE.triggerNodeChange();
3021 case "Strikethrough":
3022 this.getDoc().execCommand(command, user_interface, value);
3023 tinyMCE.triggerNodeChange();
3026 case "mceSelectNode":
3027 this.selection.selectNode(value);
3028 tinyMCE.triggerNodeChange();
3029 tinyMCE.selectedNode = value;
3033 if (value == null || value == '') {
3034 var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp");
3037 this.execCommand("mceRemoveNode", false, elm);
3039 if (!this.cleanup.isValid(value))
3042 if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value))
3043 value = value.replace(/[^a-z]/gi, '');
3045 if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
3046 var b = this.selection.getBookmark();
3047 this.getDoc().execCommand("FormatBlock", false, '<p>');
3048 tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value);
3049 this.selection.moveToBookmark(b);
3051 this.getDoc().execCommand("FormatBlock", false, value);
3054 tinyMCE.triggerNodeChange();
3058 case "mceRemoveNode":
3060 value = tinyMCE.getParentElement(this.getFocusElement());
3063 value.outerHTML = value.innerHTML;
3065 var rng = value.ownerDocument.createRange();
3066 rng.setStartBefore(value);
3067 rng.setEndAfter(value);
3068 rng.deleteContents();
3069 rng.insertNode(rng.createContextualFragment(value.innerHTML));
3072 tinyMCE.triggerNodeChange();
3076 case "mceSelectNodeDepth":
3077 var parentNode = this.getFocusElement();
3078 for (i=0; parentNode; i++) {
3079 if (parentNode.nodeName.toLowerCase() == "body")
3082 if (parentNode.nodeName.toLowerCase() == "#text") {
3084 parentNode = parentNode.parentNode;
3089 this.selection.selectNode(parentNode, false);
3090 tinyMCE.triggerNodeChange();
3091 tinyMCE.selectedNode = parentNode;
3095 parentNode = parentNode.parentNode;
3100 case "mceSetStyleInfo":
3101 case "SetStyleInfo":
3102 var rng = this.getRng();
3103 var sel = this.getSel();
3104 var scmd = value.command;
3105 var sname = value.name;
3106 var svalue = value.value == null ? '' : value.value;
3107 //var svalue = value['value'] == null ? '' : value['value'];
3108 var wrapper = value.wrapper ? value.wrapper : "span";
3109 var parentElm = null;
3110 var invalidRe = new RegExp("^BODY|HTML$", "g");
3111 var invalidParentsRe = tinyMCE.settings.merge_styles_invalid_parents !== '' ? new RegExp(tinyMCE.settings.merge_styles_invalid_parents, "gi") : null;
3113 // Whole element selected check
3117 parentElm = rng.item(0);
3119 var pelm = rng.parentElement();
3120 var prng = doc.selection.createRange();
3121 prng.moveToElementText(pelm);
3123 if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
3124 if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
3129 var felm = this.getFocusElement();
3130 if (sel.isCollapsed || (new RegExp('td|tr|tbody|table|img', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode))
3134 // Whole element selected
3135 if (parentElm && !invalidRe.test(parentElm.nodeName)) {
3136 if (scmd == "setstyle")
3137 tinyMCE.setStyleAttrib(parentElm, sname, svalue);
3139 if (scmd == "setattrib")
3140 tinyMCE.setAttrib(parentElm, sname, svalue);
3142 if (scmd == "removeformat") {
3143 parentElm.style.cssText = '';
3144 tinyMCE.setAttrib(parentElm, 'class', '');
3147 // Remove style/attribs from all children
3148 var ch = tinyMCE.getNodeTree(parentElm, [], 1);
3149 for (z=0; z<ch.length; z++) {
3150 if (ch[z] == parentElm)
3153 if (scmd == "setstyle")
3154 tinyMCE.setStyleAttrib(ch[z], sname, '');
3156 if (scmd == "setattrib")
3157 tinyMCE.setAttrib(ch[z], sname, '');
3159 if (scmd == "removeformat") {
3160 ch[z].style.cssText = '';
3161 tinyMCE.setAttrib(ch[z], 'class', '');
3165 this._setUseCSS(false); // Bug in FF when running in fullscreen
3166 doc.execCommand("FontName", false, "#mce_temp_font#");
3167 var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#");
3170 for (x=0; x<elementArray.length; x++) {
3171 elm = elementArray[x];
3173 var spanElm = doc.createElement(wrapper);
3175 if (scmd == "setstyle")
3176 tinyMCE.setStyleAttrib(spanElm, sname, svalue);
3178 if (scmd == "setattrib")
3179 tinyMCE.setAttrib(spanElm, sname, svalue);
3181 if (scmd == "removeformat") {
3182 spanElm.style.cssText = '';
3183 tinyMCE.setAttrib(spanElm, 'class', '');
3186 if (elm.hasChildNodes()) {
3187 for (i=0; i<elm.childNodes.length; i++)
3188 spanElm.appendChild(elm.childNodes[i].cloneNode(true));
3191 spanElm.setAttribute("mce_new", "true");
3192 elm.parentNode.replaceChild(spanElm, elm);
3194 // Remove style/attribs from all children
3195 var ch = tinyMCE.getNodeTree(spanElm, [], 1);
3196 for (z=0; z<ch.length; z++) {
3197 if (ch[z] == spanElm)
3200 if (scmd == "setstyle")
3201 tinyMCE.setStyleAttrib(ch[z], sname, '');
3203 if (scmd == "setattrib")
3204 tinyMCE.setAttrib(ch[z], sname, '');
3206 if (scmd == "removeformat") {
3207 ch[z].style.cssText = '';
3208 tinyMCE.setAttrib(ch[z], 'class', '');
3216 var nodes = doc.getElementsByTagName(wrapper);
3217 for (i=nodes.length-1; i>=0; i--) {
3219 var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
3221 elm.removeAttribute("mce_new");
3223 // Is only child a element
3224 if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
3225 //tinyMCE.debug("merge1" + isNew);
3226 this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
3230 // Is I the only child
3231 if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
3232 //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
3233 if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
3234 this._mergeElements(scmd, elm.parentNode, elm, false);
3238 // Remove empty wrappers
3239 var nodes = doc.getElementsByTagName(wrapper);
3240 for (i=nodes.length-1; i>=0; i--) {
3241 var elm = nodes[i], isEmpty = true;
3243 // Check if it has any attribs
3244 var tmp = doc.createElement("body");
3245 tmp.appendChild(elm.cloneNode(false));
3247 // Is empty span, remove it
3248 tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
3249 //tinyMCE.debug(tmp.innerHTML);
3250 if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) {
3251 for (x=0; x<elm.childNodes.length; x++) {
3252 if (elm.parentNode != null)
3253 elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm);
3256 elm.parentNode.removeChild(elm);
3260 // Re add the visual aids
3261 if (scmd == "removeformat")
3262 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
3264 tinyMCE.triggerNodeChange();
3269 if (value == null) {
3270 var s = this.getSel();
3272 // Find font and select it
3273 if (tinyMCE.isGecko && s.isCollapsed) {
3274 var f = tinyMCE.getParentElement(this.getFocusElement(), "font");
3277 this.selection.selectNode(f, false);
3281 this.getDoc().execCommand("RemoveFormat", false, null);
3283 // Collapse range if font was found
3284 if (f != null && tinyMCE.isGecko) {
3285 var r = this.getRng().cloneRange();
3287 s.removeAllRanges();
3291 this.getDoc().execCommand('FontName', false, value);
3293 if (tinyMCE.isGecko)
3294 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
3299 this.getDoc().execCommand('FontSize', false, value);
3301 if (tinyMCE.isGecko)
3302 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
3307 value = value == null ? this.foreColor : value;
3308 value = tinyMCE.trim(value);
3309 value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
3311 this.foreColor = value;
3312 this.getDoc().execCommand('forecolor', false, value);
3316 value = value == null ? this.backColor : value;
3317 value = tinyMCE.trim(value);
3318 value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
3319 this.backColor = value;
3321 if (tinyMCE.isGecko || tinyMCE.isOpera) {
3322 this._setUseCSS(true);
3323 this.getDoc().execCommand('hilitecolor', false, value);
3324 this._setUseCSS(false);
3326 this.getDoc().execCommand('BackColor', false, value);
3332 var cmdFailed = false;
3334 // Try executing command
3335 eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');
3337 if (tinyMCE.isOpera && cmdFailed)
3338 alert('Currently not supported by your browser, use keyboard shortcuts instead.');
3340 // Alert error in gecko if command failed
3341 if (tinyMCE.isGecko && cmdFailed) {
3342 // Confirm more info
3343 if (confirm(tinyMCE.entityDecode(tinyMCE.getLang('lang_clipboard_msg'))))
3344 window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
3348 tinyMCE.triggerNodeChange();
3351 case "mceSetContent":
3355 // Call custom cleanup code
3356 value = tinyMCE.storeAwayURLs(value);
3357 value = tinyMCE._customCleanup(this, "insert_to_editor", value);
3359 if (this.getBody().nodeName == 'BODY')
3360 tinyMCE._setHTML(doc, value);
3362 this.getBody().innerHTML = value;
3364 tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, doc, this.settings, this.getBody(), false, false, false, true));
3365 tinyMCE.convertAllRelativeURLs(this.getBody());
3367 // Cleanup any mess left from storyAwayURLs
3368 tinyMCE._removeInternal(this.getBody());
3370 // When editing always use fonts internaly
3371 if (tinyMCE.getParam("convert_fonts_to_spans"))
3372 tinyMCE.convertSpansToFonts(doc);
3374 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
3375 tinyMCE._setEventsEnabled(this.getBody(), false);
3381 var b = this.selection.getBookmark();
3382 tinyMCE._setHTML(this.contentDocument, this.getBody().innerHTML);
3383 tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, this.getBody(), this.visualAid));
3384 tinyMCE.convertAllRelativeURLs(doc.body);
3386 // When editing always use fonts internaly
3387 if (tinyMCE.getParam("convert_fonts_to_spans"))
3388 tinyMCE.convertSpansToFonts(doc);
3390 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
3391 tinyMCE._setEventsEnabled(this.getBody(), false);
3394 this.selection.moveToBookmark(b);
3395 tinyMCE.triggerNodeChange();
3398 case "mceReplaceContent":
3399 // Force empty string
3403 this.getWin().focus();
3405 var selectedText = "";
3408 var rng = doc.selection.createRange();
3409 selectedText = rng.text;
3411 selectedText = this.getSel().toString();
3413 if (selectedText.length > 0) {
3414 value = tinyMCE.replaceVar(value, "selection", selectedText);
3415 tinyMCE.execCommand('mceInsertContent', false, value);
3419 tinyMCE.triggerNodeChange();
3422 case "mceSetAttribute":
3423 if (typeof(value) == 'object') {
3424 var targetElms = (typeof(value.targets) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value.targets;
3425 var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
3428 targetNode.setAttribute(value.name, value.value);
3429 tinyMCE.triggerNodeChange();
3434 case "mceSetCSSClass":
3435 this.execCommand("mceSetStyleInfo", false, {command : "setattrib", name : "class", value : value});
3438 case "mceInsertRawHTML":
3439 var key = 'tiny_mce_marker';
3441 this.execCommand('mceBeginUndoLevel');
3443 // Insert marker key
3444 this.execCommand('mceInsertContent', false, key);
3446 // Store away scroll pos
3447 var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft;
3448 var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop;
3450 // Find marker and replace with RAW HTML
3451 var html = this.getBody().innerHTML;
3452 if ((pos = html.indexOf(key)) != -1)
3453 tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
3455 // Restore scoll pos
3456 this.contentWindow.scrollTo(scrollX, scrollY);
3458 this.execCommand('mceEndUndoLevel');
3462 case "mceInsertContent":
3463 // Force empty string
3467 var insertHTMLFailed = false;
3469 // Removed since it produced problems in IE
3470 // this.getWin().focus();
3472 if (tinyMCE.isGecko || tinyMCE.isOpera) {
3474 // Is plain text or HTML, &, etc will be encoded wrong in FF
3475 if (value.indexOf('<') == -1 && !value.match(/(&| |<|>)/g)) {
3476 var r = this.getRng();
3477 var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value));
3478 var s = this.getSel();
3479 var r2 = r.cloneRange();
3481 // Insert text at cursor position
3482 s.removeAllRanges();
3486 // Move the cursor to the end of text
3489 s.removeAllRanges();
3492 value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value);
3493 this.getDoc().execCommand('inserthtml', false, value);
3494 tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
3497 insertHTMLFailed = true;
3500 if (!insertHTMLFailed) {
3501 tinyMCE.triggerNodeChange();
3506 if (!tinyMCE.isIE) {
3507 var isHTML = value.indexOf('<') != -1;
3508 var sel = this.getSel();
3509 var rng = this.getRng();
3512 if (tinyMCE.isSafari) {
3513 var tmpRng = this.getDoc().createRange();
3515 tmpRng.setStart(this.getBody(), 0);
3516 tmpRng.setEnd(this.getBody(), 0);
3518 value = tmpRng.createContextualFragment(value);
3520 value = rng.createContextualFragment(value);
3523 value = doc.createTextNode(tinyMCE.entityDecode(value));
3526 // Insert plain text in Safari
3527 if (tinyMCE.isSafari && !isHTML) {
3528 this.execCommand('InsertText', false, value.nodeValue);
3529 tinyMCE.triggerNodeChange();
3531 } else if (tinyMCE.isSafari && isHTML) {
3532 rng.deleteContents();
3533 rng.insertNode(value);
3534 tinyMCE.triggerNodeChange();
3538 rng.deleteContents();
3540 // If target node is text do special treatment, (Mozilla 1.3 fix)
3541 if (rng.startContainer.nodeType == 3) {
3542 var node = rng.startContainer.splitText(rng.startOffset);
3543 node.parentNode.insertBefore(value, node);
3545 rng.insertNode(value);
3548 // Removes weird selection trails
3549 sel.selectAllChildren(doc.body);
3550 sel.removeAllRanges();
3552 // Move cursor to end of content
3553 var rng = doc.createRange();
3555 rng.selectNode(value);
3556 rng.collapse(false);
3560 rng.collapse(false);
3562 tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
3564 var rng = doc.selection.createRange(), tmpRng = null;
3565 var c = value.indexOf('<!--') != -1;
3567 // Fix comment bug, add tag before comments
3569 value = tinyMCE.uniqueTag + value;
3571 // tmpRng = rng.duplicate(); // Store away range (Fixes Undo bookmark bug in IE)
3574 rng.item(0).outerHTML = value;
3576 rng.pasteHTML(value);
3579 // tmpRng.select(); // Restore range (Fixes Undo bookmark bug in IE)
3581 // Remove unique tag
3583 var e = this.getDoc().getElementById('mceTMPElement');
3584 e.parentNode.removeChild(e);
3588 tinyMCE.execCommand("mceAddUndoLevel");
3589 tinyMCE.triggerNodeChange();
3592 case "mceStartTyping":
3593 if (tinyMCE.settings.custom_undo_redo && this.undoRedo.typingUndoIndex == -1) {
3594 this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex;
3595 tinyMCE.typingUndoIndex = tinyMCE.undoIndex;
3596 this.execCommand('mceAddUndoLevel');
3600 case "mceEndTyping":
3601 if (tinyMCE.settings.custom_undo_redo && this.undoRedo.typingUndoIndex != -1) {
3602 this.execCommand('mceAddUndoLevel');
3603 this.undoRedo.typingUndoIndex = -1;
3606 tinyMCE.typingUndoIndex = -1;
3609 case "mceBeginUndoLevel":
3610 this.undoRedoLevel = false;
3613 case "mceEndUndoLevel":
3614 this.undoRedoLevel = true;
3615 this.execCommand('mceAddUndoLevel');
3618 case "mceAddUndoLevel":
3619 if (tinyMCE.settings.custom_undo_redo && this.undoRedoLevel) {
3620 if (this.undoRedo.add())
3621 tinyMCE.triggerNodeChange(false);
3626 if (tinyMCE.settings.custom_undo_redo) {
3627 tinyMCE.execCommand("mceEndTyping");
3628 this.undoRedo.undo();
3629 tinyMCE.triggerNodeChange();
3631 this.getDoc().execCommand(command, user_interface, value);
3635 if (tinyMCE.settings.custom_undo_redo) {
3636 tinyMCE.execCommand("mceEndTyping");
3637 this.undoRedo.redo();
3638 tinyMCE.triggerNodeChange();
3640 this.getDoc().execCommand(command, user_interface, value);
3643 case "mceToggleVisualAid":
3644 this.visualAid = !this.visualAid;
3645 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
3646 tinyMCE.triggerNodeChange();
3650 this.getDoc().execCommand(command, user_interface, value);
3651 tinyMCE.triggerNodeChange();
3654 var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
3656 if (n && n.nodeName == "BLOCKQUOTE") {
3657 n.removeAttribute("dir");
3658 n.removeAttribute("style");
3660 } while (n != null && (n = n.parentNode) != null);
3664 case "RemoveFormat":
3665 case "removeformat":
3666 var text = this.selection.getSelectedText();
3668 if (tinyMCE.isOpera) {
3669 this.getDoc().execCommand("RemoveFormat", false, null);
3675 var rng = doc.selection.createRange();
3676 rng.execCommand("RemoveFormat", false, null);
3681 this.execCommand("mceSetStyleInfo", false, {command : "removeformat"});
3683 this.getDoc().execCommand(command, user_interface, value);
3685 this.execCommand("mceSetStyleInfo", false, {command : "removeformat"});
3689 if (text.length == 0)
3690 this.execCommand("mceSetCSSClass", false, "");
3692 tinyMCE.triggerNodeChange();
3696 this.getDoc().execCommand(command, user_interface, value);
3698 if (tinyMCE.isGecko)
3699 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
3701 tinyMCE.triggerNodeChange();
3704 // Add undo level after modification
3705 if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceStartTyping" && command != "mceEndTyping")
3706 tinyMCE.execCommand("mceAddUndoLevel");
3709 queryCommandValue : function(c) {
3711 return this.getDoc().queryCommandValue(c);
3717 queryCommandState : function(c) {
3718 return this.getDoc().queryCommandState(c);
3721 _addBogusBR : function() {
3722 var b = this.getBody();
3724 if (tinyMCE.isGecko && !b.hasChildNodes())
3725 b.innerHTML = '<br _moz_editor_bogus_node="TRUE" />';
3728 _onAdd : function(replace_element, form_element_name, target_document) {
3729 var hc, th, tos, editorTemplate, targetDoc, deltaWidth, deltaHeight, html, rng, fragment;
3730 var dynamicIFrame, tElm, doc, parentElm;
3732 th = this.settings.theme;
3733 tos = tinyMCE.themes[th];
3735 targetDoc = target_document ? target_document : document;
3737 this.targetDoc = targetDoc;
3739 tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings.theme;
3740 this.settings.themeurl = tinyMCE.themeURL;
3742 if (!replace_element) {
3743 alert("Error: Could not find the target element.");
3747 if (tos.getEditorTemplate)
3748 editorTemplate = tos.getEditorTemplate(this.settings, this.editorId);
3750 deltaWidth = editorTemplate.delta_width ? editorTemplate.delta_width : 0;
3751 deltaHeight = editorTemplate.delta_height ? editorTemplate.delta_height : 0;
3752 html = '<span id="' + this.editorId + '_parent" class="mceEditorContainer">' + editorTemplate.html;
3754 html = tinyMCE.replaceVar(html, "editor_id", this.editorId);
3756 if (!this.settings.default_document)
3757 this.settings.default_document = tinyMCE.baseURL + "/blank.htm";
3759 this.settings.old_width = this.settings.width;
3760 this.settings.old_height = this.settings.height;
3762 // Set default width, height
3763 if (this.settings.width == -1)
3764 this.settings.width = replace_element.offsetWidth;
3766 if (this.settings.height == -1)
3767 this.settings.height = replace_element.offsetHeight;
3769 // Try the style width
3770 if (this.settings.width == 0)
3771 this.settings.width = replace_element.style.width;
3773 // Try the style height
3774 if (this.settings.height == 0)
3775 this.settings.height = replace_element.style.height;
3777 // If no width/height then default to 320x240, better than nothing
3778 if (this.settings.width == 0)
3779 this.settings.width = 320;
3781 if (this.settings.height == 0)
3782 this.settings.height = 240;
3784 this.settings.area_width = parseInt(this.settings.width);
3785 this.settings.area_height = parseInt(this.settings.height);
3786 this.settings.area_width += deltaWidth;
3787 this.settings.area_height += deltaHeight;
3788 this.settings.width_style = "" + this.settings.width;
3789 this.settings.height_style = "" + this.settings.height;
3791 // Special % handling
3792 if (("" + this.settings.width).indexOf('%') != -1)
3793 this.settings.area_width = "100%";
3795 this.settings.width_style += 'px';
3797 if (("" + this.settings.height).indexOf('%') != -1)
3798 this.settings.area_height = "100%";
3800 this.settings.height_style += 'px';
3802 if (("" + replace_element.style.width).indexOf('%') != -1) {
3803 this.settings.width = replace_element.style.width;
3804 this.settings.area_width = "100%";
3805 this.settings.width_style = "100%";
3808 if (("" + replace_element.style.height).indexOf('%') != -1) {
3809 this.settings.height = replace_element.style.height;
3810 this.settings.area_height = "100%";
3811 this.settings.height_style = "100%";
3814 html = tinyMCE.applyTemplate(html);
3816 this.settings.width = this.settings.old_width;
3817 this.settings.height = this.settings.old_height;
3819 this.visualAid = this.settings.visual;
3820 this.formTargetElementId = form_element_name;
3822 // Get replace_element contents
3823 if (replace_element.nodeName == "TEXTAREA" || replace_element.nodeName == "INPUT")
3824 this.startContent = replace_element.value;
3826 this.startContent = replace_element.innerHTML;
3828 // If not text area or input
3829 if (replace_element.nodeName != "TEXTAREA" && replace_element.nodeName != "INPUT") {
3830 this.oldTargetElement = replace_element;
3833 hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />';
3834 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
3835 this.oldTargetElement.style.display = "none";
3839 if (tinyMCE.isGecko)
3844 // Output HTML and set editable
3845 if (tinyMCE.isGecko) {
3846 rng = replace_element.ownerDocument.createRange();
3847 rng.setStartBefore(replace_element);
3849 fragment = rng.createContextualFragment(html);
3850 tinyMCE.insertAfter(fragment, replace_element);
3852 replace_element.insertAdjacentHTML("beforeBegin", html);
3856 // Just hide the textarea element
3857 this.oldTargetElement = replace_element;
3859 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
3860 this.oldTargetElement.style.display = "none";
3862 // Output HTML and set editable
3863 if (tinyMCE.isGecko) {
3864 rng = replace_element.ownerDocument.createRange();
3865 rng.setStartBefore(replace_element);
3867 fragment = rng.createContextualFragment(html);
3868 tinyMCE.insertAfter(fragment, replace_element);
3870 replace_element.insertAdjacentHTML("beforeBegin", html);
3874 dynamicIFrame = false;
3875 tElm = targetDoc.getElementById(this.editorId);
3877 if (!tinyMCE.isIE) {
3878 // Node case is preserved in XML strict mode
3879 if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) {
3880 tElm = tinyMCE._createIFrame(tElm, targetDoc);
3881 dynamicIFrame = true;
3884 this.targetElement = tElm;
3885 this.iframeElement = tElm;
3886 this.contentDocument = tElm.contentDocument;
3887 this.contentWindow = tElm.contentWindow;
3889 //this.getDoc().designMode = "on";
3891 if (tElm && tElm.nodeName == "SPAN")
3892 tElm = tinyMCE._createIFrame(tElm, targetDoc, targetDoc.parentWindow);
3894 tElm = targetDoc.frames[this.editorId];
3896 this.targetElement = tElm;
3897 this.iframeElement = targetDoc.getElementById(this.editorId);
3899 if (tinyMCE.isOpera) {
3900 this.contentDocument = this.iframeElement.contentDocument;
3901 this.contentWindow = this.iframeElement.contentWindow;
3902 dynamicIFrame = true;
3904 this.contentDocument = tElm.window.document;
3905 this.contentWindow = tElm.window;
3908 this.getDoc().designMode = "on";
3912 doc = this.contentDocument;
3913 if (dynamicIFrame) {
3914 html = tinyMCE.getParam('doctype') + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + tinyMCE.settings.base_href + '" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';
3917 if (!this.isHidden())
3918 this.getDoc().designMode = "on";
3924 // Failed Mozilla 1.3
3925 this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm";
3929 // This timeout is needed in MSIE 5.5 for some odd reason
3930 // it seems that the document.frames isn't initialized yet?
3932 window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
3934 // Setup element references
3935 parentElm = this.targetDoc.getElementById(this.editorId + '_parent');
3936 this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
3938 tinyMCE.setupContent(this.editorId, true);
3943 setBaseHREF : function(u) {
3947 nl = d.getElementsByTagName("base");
3948 b = nl.length > 0 ? nl[0] : null;
3951 nl = d.getElementsByTagName("head");
3952 h = nl.length > 0 ? nl[0] : null;
3954 b = d.createElement("base");
3955 b.setAttribute('href', u);
3958 if (u == '' || u == null)
3959 b.parentNode.removeChild(b);
3961 b.setAttribute('href', u);
3965 getHTML : function(r) {
3966 var h, d = this.getDoc(), b = this.getBody();
3971 h = tinyMCE._cleanupHTML(this, d, this.settings, b, false, true, false, true);
3973 if (tinyMCE.getParam("convert_fonts_to_spans"))
3974 tinyMCE.convertSpansToFonts(d);
3979 setHTML : function(h) {
3980 this.execCommand('mceSetContent', false, h);
3984 getFocusElement : function() {
3985 return this.selection.getFocusElement();
3988 getSel : function() {
3989 return this.selection.getSel();
3992 getRng : function() {
3993 return this.selection.getRng();
3996 triggerSave : function(skip_cleanup, skip_callback) {
3997 var e, nl = [], i, s, content, htm;
4002 this.switchSettings();
4003 s = tinyMCE.settings;
4005 // Force hidden tabs visible while serializing
4006 if (tinyMCE.isRealIE) {
4007 e = this.iframeElement;
4010 if (e.style && e.style.display == 'none') {
4011 e.style.display = 'block';
4012 nl[nl.length] = {elm : e, type : 'style'};
4015 if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
4016 e.className = s.display_tab_class;
4017 nl[nl.length] = {elm : e, type : 'class'};
4019 } while ((e = e.parentNode) != null)
4022 tinyMCE.settings.preformatted = false;
4025 if (typeof(skip_cleanup) == "undefined")
4026 skip_cleanup = false;
4029 if (typeof(skip_callback) == "undefined")
4030 skip_callback = false;
4032 tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML);
4034 // Remove visual aids when cleanup is disabled
4035 if (this.settings.cleanup == false) {
4036 tinyMCE.handleVisualAid(this.getBody(), true, false, this);
4037 tinyMCE._setEventsEnabled(this.getBody(), true);
4040 tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body);
4041 htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);
4042 htm = tinyMCE._customCleanup(this, "submit_content", htm);
4044 if (!skip_callback && tinyMCE.settings.save_callback !== '')
4045 content = tinyMCE.resolveDots(tinyMCE.settings.save_callback, window)(this.formTargetElementId,htm,this.getBody());
4047 // Use callback content if available
4048 if ((typeof(content) != "undefined") && content != null)
4051 // Replace some weird entities (Bug: #1056343)
4052 htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");
4053 htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");
4054 htm = tinyMCE.regexpReplace(htm, ";", ";", "gi");
4055 htm = tinyMCE.regexpReplace(htm, """, """, "gi");
4056 htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");
4058 if (this.formElement)
4059 this.formElement.value = htm;
4061 if (tinyMCE.isSafari && this.formElement)
4062 this.formElement.innerText = htm;
4064 // Hide them again (tabs in MSIE)
4065 for (i=0; i<nl.length; i++) {
4066 if (nl[i].type == 'style')
4067 nl[i].elm.style.display = 'none';
4069 nl[i].elm.className = s.hidden_tab_class;
4075 /* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
4077 tinyMCE.add(TinyMCE_Engine, {
4078 cleanupHTMLCode : function(s) {
4079 s = s.replace(new RegExp('<p \\/>', 'gi'), '<p> </p>');
4080 s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p> </p>');
4082 // Fix close BR elements
4083 s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />');
4085 // Open closed tags like <b/> to <b></b>
4086 s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3></$1$2>');
4088 // Remove trailing space <b > to <b>
4089 s = s.replace(new RegExp('\\s+></', 'gi'), '></');
4091 // Close tags <img></img> to <img/>
4092 s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />');
4094 // Weird MSIE bug, <p><hr /></p> breaks runtime?
4096 s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");
4098 // Weird tags will make IE error #bug: 1538495
4100 s = s.replace(/<!(\s*)\/>/g, '');
4102 // Convert relative anchors to absolute URLs ex: #something to file.htm#something
4103 // Removed: Since local document anchors should never be forced absolute example edit.php?id=something
4104 //if (tinyMCE.getParam('convert_urls'))
4105 // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings.document_base_url + "#");
4110 parseStyle : function(str) {
4111 var ar = [], st, i, re, pa;
4116 st = str.split(';');
4118 tinyMCE.clearArray(ar);
4120 for (i=0; i<st.length; i++) {
4124 re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');
4125 pa = st[i].replace(re, '$1||$2').split('||');
4126 //tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2'));
4128 ar[pa[0].toLowerCase()] = pa[1];
4134 compressStyle : function(ar, pr, sf, res) {
4137 box[0] = ar[pr + '-top' + sf];
4138 box[1] = ar[pr + '-left' + sf];
4139 box[2] = ar[pr + '-right' + sf];
4140 box[3] = ar[pr + '-bottom' + sf];
4142 for (i=0; i<box.length; i++) {
4146 if (i && box[i] != box[i-1])
4150 // They are all the same
4152 ar[pr + '-top' + sf] = null;
4153 ar[pr + '-left' + sf] = null;
4154 ar[pr + '-right' + sf] = null;
4155 ar[pr + '-bottom' + sf] = null;
4158 serializeStyle : function(ar) {
4159 var str = "", key, val, m;
4162 tinyMCE.compressStyle(ar, "border", "", "border");
4163 tinyMCE.compressStyle(ar, "border", "-width", "border-width");
4164 tinyMCE.compressStyle(ar, "border", "-color", "border-color");
4165 tinyMCE.compressStyle(ar, "border", "-style", "border-style");
4166 tinyMCE.compressStyle(ar, "padding", "", "padding");
4167 tinyMCE.compressStyle(ar, "margin", "", "margin");
4172 if (typeof(val) == 'function')
4175 if (key.indexOf('mso-') == 0)
4178 if (val != null && val !== '') {
4179 val = '' + val; // Force string
4182 val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')");
4185 if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) {
4186 m = new RegExp("url\\('(.*?)'\\)").exec(val);
4189 val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')";
4193 if (tinyMCE.getParam("force_hex_style_colors"))
4194 val = tinyMCE.convertRGBToHex(val, true);
4196 val = val.replace(/\"/g, '\'');
4198 if (val != "url('')")
4199 str += key.toLowerCase() + ": " + val + "; ";
4203 if (new RegExp('; $').test(str))
4204 str = str.substring(0, str.length - 2);
4209 convertRGBToHex : function(s, k) {
4212 if (s.toLowerCase().indexOf('rgb') != -1) {
4213 re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
4214 rgb = s.replace(re, "$1,$2,$3,$4,$5").split(',');
4216 if (rgb.length == 5) {
4217 r = parseInt(rgb[1]).toString(16);
4218 g = parseInt(rgb[2]).toString(16);
4219 b = parseInt(rgb[3]).toString(16);
4221 r = r.length == 1 ? '0' + r : r;
4222 g = g.length == 1 ? '0' + g : g;
4223 b = b.length == 1 ? '0' + b : b;
4225 s = "#" + r + g + b;
4228 s = rgb[0] + s + rgb[4];
4235 convertHexToRGB : function(s) {
4236 if (s.indexOf('#') != -1) {
4237 s = s.replace(new RegExp('[^0-9A-F]', 'gi'), '');
4238 return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")";
4244 convertSpansToFonts : function(doc) {
4245 var s, i, size, fSize, x, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
4247 s = tinyMCE.selectElements(doc, 'span,font');
4248 for (i=0; i<s.length; i++) {
4249 size = tinyMCE.trim(s[i].style.fontSize).toLowerCase();
4252 for (x=0; x<sizes.length; x++) {
4253 if (sizes[x] == size) {
4260 tinyMCE.setAttrib(s[i], 'size', fSize);
4261 s[i].style.fontSize = '';
4264 fFace = s[i].style.fontFamily;
4265 if (fFace != null && fFace !== '') {
4266 tinyMCE.setAttrib(s[i], 'face', fFace);
4267 s[i].style.fontFamily = '';
4270 fColor = s[i].style.color;
4271 if (fColor != null && fColor !== '') {
4272 tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor));
4273 s[i].style.color = '';
4278 convertFontsToSpans : function(doc) {
4279 var fsClasses, s, i, fSize, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
4281 fsClasses = tinyMCE.getParam('font_size_classes');
4282 if (fsClasses !== '')
4283 fsClasses = fsClasses.replace(/\s+/, '').split(',');
4287 s = tinyMCE.selectElements(doc, 'span,font');
4288 for (i=0; i<s.length; i++) {
4289 fSize = tinyMCE.getAttrib(s[i], 'size');
4290 fFace = tinyMCE.getAttrib(s[i], 'face');
4291 fColor = tinyMCE.getAttrib(s[i], 'color');
4294 fSize = parseInt(fSize);
4296 if (fSize > 0 && fSize < 8) {
4297 if (fsClasses != null)
4298 tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]);
4300 s[i].style.fontSize = sizes[fSize-1];
4303 s[i].removeAttribute('size');
4307 s[i].style.fontFamily = fFace;
4308 s[i].removeAttribute('face');
4311 if (fColor !== '') {
4312 s[i].style.color = fColor;
4313 s[i].removeAttribute('color');
4318 cleanupAnchors : function(doc) {
4319 var i, cn, x, an = doc.getElementsByTagName("a");
4321 // Loops backwards due to bug #1467987
4322 for (i=an.length-1; i>=0; i--) {
4323 if (tinyMCE.getAttrib(an[i], "name") !== '' && tinyMCE.getAttrib(an[i], "href") == '') {
4324 cn = an[i].childNodes;
4326 for (x=cn.length-1; x>=0; x--)
4327 tinyMCE.insertAfter(cn[x], an[i]);
4332 getContent : function(editor_id) {
4333 if (typeof(editor_id) != "undefined")
4334 tinyMCE.getInstanceById(editor_id).select();
4336 if (tinyMCE.selectedInstance)
4337 return tinyMCE.selectedInstance.getHTML();
4342 _fixListElements : function(d) {
4343 var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np;
4345 for (x=0; x<a.length; x++) {
4346 nl = d.getElementsByTagName(a[x]);
4348 for (i=0; i<nl.length; i++) {
4352 if (r.test(p.nodeName)) {
4353 np = tinyMCE.prevNode(n, 'LI');
4356 np = d.createElement('li');
4357 np.innerHTML = ' ';
4359 p.insertBefore(np, p.firstChild);
4367 _fixTables : function(d) {
4368 var nl, i, n, p, np, x, t;
4370 nl = d.getElementsByTagName('table');
4371 for (i=0; i<nl.length; i++) {
4374 if ((p = tinyMCE.getParentElement(n, 'p,h1,h2,h3,h4,h5,h6')) != null) {
4375 np = p.cloneNode(false);
4376 np.removeAttribute('id');
4380 while ((n = n.nextSibling))
4383 tinyMCE.insertAfter(np, p);
4384 tinyMCE.insertAfter(t, p);
4389 _cleanupHTML : function(inst, doc, config, elm, visual, on_save, on_submit, inn) {
4390 var h, d, t1, t2, t3, t4, t5, c, s, nb;
4392 if (!tinyMCE.getParam('cleanup'))
4393 return elm.innerHTML;
4395 on_save = typeof(on_save) == 'undefined' ? false : on_save;
4399 d = c.settings.debug;
4402 t1 = new Date().getTime();
4404 inst._fixRootBlocks();
4406 if (tinyMCE.getParam("convert_fonts_to_spans"))
4407 tinyMCE.convertFontsToSpans(doc);
4409 if (tinyMCE.getParam("fix_list_elements"))
4410 tinyMCE._fixListElements(doc);
4412 if (tinyMCE.getParam("fix_table_elements"))
4413 tinyMCE._fixTables(doc);
4415 // Call custom cleanup code
4416 tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);
4419 t2 = new Date().getTime();
4421 c.settings.on_save = on_save;
4424 c.serializationId++; // Unique ID needed for the content duplication bug
4425 c.serializedNodes = [];
4428 if (s.cleanup_serializer == "xml")
4429 h = c.serializeNodeAsXML(elm, inn);
4431 h = c.serializeNodeAsHTML(elm, inn);
4434 t3 = new Date().getTime();
4437 nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? ' ' : ' ';
4438 h = h.replace(/<\/?(body|head|html)[^>]*>/gi, '');
4439 h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), '');
4440 h = h.replace(/<p><hr \/><\/p>/g, '<hr />');
4441 h = h.replace(/<p>( | )<\/p><hr \/><p>( | )<\/p>/g, '<hr />');
4442 h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>');
4443 h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
4444 h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko
4445 h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko
4446 h = h.replace(/<p>\s*( | )\s*<br \/>\s*( | )\s*<\/p>/g, '<p>' + nb + '</p>');
4447 h = h.replace(/<p>\s*( | )\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
4448 h = h.replace(/<p>\s*<br \/>\s* \s*<\/p>/g, '<p>' + nb + '</p>');
4449 h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1');
4450 h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>');
4453 if (/^\s*(<br \/>|<p> <\/p>|<p> <\/p>|<p><\/p>)\s*$/.test(h))
4457 if (s.preformatted) {
4458 h = h.replace(/^<pre>/, '');
4459 h = h.replace(/<\/pre>$/, '');
4460 h = '<pre>' + h + '</pre>';
4463 // Gecko specific processing
4464 if (tinyMCE.isGecko) {
4465 // Makes no sence but FF generates it!!
4466 h = h.replace(/<br \/>\s*<\/li>/g, '</li>');
4467 h = h.replace(/ \s*<\/(dd|dt)>/g, '</$1>');
4468 h = h.replace(/<o:p _moz-userdefined="" \/>/g, '');
4469 h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>');
4472 if (s.force_br_newlines)
4473 h = h.replace(/<p>( | )<\/p>/g, '<br />');
4475 // Call custom cleanup code
4476 h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h);
4478 // Remove internal classes
4480 h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), '');
4481 h = h.replace(new RegExp(' ?class=""', 'g'), '');
4484 if (s.remove_linebreaks && !c.settings.indent)
4485 h = h.replace(/\n|\r/g, ' ');
4488 t4 = new Date().getTime();
4490 if (on_save && c.settings.indent)
4491 h = c.formatHTML(h);
4493 // If encoding (not recommended option)
4494 if (on_submit && (s.encoding == "xml" || s.encoding == "html"))
4498 t5 = new Date().getTime();
4500 if (c.settings.debug)
4501 tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + ".");
4507 function TinyMCE_Cleanup() {
4508 this.isIE = (navigator.appName == "Microsoft Internet Explorer");
4509 this.rules = tinyMCE.clearArray([]);
4513 indent_elements : 'head,table,tbody,thead,tfoot,form,tr,ul,ol,blockquote,object',
4514 newline_before_elements : 'h1,h2,h3,h4,h5,h6,pre,address,div,ul,ol,li,meta,option,area,title,link,base,script,td',
4515 newline_after_elements : 'br,hr,p,pre,address,div,ul,ol,meta,option,area,link,base,script',
4516 newline_before_after_elements : 'html,head,body,table,thead,tbody,tfoot,tr,form,ul,ol,blockquote,p,object,param,hr,div',
4519 entity_encoding : 'raw',
4520 valid_elements : '*[*]',
4523 invalid_elements : '',
4527 this.vElements = tinyMCE.clearArray([]);
4528 this.vElementsRe = '';
4529 this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/;
4530 this.codeElementsRe = /^(SCRIPT|STYLE)$/;
4531 this.serializationId = 0;
4539 TinyMCE_Cleanup.prototype = {
4540 init : function(s) {
4541 var n, a, i, ir, or, st;
4544 this.settings[n] = s[n];
4546 // Setup code formating
4550 this.inRe = this._arrayToRe(s.indent_elements.split(','), '', '^<(', ')[^>]*');
4551 this.ouRe = this._arrayToRe(s.indent_elements.split(','), '', '^<\\/(', ')[^>]*');
4552 this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>');
4553 this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>');
4554 this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>');
4555 this.serializedNodes = [];
4556 this.serializationId = 0;
4558 if (s.invalid_elements !== '')
4559 this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$');
4565 for (i=0; i<s.indent_levels; i++)
4566 st += s.indent_char;
4570 // If verify_html if false force *[*]
4571 if (!s.verify_html) {
4572 s.valid_elements = '*[*]';
4573 s.extended_valid_elements = '';
4576 this.fillStr = s.entity_encoding == "named" ? " " : " ";
4578 this.xmlEncodeRe = new RegExp('[\u007F-\uFFFF<>&"]', 'g');
4581 addRuleStr : function(s) {
4582 var r = this.parseRuleStr(s), n;
4586 this.rules[n] = r[n];
4589 this.vElements = tinyMCE.clearArray([]);
4591 for (n in this.rules) {
4593 this.vElements[this.vElements.length] = this.rules[n].tag;
4596 this.vElementsRe = this._arrayToRe(this.vElements, '');
4599 isValid : function(n) {
4600 if (!this.rulesDone)
4601 this._setupRules(); // Will initialize cleanup rules
4603 // Empty is true since it removes formatting
4607 // Clean the name up a bit
4608 n = n.replace(/[^a-z0-9]+/gi, '').toUpperCase();
4610 return !tinyMCE.getParam('cleanup') || this.vElementsRe.test(n);
4613 addChildRemoveRuleStr : function(s) {
4614 var x, y, p, i, t, tn, ta, cl, r;
4620 for (x=0; x<ta.length; x++) {
4623 // Split tag/children
4624 p = this.split(/\[|\]/, s);
4625 if (p == null || p.length < 1)
4626 t = s.toUpperCase();
4628 t = p[0].toUpperCase();
4630 // Handle all tag names
4631 tn = this.split('/', t);
4632 for (y=0; y<tn.length; y++) {
4636 cl = this.split(/\|/, p[1]);
4637 for (i=0; i<cl.length; i++) {
4638 if (cl[i] == '%istrict')
4639 r += tinyMCE.inlineStrict;
4640 else if (cl[i] == '%itrans')
4641 r += tinyMCE.inlineTransitional;
4642 else if (cl[i] == '%istrict_na')
4643 r += tinyMCE.inlineStrict.substring(2);
4644 else if (cl[i] == '%itrans_na')
4645 r += tinyMCE.inlineTransitional.substring(2);
4646 else if (cl[i] == '%btrans')
4647 r += tinyMCE.blockElms;
4648 else if (cl[i] == '%strict')
4649 r += tinyMCE.blockStrict;
4651 r += (cl[i].charAt(0) != '#' ? cl[i].toUpperCase() : cl[i]);
4653 r += (i != cl.length - 1 ? '|' : '');
4658 if (this.childRules == null)
4659 this.childRules = tinyMCE.clearArray([]);
4661 this.childRules[tn[y]] = new RegExp(r);
4664 this.childRules[tn[y]].wrapTag = p[2];
4669 parseRuleStr : function(s) {
4670 var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray([]), dv;
4672 if (s == null || s.length == 0)
4676 for (x=0; x<ta.length; x++) {
4682 p = this.split(/\[|\]/, s);
4683 if (p == null || p.length < 1)
4684 t = s.toUpperCase();
4686 t = p[0].toUpperCase();
4688 // Handle all tag names
4689 tn = this.split('/', t);
4690 for (y=0; y<tn.length; y++) {
4694 r.forceAttribs = null;
4695 r.defaultAttribs = null;
4696 r.validAttribValues = null;
4699 px = r.tag.charAt(0);
4700 r.forceOpen = px == '+';
4701 r.removeEmpty = px == '-';
4703 r.tag = r.tag.replace(/\+|-|#/g, '');
4704 r.oTagName = tn[0].replace(/\+|-|#/g, '').toLowerCase();
4705 r.isWild = new RegExp('\\*|\\?|\\+', 'g').test(r.tag);
4706 r.validRe = new RegExp(this._wildcardToRe('^' + r.tag + '$'));
4708 // Setup valid attributes
4710 r.vAttribsRe = '^(';
4711 a = this.split(/\|/, p[1]);
4713 for (i=0; i<a.length; i++) {
4716 if (t.charAt(0) == '!') {
4717 a[i] = t = t.substring(1);
4719 if (!r.reqAttribsRe)
4720 r.reqAttribsRe = '\\s+(' + t;
4722 r.reqAttribsRe += '|' + t;
4725 av = new RegExp('(=|:|<)(.*?)$').exec(t);
4726 t = t.replace(new RegExp('(=|:|<).*?$'), '');
4727 if (av && av.length > 0) {
4728 if (av[0].charAt(0) == ':') {
4729 if (!r.forceAttribs)
4730 r.forceAttribs = tinyMCE.clearArray([]);
4732 r.forceAttribs[t.toLowerCase()] = av[0].substring(1);
4733 } else if (av[0].charAt(0) == '=') {
4734 if (!r.defaultAttribs)
4735 r.defaultAttribs = tinyMCE.clearArray([]);
4737 dv = av[0].substring(1);
4739 r.defaultAttribs[t.toLowerCase()] = dv == '' ? "mce_empty" : dv;
4740 } else if (av[0].charAt(0) == '<') {
4741 if (!r.validAttribValues)
4742 r.validAttribValues = tinyMCE.clearArray([]);
4744 r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i');
4748 r.vAttribsRe += '' + t.toLowerCase() + (i != a.length - 1 ? '|' : '');
4750 a[i] = t.toLowerCase();
4754 r.reqAttribsRe = new RegExp(r.reqAttribsRe + ')=\"', 'g');
4756 r.vAttribsRe += ')$';
4757 r.vAttribsRe = this._wildcardToRe(r.vAttribsRe);
4758 r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe);
4759 r.vAttribsRe = new RegExp(r.vAttribsRe);
4760 r.vAttribs = a.reverse();
4762 //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC);
4765 r.vAttribs = tinyMCE.clearArray([]);
4766 r.vAttribsReIsWild = false;
4776 serializeNodeAsXML : function(n) {
4781 try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
4784 try {this.xmlDoc = new ActiveXObject('Microsoft.XmlDom');} catch (e) {}
4786 this.xmlDoc = document.implementation.createDocument('', '', null);
4789 alert("Error XML Parser could not be found.");
4792 if (this.xmlDoc.firstChild)
4793 this.xmlDoc.removeChild(this.xmlDoc.firstChild);
4795 b = this.xmlDoc.createElement("html");
4796 b = this.xmlDoc.appendChild(b);
4798 this._convertToXML(n, b);
4801 return this.xmlDoc.xml;
4803 return new XMLSerializer().serializeToString(this.xmlDoc);
4806 _convertToXML : function(n, xn) {
4807 var xd, el, i, l, cn, at, no, hc = false;
4809 if (tinyMCE.isRealIE && this._isDuplicate(n))
4814 switch (n.nodeType) {
4816 hc = n.hasChildNodes();
4818 el = xd.createElement(n.nodeName.toLowerCase());
4821 for (i=at.length-1; i>-1; i--) {
4824 if (no.specified && no.nodeValue)
4825 el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue);
4828 if (!hc && !this.closeElementsRe.test(n.nodeName))
4829 el.appendChild(xd.createTextNode(""));
4831 xn = xn.appendChild(el);
4835 xn.appendChild(xd.createTextNode(n.nodeValue));
4839 xn.appendChild(xd.createComment(n.nodeValue));
4846 for (i=0, l=cn.length; i<l; i++)
4847 this._convertToXML(cn[i], xn);
4851 serializeNodeAsHTML : function(n, inn) {
4852 var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr, nn;
4854 if (!this.rulesDone)
4855 this._setupRules(); // Will initialize cleanup rules
4857 if (tinyMCE.isRealIE && this._isDuplicate(n))
4860 // Skip non valid child elements
4861 if (n.parentNode && this.childRules != null) {
4862 cr = this.childRules[n.parentNode.nodeName];
4864 if (typeof(cr) != "undefined" && !cr.test(n.nodeName)) {
4870 switch (n.nodeType) {
4872 hc = n.hasChildNodes();
4879 if (tinyMCE.isRealIE) {
4880 // MSIE sometimes produces <//tag>
4881 if (n.nodeName.indexOf('/') != -1)
4884 // MSIE has it's NS in a separate attrib
4885 if (n.scopeName && n.scopeName != 'HTML')
4886 nn = n.scopeName.toUpperCase() + ':' + nn.toUpperCase();
4887 } else if (tinyMCE.isOpera && nn.indexOf(':') > 0)
4888 nn = nn.toUpperCase();
4890 // Convert fonts to spans
4891 if (this.settings.convert_fonts_to_spans) {
4892 // On get content FONT -> SPAN
4893 if (this.settings.on_save && nn == 'FONT')
4896 // On insert content SPAN -> FONT
4897 if (!this.settings.on_save && nn == 'SPAN')
4901 if (this.vElementsRe.test(nn) && (!this.iveRe || !this.iveRe.test(nn)) && !inn) {
4908 if (at[no] && at[no].validRe.test(nn)) {
4915 en = r.isWild ? nn.toLowerCase() : r.oTagName;
4918 if (r.removeEmpty && !hc)
4923 if (r.vAttribsReIsWild) {
4924 // Serialize wildcard attributes
4926 for (i=at.length-1; i>-1; i--) {
4928 if (no.specified && r.vAttribsRe.test(no.nodeName))
4929 t += this._serializeAttribute(n, r, no.nodeName);
4932 // Serialize specific attributes
4933 for (i=r.vAttribs.length-1; i>-1; i--)
4934 t += this._serializeAttribute(n, r, r.vAttribs[i]);
4937 // Serialize mce_ atts
4938 if (!this.settings.on_save) {
4939 at = this.mceAttribs;
4943 t += this._serializeAttribute(n, r, at[no]);
4947 // Check for required attribs
4948 if (r.reqAttribsRe && !t.match(r.reqAttribsRe))
4952 if (t != null && this.closeElementsRe.test(nn))
4958 if (this.isIE && this.codeElementsRe.test(nn))
4967 if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
4968 return this.isIE ? '' : n.nodeValue;
4970 return this.xmlEncode(n.nodeValue);
4976 return "<!--" + this._trimComment(n.nodeValue) + "-->";
4982 for (i=0, l=cn.length; i<l; i++)
4983 h += this.serializeNodeAsHTML(cn[i]);
4991 if (t != null && va)
4992 h += '</' + en + '>';
4997 _serializeAttribute : function(n, r, an) {
4998 var av = '', t, os = this.settings.on_save;
5000 if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0))
5003 if (os && this.mceAttribs[an])
5004 av = this._getAttrib(n, this.mceAttribs[an]);
5007 av = this._getAttrib(n, an);
5009 if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) {
5012 if (av == "mce_empty")
5013 return " " + an + '=""';
5016 if (r.forceAttribs && (t = r.forceAttribs[an]))
5019 if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an))
5020 av = this._urlConverter(this, n, av);
5022 if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
5025 if (av.length != 0 && av == "{$uid}")
5026 av = "uid_" + (this.idCount++);
5028 if (av.length != 0) {
5029 if (an.indexOf('on') != 0)
5030 av = this.xmlEncode(av, 1);
5032 return " " + an + "=" + '"' + av + '"';
5038 formatHTML : function(h) {
5039 var s = this.settings, p = '', i = 0, li = 0, o = '', l;
5041 // Replace BR in pre elements to \n
5042 h = h.replace(/<pre([^>]*)>(.*?)<\/pre>/gi, function (a, b, c) {
5043 c = c.replace(/<br\s*\/>/gi, '\n');
5044 return '<pre' + b + '>' + c + '</pre>';
5047 h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :)
5049 h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting
5050 h = h.replace(this.nlBeforeRe, '\n<$1$2>');
5051 h = h.replace(this.nlAfterRe, '<$1$2>\n');
5052 h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n');
5057 while ((i = h.indexOf('\n', i + 1)) != -1) {
5058 if ((l = h.substring(li + 1, i)).length != 0) {
5059 if (this.ouRe.test(l) && p.length >= s.indent_levels)
5060 p = p.substring(s.indent_levels);
5064 if (this.inRe.test(l))
5076 xmlEncode : function(s) {
5077 var cl = this, re = this.xmlEncodeRe;
5079 if (!this.entitiesDone)
5080 this._setupEntities(); // Will intialize lookup table
5082 switch (this.settings.entity_encoding) {
5084 return tinyMCE.xmlEncode(s);
5087 return s.replace(re, function (c) {
5088 var b = cl.entities[c.charCodeAt(0)];
5090 return b ? '&' + b + ';' : c;
5094 return s.replace(re, function (c) {
5095 return '&#' + c.charCodeAt(0) + ';';
5102 split : function(re, s) {
5103 var i, l, o = [], c = s.split(re);
5105 for (i=0, l=c.length; i<l; i++) {
5113 _trimComment : function(s) {
5114 // Remove mce_src, mce_href
5115 s = s.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
5116 s = s.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
5121 _getAttrib : function(e, n, d) {
5124 if (typeof(d) == "undefined")
5127 if (!e || e.nodeType != 1)
5131 v = e.getAttribute(n, 0);
5133 // IE 7 may cast exception on invalid attributes
5134 v = e.getAttribute(n, 2);
5137 if (n == "class" && !v)
5141 if (n == "http-equiv")
5146 // Skip the default values that IE returns
5147 if (nn == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
5150 if (nn == "INPUT" && n == "size" && v == "20")
5153 if (nn == "INPUT" && n == "maxlength" && v == "2147483647")
5157 if (n == "width" || n == "height")
5158 v = e.getAttribute(n, 2);
5161 if (n == 'style' && v) {
5162 if (!tinyMCE.isOpera)
5163 v = e.style.cssText;
5165 v = tinyMCE.serializeStyle(tinyMCE.parseStyle(v));
5168 if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v !== '')
5169 v = tinyMCE.cleanupEventStr(v);
5171 return (v && v !== '') ? '' + v : d;
5174 _urlConverter : function(c, n, v) {
5175 if (!c.settings.on_save)
5176 return tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, v);
5177 else if (tinyMCE.getParam('convert_urls')) {
5178 if (!this.urlConverter)
5179 this.urlConverter = eval(tinyMCE.settings.urlconverter_callback);
5181 return this.urlConverter(v, n, true);
5187 _arrayToRe : function(a, op, be, af) {
5190 op = typeof(op) == "undefined" ? "gi" : op;
5191 be = typeof(be) == "undefined" ? "^(" : be;
5192 af = typeof(af) == "undefined" ? ")$" : af;
5196 for (i=0; i<a.length; i++)
5197 r += this._wildcardToRe(a[i]) + (i != a.length-1 ? "|" : "");
5201 return new RegExp(r, op);
5204 _wildcardToRe : function(s) {
5205 s = s.replace(/\?/g, '(\\S?)');
5206 s = s.replace(/\+/g, '(\\S+)');
5207 s = s.replace(/\*/g, '(\\S*)');
5212 _setupEntities : function() {
5213 var n, a, i, s = this.settings;
5216 if (s.entity_encoding == "named") {
5217 n = tinyMCE.clearArray([]);
5218 a = this.split(',', s.entities);
5219 for (i=0; i<a.length; i+=2)
5225 this.entitiesDone = true;
5228 _setupRules : function() {
5229 var s = this.settings;
5231 // Setup default rule
5232 this.addRuleStr(s.valid_elements);
5233 this.addRuleStr(s.extended_valid_elements);
5234 this.addChildRemoveRuleStr(s.valid_child_elements);
5236 this.rulesDone = true;
5239 _isDuplicate : function(n) {
5242 if (!this.settings.fix_content_duplication)
5245 if (tinyMCE.isRealIE && n.nodeType == 1) {
5247 if (n.mce_serialized == this.serializationId)
5250 n.setAttribute('mce_serialized', this.serializationId);
5252 sn = this.serializedNodes;
5254 // Search lookup table for text nodes and comments
5255 for (i=0, l = sn.length; i<l; i++) {
5268 /* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
5270 tinyMCE.add(TinyMCE_Engine, {
5271 createTagHTML : function(tn, a, h) {
5272 var o = '', f = tinyMCE.xmlEncode, n;
5278 if (typeof(a[n]) != 'function' && a[n] != null)
5279 o += ' ' + f(n) + '="' + f('' + a[n]) + '"';
5283 o += !h ? ' />' : '>' + h + '</' + tn + '>';
5288 createTag : function(d, tn, a, h) {
5289 var o = d.createElement(tn), n;
5293 if (typeof(a[n]) != 'function' && a[n] != null)
5294 tinyMCE.setAttrib(o, n, a[n]);
5304 getElementByAttributeValue : function(n, e, a, v) {
5305 return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];
5308 getElementsByAttributeValue : function(n, e, a, v) {
5309 var i, nl = n.getElementsByTagName(e), o = [];
5311 for (i=0; i<nl.length; i++) {
5312 if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)
5313 o[o.length] = nl[i];
5319 isBlockElement : function(n) {
5320 return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);
5323 getParentBlockElement : function(n, r) {
5324 return this.getParentNode(n, function(n) {
5325 return tinyMCE.isBlockElement(n);
5331 insertAfter : function(n, r){
5333 r.parentNode.insertBefore(n, r.nextSibling);
5335 r.parentNode.appendChild(n);
5338 setInnerHTML : function(e, h) {
5341 // Convert all strong/em to b/i in Gecko
5342 if (tinyMCE.isGecko) {
5343 h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>');
5344 h = h.replace(/<em([^>]*)>/gi, '<i$1>');
5345 h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>');
5346 h = h.replace(/<strong([^>]*)>/gi, '<b$1>');
5347 h = h.replace(/<\/strong>/gi, '</b>');
5348 h = h.replace(/<\/em>/gi, '</i>');
5351 if (tinyMCE.isRealIE) {
5352 // Since MSIE handles invalid HTML better that valid XHTML we
5353 // need to make some things invalid. <hr /> gets converted to <hr>.
5354 h = h.replace(/\s\/>/g, '>');
5356 // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones
5357 h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs
5358 h = h.replace(/<p([^>]*)>\s* \s*<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs
5359 h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs
5361 // Remove first comment
5362 e.innerHTML = tinyMCE.uniqueTag + h;
5363 e.firstChild.removeNode(true);
5365 // Remove weird auto generated empty paragraphs unless it's supposed to be there
5366 nl = e.getElementsByTagName("p");
5367 for (i=nl.length-1; i>=0; i--) {
5370 if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep)
5371 n.parentNode.removeChild(n);
5374 h = this.fixGeckoBaseHREFBug(1, e, h);
5376 this.fixGeckoBaseHREFBug(2, e, h);
5380 getOuterHTML : function(e) {
5386 d = e.ownerDocument.createElement("body");
5387 d.appendChild(e.cloneNode(true));
5392 setOuterHTML : function(e, h, d) {
5393 var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t;
5395 if (tinyMCE.isIE && e.nodeType == 1)
5398 t = d.createElement("body");
5401 for (i=0, nl=t.childNodes; i<nl.length; i++)
5402 e.parentNode.insertBefore(nl[i].cloneNode(true), e);
5404 e.parentNode.removeChild(e);
5408 _getElementById : function(id, d) {
5411 if (typeof(d) == "undefined")
5414 e = d.getElementById(id);
5418 for (i=0; i<f.length; i++) {
5419 for (j=0; j<f[i].elements.length; j++) {
5420 if (f[i].elements[j].name == id) {
5421 e = f[i].elements[j];
5431 getNodeTree : function(n, na, t, nn) {
5432 return this.selectNodes(n, function(n) {
5433 return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
5437 getParentElement : function(n, na, f, r) {
5438 var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v;
5440 // Compatiblity with old scripts where f param was a attribute string
5441 if (f && typeof(f) == 'string')
5442 return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) !== '';});
5444 return this.getParentNode(n, function(n) {
5445 return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n));
5449 getParentNode : function(n, f, r) {
5463 getAttrib : function(elm, name, dv) {
5466 if (typeof(dv) == "undefined")
5470 if (!elm || elm.nodeType != 1)
5474 v = elm.getAttribute(name, 0);
5476 // IE 7 may cast exception on invalid attributes
5477 v = elm.getAttribute(name, 2);
5480 // Try className for class attrib
5481 if (name == "class" && !v)
5484 // Workaround for a issue with Firefox 1.5rc2+
5485 if (tinyMCE.isGecko) {
5486 if (name == "src" && elm.src != null && elm.src !== '')
5489 // Workaround for a issue with Firefox 1.5rc2+
5490 if (name == "href" && elm.href != null && elm.href !== '')
5492 } else if (tinyMCE.isIE) {
5500 v = elm.getAttribute(name, 2);
5505 if (name == "style" && !tinyMCE.isOpera)
5506 v = elm.style.cssText;
5508 return (v && v !== '') ? v : dv;
5511 setAttrib : function(el, name, va, fix) {
5512 if (typeof(va) == "number" && va != null)
5519 va = va.replace(/[^0-9%]/g, '');
5522 if (name == "style")
5523 el.style.cssText = va;
5525 if (name == "class")
5528 if (va != null && va !== '' && va != -1)
5529 el.setAttribute(name, va);
5531 el.removeAttribute(name);
5534 setStyleAttrib : function(e, n, v) {
5537 // Style attrib deleted in IE
5538 if (tinyMCE.isIE && v == null || v == '') {
5539 v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText));
5540 e.style.cssText = v;
5541 e.setAttribute("style", v);
5545 switchClass : function(ei, c) {
5548 if (tinyMCE.switchClassCache[ei])
5549 e = tinyMCE.switchClassCache[ei];
5551 e = tinyMCE.switchClassCache[ei] = document.getElementById(ei);
5555 if (tinyMCE.settings.button_tile_map && e.className && e.className.indexOf('mceTiledButton') == 0)
5556 c = 'mceTiledButton ' + c;
5562 getAbsPosition : function(n, cn) {
5565 while (n && n != cn) {
5571 return {absLeft : l, absTop : t};
5574 prevNode : function(e, n) {
5575 var a = n.split(','), i;
5577 while ((e = e.previousSibling) != null) {
5578 for (i=0; i<a.length; i++) {
5579 if (e.nodeName == a[i])
5587 nextNode : function(e, n) {
5588 var a = n.split(','), i;
5590 while ((e = e.nextSibling) != null) {
5591 for (i=0; i<a.length; i++) {
5592 if (e.nodeName == a[i])
5600 selectElements : function(n, na, f) {
5601 var i, a = [], nl, x;
5603 for (x=0, na = na.split(','); x<na.length; x++)
5604 for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
5605 (!f || f(nl[i])) && a.push(nl[i]);
5610 selectNodes : function(n, f, a) {
5619 if (n.hasChildNodes()) {
5620 for (i=0; i<n.childNodes.length; i++)
5621 tinyMCE.selectNodes(n.childNodes[i], f, a);
5627 addCSSClass : function(e, c, b) {
5628 var o = this.removeCSSClass(e, c);
5629 return e.className = b ? c + (o !== '' ? (' ' + o) : '') : (o !== '' ? (o + ' ') : '') + c;
5632 removeCSSClass : function(e, c) {
5633 c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
5634 return e.className = c != ' ' ? c : '';
5637 hasCSSClass : function(n, c) {
5638 return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
5641 renameElement : function(e, n, d) {
5644 d = typeof(d) == "undefined" ? tinyMCE.selectedInstance.getDoc() : d;
5647 ne = d.createElement(n);
5650 for (i=ar.length-1; i>-1; i--) {
5651 if (ar[i].specified && ar[i].nodeValue)
5652 ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue);
5656 for (i=0; i<ar.length; i++)
5657 ne.appendChild(ar[i].cloneNode(true));
5659 e.parentNode.replaceChild(ne, e);
5663 getViewPort : function(w) {
5664 var d = w.document, m = d.compatMode == 'CSS1Compat', b = d.body, de = d.documentElement;
5667 left : w.pageXOffset || (m ? de.scrollLeft : b.scrollLeft),
5668 top : w.pageYOffset || (m ? de.scrollTop : b.scrollTop),
5669 width : w.innerWidth || (m ? de.clientWidth : b.clientWidth),
5670 height : w.innerHeight || (m ? de.clientHeight : b.clientHeight)
5674 getStyle : function(n, na, d) {
5679 if (tinyMCE.isGecko && n.ownerDocument.defaultView) {
5681 return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na);
5683 // Old safari might fail
5688 // Camelcase it, if needed
5689 na = na.replace(/-(\D)/g, function(a, b){
5690 return b.toUpperCase();
5695 return n.currentStyle[na];
5702 /* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
5704 tinyMCE.add(TinyMCE_Engine, {
5705 parseURL : function(url_str) {
5706 var urlParts = [], i, pos, lastPos, chr;
5709 // Parse protocol part
5710 pos = url_str.indexOf('://');
5712 urlParts.protocol = url_str.substring(0, pos);
5716 // Find port or path start
5717 for (i=lastPos; i<url_str.length; i++) {
5718 chr = url_str.charAt(i);
5729 urlParts.host = url_str.substring(lastPos, pos);
5734 if (url_str.charAt(pos) == ':') {
5735 pos = url_str.indexOf('/', lastPos);
5736 urlParts.port = url_str.substring(lastPos+1, pos);
5741 pos = url_str.indexOf('?', lastPos);
5744 pos = url_str.indexOf('#', lastPos);
5747 pos = url_str.length;
5749 urlParts.path = url_str.substring(lastPos, pos);
5753 if (url_str.charAt(pos) == '?') {
5754 pos = url_str.indexOf('#');
5755 pos = (pos == -1) ? url_str.length : pos;
5756 urlParts.query = url_str.substring(lastPos+1, pos);
5761 if (url_str.charAt(pos) == '#') {
5762 pos = url_str.length;
5763 urlParts.anchor = url_str.substring(lastPos+1, pos);
5770 serializeURL : function(up) {
5774 o += up.protocol + "://";
5786 o += "?" + up.query;
5789 o += "#" + up.anchor;
5794 convertAbsoluteURLToRelativeURL : function(base_url, url_to_relative) {
5795 var baseURL = this.parseURL(base_url), targetURL = this.parseURL(url_to_relative);
5796 var i, strTok1, strTok2, breakPoint = 0, outPath = "", forceSlash = false;
5799 if (targetURL.path == '')
5800 targetURL.path = "/";
5804 // Crop away last path part
5805 base_url = baseURL.path.substring(0, baseURL.path.lastIndexOf('/'));
5806 strTok1 = base_url.split('/');
5807 strTok2 = targetURL.path.split('/');
5809 if (strTok1.length >= strTok2.length) {
5810 for (i=0; i<strTok1.length; i++) {
5811 if (i >= strTok2.length || strTok1[i] != strTok2[i]) {
5818 if (strTok1.length < strTok2.length) {
5819 for (i=0; i<strTok2.length; i++) {
5820 if (i >= strTok1.length || strTok1[i] != strTok2[i]) {
5827 if (breakPoint == 1)
5828 return targetURL.path;
5830 for (i=0; i<(strTok1.length-(breakPoint-1)); i++)
5833 for (i=breakPoint-1; i<strTok2.length; i++) {
5834 if (i != (breakPoint-1))
5835 outPath += "/" + strTok2[i];
5837 outPath += strTok2[i];
5840 targetURL.protocol = null;
5841 targetURL.host = null;
5842 targetURL.port = null;
5843 targetURL.path = outPath == '' && forceSlash ? "/" : outPath;
5845 // Remove document prefix from local anchors
5846 fileName = baseURL.path;
5848 if ((pos = fileName.lastIndexOf('/')) != -1)
5849 fileName = fileName.substring(pos + 1);
5852 if (fileName == targetURL.path && targetURL.anchor !== '')
5853 targetURL.path = "";
5855 // If empty and not local anchor force filename or slash
5856 if (targetURL.path == '' && !targetURL.anchor)
5857 targetURL.path = fileName !== '' ? fileName : "/";
5859 return this.serializeURL(targetURL);
5862 convertRelativeToAbsoluteURL : function(base_url, relative_url) {
5863 var baseURL = this.parseURL(base_url), baseURLParts, relURLParts, newRelURLParts, numBack, relURL = this.parseURL(relative_url), i;
5864 var len, absPath, start, end, newBaseURLParts;
5866 if (relative_url == '' || relative_url.indexOf('://') != -1 || /^(mailto:|javascript:|#|\/)/.test(relative_url))
5867 return relative_url;
5870 baseURLParts = baseURL.path.split('/');
5871 relURLParts = relURL.path.split('/');
5873 // Remove empty chunks
5874 newBaseURLParts = [];
5875 for (i=baseURLParts.length-1; i>=0; i--) {
5876 if (baseURLParts[i].length == 0)
5879 newBaseURLParts[newBaseURLParts.length] = baseURLParts[i];
5881 baseURLParts = newBaseURLParts.reverse();
5883 // Merge relURLParts chunks
5884 newRelURLParts = [];
5886 for (i=relURLParts.length-1; i>=0; i--) {
5887 if (relURLParts[i].length == 0 || relURLParts[i] == ".")
5890 if (relURLParts[i] == '..') {
5900 newRelURLParts[newRelURLParts.length] = relURLParts[i];
5903 relURLParts = newRelURLParts.reverse();
5905 // Remove end from absolute path
5906 len = baseURLParts.length-numBack;
5907 absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/');
5912 relURL.protocol = baseURL.protocol;
5913 relURL.host = baseURL.host;
5914 relURL.port = baseURL.port;
5916 // Re-add trailing slash if it's removed
5917 if (relURL.path.charAt(relURL.path.length-1) == "/")
5920 relURL.path = absPath;
5922 return this.serializeURL(relURL);
5925 convertURL : function(url, node, on_save) {
5926 var dl = document.location, start, portPart, urlParts, baseUrlParts, tmpUrlParts, curl;
5927 var prot = dl.protocol, host = dl.hostname, port = dl.port;
5929 // Pass through file protocol
5930 if (prot == "file:")
5933 // Something is wrong, remove weirdness
5934 url = tinyMCE.regexpReplace(url, '(http|https):///', '/');
5936 // Mailto link or anchor (Pass through)
5937 if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || /^[ \t\r\n\+]*[#\?]/.test(url))
5940 // Fix relative/Mozilla
5941 if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
5942 return tinyMCE.settings.base_href + url;
5944 // Handle relative URLs
5945 if (on_save && tinyMCE.getParam('relative_urls')) {
5946 curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url);
5947 if (curl.charAt(0) == '/')
5948 curl = tinyMCE.settings.document_base_prefix + curl;
5950 urlParts = tinyMCE.parseURL(curl);
5951 tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings.document_base_url);
5954 if (urlParts.host == tmpUrlParts.host && (urlParts.port == tmpUrlParts.port))
5955 return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings.document_base_url, curl);
5958 // Handle absolute URLs
5959 if (!tinyMCE.getParam('relative_urls')) {
5960 urlParts = tinyMCE.parseURL(url);
5961 baseUrlParts = tinyMCE.parseURL(tinyMCE.settings.base_href);
5963 // Force absolute URLs from relative URLs
5964 url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url);
5966 // If anchor and path is the same page
5967 if (urlParts.anchor && urlParts.path == baseUrlParts.path)
5968 return "#" + urlParts.anchor;
5971 // Remove current domain
5972 if (tinyMCE.getParam('remove_script_host')) {
5977 portPart = ":" + port;
5979 start = prot + "//" + host + portPart + "/";
5981 if (url.indexOf(start) == 0)
5982 url = url.substring(start.length-1);
5988 convertAllRelativeURLs : function(body) {
5989 var i, elms, src, href, mhref, msrc;
5991 // Convert all image URL:s to absolute URL
5992 elms = body.getElementsByTagName("img");
5993 for (i=0; i<elms.length; i++) {
5994 src = tinyMCE.getAttrib(elms[i], 'src');
5996 msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
6001 src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, src);
6002 elms[i].setAttribute("src", src);
6006 // Convert all link URL:s to absolute URL
6007 elms = body.getElementsByTagName("a");
6008 for (i=0; i<elms.length; i++) {
6009 href = tinyMCE.getAttrib(elms[i], 'href');
6011 mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
6015 if (href && href !== '') {
6016 href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, href);
6017 elms[i].setAttribute("href", href);
6024 /* file:jscripts/tiny_mce/classes/TinyMCE_Array.class.js */
6026 tinyMCE.add(TinyMCE_Engine, {
6027 clearArray : function(a) {
6036 explode : function(d, s) {
6037 var ar = s.split(d), oar = [], i;
6039 for (i = 0; i<ar.length; i++) {
6041 oar[oar.length] = ar[i];
6048 /* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */
6050 tinyMCE.add(TinyMCE_Engine, {
6051 _setEventsEnabled : function(node, state) {
6052 var evs, x, y, elms, i, event;
6053 var events = ['onfocus','onblur','onclick','ondblclick',
6054 'onmousedown','onmouseup','onmouseover','onmousemove',
6055 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'];
6057 evs = tinyMCE.settings.event_elements.split(',');
6058 for (y=0; y<evs.length; y++){
6059 elms = node.getElementsByTagName(evs[y]);
6060 for (i=0; i<elms.length; i++) {
6063 for (x=0; x<events.length; x++) {
6064 if ((event = tinyMCE.getAttrib(elms[i], events[x])) !== '') {
6065 event = tinyMCE.cleanupEventStr("" + event);
6068 event = "return true;" + event;
6070 event = event.replace(/^return true;/gi, '');
6072 elms[i].removeAttribute(events[x]);
6073 elms[i].setAttribute(events[x], event);
6080 _eventPatch : function(editor_id) {
6081 var n, inst, win, e;
6083 // Remove odd, error
6084 if (typeof(tinyMCE) == "undefined")
6088 // Try selected instance first
6089 if (tinyMCE.selectedInstance) {
6090 win = tinyMCE.selectedInstance.getWin();
6092 if (win && win.event) {
6096 e.target = e.srcElement;
6098 TinyMCE_Engine.prototype.handleEvent(e);
6104 for (n in tinyMCE.instances) {
6105 inst = tinyMCE.instances[n];
6107 if (!tinyMCE.isInstance(inst))
6111 win = inst.getWin();
6113 if (win && win.event) {
6117 e.target = e.srcElement;
6119 TinyMCE_Engine.prototype.handleEvent(e);
6124 // Ignore error if iframe is pointing to external URL
6128 findEvent : function(e) {
6134 for (n in tinyMCE.instances) {
6135 inst = tinyMCE.instances[n];
6137 if (tinyMCE.isInstance(inst) && inst.getWin().event)
6138 return inst.getWin().event;
6144 unloadHandler : function() {
6145 tinyMCE.triggerSave(true, true);
6148 addEventHandlers : function(inst) {
6149 this.setEventHandlers(inst, 1);
6152 setEventHandlers : function(inst, s) {
6153 var doc = inst.getDoc(), ie, ot, i, f = s ? tinyMCE.addEvent : tinyMCE.removeEvent;
6155 ie = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick'];
6156 ot = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'focus', 'blur', 'dragdrop'];
6158 inst.switchSettings();
6161 for (i=0; i<ie.length; i++)
6162 f(doc, ie[i], TinyMCE_Engine.prototype._eventPatch);
6164 for (i=0; i<ot.length; i++)
6165 f(doc, ot[i], tinyMCE.handleEvent);
6169 doc.designMode = "On";
6176 onMouseMove : function() {
6179 // Fix for IE7 bug where it's not restoring hover on anchors correctly
6180 if (tinyMCE.lastHover) {
6181 lh = tinyMCE.lastHover;
6183 // Call out on menus and refresh class on normal buttons
6184 if (lh.className.indexOf('mceMenu') != -1)
6185 tinyMCE._menuButtonEvent('out', lh);
6187 lh.className = lh.className;
6189 tinyMCE.lastHover = null;
6192 if (!tinyMCE.hasMouseMoved) {
6193 inst = tinyMCE.selectedInstance;
6195 // Workaround for bug #1437457 (Odd MSIE bug)
6196 if (inst.isFocused) {
6197 inst.undoBookmark = inst.selection.getBookmark();
6198 tinyMCE.hasMouseMoved = true;
6202 // tinyMCE.cancelEvent(inst.getWin().event);
6206 cancelEvent : function(e) {
6211 e.returnValue = false;
6212 e.cancelBubble = true;
6215 e.stopPropagation && e.stopPropagation();
6221 addEvent : function(o, n, h) {
6222 // Add cleanup for all non unload events
6223 if (n != 'unload') {
6228 tinyMCE.removeEvent(o, n, h);
6229 tinyMCE.removeEvent(window, 'unload', clean);
6232 // IE may produce access denied exception on unload
6236 // Add memory cleaner
6237 tinyMCE.addEvent(window, 'unload', clean);
6241 o.attachEvent("on" + n, h);
6243 o.addEventListener(n, h, false);
6246 removeEvent : function(o, n, h) {
6248 o.detachEvent("on" + n, h);
6250 o.removeEventListener(n, h, false);
6253 addSelectAccessibility : function(e, s, w) {
6254 // Add event handlers
6255 if (!s._isAccessible) {
6256 s.onkeydown = tinyMCE.accessibleEventHandler;
6257 s.onblur = tinyMCE.accessibleEventHandler;
6258 s._isAccessible = true;
6265 accessibleEventHandler : function(e) {
6266 var elm, win = this._win;
6268 e = tinyMCE.isIE ? win.event : e;
6269 elm = tinyMCE.isIE ? e.srcElement : e.target;
6271 // Unpiggyback onchange on blur
6272 if (e.type == "blur") {
6273 if (elm.oldonchange) {
6274 elm.onchange = elm.oldonchange;
6275 elm.oldonchange = null;
6281 // Piggyback onchange
6282 if (elm.nodeName == "SELECT" && !elm.oldonchange) {
6283 elm.oldonchange = elm.onchange;
6284 elm.onchange = null;
6287 // Execute onchange and remove piggyback
6288 if (e.keyCode == 13 || e.keyCode == 32) {
6289 elm.onchange = elm.oldonchange;
6291 elm.oldonchange = null;
6293 tinyMCE.cancelEvent(e);
6300 _resetIframeHeight : function() {
6303 if (tinyMCE.isRealIE) {
6304 ife = tinyMCE.selectedInstance.iframeElement;
6306 /* if (ife._oldWidth) {
6307 ife.style.width = ife._oldWidth;
6308 ife.width = ife._oldWidth;
6311 if (ife._oldHeight) {
6312 ife.style.height = ife._oldHeight;
6313 ife.height = ife._oldHeight;
6320 /* file:jscripts/tiny_mce/classes/TinyMCE_Selection.class.js */
6322 function TinyMCE_Selection(inst) {
6323 this.instance = inst;
6326 TinyMCE_Selection.prototype = {
6327 getSelectedHTML : function() {
6328 var inst = this.instance, e, r = this.getRng(), h;
6333 e = document.createElement("body");
6335 if (r.cloneContents)
6336 e.appendChild(document.importNode(r.cloneContents(), true));
6337 else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined')
6338 e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
6340 e.innerHTML = r.toString(); // Failed, use text for now
6342 h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
6344 // When editing always use fonts internaly
6345 //if (tinyMCE.getParam("convert_fonts_to_spans"))
6346 // tinyMCE.convertSpansToFonts(inst.getDoc());
6351 getSelectedText : function() {
6352 var inst = this.instance, d, r, s, t;
6357 if (d.selection.type == "Text") {
6358 r = d.selection.createRange();
6365 if (s && s.toString)
6374 getBookmark : function(simple) {
6375 var inst = this.instance, rng = this.getRng(), doc = inst.getDoc(), b = inst.getBody();
6376 var trng, sx, sy, xx = -999999999, vp = inst.getViewPort();
6377 var sp, le, s, e, nl, i, si, ei, w;
6383 return {rng : rng, scrollX : sx, scrollY : sy};
6385 if (tinyMCE.isRealIE) {
6389 nl = b.getElementsByTagName(e.nodeName);
6390 for (i=0; i<nl.length; i++) {
6404 trng = doc.body.createTextRange();
6405 trng.moveToElementText(inst.getBody());
6406 trng.collapse(true);
6407 bp = Math.abs(trng.move('character', xx));
6409 trng = rng.duplicate();
6410 trng.collapse(true);
6411 sp = Math.abs(trng.move('character', xx));
6413 trng = rng.duplicate();
6414 trng.collapse(false);
6415 le = Math.abs(trng.move('character', xx)) - sp;
6426 e = this.getFocusElement();
6431 if (e && e.nodeName == 'IMG') {
6432 /*nl = b.getElementsByTagName('IMG');
6433 for (i=0; i<nl.length; i++) {
6449 // Caret or selection
6450 if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
6451 e = this._getPosText(b, s.anchorNode, s.focusNode);
6454 return {scrollX : sx, scrollY : sy};
6457 start : e.start + s.anchorOffset,
6458 end : e.end + s.focusOffset,
6463 e = this._getPosText(b, rng.startContainer, rng.endContainer);
6466 return {scrollX : sx, scrollY : sy};
6469 start : e.start + rng.startOffset,
6470 end : e.end + rng.endOffset,
6480 moveToBookmark : function(bookmark) {
6481 var inst = this.instance, rng, nl, i, ex, b = inst.getBody(), sd;
6482 var doc = inst.getDoc(), win = inst.getWin(), sel = this.getSel();
6487 if (tinyMCE.isSafari && bookmark.rng) {
6488 sel.setBaseAndExtent(bookmark.rng.startContainer, bookmark.rng.startOffset, bookmark.rng.endContainer, bookmark.rng.endOffset);
6492 if (tinyMCE.isRealIE) {
6495 bookmark.rng.select();
6506 rng = b.createControlRange();
6508 nl = b.getElementsByTagName(bookmark.tag);
6510 if (nl.length > bookmark.index) {
6512 rng.addElement(nl[bookmark.index]);
6514 // Might be thrown if the node no longer exists
6518 // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
6520 // Incorrect bookmark
6521 if (bookmark.start < 0)
6524 rng = inst.getSel().createRange();
6525 rng.moveToElementText(inst.getBody());
6527 rng.moveStart('character', bookmark.start);
6528 rng.moveEnd('character', bookmark.length);
6536 win.scrollTo(bookmark.scrollX, bookmark.scrollY);
6540 if (tinyMCE.isGecko || tinyMCE.isOpera) {
6545 sel.removeAllRanges();
6546 sel.addRange(bookmark.rng);
6549 if (bookmark.start != -1 && bookmark.end != -1) {
6551 sd = this._getTextPos(b, bookmark.start, bookmark.end);
6552 rng = doc.createRange();
6553 rng.setStart(sd.startNode, sd.startOffset);
6554 rng.setEnd(sd.endNode, sd.endOffset);
6555 sel.removeAllRanges();
6558 if (!tinyMCE.isOpera)
6566 if (typeof(bookmark.index) != 'undefined') {
6567 tinyMCE.selectElements(b, 'IMG', function (n) {
6568 if (bookmark.index-- == 0) {
6569 // Select image in Gecko here
6577 win.scrollTo(bookmark.scrollX, bookmark.scrollY);
6584 _getPosText : function(r, sn, en) {
6585 var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
6587 while ((n = w.nextNode()) != null) {
6596 p += n.nodeValue ? n.nodeValue.length : 0;
6602 _getTextPos : function(r, sp, ep) {
6603 var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
6605 while ((n = w.nextNode()) != null) {
6606 p += n.nodeValue ? n.nodeValue.length : 0;
6608 if (p >= sp && !d.startNode) {
6610 d.startOffset = sp - (p - n.nodeValue.length);
6615 d.endOffset = ep - (p - n.nodeValue.length);
6624 selectNode : function(node, collapse, select_text_node, to_start) {
6625 var inst = this.instance, sel, rng, nodes;
6630 if (typeof(collapse) == "undefined")
6633 if (typeof(select_text_node) == "undefined")
6634 select_text_node = false;
6636 if (typeof(to_start) == "undefined")
6639 if (inst.settings.auto_resize)
6640 inst.resizeToContent();
6642 if (tinyMCE.isRealIE) {
6643 rng = inst.getDoc().body.createTextRange();
6646 rng.moveToElementText(node);
6649 rng.collapse(to_start);
6653 // Throws illigal agrument in MSIE some times
6656 sel = this.getSel();
6661 if (tinyMCE.isSafari) {
6662 sel.setBaseAndExtent(node, 0, node, node.innerText.length);
6666 sel.collapseToStart();
6668 sel.collapseToEnd();
6671 this.scrollToNode(node);
6676 rng = inst.getDoc().createRange();
6678 if (select_text_node) {
6679 // Find first textnode in tree
6680 nodes = tinyMCE.getNodeTree(node, [], 3);
6681 if (nodes.length > 0)
6682 rng.selectNodeContents(nodes[0]);
6684 rng.selectNodeContents(node);
6686 rng.selectNode(node);
6689 // Special treatment of textnode collapse
6690 if (!to_start && node.nodeType == 3) {
6691 rng.setStart(node, node.nodeValue.length);
6692 rng.setEnd(node, node.nodeValue.length);
6694 rng.collapse(to_start);
6697 sel.removeAllRanges();
6701 this.scrollToNode(node);
6703 // Set selected element
6704 tinyMCE.selectedElement = null;
6705 if (node.nodeType == 1)
6706 tinyMCE.selectedElement = node;
6709 scrollToNode : function(node) {
6710 var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin;
6712 // Only scroll if out of visible area
6713 if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25))
6714 w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25);
6716 // Scroll container window
6717 if (inst.settings.auto_resize) {
6718 cwin = inst.getContainerWin();
6719 cvp = tinyMCE.getViewPort(cwin);
6720 p = this.getAbsPosition(node);
6722 if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height)
6723 cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25);
6727 getAbsPosition : function(n) {
6728 var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement);
6731 absLeft : ipos.absLeft + pos.absLeft,
6732 absTop : ipos.absTop + pos.absTop
6736 getSel : function() {
6737 var inst = this.instance;
6739 if (tinyMCE.isRealIE)
6740 return inst.getDoc().selection;
6742 return inst.contentWindow.getSelection();
6745 getRng : function() {
6746 var s = this.getSel();
6751 if (tinyMCE.isRealIE)
6752 return s.createRange();
6754 if (tinyMCE.isSafari && !s.getRangeAt)
6755 return '' + window.getSelection();
6757 if (s.rangeCount > 0)
6758 return s.getRangeAt(0);
6763 isCollapsed : function() {
6764 var r = this.getRng();
6769 return r.boundingWidth == 0 || this.getSel().isCollapsed;
6772 collapse : function(b) {
6773 var r = this.getRng(), s = this.getSel();
6780 s.collapseToStart();
6786 getFocusElement : function() {
6787 var inst = this.instance, doc, rng, sel, elm;
6789 if (tinyMCE.isRealIE) {
6790 doc = inst.getDoc();
6791 rng = doc.selection.createRange();
6793 // if (rng.collapse)
6794 // rng.collapse(true);
6796 elm = rng.item ? rng.item(0) : rng.parentElement();
6798 if (!tinyMCE.isSafari && inst.isHidden())
6799 return inst.getBody();
6801 sel = this.getSel();
6802 rng = this.getRng();
6807 elm = rng.commonAncestorContainer;
6808 //elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
6810 // Handle selection a image or other control like element such as anchors
6811 if (!rng.collapsed) {
6812 // Is selection small
6813 if (rng.startContainer == rng.endContainer) {
6814 if (rng.startOffset - rng.endOffset < 2) {
6815 if (rng.startContainer.hasChildNodes())
6816 elm = rng.startContainer.childNodes[rng.startOffset];
6821 // Get the element parent of the node
6822 elm = tinyMCE.getParentElement(elm);
6824 //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
6825 // elm = tinyMCE.selectedElement;
6833 /* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */
6835 function TinyMCE_UndoRedo(inst) {
6836 this.instance = inst;
6837 this.undoLevels = [];
6839 this.typingUndoIndex = -1;
6840 this.undoRedo = true;
6843 TinyMCE_UndoRedo.prototype = {
6845 var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur;
6848 this.undoLevels[this.undoLevels.length] = l;
6852 if (this.typingUndoIndex != -1) {
6853 this.undoIndex = this.typingUndoIndex;
6855 if (tinyMCE.typingUndoIndex != -1)
6856 tinyMCE.undoIndex = tinyMCE.typingUndoIndex;
6859 newHTML = tinyMCE.trim(inst.getBody().innerHTML);
6860 if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
6861 //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content);
6864 inst.isNotDirty = false;
6866 tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
6869 customUndoLevels = tinyMCE.settings.custom_undo_redo_levels;
6870 if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
6871 for (i=0; i<this.undoLevels.length-1; i++)
6872 this.undoLevels[i] = this.undoLevels[i+1];
6874 this.undoLevels.length--;
6877 // Todo: Implement global undo/redo logic here
6880 b = inst.undoBookmark;
6883 b = inst.selection.getBookmark();
6886 this.undoLevels[this.undoIndex] = {
6891 // Remove all above from global undo/redo
6892 ul = tinyMCE.undoLevels;
6893 for (i=tinyMCE.undoIndex + 1; i<ul.length; i++) {
6894 ur = ul[i].undoRedo;
6896 if (ur.undoIndex == ur.undoLevels.length -1)
6899 ur.undoLevels.length--;
6902 // Add global undo level
6903 tinyMCE.undoLevels[tinyMCE.undoIndex++] = inst;
6904 tinyMCE.undoLevels.length = tinyMCE.undoIndex;
6906 this.undoLevels.length = this.undoIndex + 1;
6915 var inst = this.instance;
6918 if (this.undoIndex > 0) {
6921 tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
6924 if (inst.settings.custom_undo_redo_restore_selection)
6925 inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
6930 var inst = this.instance;
6932 tinyMCE.execCommand("mceEndTyping");
6934 if (this.undoIndex < (this.undoLevels.length-1)) {
6937 tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
6940 if (inst.settings.custom_undo_redo_restore_selection)
6941 inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
6944 tinyMCE.triggerNodeChange();
6949 /* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
6951 var TinyMCE_ForceParagraphs = {
6952 _insertPara : function(inst, e) {
6953 var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0);
6954 var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock;
6955 var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null;
6956 var paraBefore, paraAfter, startChop, endChop, contents, i;
6958 function isEmpty(para) {
6961 function isEmptyHTML(html) {
6962 return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == '';
6966 if (para.getElementsByTagName("img").length > 0)
6970 if (para.getElementsByTagName("table").length > 0)
6974 if (para.getElementsByTagName("hr").length > 0)
6977 // Check all textnodes
6978 nodes = tinyMCE.getNodeTree(para, [], 3);
6979 for (i=0; i<nodes.length; i++) {
6980 if (!isEmptyHTML(nodes[i].nodeValue))
6984 // No images, no tables, no hrs, no text content then it's empty
6988 // tinyMCE.debug(body.innerHTML);
6990 // debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString());
6992 // Setup before range
6993 rngBefore = doc.createRange();
6994 rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
6995 rngBefore.collapse(true);
6997 // Setup after range
6998 rngAfter = doc.createRange();
6999 rngAfter.setStart(sel.focusNode, sel.focusOffset);
7000 rngAfter.collapse(true);
7002 // Setup start/end points
7003 direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
7004 startNode = direct ? sel.anchorNode : sel.focusNode;
7005 startOffset = direct ? sel.anchorOffset : sel.focusOffset;
7006 endNode = direct ? sel.focusNode : sel.anchorNode;
7007 endOffset = direct ? sel.focusOffset : sel.anchorOffset;
7009 startNode = startNode.nodeName == "HTML" ? doc.body : startNode; // Fix for Opera bug: https://bugs.opera.com/show_bug.cgi?id=273224&comments=yes
7010 startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;
7011 endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;
7013 // Get block elements
7014 startBlock = inst.getParentBlockElement(startNode);
7015 endBlock = inst.getParentBlockElement(endNode);
7017 // If absolute force paragraph generation within
7018 if (startBlock && (startBlock.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(startBlock.style.position)))
7021 if (endBlock && (endBlock.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(endBlock.style.position)))
7024 // Use current block name
7025 if (startBlock != null) {
7026 blockName = startBlock.nodeName;
7029 if (/(TD|TABLE|TH|CAPTION)/.test(blockName) || (blockName == "DIV" && /left|right/gi.test(startBlock.style.cssFloat)))
7033 // Within a list use normal behaviour
7034 if (tinyMCE.getParentElement(startBlock, "OL,UL", null, body) != null)
7037 // Within a table create new paragraphs
7038 if ((startBlock != null && startBlock.nodeName == "TABLE") || (endBlock != null && endBlock.nodeName == "TABLE"))
7039 startBlock = endBlock = null;
7041 // Setup new paragraphs
7042 paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
7043 paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
7045 // Is header, then force paragraph under
7046 if (/^(H[1-6])$/.test(blockName))
7047 paraAfter = doc.createElement("p");
7050 startChop = startNode;
7053 // Get startChop node
7056 if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
7060 } while ((node = node.previousSibling ? node.previousSibling : node.parentNode));
7065 if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
7069 } while ((node = node.nextSibling ? node.nextSibling : node.parentNode));
7071 // Fix when only a image is within the TD
7072 if (startChop.nodeName == "TD")
7073 startChop = startChop.firstChild;
7075 if (endChop.nodeName == "TD")
7076 endChop = endChop.lastChild;
7078 // If not in a block element
7079 if (startBlock == null) {
7081 rng.deleteContents();
7083 if (!tinyMCE.isSafari)
7084 sel.removeAllRanges();
7086 if (startChop != rootElm && endChop != rootElm) {
7087 // Insert paragraph before
7088 rngBefore = rng.cloneRange();
7090 if (startChop == body)
7091 rngBefore.setStart(startChop, 0);
7093 rngBefore.setStartBefore(startChop);
7095 paraBefore.appendChild(rngBefore.cloneContents());
7097 // Insert paragraph after
7098 if (endChop.parentNode.nodeName == blockName)
7099 endChop = endChop.parentNode;
7101 // If not after image
7102 //if (rng.startContainer.nodeName != "BODY" && rng.endContainer.nodeName != "BODY")
7103 rng.setEndAfter(endChop);
7105 if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")
7106 rngBefore.setEndAfter(endChop);
7108 contents = rng.cloneContents();
7109 if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
7110 paraAfter.innerHTML = contents.firstChild.innerHTML;
7112 paraAfter.appendChild(contents);
7114 // Check if it's a empty paragraph
7115 if (isEmpty(paraBefore))
7116 paraBefore.innerHTML = " ";
7118 // Check if it's a empty paragraph
7119 if (isEmpty(paraAfter))
7120 paraAfter.innerHTML = " ";
7122 // Delete old contents
7123 rng.deleteContents();
7124 rngAfter.deleteContents();
7125 rngBefore.deleteContents();
7127 // Insert new paragraphs
7128 if (tinyMCE.isOpera) {
7129 paraBefore.normalize();
7130 rngBefore.insertNode(paraBefore);
7131 paraAfter.normalize();
7132 rngBefore.insertNode(paraAfter);
7134 paraAfter.normalize();
7135 rngBefore.insertNode(paraAfter);
7136 paraBefore.normalize();
7137 rngBefore.insertNode(paraBefore);
7140 //tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
7142 body.innerHTML = "<" + blockName + "> </" + blockName + "><" + blockName + "> </" + blockName + ">";
7143 paraAfter = body.childNodes[1];
7146 inst.selection.moveToBookmark(b);
7147 inst.selection.selectNode(paraAfter, true, true);
7152 // Place first part within new paragraph
7153 if (startChop.nodeName == blockName)
7154 rngBefore.setStart(startChop, 0);
7156 rngBefore.setStartBefore(startChop);
7158 rngBefore.setEnd(startNode, startOffset);
7159 paraBefore.appendChild(rngBefore.cloneContents());
7161 // Place secound part within new paragraph
7162 rngAfter.setEndAfter(endChop);
7163 rngAfter.setStart(endNode, endOffset);
7164 contents = rngAfter.cloneContents();
7166 if (contents.firstChild && contents.firstChild.nodeName == blockName) {
7167 /* var nodes = contents.firstChild.childNodes;
7168 for (i=0; i<nodes.length; i++) {
7169 //tinyMCE.debug(nodes[i].nodeName);
7170 if (nodes[i].nodeName != "BODY")
7171 paraAfter.appendChild(nodes[i]);
7174 paraAfter.innerHTML = contents.firstChild.innerHTML;
7176 paraAfter.appendChild(contents);
7178 // Check if it's a empty paragraph
7179 if (isEmpty(paraBefore))
7180 paraBefore.innerHTML = " ";
7182 // Check if it's a empty paragraph
7183 if (isEmpty(paraAfter))
7184 paraAfter.innerHTML = " ";
7186 // Create a range around everything
7187 rng = doc.createRange();
7189 if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
7190 rng.setStartBefore(startChop.parentNode);
7192 if (rngBefore.startContainer.nodeName.toUpperCase() == blockName && rngBefore.startOffset == 0)
7193 rng.setStartBefore(rngBefore.startContainer);
7195 rng.setStart(rngBefore.startContainer, rngBefore.startOffset);
7198 if (!endChop.nextSibling && endChop.parentNode.nodeName.toUpperCase() == blockName)
7199 rng.setEndAfter(endChop.parentNode);
7201 rng.setEnd(rngAfter.endContainer, rngAfter.endOffset);
7203 // Delete all contents and insert new paragraphs
7204 rng.deleteContents();
7206 if (tinyMCE.isOpera) {
7207 rng.insertNode(paraBefore);
7208 rng.insertNode(paraAfter);
7210 rng.insertNode(paraAfter);
7211 rng.insertNode(paraBefore);
7214 //tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
7217 paraAfter.normalize();
7218 paraBefore.normalize();
7220 inst.selection.moveToBookmark(b);
7221 inst.selection.selectNode(paraAfter, true, true);
7226 _handleBackSpace : function(inst) {
7227 var r = inst.getRng(), sn = r.startContainer, nv, s = false;
7229 // Added body check for bug #1527787
7230 if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR" && sn.parentNode.nodeName != "BODY") {
7233 // Handle if a backspace is pressed after a space character #bug 1466054 removed since fix for #1527787
7234 /*if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
7237 // Only remove BRs if we are at the end of line #bug 1464152
7238 if (nv != null && r.startOffset == nv.length)
7239 sn.nextSibling.parentNode.removeChild(sn.nextSibling);
7242 if (inst.settings.auto_resize)
7243 inst.resizeToContent();
7250 /* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */
7252 function TinyMCE_Layer(id, bm) {
7254 this.blockerElement = null;
7255 this.events = false;
7256 this.element = null;
7257 this.blockMode = typeof(bm) != 'undefined' ? bm : true;
7258 this.doc = document;
7261 TinyMCE_Layer.prototype = {
7262 moveRelativeTo : function(re, p) {
7263 var rep = this.getAbsPosition(re), e = this.getElement(), x, y;
7264 var w = parseInt(re.offsetWidth), h = parseInt(re.offsetHeight);
7265 var ew = parseInt(e.offsetWidth), eh = parseInt(e.offsetHeight);
7274 x = rep.absLeft + w;
7284 x = rep.absLeft + w;
7289 x = rep.absLeft + (w / 2) - (ew / 2);
7290 y = rep.absTop + (h / 2) - (eh / 2);
7297 moveBy : function(x, y) {
7298 var e = this.getElement();
7299 this.moveTo(parseInt(e.style.left) + x, parseInt(e.style.top) + y);
7302 moveTo : function(x, y) {
7303 var e = this.getElement();
7305 e.style.left = x + "px";
7306 e.style.top = y + "px";
7308 this.updateBlocker();
7311 resizeBy : function(w, h) {
7312 var e = this.getElement();
7313 this.resizeTo(parseInt(e.style.width) + w, parseInt(e.style.height) + h);
7316 resizeTo : function(w, h) {
7317 var e = this.getElement();
7320 e.style.width = w + "px";
7323 e.style.height = h + "px";
7325 this.updateBlocker();
7329 var el = this.getElement();
7332 el.style.display = 'block';
7333 this.updateBlocker();
7338 var el = this.getElement();
7341 el.style.display = 'none';
7342 this.updateBlocker();
7346 isVisible : function() {
7347 return this.getElement().style.display == 'block';
7350 getElement : function() {
7352 this.element = this.doc.getElementById(this.id);
7354 return this.element;
7357 setBlockMode : function(s) {
7361 updateBlocker : function() {
7362 var e, b, x, y, w, h;
7364 b = this.getBlocker();
7366 if (this.blockMode) {
7367 e = this.getElement();
7368 x = this.parseInt(e.style.left);
7369 y = this.parseInt(e.style.top);
7370 w = this.parseInt(e.offsetWidth);
7371 h = this.parseInt(e.offsetHeight);
7373 b.style.left = x + 'px';
7374 b.style.top = y + 'px';
7375 b.style.width = w + 'px';
7376 b.style.height = h + 'px';
7377 b.style.display = e.style.display;
7379 b.style.display = 'none';
7383 getBlocker : function() {
7386 if (!this.blockerElement && this.blockMode) {
7388 b = d.getElementById(this.id + "_blocker");
7391 b = d.createElement("iframe");
7393 b.setAttribute('id', this.id + "_blocker");
7394 b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
7395 b.src = 'javascript:false;';
7396 b.frameBorder = '0';
7399 d.body.appendChild(b);
7402 this.blockerElement = b;
7405 return this.blockerElement;
7408 getAbsPosition : function(n) {
7409 var p = {absLeft : 0, absTop : 0};
7412 p.absLeft += n.offsetLeft;
7413 p.absTop += n.offsetTop;
7420 create : function(n, c, p, h) {
7421 var d = this.doc, e = d.createElement(n);
7423 e.setAttribute('id', this.id);
7436 return this.element = e;
7439 exists : function() {
7440 return this.doc.getElementById(this.id) != null;
7443 parseInt : function(s) {
7444 if (s == null || s == '')
7450 remove : function() {
7451 var e = this.getElement(), b = this.getBlocker();
7454 e.parentNode.removeChild(e);
7457 b.parentNode.removeChild(b);
7462 /* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */
7464 function TinyMCE_Menu() {
7467 if (typeof(tinyMCE.menuCounter) == "undefined")
7468 tinyMCE.menuCounter = 0;
7470 id = "mc_menu_" + tinyMCE.menuCounter++;
7472 TinyMCE_Layer.call(this, id, true);
7476 this.needsUpdate = true;
7479 TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
7480 init : function(s) {
7485 separator_class : 'mceMenuSeparator',
7486 title_class : 'mceMenuTitle',
7487 disabled_class : 'mceMenuDisabled',
7488 menu_class : 'mceMenu',
7493 this.settings[n] = s[n];
7495 this.create('div', this.settings.menu_class);
7498 clear : function() {
7502 addTitle : function(t) {
7503 this.add({type : 'title', text : t});
7506 addDisabled : function(t) {
7507 this.add({type : 'disabled', text : t});
7510 addSeparator : function() {
7511 this.add({type : 'separator'});
7514 addItem : function(t, js) {
7515 this.add({text : t, js : js});
7518 add : function(mi) {
7519 this.items[this.items.length] = mi;
7520 this.needsUpdate = true;
7523 update : function() {
7524 var e = this.getElement(), h = '', i, t, m = this.items, s = this.settings;
7526 if (this.settings.drop_menu)
7527 h += '<span class="mceMenuLine"></span>';
7529 h += '<table border="0" cellpadding="0" cellspacing="0">';
7531 for (i=0; i<m.length; i++) {
7532 t = tinyMCE.xmlEncode(m[i].text);
7533 c = m[i].class_name ? ' class="' + m[i].class_name + '"' : '';
7535 switch (m[i].type) {
7537 h += '<tr class="' + s.separator_class + '"><td>';
7541 h += '<tr class="' + s.title_class + '"><td><span' + c +'>' + t + '</span>';
7545 h += '<tr class="' + s.disabled_class + '"><td><span' + c +'>' + t + '</span>';
7549 h += '<tr><td><a href="' + tinyMCE.xmlEncode(m[i].js) + '" onmousedown="' + tinyMCE.xmlEncode(m[i].js) + ';return tinyMCE.cancelEvent(event);" onclick="return tinyMCE.cancelEvent(event);" onmouseup="return tinyMCE.cancelEvent(event);"><span' + c +'>' + t + '</span></a>';
7559 this.needsUpdate = false;
7560 this.updateBlocker();
7566 if (tinyMCE.lastMenu == this)
7569 if (this.needsUpdate)
7572 if (tinyMCE.lastMenu && tinyMCE.lastMenu != this)
7573 tinyMCE.lastMenu.hide();
7575 TinyMCE_Layer.prototype.show.call(this);
7577 if (!tinyMCE.isOpera) {
7578 // Accessibility stuff
7579 /* nl = this.getElement().getElementsByTagName("a");
7584 tinyMCE.lastMenu = this;
7589 /* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
7591 tinyMCE.add(TinyMCE_Engine, {
7592 debug : function() {
7593 var m = "", a, i, l = tinyMCE.log.length;
7595 for (i=0, a = this.debug.arguments; i<a.length; i++) {
7603 tinyMCE.log[l] = "[debug] " + m;