2 /* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
\r
4 function TinyMCE_Engine() {
\r
7 this.majorVersion = "2";
\r
8 this.minorVersion = "1.1.1";
\r
9 this.releaseDate = "2007-05-14";
\r
11 this.instances = [];
\r
12 this.switchClassCache = [];
\r
13 this.windowArgs = [];
\r
14 this.loadedFiles = [];
\r
15 this.pendingFiles = [];
\r
16 this.loadingIndex = 0;
\r
18 this.currentConfig = 0;
\r
19 this.eventHandlers = [];
\r
21 this.undoLevels = [];
\r
23 this.typingUndoIndex = -1;
\r
27 ua = navigator.userAgent;
\r
28 this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
\r
29 this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
\r
30 this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
\r
31 this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1);
\r
32 this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari
\r
33 this.isSafari = ua.indexOf('Safari') != -1;
\r
34 this.isOpera = window['opera'] && opera.buildNumber ? true : false;
\r
35 this.isMac = ua.indexOf('Mac') != -1;
\r
36 this.isNS7 = ua.indexOf('Netscape/7') != -1;
\r
37 this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
\r
38 this.dialogCounter = 0;
\r
42 this.loadedPlugins = [];
\r
43 this.buttonMap = [];
\r
44 this.isLoaded = false;
\r
46 // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those
\r
49 this.isGecko = false;
\r
50 this.isSafari = false;
\r
53 this.isIE = this.isMSIE;
\r
54 this.isRealIE = this.isMSIE && !this.isOpera;
\r
56 // TinyMCE editor id instance counter
\r
60 TinyMCE_Engine.prototype = {
\r
61 init : function(settings) {
\r
62 var theme, nl, baseHREF = "", i, cssPath, entities, h, p, src, elements = [], head;
\r
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.
\r
68 this.settings = settings;
\r
70 // Check if valid browser has execcommand support
\r
71 if (typeof(document.execCommand) == 'undefined')
\r
74 // Get script base path
\r
75 if (!tinyMCE.baseURL) {
\r
76 // Search through head
\r
77 head = document.getElementsByTagName('head')[0];
\r
80 for (i=0, nl = head.getElementsByTagName('script'); i<nl.length; i++)
\r
81 elements.push(nl[i]);
\r
84 // Search through rest of document
\r
85 for (i=0, nl = document.getElementsByTagName('script'); i<nl.length; i++)
\r
86 elements.push(nl[i]);
\r
88 // If base element found, add that infront of baseURL
\r
89 nl = document.getElementsByTagName('base');
\r
90 for (i=0; i<nl.length; i++) {
\r
92 baseHREF = nl[i].href;
\r
95 for (i=0; i<elements.length; i++) {
\r
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)) {
\r
97 src = elements[i].src;
\r
99 tinyMCE.srcMode = (src.indexOf('_src') != -1 || src.indexOf('_dev') != -1) ? '_src' : '';
\r
100 tinyMCE.gzipMode = src.indexOf('_gzip') != -1;
\r
101 src = src.substring(0, src.lastIndexOf('/'));
\r
103 if (settings.exec_mode == "src" || settings.exec_mode == "normal")
\r
104 tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
\r
106 // Force it absolute if page has a base href
\r
107 if (baseHREF !== '' && src.indexOf('://') == -1)
\r
108 tinyMCE.baseURL = baseHREF + src;
\r
110 tinyMCE.baseURL = src;
\r
117 // Get document base path
\r
118 this.documentBasePath = document.location.href;
\r
119 if (this.documentBasePath.indexOf('?') != -1)
\r
120 this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));
\r
121 this.documentURL = this.documentBasePath;
\r
122 this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));
\r
124 // If not HTTP absolute
\r
125 if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {
\r
126 // If site absolute
\r
127 tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;
\r
130 // Set default values on settings
\r
131 this._def("mode", "none");
\r
132 this._def("theme", "advanced");
\r
133 this._def("plugins", "", true);
\r
134 this._def("language", "en");
\r
135 this._def("docs_language", this.settings.language);
\r
136 this._def("elements", "");
\r
137 this._def("textarea_trigger", "mce_editable");
\r
138 this._def("editor_selector", "");
\r
139 this._def("editor_deselector", "mceNoEditor");
\r
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]");
\r
141 this._def("extended_valid_elements", "");
\r
142 this._def("invalid_elements", "");
\r
143 this._def("encoding", "");
\r
144 this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL"));
\r
145 this._def("save_callback", "");
\r
146 this._def("force_br_newlines", false);
\r
147 this._def("force_p_newlines", true);
\r
148 this._def("add_form_submit_trigger", true);
\r
149 this._def("relative_urls", true);
\r
150 this._def("remove_script_host", true);
\r
151 this._def("focus_alert", true);
\r
152 this._def("document_base_url", this.documentURL);
\r
153 this._def("visual", true);
\r
154 this._def("visual_table_class", "mceVisualAid");
\r
155 this._def("setupcontent_callback", "");
\r
156 this._def("fix_content_duplication", true);
\r
157 this._def("custom_undo_redo", true);
\r
158 this._def("custom_undo_redo_levels", -1);
\r
159 this._def("custom_undo_redo_keyboard_shortcuts", true);
\r
160 this._def("custom_undo_redo_restore_selection", true);
\r
161 this._def("custom_undo_redo_global", false);
\r
162 this._def("verify_html", true);
\r
163 this._def("apply_source_formatting", false);
\r
164 this._def("directionality", "ltr");
\r
165 this._def("cleanup_on_startup", false);
\r
166 this._def("inline_styles", false);
\r
167 this._def("convert_newlines_to_brs", false);
\r
168 this._def("auto_reset_designmode", true);
\r
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);
\r
170 this._def("entity_encoding", "named");
\r
171 this._def("cleanup_callback", "");
\r
172 this._def("add_unload_trigger", true);
\r
173 this._def("ask", false);
\r
174 this._def("nowrap", false);
\r
175 this._def("auto_resize", false);
\r
176 this._def("auto_focus", false);
\r
177 this._def("cleanup", true);
\r
178 this._def("remove_linebreaks", true);
\r
179 this._def("button_tile_map", false);
\r
180 this._def("submit_patch", true);
\r
181 this._def("browsers", "msie,safari,gecko,opera", true);
\r
182 this._def("dialog_type", "window");
\r
183 this._def("accessibility_warnings", true);
\r
184 this._def("accessibility_focus", true);
\r
185 this._def("merge_styles_invalid_parents", "");
\r
186 this._def("force_hex_style_colors", true);
\r
187 this._def("trim_span_elements", true);
\r
188 this._def("convert_fonts_to_spans", false);
\r
189 this._def("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
\r
190 this._def("font_size_classes", '');
\r
191 this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true);
\r
192 this._def("event_elements", 'a,img', true);
\r
193 this._def("convert_urls", true);
\r
194 this._def("table_inline_editing", false);
\r
195 this._def("object_resizing", true);
\r
196 this._def("custom_shortcuts", true);
\r
197 this._def("convert_on_click", false);
\r
198 this._def("content_css", '');
\r
199 this._def("fix_list_elements", true);
\r
200 this._def("fix_table_elements", false);
\r
201 this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
\r
202 this._def("hidden_tab_class", '');
\r
203 this._def("display_tab_class", '');
\r
204 this._def("gecko_spellcheck", false);
\r
205 this._def("hide_selects_on_submit", true);
\r
206 this._def("forced_root_block", false);
\r
207 this._def("remove_trailing_nbsp", false);
\r
209 // Force strict loading mode to false on non Gecko browsers
\r
210 if (this.isMSIE && !this.isOpera)
\r
211 this.settings.strict_loading_mode = false;
\r
213 // Browser check IE
\r
214 if (this.isMSIE && this.settings.browsers.indexOf('msie') == -1)
\r
217 // Browser check Gecko
\r
218 if (this.isGecko && this.settings.browsers.indexOf('gecko') == -1)
\r
221 // Browser check Safari
\r
222 if (this.isSafari && this.settings.browsers.indexOf('safari') == -1)
\r
225 // Browser check Opera
\r
226 if (this.isOpera && this.settings.browsers.indexOf('opera') == -1)
\r
229 // If not super absolute make it so
\r
230 baseHREF = tinyMCE.settings.document_base_url;
\r
231 h = document.location.href;
\r
232 p = h.indexOf('://');
\r
233 if (p > 0 && document.location.protocol != "file:") {
\r
234 p = h.indexOf('/', p + 3);
\r
235 h = h.substring(0, p);
\r
237 if (baseHREF.indexOf('://') == -1)
\r
238 baseHREF = h + baseHREF;
\r
240 tinyMCE.settings.document_base_url = baseHREF;
\r
241 tinyMCE.settings.document_base_prefix = h;
\r
244 // Trim away query part
\r
245 if (baseHREF.indexOf('?') != -1)
\r
246 baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
\r
248 this.settings.base_href = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
\r
250 theme = this.settings.theme;
\r
251 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';
\r
252 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';
\r
253 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';
\r
254 this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
\r
255 this.posKeyCodes = [13,45,36,35,33,34,37,38,39,40];
\r
256 this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL
\r
257 this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
\r
258 this.callbacks = ['onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance'];
\r
261 this.settings.theme_href = tinyMCE.baseURL + "/themes/" + theme;
\r
263 if (!tinyMCE.isIE || tinyMCE.isOpera)
\r
264 this.settings.force_br_newlines = false;
\r
266 if (tinyMCE.getParam("popups_css", false)) {
\r
267 cssPath = tinyMCE.getParam("popups_css", "");
\r
270 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
\r
271 this.settings.popups_css = this.documentBasePath + "/" + cssPath;
\r
273 this.settings.popups_css = cssPath;
\r
275 this.settings.popups_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
\r
277 if (tinyMCE.getParam("editor_css", false)) {
\r
278 cssPath = tinyMCE.getParam("editor_css", "");
\r
281 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
\r
282 this.settings.editor_css = this.documentBasePath + "/" + cssPath;
\r
284 this.settings.editor_css = cssPath;
\r
286 if (this.settings.editor_css !== '')
\r
287 this.settings.editor_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
\r
290 // Only do this once
\r
291 if (this.configs.length == 0) {
\r
292 if (typeof(TinyMCECompressed) == "undefined") {
\r
293 tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
\r
295 if (tinyMCE.isRealIE) {
\r
297 tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
\r
299 tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad);
\r
302 tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad);
\r
303 tinyMCE._addUnloadEvents();
\r
307 this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings.theme + '/editor_template' + tinyMCE.srcMode + '.js');
\r
308 this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings.language + '.js');
\r
309 this.loadCSS(this.settings.editor_css);
\r
312 p = tinyMCE.getParam('plugins', '', true, ',');
\r
313 if (p.length > 0) {
\r
314 for (i=0; i<p.length; i++) {
\r
315 if (p[i].charAt(0) != '-')
\r
316 this.loadScript(tinyMCE.baseURL + '/plugins/' + p[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');
\r
321 if (tinyMCE.getParam('entity_encoding') == 'named') {
\r
322 settings.cleanup_entities = [];
\r
323 entities = tinyMCE.getParam('entities', '', true, ',');
\r
324 for (i=0; i<entities.length; i+=2)
\r
325 settings.cleanup_entities['c' + entities[i]] = entities[i+1];
\r
328 // Save away this config
\r
329 settings.index = this.configs.length;
\r
330 this.configs[this.configs.length] = settings;
\r
332 // Start loading first one in chain
\r
333 this.loadNextScript();
\r
335 // Force flicker free CSS backgrounds in IE
\r
336 if (this.isIE && !this.isOpera) {
\r
338 document.execCommand('BackgroundImageCache', false, true);
\r
344 // Setup XML encoding regexps
\r
345 this.xmlEncodeRe = new RegExp('[<>&"]', 'g');
\r
348 _addUnloadEvents : function() {
\r
349 var st = tinyMCE.settings.add_unload_trigger;
\r
351 if (tinyMCE.isIE) {
\r
353 tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
\r
354 tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler);
\r
358 tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);});
\r
362 _def : function(key, def_val, t) {
\r
363 var v = tinyMCE.getParam(key, def_val);
\r
365 v = t ? v.replace(/\s+/g, "") : v;
\r
367 this.settings[key] = v;
\r
370 hasPlugin : function(n) {
\r
371 return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
\r
374 addPlugin : function(n, p) {
\r
375 var op = this.plugins[n];
\r
377 // Use the previous plugin object base URL used when loading external plugins
\r
378 p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n;
\r
379 this.plugins[n] = p;
\r
381 this.loadNextScript();
\r
384 setPluginBaseURL : function(n, u) {
\r
385 var op = this.plugins[n];
\r
390 this.plugins[n] = {baseURL : u};
\r
393 loadPlugin : function(n, u) {
\r
394 u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u;
\r
395 u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u;
\r
396 this.plugins[n] = {baseURL : u};
\r
397 this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js");
\r
400 hasTheme : function(n) {
\r
401 return typeof(this.themes[n]) != "undefined" && this.themes[n] != null;
\r
404 addTheme : function(n, t) {
\r
405 this.themes[n] = t;
\r
407 this.loadNextScript();
\r
410 addMenu : function(n, m) {
\r
414 hasMenu : function(n) {
\r
415 return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
\r
418 loadScript : function(url) {
\r
421 for (i=0; i<this.loadedFiles.length; i++) {
\r
422 if (this.loadedFiles[i] == url)
\r
426 if (tinyMCE.settings.strict_loading_mode)
\r
427 this.pendingFiles[this.pendingFiles.length] = url;
\r
429 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
\r
431 this.loadedFiles[this.loadedFiles.length] = url;
\r
434 loadNextScript : function() {
\r
435 var d = document, se;
\r
437 if (!tinyMCE.settings.strict_loading_mode)
\r
440 if (this.loadingIndex < this.pendingFiles.length) {
\r
441 se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script');
\r
442 se.setAttribute('language', 'javascript');
\r
443 se.setAttribute('type', 'text/javascript');
\r
444 se.setAttribute('src', this.pendingFiles[this.loadingIndex++]);
\r
446 d.getElementsByTagName("head")[0].appendChild(se);
\r
448 this.loadingIndex = -1; // Done with loading
\r
451 loadCSS : function(url) {
\r
452 var ar = url.replace(/\s+/, '').split(',');
\r
453 var lflen = 0, csslen = 0, skip = false;
\r
454 var x = 0, i = 0, nl, le;
\r
456 for (x = 0,csslen = ar.length; x<csslen; x++) {
\r
457 if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) {
\r
458 /* Make sure it doesn't exist. */
\r
459 for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) {
\r
460 if (this.loadedFiles[i] == ar[x]) {
\r
467 if (tinyMCE.settings.strict_loading_mode) {
\r
468 nl = document.getElementsByTagName("head");
\r
470 le = document.createElement('link');
\r
471 le.setAttribute('href', ar[x]);
\r
472 le.setAttribute('rel', 'stylesheet');
\r
473 le.setAttribute('type', 'text/css');
\r
475 nl[0].appendChild(le);
\r
477 document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />');
\r
479 this.loadedFiles[this.loadedFiles.length] = ar[x];
\r
485 importCSS : function(doc, css) {
\r
486 var css_ary = css.replace(/\s+/, '').split(',');
\r
487 var csslen, elm, headArr, x, css_file;
\r
489 for (x = 0, csslen = css_ary.length; x<csslen; x++) {
\r
490 css_file = css_ary[x];
\r
492 if (css_file != null && css_file != 'null' && css_file.length > 0) {
\r
493 // Is relative, make absolute
\r
494 if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/')
\r
495 css_file = this.documentBasePath + "/" + css_file;
\r
497 if (typeof(doc.createStyleSheet) == "undefined") {
\r
498 elm = doc.createElement("link");
\r
500 elm.rel = "stylesheet";
\r
501 elm.href = css_file;
\r
503 if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
\r
504 headArr[0].appendChild(elm);
\r
506 doc.createStyleSheet(css_file);
\r
511 confirmAdd : function(e, settings) {
\r
512 var elm = tinyMCE.isIE ? event.srcElement : e.target;
\r
513 var elementId = elm.name ? elm.name : elm.id;
\r
515 tinyMCE.settings = settings;
\r
517 if (tinyMCE.settings.convert_on_click || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang.lang_edit_confirm)))
\r
518 tinyMCE.addMCEControl(elm, elementId);
\r
520 elm.setAttribute('mce_noask', 'true');
\r
523 updateContent : function(form_element_name) {
\r
524 var formElement, n, inst, doc;
\r
526 // Find MCE instance linked to given form element and copy it's value
\r
527 formElement = document.getElementById(form_element_name);
\r
528 for (n in tinyMCE.instances) {
\r
529 inst = tinyMCE.instances[n];
\r
531 if (!tinyMCE.isInstance(inst))
\r
534 inst.switchSettings();
\r
536 if (inst.formElement == formElement) {
\r
537 doc = inst.getDoc();
\r
539 tinyMCE._setHTML(doc, inst.formElement.value);
\r
542 doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
\r
547 addMCEControl : function(replace_element, form_element_name, target_document) {
\r
548 var id = "mce_editor_" + tinyMCE.idCounter++;
\r
549 var inst = new TinyMCE_Control(tinyMCE.settings);
\r
551 inst.editorId = id;
\r
552 this.instances[id] = inst;
\r
554 inst._onAdd(replace_element, form_element_name, target_document);
\r
557 removeInstance : function(ti) {
\r
560 // Remove from instances
\r
561 for (n in tinyMCE.instances) {
\r
562 i = tinyMCE.instances[n];
\r
564 if (tinyMCE.isInstance(i) && ti != i)
\r
568 tinyMCE.instances = t;
\r
570 // Remove from global undo/redo
\r
572 t = tinyMCE.undoLevels;
\r
574 for (i=0; i<t.length; i++) {
\r
579 tinyMCE.undoLevels = n;
\r
580 tinyMCE.undoIndex = n.length;
\r
582 // Dispatch remove instance call
\r
583 tinyMCE.dispatchCallback(ti, 'remove_instance_callback', 'removeInstance', ti);
\r
588 removeMCEControl : function(editor_id) {
\r
589 var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn;
\r
592 inst.switchSettings();
\r
594 editor_id = inst.editorId;
\r
595 h = tinyMCE.getContent(editor_id);
\r
597 this.removeInstance(inst);
\r
599 tinyMCE.selectedElement = null;
\r
600 tinyMCE.selectedInstance = null;
\r
603 re = document.getElementById(editor_id + "_parent");
\r
604 ot = inst.oldTargetElement;
\r
605 tn = ot.nodeName.toLowerCase();
\r
607 if (tn == "textarea" || tn == "input") {
\r
608 re.parentNode.removeChild(re);
\r
609 ot.style.display = "inline";
\r
613 ot.style.display = 'block';
\r
614 re.parentNode.insertBefore(ot, re);
\r
615 re.parentNode.removeChild(re);
\r
620 triggerSave : function(skip_cleanup, skip_callback) {
\r
623 // Default to false
\r
624 if (typeof(skip_cleanup) == "undefined")
\r
625 skip_cleanup = false;
\r
627 // Default to false
\r
628 if (typeof(skip_callback) == "undefined")
\r
629 skip_callback = false;
\r
631 // Cleanup and set all form fields
\r
632 for (n in tinyMCE.instances) {
\r
633 inst = tinyMCE.instances[n];
\r
635 if (!tinyMCE.isInstance(inst))
\r
638 inst.triggerSave(skip_cleanup, skip_callback);
\r
642 resetForm : function(form_index) {
\r
643 var i, inst, n, formObj = document.forms[form_index];
\r
645 for (n in tinyMCE.instances) {
\r
646 inst = tinyMCE.instances[n];
\r
648 if (!tinyMCE.isInstance(inst))
\r
651 inst.switchSettings();
\r
653 for (i=0; i<formObj.elements.length; i++) {
\r
654 if (inst.formTargetElementId == formObj.elements[i].name)
\r
655 inst.getBody().innerHTML = inst.startContent;
\r
660 execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
\r
661 var inst = tinyMCE.getInstanceById(editor_id), r;
\r
664 r = inst.selection.getRng();
\r
666 if (typeof(focus) == "undefined")
\r
669 // IE bug lost focus on images in absolute divs Bug #1534575
\r
670 if (focus && (!r || !r.item))
\r
671 inst.contentWindow.focus();
\r
673 // Reset design mode if lost
\r
674 inst.autoResetDesignMode();
\r
676 this.selectedElement = inst.getFocusElement();
\r
678 tinyMCE.execCommand(command, user_interface, value);
\r
680 // Cancel event so it doesn't call onbeforeonunlaod
\r
681 if (tinyMCE.isIE && window.event != null)
\r
682 tinyMCE.cancelEvent(window.event);
\r
686 execCommand : function(command, user_interface, value) {
\r
687 var inst = tinyMCE.selectedInstance, n, pe, te;
\r
690 user_interface = user_interface ? user_interface : false;
\r
691 value = value ? value : null;
\r
694 inst.switchSettings();
\r
698 if (this.getParam('custom_undo_redo_global')) {
\r
699 if (this.undoIndex > 0) {
\r
700 tinyMCE.nextUndoRedoAction = 'Undo';
\r
701 inst = this.undoLevels[--this.undoIndex];
\r
704 if (!tinyMCE.nextUndoRedoInstanceId)
\r
705 inst.execCommand('Undo');
\r
708 inst.execCommand('Undo');
\r
712 if (this.getParam('custom_undo_redo_global')) {
\r
713 if (this.undoIndex <= this.undoLevels.length - 1) {
\r
714 tinyMCE.nextUndoRedoAction = 'Redo';
\r
715 inst = this.undoLevels[this.undoIndex++];
\r
718 if (!tinyMCE.nextUndoRedoInstanceId)
\r
719 inst.execCommand('Redo');
\r
722 inst.execCommand('Redo');
\r
727 inst = tinyMCE.getInstanceById(value);
\r
730 inst.getWin().focus();
\r
733 case "mceAddControl":
\r
734 case "mceAddEditor":
\r
735 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
\r
738 case "mceAddFrameControl":
\r
739 tinyMCE.addMCEControl(tinyMCE._getElementById(value.element, value.document), value.element, value.document);
\r
742 case "mceRemoveControl":
\r
743 case "mceRemoveEditor":
\r
744 tinyMCE.removeMCEControl(value);
\r
747 case "mceToggleEditor":
\r
748 inst = tinyMCE.getInstanceById(value);
\r
751 pe = document.getElementById(inst.editorId + '_parent');
\r
752 te = inst.oldTargetElement;
\r
754 if (typeof(inst.enabled) == 'undefined')
\r
755 inst.enabled = true;
\r
757 inst.enabled = !inst.enabled;
\r
759 if (!inst.enabled) {
\r
760 pe.style.display = 'none';
\r
762 if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT')
\r
763 te.value = inst.getHTML();
\r
765 te.innerHTML = inst.getHTML();
\r
767 te.style.display = inst.oldTargetDisplay;
\r
768 tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst);
\r
770 pe.style.display = 'block';
\r
771 te.style.display = 'none';
\r
773 if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT')
\r
774 inst.setHTML(te.value);
\r
776 inst.setHTML(te.innerHTML);
\r
778 inst.useCSS = false;
\r
779 tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst);
\r
782 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
\r
786 case "mceResetDesignMode":
\r
787 // Resets the designmode state of the editors in Gecko
\r
788 if (tinyMCE.isGecko) {
\r
789 for (n in tinyMCE.instances) {
\r
790 if (!tinyMCE.isInstance(tinyMCE.instances[n]))
\r
794 tinyMCE.instances[n].getDoc().designMode = "off";
\r
795 tinyMCE.instances[n].getDoc().designMode = "on";
\r
796 tinyMCE.instances[n].useCSS = false;
\r
798 // Ignore any errors
\r
807 inst.execCommand(command, user_interface, value);
\r
808 } else if (tinyMCE.settings.focus_alert)
\r
809 alert(tinyMCELang.lang_focus_alert);
\r
812 _createIFrame : function(replace_element, doc, win) {
\r
813 var iframe, id = replace_element.getAttribute("id");
\r
816 if (typeof(doc) == "undefined")
\r
819 if (typeof(win) == "undefined")
\r
822 iframe = doc.createElement("iframe");
\r
824 aw = "" + tinyMCE.settings.area_width;
\r
825 ah = "" + tinyMCE.settings.area_height;
\r
827 if (aw.indexOf('%') == -1) {
\r
829 aw = (isNaN(aw) || aw < 0) ? 300 : aw;
\r
833 if (ah.indexOf('%') == -1) {
\r
835 ah = (isNaN(ah) || ah < 0) ? 240 : ah;
\r
839 iframe.setAttribute("id", id);
\r
840 iframe.setAttribute("name", id);
\r
841 iframe.setAttribute("class", "mceEditorIframe");
\r
842 iframe.setAttribute("border", "0");
\r
843 iframe.setAttribute("frameBorder", "0");
\r
844 iframe.setAttribute("marginWidth", "0");
\r
845 iframe.setAttribute("marginHeight", "0");
\r
846 iframe.setAttribute("leftMargin", "0");
\r
847 iframe.setAttribute("topMargin", "0");
\r
848 iframe.setAttribute("width", aw);
\r
849 iframe.setAttribute("height", ah);
\r
850 iframe.setAttribute("allowtransparency", "true");
\r
851 iframe.className = 'mceEditorIframe';
\r
853 if (tinyMCE.settings.auto_resize)
\r
854 iframe.setAttribute("scrolling", "no");
\r
856 // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
\r
857 if (tinyMCE.isRealIE)
\r
858 iframe.setAttribute("src", this.settings.default_document);
\r
860 iframe.style.width = aw;
\r
861 iframe.style.height = ah;
\r
863 // Ugly hack for Gecko problem in strict mode
\r
864 if (tinyMCE.settings.strict_loading_mode)
\r
865 iframe.style.marginBottom = '-5px';
\r
868 if (tinyMCE.isRealIE)
\r
869 replace_element.outerHTML = iframe.outerHTML;
\r
871 replace_element.parentNode.replaceChild(iframe, replace_element);
\r
873 if (tinyMCE.isRealIE)
\r
874 return win.frames[id];
\r
879 setupContent : function(editor_id) {
\r
880 var inst = tinyMCE.instances[editor_id], i, doc = inst.getDoc(), head = doc.getElementsByTagName('head').item(0);
\r
881 var content = inst.startContent, contentElement, body;
\r
883 // HTML values get XML encoded in strict mode
\r
884 if (tinyMCE.settings.strict_loading_mode) {
\r
885 content = content.replace(/</g, '<');
\r
886 content = content.replace(/>/g, '>');
\r
887 content = content.replace(/"/g, '"');
\r
888 content = content.replace(/&/g, '&');
\r
891 tinyMCE.selectedInstance = inst;
\r
892 inst.switchSettings();
\r
894 // Not loaded correctly hit it again, Mozilla bug #997860
\r
895 if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
\r
896 // This part will remove the designMode status
\r
897 // Failes first time in Firefox 1.5b2 on Mac
\r
898 try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
\r
899 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);
\r
903 // Wait for it to load
\r
904 if (!head || !doc.body) {
\r
905 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);
\r
909 // Import theme specific content CSS the user specific
\r
910 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings.theme + "/css/editor_content.css");
\r
911 tinyMCE.importCSS(inst.getDoc(), inst.settings.content_css);
\r
912 tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst);
\r
914 // Setup keyboard shortcuts
\r
915 if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) {
\r
916 inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo');
\r
917 inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
\r
920 // BlockFormat shortcuts keys
\r
921 for (i=1; i<=6; i++)
\r
922 inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, '<h' + i + '>');
\r
924 inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '<p>');
\r
925 inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '<div>');
\r
926 inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '<address>');
\r
928 // Add default shortcuts for gecko
\r
929 if (tinyMCE.isGecko) {
\r
930 inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
\r
931 inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic');
\r
932 inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline');
\r
935 // Setup span styles
\r
936 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
937 inst.getBody().setAttribute('id', 'mceSpanFonts');
\r
939 if (tinyMCE.settings.nowrap)
\r
940 doc.body.style.whiteSpace = "nowrap";
\r
942 doc.body.dir = this.settings.directionality;
\r
943 doc.editorId = editor_id;
\r
945 // Add on document element in Mozilla
\r
947 doc.documentElement.editorId = editor_id;
\r
949 inst.setBaseHREF(tinyMCE.settings.base_href);
\r
951 // Replace new line characters to BRs
\r
952 if (tinyMCE.settings.convert_newlines_to_brs) {
\r
953 content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
\r
954 content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
\r
955 content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
\r
958 // Open closed anchors
\r
959 // content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
\r
961 // Call custom cleanup code
\r
962 content = tinyMCE.storeAwayURLs(content);
\r
963 content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
\r
965 if (tinyMCE.isIE) {
\r
967 window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
\r
969 if (tinyMCE.settings.force_br_newlines)
\r
970 doc.styleSheets[0].addRule("p", "margin: 0;");
\r
972 body = inst.getBody();
\r
973 body.editorId = editor_id;
\r
976 content = tinyMCE.cleanupHTMLCode(content);
\r
978 // Fix for bug #958637
\r
979 if (!tinyMCE.isIE) {
\r
980 contentElement = inst.getDoc().createElement("body");
\r
981 doc = inst.getDoc();
\r
983 contentElement.innerHTML = content;
\r
985 if (tinyMCE.settings.cleanup_on_startup)
\r
986 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
\r
988 tinyMCE.setInnerHTML(inst.getBody(), content);
\r
990 tinyMCE.convertAllRelativeURLs(inst.getBody());
\r
992 if (tinyMCE.settings.cleanup_on_startup) {
\r
993 tinyMCE._setHTML(inst.getDoc(), content);
\r
995 // Produces permission denied error in MSIE 5.5
\r
997 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));
\r
1002 tinyMCE._setHTML(inst.getDoc(), content);
\r
1005 // Fix for bug #957681
\r
1006 //inst.getDoc().designMode = inst.getDoc().designMode;
\r
1008 tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings.visual, inst);
\r
1009 tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
\r
1011 // Re-add design mode on mozilla
\r
1012 if (!tinyMCE.isIE)
\r
1013 tinyMCE.addEventHandlers(inst);
\r
1015 // Add blur handler
\r
1016 if (tinyMCE.isIE) {
\r
1017 tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
\r
1018 tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
\r
1020 // Workaround for drag drop/copy paste base href bug
\r
1021 if (!tinyMCE.isOpera) {
\r
1022 tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove);
\r
1023 tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch);
\r
1024 tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch);
\r
1028 // Trigger node change, this call locks buttons for tables and so forth
\r
1030 tinyMCE.selectedElement = inst.contentWindow.document.body;
\r
1032 // Call custom DOM cleanup
\r
1033 tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
\r
1034 tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
\r
1035 tinyMCE._setEventsEnabled(inst.getBody(), false);
\r
1036 tinyMCE.cleanupAnchors(inst.getDoc());
\r
1038 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
1039 tinyMCE.convertSpansToFonts(inst.getDoc());
\r
1041 inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
\r
1042 inst.undoRedo.add({ content : inst.startContent });
\r
1044 // Cleanup any mess left from storyAwayURLs
\r
1045 if (tinyMCE.isGecko) {
\r
1046 // Remove mce_src from textnodes and comments
\r
1047 tinyMCE.selectNodes(inst.getBody(), function(n) {
\r
1048 if (n.nodeType == 3 || n.nodeType == 8)
\r
1049 n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
\r
1055 // Remove Gecko spellchecking
\r
1056 if (tinyMCE.isGecko)
\r
1057 inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck");
\r
1059 // Cleanup any mess left from storyAwayURLs
\r
1060 tinyMCE._removeInternal(inst.getBody());
\r
1063 tinyMCE.triggerNodeChange(false, true);
\r
1066 storeAwayURLs : function(s) {
\r
1067 // Remove all mce_src, mce_href and replace them with new ones
\r
1068 // s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
\r
1069 // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
\r
1071 if (!s.match(/(mce_src|mce_href)/gi, s)) {
\r
1072 s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"');
\r
1073 s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"');
\r
1079 _removeInternal : function(n) {
\r
1080 if (tinyMCE.isGecko) {
\r
1081 // Remove mce_src from textnodes and comments
\r
1082 tinyMCE.selectNodes(n, function(n) {
\r
1083 if (n.nodeType == 3 || n.nodeType == 8)
\r
1084 n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
\r
1091 removeTinyMCEFormElements : function(form_obj) {
\r
1094 // Skip form element removal
\r
1095 if (!tinyMCE.getParam('hide_selects_on_submit'))
\r
1098 // Check if form is valid
\r
1099 if (typeof(form_obj) == "undefined" || form_obj == null)
\r
1102 // If not a form, find the form
\r
1103 if (form_obj.nodeName != "FORM") {
\r
1104 if (form_obj.form)
\r
1105 form_obj = form_obj.form;
\r
1107 form_obj = tinyMCE.getParentElement(form_obj, "form");
\r
1111 if (form_obj == null)
\r
1114 // Disable all UI form elements that TinyMCE created
\r
1115 for (i=0; i<form_obj.elements.length; i++) {
\r
1116 elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
\r
1118 if (elementId.indexOf('mce_editor_') == 0)
\r
1119 form_obj.elements[i].disabled = true;
\r
1123 handleEvent : function(e) {
\r
1124 var inst = tinyMCE.selectedInstance, i, elm, keys;
\r
1126 // Remove odd, error
\r
1127 if (typeof(tinyMCE) == "undefined")
\r
1130 //tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""));
\r
1132 if (tinyMCE.executeCallback(tinyMCE.selectedInstance, 'handle_event_callback', 'handleEvent', e))
\r
1136 case "beforedeactivate": // Was added due to bug #1439953
\r
1138 if (tinyMCE.selectedInstance)
\r
1139 tinyMCE.selectedInstance.execCommand('mceEndTyping');
\r
1141 tinyMCE.hideMenus();
\r
1145 // Workaround for drag drop/copy paste base href bug
\r
1147 case "beforepaste":
\r
1148 if (tinyMCE.selectedInstance)
\r
1149 tinyMCE.selectedInstance.setBaseHREF(null);
\r
1151 // Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks
\r
1152 // This logic forces the width/height to be in pixels while the user is drag/dropping
\r
1153 if (tinyMCE.isRealIE) {
\r
1154 var ife = tinyMCE.selectedInstance.iframeElement;
\r
1156 /*if (ife.style.width.indexOf('%') != -1) {
\r
1157 ife._oldWidth = ife.width.height;
\r
1158 ife.style.width = ife.clientWidth;
\r
1161 if (ife.style.height.indexOf('%') != -1) {
\r
1162 ife._oldHeight = ife.style.height;
\r
1163 ife.style.height = ife.clientHeight;
\r
1167 window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings.base_href);tinyMCE._resetIframeHeight();", 1);
\r
1171 tinyMCE.formSubmit(tinyMCE.isMSIE ? window.event.srcElement : e.target);
\r
1175 var formObj = tinyMCE.isIE ? window.event.srcElement : e.target;
\r
1177 for (i=0; i<document.forms.length; i++) {
\r
1178 if (document.forms[i] == formObj)
\r
1179 window.setTimeout('tinyMCE.resetForm(' + i + ');', 10);
\r
1185 if (inst && inst.handleShortcut(e))
\r
1188 if (e.target.editorId) {
\r
1189 tinyMCE.instances[e.target.editorId].select();
\r
1191 if (e.target.ownerDocument.editorId)
\r
1192 tinyMCE.instances[e.target.ownerDocument.editorId].select();
\r
1195 if (tinyMCE.selectedInstance)
\r
1196 tinyMCE.selectedInstance.switchSettings();
\r
1198 // Insert P element
\r
1199 if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings.force_p_newlines && e.keyCode == 13 && !e.shiftKey) {
\r
1200 // Insert P element instead of BR
\r
1201 if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) {
\r
1203 tinyMCE.execCommand("mceAddUndoLevel");
\r
1204 return tinyMCE.cancelEvent(e);
\r
1208 // Handle backspace
\r
1209 if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
\r
1210 // Insert P element instead of BR
\r
1211 if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
\r
1213 tinyMCE.execCommand("mceAddUndoLevel");
\r
1214 return tinyMCE.cancelEvent(e);
\r
1218 // Return key pressed
\r
1219 if (tinyMCE.isIE && tinyMCE.settings.force_br_newlines && e.keyCode == 13) {
\r
1220 if (e.target.editorId)
\r
1221 tinyMCE.instances[e.target.editorId].select();
\r
1223 if (tinyMCE.selectedInstance) {
\r
1224 var sel = tinyMCE.selectedInstance.getDoc().selection;
\r
1225 var rng = sel.createRange();
\r
1227 if (tinyMCE.getParentElement(rng.parentElement(), "li") != null)
\r
1231 e.returnValue = false;
\r
1232 e.cancelBubble = true;
\r
1234 // Insert BR element
\r
1235 rng.pasteHTML("<br />");
\r
1236 rng.collapse(false);
\r
1239 tinyMCE.execCommand("mceAddUndoLevel");
\r
1240 tinyMCE.triggerNodeChange(false);
\r
1245 // Backspace or delete
\r
1246 if (e.keyCode == 8 || e.keyCode == 46) {
\r
1247 tinyMCE.selectedElement = e.target;
\r
1248 tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
\r
1249 tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
\r
1250 tinyMCE.triggerNodeChange(false);
\r
1257 tinyMCE.hideMenus();
\r
1258 tinyMCE.hasMouseMoved = false;
\r
1260 if (inst && inst.handleShortcut(e))
\r
1263 inst._fixRootBlocks();
\r
1265 if (inst.settings.remove_trailing_nbsp)
\r
1266 inst._fixTrailingNbsp();
\r
1268 if (e.target.editorId)
\r
1269 tinyMCE.instances[e.target.editorId].select();
\r
1271 if (tinyMCE.selectedInstance)
\r
1272 tinyMCE.selectedInstance.switchSettings();
\r
1274 inst = tinyMCE.selectedInstance;
\r
1276 // Handle backspace
\r
1277 if (tinyMCE.isGecko && tinyMCE.settings.force_p_newlines && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
\r
1278 // Insert P element instead of BR
\r
1279 if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
\r
1281 tinyMCE.execCommand("mceAddUndoLevel");
\r
1282 e.preventDefault();
\r
1287 tinyMCE.selectedElement = null;
\r
1288 tinyMCE.selectedNode = null;
\r
1289 elm = tinyMCE.selectedInstance.getFocusElement();
\r
1290 tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
\r
1291 tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
\r
1292 tinyMCE.selectedElement = elm;
\r
1294 // Update visualaids on tabs
\r
1295 if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
\r
1296 tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings.visual, tinyMCE.selectedInstance);
\r
1298 // Fix empty elements on return/enter, check where enter occured
\r
1299 if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13)
\r
1300 tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
\r
1302 // Fix empty elements on return/enter
\r
1303 if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) {
\r
1304 elm = tinyMCE.enterKeyElement;
\r
1306 var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
\r
1307 var dre = new RegExp('^H[1-6]$','g'); // Add double on these
\r
1309 if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
\r
1310 if (dre.test(elm.nodeName))
\r
1311 elm.innerHTML = " ";
\r
1313 elm.innerHTML = " ";
\r
1318 // Check if it's a position key
\r
1319 keys = tinyMCE.posKeyCodes;
\r
1320 var posKey = false;
\r
1321 for (i=0; i<keys.length; i++) {
\r
1322 if (keys[i] == e.keyCode) {
\r
1328 // MSIE custom key handling
\r
1329 if (tinyMCE.isIE && tinyMCE.settings.custom_undo_redo) {
\r
1330 keys = [8, 46]; // Backspace,Delete
\r
1332 for (i=0; i<keys.length; i++) {
\r
1333 if (keys[i] == e.keyCode) {
\r
1334 if (e.type == "keyup")
\r
1335 tinyMCE.triggerNodeChange(false);
\r
1341 if (e.keyCode == 17)
\r
1344 // Handle Undo/Redo when typing content
\r
1346 if (tinyMCE.isGecko) {
\r
1347 // Start typing (not a position key or ctrl key, but ctrl+x and ctrl+p is ok)
\r
1348 if (!posKey && e.type == "keyup" && !e.ctrlKey || (e.ctrlKey && (e.keyCode == 86 || e.keyCode == 88)))
\r
1349 tinyMCE.execCommand("mceStartTyping");
\r
1351 // IE seems to be working better with this setting
\r
1352 if (!posKey && e.type == "keyup")
\r
1353 tinyMCE.execCommand("mceStartTyping");
\r
1356 // Store undo bookmark
\r
1357 if (e.type == "keydown" && (posKey || e.ctrlKey) && inst)
\r
1358 inst.undoBookmark = inst.selection.getBookmark();
\r
1360 // End typing (position key) or some Ctrl event
\r
1361 if (e.type == "keyup" && (posKey || e.ctrlKey))
\r
1362 tinyMCE.execCommand("mceEndTyping");
\r
1364 if (posKey && e.type == "keyup")
\r
1365 tinyMCE.triggerNodeChange(false);
\r
1367 if (tinyMCE.isIE && e.ctrlKey)
\r
1368 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
\r
1376 tinyMCE.hideMenus();
\r
1378 if (tinyMCE.selectedInstance) {
\r
1379 tinyMCE.selectedInstance.switchSettings();
\r
1380 tinyMCE.selectedInstance.isFocused = true;
\r
1383 // Check instance event trigged on
\r
1384 var targetBody = tinyMCE.getParentElement(e.target, "html");
\r
1385 for (var instanceName in tinyMCE.instances) {
\r
1386 if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
\r
1389 inst = tinyMCE.instances[instanceName];
\r
1391 // Reset design mode if lost (on everything just in case)
\r
1392 inst.autoResetDesignMode();
\r
1394 // Use HTML element since users might click outside of body element
\r
1395 if (inst.getBody().parentNode == targetBody) {
\r
1397 tinyMCE.selectedElement = e.target;
\r
1398 tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
\r
1399 tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
\r
1404 // Add first bookmark location
\r
1405 if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark && (e.type == "mouseup" || e.type == "dblclick"))
\r
1406 tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
\r
1408 // Reset selected node
\r
1409 if (e.type != "focus")
\r
1410 tinyMCE.selectedNode = null;
\r
1412 tinyMCE.triggerNodeChange(false);
\r
1413 tinyMCE.execCommand("mceEndTyping");
\r
1415 if (e.type == "mouseup")
\r
1416 tinyMCE.execCommand("mceAddUndoLevel");
\r
1419 if (!tinyMCE.selectedInstance && e.target.editorId)
\r
1420 tinyMCE.instances[e.target.editorId].select();
\r
1426 getButtonHTML : function(id, lang, img, cmd, ui, val) {
\r
1427 var h = '', m, x, io = '';
\r
1429 cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
\r
1431 if (typeof(ui) != "undefined" && ui != null)
\r
1434 if (typeof(val) != "undefined" && val != null)
\r
1435 cmd += ",'" + val + "'";
\r
1439 // Patch for IE7 bug with hover out not restoring correctly
\r
1440 if (tinyMCE.isRealIE)
\r
1441 io = 'onmouseover="tinyMCE.lastHover = this;"';
\r
1443 // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
\r
1444 if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
\r
1446 x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
\r
1447 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceTiledButton mceButtonNormal" target="_self">';
\r
1448 h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" alt="{$'+lang+'}" title="{$' + lang + '}" />';
\r
1452 h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">';
\r
1453 h += '<img src="' + img + '" alt="{$'+lang+'}" title="{$' + lang + '}" />';
\r
1460 getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) {
\r
1463 mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');';
\r
1464 cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
\r
1466 if (typeof(ui) != "undefined" && ui != null)
\r
1469 if (typeof(val) != "undefined" && val != null)
\r
1470 cmd += ",'" + val + "'";
\r
1474 // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
\r
1475 if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
\r
1476 x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
\r
1478 if (tinyMCE.isRealIE)
\r
1479 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
\r
1481 h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
\r
1483 h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceMenuButtonNormal" target="_self">';
\r
1484 h += '<img src="{$themeurl}/images/spacer.gif" style="width: 20px; height: 20px; background-position: ' + x + 'px 0" title="{$' + lang + '}" /></a>';
\r
1485 h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
\r
1486 h += '</a></span>';
\r
1488 if (tinyMCE.isRealIE)
\r
1489 h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
\r
1491 h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">';
\r
1493 h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
\r
1494 h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
\r
1495 h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
\r
1496 h += '</a></span>';
\r
1502 _menuButtonEvent : function(e, o) {
\r
1503 if (o.className == 'mceMenuButtonFocus')
\r
1507 o.className = o.className + ' mceMenuHover';
\r
1509 o.className = o.className.replace(/\s.*$/, '');
\r
1512 addButtonMap : function(m) {
\r
1513 var i, a = m.replace(/\s+/, '').split(',');
\r
1515 for (i=0; i<a.length; i++)
\r
1516 this.buttonMap[a[i]] = i;
\r
1519 formSubmit : function(f, p) {
\r
1520 var n, inst, found = false;
\r
1525 // Is it a form that has a TinyMCE instance
\r
1526 for (n in tinyMCE.instances) {
\r
1527 inst = tinyMCE.instances[n];
\r
1529 if (!tinyMCE.isInstance(inst))
\r
1532 if (inst.formElement) {
\r
1533 if (f == inst.formElement.form) {
\r
1535 inst.isNotDirty = true;
\r
1542 tinyMCE.removeTinyMCEFormElements(f);
\r
1543 tinyMCE.triggerSave();
\r
1547 if (f.mceOldSubmit && p)
\r
1551 submitPatch : function() {
\r
1552 tinyMCE.formSubmit(this, true);
\r
1555 onLoad : function() {
\r
1556 var r, i, c, mode, trigger, elements, element, settings, elementId, elm;
\r
1557 var selector, deselector, elementRefAr, form;
\r
1559 // Wait for everything to be loaded first
\r
1560 if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) {
\r
1561 window.setTimeout('tinyMCE.onLoad();', 1);
\r
1565 if (tinyMCE.isRealIE && window.event.type == "readystatechange" && document.readyState != "complete")
\r
1568 if (tinyMCE.isLoaded)
\r
1571 tinyMCE.isLoaded = true;
\r
1573 // IE produces JS error if TinyMCE is placed in a frame
\r
1574 // It seems to have something to do with the selection not beeing
\r
1575 // correctly initialized in IE so this hack solves the problem
\r
1576 if (tinyMCE.isRealIE && document.body && window.location.href != window.top.location.href) {
\r
1577 r = document.body.createTextRange();
\r
1582 tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad');
\r
1584 for (c=0; c<tinyMCE.configs.length; c++) {
\r
1585 tinyMCE.settings = tinyMCE.configs[c];
\r
1587 selector = tinyMCE.getParam("editor_selector");
\r
1588 deselector = tinyMCE.getParam("editor_deselector");
\r
1589 elementRefAr = [];
\r
1591 // Add submit triggers
\r
1592 if (document.forms && tinyMCE.settings.add_form_submit_trigger && !tinyMCE.submitTriggers) {
\r
1593 for (i=0; i<document.forms.length; i++) {
\r
1594 form = document.forms[i];
\r
1596 tinyMCE.addEvent(form, "submit", TinyMCE_Engine.prototype.handleEvent);
\r
1597 tinyMCE.addEvent(form, "reset", TinyMCE_Engine.prototype.handleEvent);
\r
1598 tinyMCE.submitTriggers = true; // Do it only once
\r
1600 // Patch the form.submit function
\r
1601 if (tinyMCE.settings.submit_patch) {
\r
1603 form.mceOldSubmit = form.submit;
\r
1604 form.submit = TinyMCE_Engine.prototype.submitPatch;
\r
1612 // Add editor instances based on mode
\r
1613 mode = tinyMCE.settings.mode;
\r
1616 elements = tinyMCE.getParam('elements', '', true, ',');
\r
1618 for (i=0; i<elements.length; i++) {
\r
1619 element = tinyMCE._getElementById(elements[i]);
\r
1620 trigger = element ? element.getAttribute(tinyMCE.settings.textarea_trigger) : "";
\r
1622 if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class")))
\r
1625 if (trigger == "false")
\r
1628 if ((tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) && element) {
\r
1629 elementRefAr[elementRefAr.length] = element;
\r
1634 tinyMCE.addMCEControl(element, elements[i]);
\r
1638 case "specific_textareas":
\r
1640 elements = document.getElementsByTagName("textarea");
\r
1642 for (i=0; i<elements.length; i++) {
\r
1643 elm = elements.item(i);
\r
1644 trigger = elm.getAttribute(tinyMCE.settings.textarea_trigger);
\r
1646 if (selector !== '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
\r
1649 if (selector !== '')
\r
1650 trigger = selector !== '' ? "true" : "";
\r
1652 if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
\r
1655 if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))
\r
1656 elementRefAr[elementRefAr.length] = elm;
\r
1661 for (i=0; i<elementRefAr.length; i++) {
\r
1662 element = elementRefAr[i];
\r
1663 elementId = element.name ? element.name : element.id;
\r
1665 if (tinyMCE.settings.ask || tinyMCE.settings.convert_on_click) {
\r
1666 // Focus breaks in Mozilla
\r
1667 if (tinyMCE.isGecko) {
\r
1668 settings = tinyMCE.settings;
\r
1670 tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
\r
1672 if (element.nodeName != "TEXTAREA" && element.nodeName != "INPUT")
\r
1673 tinyMCE.addEvent(element, "click", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
\r
1674 // tinyMCE.addEvent(element, "mouseover", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
\r
1676 settings = tinyMCE.settings;
\r
1678 tinyMCE.addEvent(element, "focus", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
\r
1679 tinyMCE.addEvent(element, "click", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
\r
1680 // tinyMCE.addEvent(element, "mouseenter", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
\r
1683 tinyMCE.addMCEControl(element, elementId);
\r
1686 // Handle auto focus
\r
1687 if (tinyMCE.settings.auto_focus) {
\r
1688 window.setTimeout(function () {
\r
1689 var inst = tinyMCE.getInstanceById(tinyMCE.settings.auto_focus);
\r
1690 inst.selection.selectNode(inst.getBody(), true, true);
\r
1691 inst.contentWindow.focus();
\r
1695 tinyMCE.dispatchCallback(null, 'oninit', 'onInit');
\r
1699 isInstance : function(o) {
\r
1700 return o != null && typeof(o) == "object" && o.isTinyMCE_Control;
\r
1703 getParam : function(name, default_value, strip_whitespace, split_chr) {
\r
1704 var i, outArray, value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
\r
1706 // Fix bool values
\r
1707 if (value == "true" || value == "false")
\r
1708 return (value == "true");
\r
1710 if (strip_whitespace)
\r
1711 value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "");
\r
1713 if (typeof(split_chr) != "undefined" && split_chr != null) {
\r
1714 value = value.split(split_chr);
\r
1717 for (i=0; i<value.length; i++) {
\r
1718 if (value[i] && value[i] !== '')
\r
1719 outArray[outArray.length] = value[i];
\r
1728 getLang : function(name, default_value, parse_entities, va) {
\r
1729 var v = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name], n;
\r
1731 if (parse_entities)
\r
1732 v = tinyMCE.entityDecode(v);
\r
1736 v = this.replaceVar(v, n, va[n]);
\r
1742 entityDecode : function(s) {
\r
1743 var e = document.createElement("div");
\r
1747 return !e.firstChild ? s : e.firstChild.nodeValue;
\r
1750 addToLang : function(prefix, ar) {
\r
1754 if (typeof(ar[k]) == 'function')
\r
1757 tinyMCELang[(k.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix !== '' ? (prefix + "_") : '') + k] = ar[k];
\r
1760 this.loadNextScript();
\r
1763 triggerNodeChange : function(focus, setup_content) {
\r
1764 var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st;
\r
1766 if (tinyMCE.selectedInstance) {
\r
1767 inst = tinyMCE.selectedInstance;
\r
1768 elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
\r
1770 /* if (elm == inst.lastTriggerEl)
\r
1773 inst.lastTriggerEl = elm;*/
\r
1775 editorId = inst.editorId;
\r
1776 st = inst.selection.getSelectedText();
\r
1778 if (tinyMCE.settings.auto_resize)
\r
1779 inst.resizeToContent();
\r
1781 if (setup_content && tinyMCE.isGecko && inst.isHidden())
\r
1782 elm = inst.getBody();
\r
1784 inst.switchSettings();
\r
1786 if (tinyMCE.selectedElement)
\r
1787 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0);
\r
1789 if (tinyMCE.settings.custom_undo_redo) {
\r
1790 undoIndex = inst.undoRedo.undoIndex;
\r
1791 undoLevels = inst.undoRedo.undoLevels.length;
\r
1794 tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
\r
1797 if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
\r
1798 this.selectedInstance.contentWindow.focus();
\r
1801 _customCleanup : function(inst, type, content) {
\r
1802 var pl, po, i, customCleanup;
\r
1804 // Call custom cleanup
\r
1805 customCleanup = tinyMCE.settings.cleanup_callback;
\r
1806 if (customCleanup != '')
\r
1807 content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst);
\r
1809 // Trigger theme cleanup
\r
1810 po = tinyMCE.themes[tinyMCE.settings.theme];
\r
1811 if (po && po.cleanup)
\r
1812 content = po.cleanup(type, content, inst);
\r
1814 // Trigger plugin cleanups
\r
1815 pl = inst.plugins;
\r
1816 for (i=0; i<pl.length; i++) {
\r
1817 po = tinyMCE.plugins[pl[i]];
\r
1819 if (po && po.cleanup)
\r
1820 content = po.cleanup(type, content, inst);
\r
1826 setContent : function(h) {
\r
1827 if (tinyMCE.selectedInstance) {
\r
1828 tinyMCE.selectedInstance.execCommand('mceSetContent', false, h);
\r
1829 tinyMCE.selectedInstance.repaint();
\r
1833 importThemeLanguagePack : function(name) {
\r
1834 if (typeof(name) == "undefined")
\r
1835 name = tinyMCE.settings.theme;
\r
1837 tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings.language + '.js');
\r
1840 importPluginLanguagePack : function(name) {
\r
1841 var b = tinyMCE.baseURL + '/plugins/' + name;
\r
1843 if (this.plugins[name])
\r
1844 b = this.plugins[name].baseURL;
\r
1846 tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings.language + '.js');
\r
1849 applyTemplate : function(h, ag) {
\r
1850 return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) {
\r
1851 if (s.indexOf('lang_') == 0 && tinyMCELang[s])
\r
1852 return tinyMCELang[s];
\r
1857 if (tinyMCE.settings[s])
\r
1858 return tinyMCE.settings[s];
\r
1860 if (m == 'themeurl')
\r
1861 return tinyMCE.themeURL;
\r
1867 replaceVar : function(h, r, v) {
\r
1868 return h.replace(new RegExp('{\\\$' + r + '}', 'g'), v);
\r
1871 openWindow : function(template, args) {
\r
1872 var html, width, height, x, y, resizable, scrollbars, url, name, win, modal, features;
\r
1874 args = !args ? {} : args;
\r
1876 args.mce_template_file = template.file;
\r
1877 args.mce_width = template.width;
\r
1878 args.mce_height = template.height;
\r
1879 tinyMCE.windowArgs = args;
\r
1881 html = template.html;
\r
1882 if (!(width = parseInt(template.width)))
\r
1885 if (!(height = parseInt(template.height)))
\r
1888 // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
\r
1894 x = parseInt(screen.width / 2.0) - (width / 2.0);
\r
1895 y = parseInt(screen.height / 2.0) - (height / 2.0);
\r
1897 resizable = (args && args.resizable) ? args.resizable : "no";
\r
1898 scrollbars = (args && args.scrollbars) ? args.scrollbars : "no";
\r
1900 if (template.file.charAt(0) != '/' && template.file.indexOf('://') == -1)
\r
1901 url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template.file;
\r
1903 url = template.file;
\r
1905 // Replace all args as variables in URL
\r
1906 for (name in args) {
\r
1907 if (typeof(args[name]) == 'function')
\r
1910 url = tinyMCE.replaceVar(url, name, escape(args[name]));
\r
1914 html = tinyMCE.replaceVar(html, "css", this.settings.popups_css);
\r
1915 html = tinyMCE.applyTemplate(html, args);
\r
1917 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);
\r
1918 if (win == null) {
\r
1919 alert(tinyMCELang.lang_popup_blocked);
\r
1923 win.document.write(html);
\r
1924 win.document.close();
\r
1925 win.resizeTo(width, height);
\r
1928 if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings.dialog_type == "modal") {
\r
1931 features = "resizable:" + resizable + ";scroll:" + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;";
\r
1933 window.showModalDialog(url, window, features);
\r
1935 modal = (resizable == "yes") ? "no" : "yes";
\r
1937 if (tinyMCE.isGecko && tinyMCE.isMac)
\r
1940 if (template.close_previous != "no")
\r
1941 try {tinyMCE.lastWindow.close();} catch (ex) {}
\r
1943 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);
\r
1944 if (win == null) {
\r
1945 alert(tinyMCELang.lang_popup_blocked);
\r
1949 if (template.close_previous != "no")
\r
1950 tinyMCE.lastWindow = win;
\r
1953 win.resizeTo(width, height);
\r
1958 // Make it bigger if statusbar is forced
\r
1959 if (tinyMCE.isGecko) {
\r
1960 if (win.document.defaultView.statusbar.visible)
\r
1961 win.resizeBy(0, tinyMCE.isMac ? 10 : 24);
\r
1969 closeWindow : function(win) {
\r
1973 getVisualAidClass : function(class_name, state) {
\r
1974 var i, classNames, ar, className, aidClass = tinyMCE.settings.visual_table_class;
\r
1976 if (typeof(state) == "undefined")
\r
1977 state = tinyMCE.settings.visual;
\r
1981 ar = class_name.split(' ');
\r
1982 for (i=0; i<ar.length; i++) {
\r
1983 if (ar[i] == aidClass)
\r
1987 classNames[classNames.length] = ar[i];
\r
1991 classNames[classNames.length] = aidClass;
\r
1995 for (i=0; i<classNames.length; i++) {
\r
1999 className += classNames[i];
\r
2005 handleVisualAid : function(el, deep, state, inst, skip_dispatch) {
\r
2006 var i, x, y, tableElement, anchorName, oldW, oldH, bo, cn;
\r
2011 if (!skip_dispatch)
\r
2012 tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst);
\r
2014 tableElement = null;
\r
2016 switch (el.nodeName) {
\r
2018 oldW = el.style.width;
\r
2019 oldH = el.style.height;
\r
2020 bo = tinyMCE.getAttrib(el, "border");
\r
2022 bo = bo == '' || bo == "0" ? true : false;
\r
2024 tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
\r
2026 el.style.width = oldW;
\r
2027 el.style.height = oldH;
\r
2029 for (y=0; y<el.rows.length; y++) {
\r
2030 for (x=0; x<el.rows[y].cells.length; x++) {
\r
2031 cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);
\r
2032 tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn);
\r
2039 anchorName = tinyMCE.getAttrib(el, "name");
\r
2041 if (anchorName !== '' && state) {
\r
2042 el.title = anchorName;
\r
2043 tinyMCE.addCSSClass(el, 'mceItemAnchor');
\r
2044 } else if (anchorName !== '' && !state)
\r
2045 el.className = '';
\r
2050 if (deep && el.hasChildNodes()) {
\r
2051 for (i=0; i<el.childNodes.length; i++)
\r
2052 tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true);
\r
2056 fixGeckoBaseHREFBug : function(m, e, h) {
\r
2059 if (tinyMCE.isGecko) {
\r
2061 h = h.replace(/\ssrc=/gi, " mce_tsrc=");
\r
2062 h = h.replace(/\shref=/gi, " mce_thref=");
\r
2066 // Why bother if there is no src or href broken
\r
2067 if (!new RegExp('(src|href)=', 'g').test(h))
\r
2070 // Restore src and href that gets messed up by Gecko
\r
2071 tinyMCE.selectElements(e, 'A,IMG,SELECT,AREA,IFRAME,BASE,INPUT,SCRIPT,EMBED,OBJECT,LINK', function (n) {
\r
2072 xsrc = tinyMCE.getAttrib(n, "mce_tsrc");
\r
2073 xhref = tinyMCE.getAttrib(n, "mce_thref");
\r
2075 if (xsrc !== '') {
\r
2077 n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, xsrc);
\r
2079 // Ignore, Firefox cast exception if local file wasn't found
\r
2082 n.removeAttribute("mce_tsrc");
\r
2085 if (xhref !== '') {
\r
2087 n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, xhref);
\r
2089 // Ignore, Firefox cast exception if local file wasn't found
\r
2092 n.removeAttribute("mce_thref");
\r
2098 // Restore text/comment nodes
\r
2099 tinyMCE.selectNodes(e, function(n) {
\r
2100 if (n.nodeType == 3 || n.nodeType == 8) {
\r
2101 n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src=");
\r
2102 n.nodeValue = n.nodeValue.replace(/\smce_thref=/gi, " href=");
\r
2113 _setHTML : function(doc, html_content) {
\r
2114 var i, html, paras, node;
\r
2116 // Force closed anchors open
\r
2117 //html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
\r
2119 html_content = tinyMCE.cleanupHTMLCode(html_content);
\r
2121 // Try innerHTML if it fails use pasteHTML in MSIE
\r
2123 tinyMCE.setInnerHTML(doc.body, html_content);
\r
2126 doc.body.createTextRange().pasteHTML(html_content);
\r
2129 // Content duplication bug fix
\r
2130 if (tinyMCE.isIE && tinyMCE.settings.fix_content_duplication) {
\r
2131 // Remove P elements in P elements
\r
2132 paras = doc.getElementsByTagName("P");
\r
2133 for (i=0; i<paras.length; i++) {
\r
2136 while ((node = node.parentNode) != null) {
\r
2137 if (node.nodeName == "P")
\r
2138 node.outerHTML = node.innerHTML;
\r
2142 // Content duplication bug fix (Seems to be word crap)
\r
2143 html = doc.body.innerHTML;
\r
2145 // Always set the htmlText output
\r
2146 tinyMCE.setInnerHTML(doc.body, html);
\r
2149 tinyMCE.cleanupAnchors(doc);
\r
2151 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
2152 tinyMCE.convertSpansToFonts(doc);
\r
2155 getEditorId : function(form_element) {
\r
2156 var inst = this.getInstanceById(form_element);
\r
2161 return inst.editorId;
\r
2164 getInstanceById : function(editor_id) {
\r
2165 var inst = this.instances[editor_id], n;
\r
2168 for (n in tinyMCE.instances) {
\r
2169 inst = tinyMCE.instances[n];
\r
2171 if (!tinyMCE.isInstance(inst))
\r
2174 if (inst.formTargetElementId == editor_id)
\r
2183 queryInstanceCommandValue : function(editor_id, command) {
\r
2184 var inst = tinyMCE.getInstanceById(editor_id);
\r
2187 return inst.queryCommandValue(command);
\r
2192 queryInstanceCommandState : function(editor_id, command) {
\r
2193 var inst = tinyMCE.getInstanceById(editor_id);
\r
2196 return inst.queryCommandState(command);
\r
2201 setWindowArg : function(n, v) {
\r
2202 this.windowArgs[n] = v;
\r
2205 getWindowArg : function(n, d) {
\r
2206 return (typeof(this.windowArgs[n]) == "undefined") ? d : this.windowArgs[n];
\r
2209 getCSSClasses : function(editor_id, doc) {
\r
2210 var i, c, x, rule, styles, rules, csses, selectorText, inst = tinyMCE.getInstanceById(editor_id);
\r
2211 var cssClass, addClass, p;
\r
2214 inst = tinyMCE.selectedInstance;
\r
2220 doc = inst.getDoc();
\r
2222 // Is cached, use that
\r
2223 if (inst && inst.cssClasses.length > 0)
\r
2224 return inst.cssClasses;
\r
2229 styles = doc.styleSheets;
\r
2231 if (styles && styles.length > 0) {
\r
2232 for (x=0; x<styles.length; x++) {
\r
2236 csses = tinyMCE.isIE ? doc.styleSheets(x).rules : styles[x].cssRules;
\r
2238 // Just ignore any errors I know this is ugly!!
\r
2244 for (i=0; i<csses.length; i++) {
\r
2245 selectorText = csses[i].selectorText;
\r
2247 // Can be multiple rules per selector
\r
2248 if (selectorText) {
\r
2249 rules = selectorText.split(',');
\r
2250 for (c=0; c<rules.length; c++) {
\r
2253 // Strip spaces between selectors
\r
2254 while (rule.indexOf(' ') == 0)
\r
2255 rule = rule.substring(1);
\r
2258 if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1)
\r
2261 if (rule.indexOf(tinyMCE.settings.visual_table_class) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1)
\r
2265 if (rule.indexOf('.') != -1) {
\r
2266 cssClass = rule.substring(rule.indexOf('.') + 1);
\r
2269 for (p=0; p<inst.cssClasses.length && addClass; p++) {
\r
2270 if (inst.cssClasses[p] == cssClass)
\r
2275 inst.cssClasses[inst.cssClasses.length] = cssClass;
\r
2283 return inst.cssClasses;
\r
2286 regexpReplace : function(in_str, reg_exp, replace_str, opts) {
\r
2289 if (in_str == null)
\r
2292 if (typeof(opts) == "undefined")
\r
2295 re = new RegExp(reg_exp, opts);
\r
2297 return in_str.replace(re, replace_str);
\r
2300 trim : function(s) {
\r
2301 return s.replace(/^\s*|\s*$/g, "");
\r
2304 cleanupEventStr : function(s) {
\r
2306 s = s.replace('function anonymous()\n{\n', '');
\r
2307 s = s.replace('\n}', '');
\r
2308 s = s.replace(/^return true;/gi, ''); // Remove event blocker
\r
2313 getControlHTML : function(c) {
\r
2314 var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl';
\r
2316 l = tinyMCE.plugins;
\r
2320 if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') {
\r
2322 return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>';
\r
2324 return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
\r
2328 o = tinyMCE.themes[tinyMCE.settings.theme];
\r
2329 if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') {
\r
2331 return '<span dir="rtl">' + v + '</span>';
\r
2339 evalFunc : function(f, idx, a, o) {
\r
2340 o = !o ? window : o;
\r
2341 f = typeof(f) == 'function' ? f : o[f];
\r
2343 return f.apply(o, Array.prototype.slice.call(a, idx));
\r
2346 dispatchCallback : function(i, p, n) {
\r
2347 return this.callFunc(i, p, n, 0, this.dispatchCallback.arguments);
\r
2350 executeCallback : function(i, p, n) {
\r
2351 return this.callFunc(i, p, n, 1, this.executeCallback.arguments);
\r
2354 execCommandCallback : function(i, p, n) {
\r
2355 return this.callFunc(i, p, n, 2, this.execCommandCallback.arguments);
\r
2358 callFunc : function(ins, p, n, m, a) {
\r
2359 var l, i, on, o, s, v;
\r
2363 l = tinyMCE.getParam(p, '');
\r
2365 if (l !== '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0)
\r
2368 if (ins != null) {
\r
2369 for (i=0, l = ins.plugins; i<l.length; i++) {
\r
2370 o = tinyMCE.plugins[l[i]];
\r
2372 if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
\r
2377 l = tinyMCE.themes;
\r
2381 if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
\r
2388 resolveDots : function(s, o) {
\r
2391 if (typeof(s) == 'string') {
\r
2392 for (i=0, s=s.split('.'); i<s.length; i++)
\r
2400 xmlEncode : function(s) {
\r
2401 return s ? ('' + s).replace(this.xmlEncodeRe, function (c, b) {
\r
2420 add : function(c, m) {
\r
2424 c.prototype[n] = m[n];
\r
2427 extend : function(p, np) {
\r
2441 hideMenus : function() {
\r
2442 var e = tinyMCE.lastSelectedMenuBtn;
\r
2444 if (tinyMCE.lastMenu) {
\r
2445 tinyMCE.lastMenu.hide();
\r
2446 tinyMCE.lastMenu = null;
\r
2450 tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass);
\r
2451 tinyMCE.lastSelectedMenuBtn = null;
\r
2457 // Global instances
\r
2458 var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors
\r
2459 var tinyMCE = new TinyMCE_Engine();
\r
2460 var tinyMCELang = {};
\r
2462 /* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */
\r
2464 function TinyMCE_Control(settings) {
\r
2465 var t, i, tos, fu, p, x, fn, fu, pn, s = settings;
\r
2467 this.undoRedoLevel = true;
\r
2468 this.isTinyMCE_Control = true;
\r
2470 // Default settings
\r
2471 this.enabled = true;
\r
2472 this.settings = s;
\r
2473 this.settings.theme = tinyMCE.getParam("theme", "default");
\r
2474 this.settings.width = tinyMCE.getParam("width", -1);
\r
2475 this.settings.height = tinyMCE.getParam("height", -1);
\r
2476 this.selection = new TinyMCE_Selection(this);
\r
2477 this.undoRedo = new TinyMCE_UndoRedo(this);
\r
2478 this.cleanup = new TinyMCE_Cleanup();
\r
2479 this.shortcuts = [];
\r
2480 this.hasMouseMoved = false;
\r
2481 this.foreColor = this.backColor = "#999999";
\r
2483 this.cssClasses = [];
\r
2485 this.cleanup.init({
\r
2486 valid_elements : s.valid_elements,
\r
2487 extended_valid_elements : s.extended_valid_elements,
\r
2488 valid_child_elements : s.valid_child_elements,
\r
2489 entities : s.entities,
\r
2490 entity_encoding : s.entity_encoding,
\r
2491 debug : s.cleanup_debug,
\r
2492 indent : s.apply_source_formatting,
\r
2493 invalid_elements : s.invalid_elements,
\r
2494 verify_html : s.verify_html,
\r
2495 fix_content_duplication : s.fix_content_duplication,
\r
2496 convert_fonts_to_spans : s.convert_fonts_to_spans
\r
2500 t = this.settings.theme;
\r
2501 if (!tinyMCE.hasTheme(t)) {
\r
2502 fn = tinyMCE.callbacks;
\r
2505 for (i=0; i<fn.length; i++) {
\r
2506 if ((fu = window['TinyMCE_' + t + "_" + fn[i]]))
\r
2510 tinyMCE.addTheme(t, tos);
\r
2513 // Wrap old plugins
\r
2514 this.plugins = [];
\r
2515 p = tinyMCE.getParam('plugins', '', true, ',');
\r
2516 if (p.length > 0) {
\r
2517 for (i=0; i<p.length; i++) {
\r
2520 if (pn.charAt(0) == '-')
\r
2521 pn = pn.substring(1);
\r
2523 if (!tinyMCE.hasPlugin(pn)) {
\r
2524 fn = tinyMCE.callbacks;
\r
2527 for (x=0; x<fn.length; x++) {
\r
2528 if ((fu = window['TinyMCE_' + pn + "_" + fn[x]]))
\r
2532 tinyMCE.addPlugin(pn, tos);
\r
2535 this.plugins[this.plugins.length] = pn;
\r
2540 TinyMCE_Control.prototype = {
\r
2547 getData : function(na) {
\r
2548 var o = this.data[na];
\r
2551 o = this.data[na] = {};
\r
2556 hasPlugin : function(n) {
\r
2559 for (i=0; i<this.plugins.length; i++) {
\r
2560 if (this.plugins[i] == n)
\r
2567 addPlugin : function(n, p) {
\r
2568 if (!this.hasPlugin(n)) {
\r
2569 tinyMCE.addPlugin(n, p);
\r
2570 this.plugins[this.plugins.length] = n;
\r
2574 repaint : function() {
\r
2577 if (tinyMCE.isRealIE)
\r
2581 s = this.selection;
\r
2582 b = s.getBookmark(true);
\r
2583 this.getBody().style.display = 'none';
\r
2584 this.getDoc().execCommand('selectall', false, null);
\r
2585 this.getSel().collapseToStart();
\r
2586 this.getBody().style.display = 'block';
\r
2587 s.moveToBookmark(b);
\r
2593 switchSettings : function() {
\r
2594 if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings.index) {
\r
2595 tinyMCE.settings = this.settings;
\r
2596 tinyMCE.currentConfig = this.settings.index;
\r
2600 select : function() {
\r
2601 var oldInst = tinyMCE.selectedInstance;
\r
2603 if (oldInst != this) {
\r
2605 oldInst.execCommand('mceEndTyping');
\r
2607 tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst);
\r
2608 tinyMCE.selectedInstance = this;
\r
2612 getBody : function() {
\r
2613 return this.contentBody ? this.contentBody : this.getDoc().body;
\r
2616 getDoc : function() {
\r
2617 // return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ?
\r
2618 return this.contentWindow.document;
\r
2621 getWin : function() {
\r
2622 return this.contentWindow;
\r
2625 getContainerWin : function() {
\r
2626 return this.containerWindow ? this.containerWindow : window;
\r
2629 getViewPort : function() {
\r
2630 return tinyMCE.getViewPort(this.getWin());
\r
2633 getParentNode : function(n, f) {
\r
2634 return tinyMCE.getParentNode(n, f, this.getBody());
\r
2637 getParentElement : function(n, na, f) {
\r
2638 return tinyMCE.getParentElement(n, na, f, this.getBody());
\r
2641 getParentBlockElement : function(n) {
\r
2642 return tinyMCE.getParentBlockElement(n, this.getBody());
\r
2645 resizeToContent : function() {
\r
2646 var d = this.getDoc(), b = d.body, de = d.documentElement;
\r
2648 this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px';
\r
2651 addShortcut : function(m, k, d, cmd, ui, va) {
\r
2652 var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts;
\r
2654 if (!tinyMCE.getParam('custom_shortcuts'))
\r
2657 m = m.toLowerCase();
\r
2658 k = ie && !n ? k.toUpperCase() : k;
\r
2659 c = n ? null : k.charCodeAt(0);
\r
2660 d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d;
\r
2663 alt : m.indexOf('alt') != -1,
\r
2664 ctrl : m.indexOf('ctrl') != -1,
\r
2665 shift : m.indexOf('shift') != -1,
\r
2667 keyCode : n ? k : (ie ? c : null),
\r
2674 for (i=0; i<scl.length; i++) {
\r
2675 if (sc.alt == scl[i].alt && sc.ctrl == scl[i].ctrl && sc.shift == scl[i].shift
\r
2676 && sc.charCode == scl[i].charCode && sc.keyCode == scl[i].keyCode) {
\r
2681 scl[scl.length] = sc;
\r
2686 handleShortcut : function(e) {
\r
2689 // Normal key press, then ignore it
\r
2690 if (!e.altKey && !e.ctrlKey)
\r
2693 s = this.shortcuts;
\r
2695 for (i=0; i<s.length; i++) {
\r
2698 if (o.alt == e.altKey && o.ctrl == e.ctrlKey && (o.keyCode == e.keyCode || o.charCode == e.charCode)) {
\r
2699 if (o.cmd && (e.type == "keydown" || (e.type == "keypress" && !tinyMCE.isOpera)))
\r
2700 tinyMCE.execCommand(o.cmd, o.ui, o.val);
\r
2702 tinyMCE.cancelEvent(e);
\r
2710 autoResetDesignMode : function() {
\r
2711 // Add fix for tab/style.display none/block problems in Gecko
\r
2712 if (!tinyMCE.isIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
\r
2713 eval('try { this.getDoc().designMode = "On"; this.useCSS = false; } catch(e) {}');
\r
2716 isHidden : function() {
\r
2722 s = this.getSel();
\r
2724 // Weird, wheres that cursor selection?
\r
2725 return (!s || !s.rangeCount || s.rangeCount == 0);
\r
2728 isDirty : function() {
\r
2729 // Is content modified and not in a submit procedure
\r
2730 return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !this.isNotDirty;
\r
2733 _mergeElements : function(scmd, pa, ch, override) {
\r
2734 var st, stc, className, n;
\r
2736 if (scmd == "removeformat") {
\r
2737 pa.className = "";
\r
2738 pa.style.cssText = "";
\r
2739 ch.className = "";
\r
2740 ch.style.cssText = "";
\r
2744 st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style"));
\r
2745 stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));
\r
2746 className = tinyMCE.getAttrib(pa, "class");
\r
2748 // Removed class adding due to bug #1478272
\r
2749 className = tinyMCE.getAttrib(ch, "class");
\r
2753 if (typeof(st[n]) == 'function')
\r
2760 if (typeof(stc[n]) == 'function')
\r
2767 tinyMCE.setAttrib(pa, "style", tinyMCE.serializeStyle(st));
\r
2768 tinyMCE.setAttrib(pa, "class", tinyMCE.trim(className));
\r
2769 ch.className = "";
\r
2770 ch.style.cssText = "";
\r
2771 ch.removeAttribute("class");
\r
2772 ch.removeAttribute("style");
\r
2775 _fixRootBlocks : function() {
\r
2776 var rb, b, ne, be, nx, bm;
\r
2778 rb = tinyMCE.getParam('forced_root_block');
\r
2782 b = this.getBody();
\r
2783 ne = b.firstChild;
\r
2786 nx = ne.nextSibling;
\r
2788 // If text node or inline element wrap it in a block element
\r
2789 if (ne.nodeType == 3 || !tinyMCE.blockRegExp.test(ne.nodeName)) {
\r
2791 bm = this.selection.getBookmark();
\r
2794 be = this.getDoc().createElement(rb);
\r
2795 be.appendChild(ne.cloneNode(true));
\r
2796 b.replaceChild(be, ne);
\r
2798 be.appendChild(ne.cloneNode(true));
\r
2799 b.removeChild(ne);
\r
2808 this.selection.moveToBookmark(bm);
\r
2811 _fixTrailingNbsp : function() {
\r
2812 var s = this.selection, e = s.getFocusElement(), bm, v;
\r
2814 if (e && tinyMCE.blockRegExp.test(e.nodeName) && e.firstChild) {
\r
2815 v = e.firstChild.nodeValue;
\r
2817 if (v && v.length > 1 && /(^\u00a0|\u00a0$)/.test(v)) {
\r
2818 e.firstChild.nodeValue = v.replace(/(^\u00a0|\u00a0$)/, '');
\r
2819 s.selectNode(e.firstChild, true, false, false); // Select and collapse
\r
2824 _setUseCSS : function(b) {
\r
2825 var d = this.getDoc();
\r
2827 try {d.execCommand("useCSS", false, !b);} catch (ex) {}
\r
2828 try {d.execCommand("styleWithCSS", false, b);} catch (ex) {}
\r
2830 if (!tinyMCE.getParam("table_inline_editing"))
\r
2831 try {d.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {}
\r
2833 if (!tinyMCE.getParam("object_resizing"))
\r
2834 try {d.execCommand('enableObjectResizing', false, "false");} catch (ex) {}
\r
2837 execCommand : function(command, user_interface, value) {
\r
2838 var i, x, z, align, img, div, doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement();
\r
2840 // Is not a undo specific command
\r
2841 if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command))
\r
2842 this.undoBookmark = null;
\r
2845 if (!tinyMCE.isIE && !this.useCSS) {
\r
2846 this._setUseCSS(false);
\r
2847 this.useCSS = true;
\r
2850 //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value);
\r
2851 this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks
\r
2853 // Don't dispatch key commands
\r
2854 if (!/mceStartTyping|mceEndTyping/.test(command)) {
\r
2855 if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value))
\r
2859 // Fix align on images
\r
2860 if (focusElm && focusElm.nodeName == "IMG") {
\r
2861 align = focusElm.getAttribute('align');
\r
2862 img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm;
\r
2864 switch (command) {
\r
2865 case "JustifyLeft":
\r
2866 if (align == 'left')
\r
2867 img.removeAttribute('align');
\r
2869 img.setAttribute('align', 'left');
\r
2872 div = focusElm.parentNode;
\r
2873 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
\r
2874 div.parentNode.replaceChild(img, div);
\r
2876 this.selection.selectNode(img);
\r
2878 tinyMCE.triggerNodeChange();
\r
2881 case "JustifyCenter":
\r
2882 img.removeAttribute('align');
\r
2885 div = tinyMCE.getParentElement(focusElm, "div");
\r
2886 if (div && div.style.textAlign == "center") {
\r
2888 if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
\r
2889 div.parentNode.replaceChild(img, div);
\r
2892 div = this.getDoc().createElement("div");
\r
2893 div.style.textAlign = 'center';
\r
2894 div.appendChild(img);
\r
2895 focusElm.parentNode.replaceChild(div, focusElm);
\r
2898 this.selection.selectNode(img);
\r
2900 tinyMCE.triggerNodeChange();
\r
2903 case "JustifyRight":
\r
2904 if (align == 'right')
\r
2905 img.removeAttribute('align');
\r
2907 img.setAttribute('align', 'right');
\r
2910 div = focusElm.parentNode;
\r
2911 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
\r
2912 div.parentNode.replaceChild(img, div);
\r
2914 this.selection.selectNode(img);
\r
2916 tinyMCE.triggerNodeChange();
\r
2921 if (tinyMCE.settings.force_br_newlines) {
\r
2922 var alignValue = "";
\r
2924 if (doc.selection.type != "Control") {
\r
2925 switch (command) {
\r
2926 case "JustifyLeft":
\r
2927 alignValue = "left";
\r
2930 case "JustifyCenter":
\r
2931 alignValue = "center";
\r
2934 case "JustifyFull":
\r
2935 alignValue = "justify";
\r
2938 case "JustifyRight":
\r
2939 alignValue = "right";
\r
2943 if (alignValue !== '') {
\r
2944 var rng = doc.selection.createRange();
\r
2946 if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null)
\r
2947 divElm.setAttribute("align", alignValue);
\r
2948 else if (rng.pasteHTML && rng.htmlText.length > 0)
\r
2949 rng.pasteHTML('<div align="' + alignValue + '">' + rng.htmlText + "</div>");
\r
2951 tinyMCE.triggerNodeChange();
\r
2957 switch (command) {
\r
2958 case "mceRepaint":
\r
2963 // Unlink if caret is inside link
\r
2964 if (tinyMCE.isGecko && this.getSel().isCollapsed) {
\r
2965 focusElm = tinyMCE.getParentElement(focusElm, 'A');
\r
2968 this.selection.selectNode(focusElm, false);
\r
2971 this.getDoc().execCommand(command, user_interface, value);
\r
2973 tinyMCE.isGecko && this.getSel().collapseToEnd();
\r
2975 tinyMCE.triggerNodeChange();
\r
2979 case "InsertUnorderedList":
\r
2980 case "InsertOrderedList":
\r
2981 this.getDoc().execCommand(command, user_interface, value);
\r
2982 tinyMCE.triggerNodeChange();
\r
2985 case "Strikethrough":
\r
2986 this.getDoc().execCommand(command, user_interface, value);
\r
2987 tinyMCE.triggerNodeChange();
\r
2990 case "mceSelectNode":
\r
2991 this.selection.selectNode(value);
\r
2992 tinyMCE.triggerNodeChange();
\r
2993 tinyMCE.selectedNode = value;
\r
2996 case "FormatBlock":
\r
2997 if (value == null || value == '') {
\r
2998 var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp");
\r
3001 this.execCommand("mceRemoveNode", false, elm);
\r
3003 if (!this.cleanup.isValid(value))
\r
3006 if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value))
\r
3007 value = value.replace(/[^a-z]/gi, '');
\r
3009 if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
\r
3010 var b = this.selection.getBookmark();
\r
3011 this.getDoc().execCommand("FormatBlock", false, '<p>');
\r
3012 tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value);
\r
3013 this.selection.moveToBookmark(b);
\r
3015 this.getDoc().execCommand("FormatBlock", false, value);
\r
3018 tinyMCE.triggerNodeChange();
\r
3022 case "mceRemoveNode":
\r
3024 value = tinyMCE.getParentElement(this.getFocusElement());
\r
3026 if (tinyMCE.isIE) {
\r
3027 value.outerHTML = value.innerHTML;
\r
3029 var rng = value.ownerDocument.createRange();
\r
3030 rng.setStartBefore(value);
\r
3031 rng.setEndAfter(value);
\r
3032 rng.deleteContents();
\r
3033 rng.insertNode(rng.createContextualFragment(value.innerHTML));
\r
3036 tinyMCE.triggerNodeChange();
\r
3040 case "mceSelectNodeDepth":
\r
3041 var parentNode = this.getFocusElement();
\r
3042 for (i=0; parentNode; i++) {
\r
3043 if (parentNode.nodeName.toLowerCase() == "body")
\r
3046 if (parentNode.nodeName.toLowerCase() == "#text") {
\r
3048 parentNode = parentNode.parentNode;
\r
3053 this.selection.selectNode(parentNode, false);
\r
3054 tinyMCE.triggerNodeChange();
\r
3055 tinyMCE.selectedNode = parentNode;
\r
3059 parentNode = parentNode.parentNode;
\r
3064 case "mceSetStyleInfo":
\r
3065 case "SetStyleInfo":
\r
3066 var rng = this.getRng();
\r
3067 var sel = this.getSel();
\r
3068 var scmd = value.command;
\r
3069 var sname = value.name;
\r
3070 var svalue = value.value == null ? '' : value.value;
\r
3071 //var svalue = value['value'] == null ? '' : value['value'];
\r
3072 var wrapper = value.wrapper ? value.wrapper : "span";
\r
3073 var parentElm = null;
\r
3074 var invalidRe = new RegExp("^BODY|HTML$", "g");
\r
3075 var invalidParentsRe = tinyMCE.settings.merge_styles_invalid_parents !== '' ? new RegExp(tinyMCE.settings.merge_styles_invalid_parents, "gi") : null;
\r
3077 // Whole element selected check
\r
3078 if (tinyMCE.isIE) {
\r
3081 parentElm = rng.item(0);
\r
3083 var pelm = rng.parentElement();
\r
3084 var prng = doc.selection.createRange();
\r
3085 prng.moveToElementText(pelm);
\r
3087 if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
\r
3088 if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
\r
3093 var felm = this.getFocusElement();
\r
3094 if (sel.isCollapsed || (new RegExp('td|tr|tbody|table|img', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode))
\r
3098 // Whole element selected
\r
3099 if (parentElm && !invalidRe.test(parentElm.nodeName)) {
\r
3100 if (scmd == "setstyle")
\r
3101 tinyMCE.setStyleAttrib(parentElm, sname, svalue);
\r
3103 if (scmd == "setattrib")
\r
3104 tinyMCE.setAttrib(parentElm, sname, svalue);
\r
3106 if (scmd == "removeformat") {
\r
3107 parentElm.style.cssText = '';
\r
3108 tinyMCE.setAttrib(parentElm, 'class', '');
\r
3111 // Remove style/attribs from all children
\r
3112 var ch = tinyMCE.getNodeTree(parentElm, [], 1);
\r
3113 for (z=0; z<ch.length; z++) {
\r
3114 if (ch[z] == parentElm)
\r
3117 if (scmd == "setstyle")
\r
3118 tinyMCE.setStyleAttrib(ch[z], sname, '');
\r
3120 if (scmd == "setattrib")
\r
3121 tinyMCE.setAttrib(ch[z], sname, '');
\r
3123 if (scmd == "removeformat") {
\r
3124 ch[z].style.cssText = '';
\r
3125 tinyMCE.setAttrib(ch[z], 'class', '');
\r
3129 this._setUseCSS(false); // Bug in FF when running in fullscreen
\r
3130 doc.execCommand("FontName", false, "#mce_temp_font#");
\r
3131 var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#");
\r
3133 // Change them all
\r
3134 for (x=0; x<elementArray.length; x++) {
\r
3135 elm = elementArray[x];
\r
3137 var spanElm = doc.createElement(wrapper);
\r
3139 if (scmd == "setstyle")
\r
3140 tinyMCE.setStyleAttrib(spanElm, sname, svalue);
\r
3142 if (scmd == "setattrib")
\r
3143 tinyMCE.setAttrib(spanElm, sname, svalue);
\r
3145 if (scmd == "removeformat") {
\r
3146 spanElm.style.cssText = '';
\r
3147 tinyMCE.setAttrib(spanElm, 'class', '');
\r
3150 if (elm.hasChildNodes()) {
\r
3151 for (i=0; i<elm.childNodes.length; i++)
\r
3152 spanElm.appendChild(elm.childNodes[i].cloneNode(true));
\r
3155 spanElm.setAttribute("mce_new", "true");
\r
3156 elm.parentNode.replaceChild(spanElm, elm);
\r
3158 // Remove style/attribs from all children
\r
3159 var ch = tinyMCE.getNodeTree(spanElm, [], 1);
\r
3160 for (z=0; z<ch.length; z++) {
\r
3161 if (ch[z] == spanElm)
\r
3164 if (scmd == "setstyle")
\r
3165 tinyMCE.setStyleAttrib(ch[z], sname, '');
\r
3167 if (scmd == "setattrib")
\r
3168 tinyMCE.setAttrib(ch[z], sname, '');
\r
3170 if (scmd == "removeformat") {
\r
3171 ch[z].style.cssText = '';
\r
3172 tinyMCE.setAttrib(ch[z], 'class', '');
\r
3179 // Cleaup wrappers
\r
3180 var nodes = doc.getElementsByTagName(wrapper);
\r
3181 for (i=nodes.length-1; i>=0; i--) {
\r
3182 var elm = nodes[i];
\r
3183 var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
\r
3185 elm.removeAttribute("mce_new");
\r
3187 // Is only child a element
\r
3188 if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
\r
3189 //tinyMCE.debug("merge1" + isNew);
\r
3190 this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
\r
3194 // Is I the only child
\r
3195 if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
\r
3196 //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
\r
3197 if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
\r
3198 this._mergeElements(scmd, elm.parentNode, elm, false);
\r
3202 // Remove empty wrappers
\r
3203 var nodes = doc.getElementsByTagName(wrapper);
\r
3204 for (i=nodes.length-1; i>=0; i--) {
\r
3205 var elm = nodes[i], isEmpty = true;
\r
3207 // Check if it has any attribs
\r
3208 var tmp = doc.createElement("body");
\r
3209 tmp.appendChild(elm.cloneNode(false));
\r
3211 // Is empty span, remove it
\r
3212 tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
\r
3213 //tinyMCE.debug(tmp.innerHTML);
\r
3214 if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) {
\r
3215 for (x=0; x<elm.childNodes.length; x++) {
\r
3216 if (elm.parentNode != null)
\r
3217 elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm);
\r
3220 elm.parentNode.removeChild(elm);
\r
3224 // Re add the visual aids
\r
3225 if (scmd == "removeformat")
\r
3226 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
\r
3228 tinyMCE.triggerNodeChange();
\r
3233 if (value == null) {
\r
3234 var s = this.getSel();
\r
3236 // Find font and select it
\r
3237 if (tinyMCE.isGecko && s.isCollapsed) {
\r
3238 var f = tinyMCE.getParentElement(this.getFocusElement(), "font");
\r
3241 this.selection.selectNode(f, false);
\r
3245 this.getDoc().execCommand("RemoveFormat", false, null);
\r
3247 // Collapse range if font was found
\r
3248 if (f != null && tinyMCE.isGecko) {
\r
3249 var r = this.getRng().cloneRange();
\r
3251 s.removeAllRanges();
\r
3255 this.getDoc().execCommand('FontName', false, value);
\r
3257 if (tinyMCE.isGecko)
\r
3258 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
\r
3263 this.getDoc().execCommand('FontSize', false, value);
\r
3265 if (tinyMCE.isGecko)
\r
3266 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
\r
3271 value = value == null ? this.foreColor : value;
\r
3272 value = tinyMCE.trim(value);
\r
3273 value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
\r
3275 this.foreColor = value;
\r
3276 this.getDoc().execCommand('forecolor', false, value);
\r
3279 case "HiliteColor":
\r
3280 value = value == null ? this.backColor : value;
\r
3281 value = tinyMCE.trim(value);
\r
3282 value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
\r
3283 this.backColor = value;
\r
3285 if (tinyMCE.isGecko) {
\r
3286 this._setUseCSS(true);
\r
3287 this.getDoc().execCommand('hilitecolor', false, value);
\r
3288 this._setUseCSS(false);
\r
3290 this.getDoc().execCommand('BackColor', false, value);
\r
3296 var cmdFailed = false;
\r
3298 // Try executing command
\r
3299 eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');
\r
3301 if (tinyMCE.isOpera && cmdFailed)
\r
3302 alert('Currently not supported by your browser, use keyboard shortcuts instead.');
\r
3304 // Alert error in gecko if command failed
\r
3305 if (tinyMCE.isGecko && cmdFailed) {
\r
3306 // Confirm more info
\r
3307 if (confirm(tinyMCE.entityDecode(tinyMCE.getLang('lang_clipboard_msg'))))
\r
3308 window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
\r
3312 tinyMCE.triggerNodeChange();
\r
3315 case "mceSetContent":
\r
3319 // Call custom cleanup code
\r
3320 value = tinyMCE.storeAwayURLs(value);
\r
3321 value = tinyMCE._customCleanup(this, "insert_to_editor", value);
\r
3323 if (this.getBody().nodeName == 'BODY')
\r
3324 tinyMCE._setHTML(doc, value);
\r
3326 this.getBody().innerHTML = value;
\r
3328 tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, doc, this.settings, this.getBody(), false, false, false, true));
\r
3329 tinyMCE.convertAllRelativeURLs(this.getBody());
\r
3331 // Cleanup any mess left from storyAwayURLs
\r
3332 tinyMCE._removeInternal(this.getBody());
\r
3334 // When editing always use fonts internaly
\r
3335 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
3336 tinyMCE.convertSpansToFonts(doc);
\r
3338 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
\r
3339 tinyMCE._setEventsEnabled(this.getBody(), false);
\r
3340 this._addBogusBR();
\r
3344 case "mceCleanup":
\r
3345 var b = this.selection.getBookmark();
\r
3346 tinyMCE._setHTML(this.contentDocument, this.getBody().innerHTML);
\r
3347 tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, this.getBody(), this.visualAid));
\r
3348 tinyMCE.convertAllRelativeURLs(doc.body);
\r
3350 // When editing always use fonts internaly
\r
3351 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
3352 tinyMCE.convertSpansToFonts(doc);
\r
3354 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
\r
3355 tinyMCE._setEventsEnabled(this.getBody(), false);
\r
3356 this._addBogusBR();
\r
3358 this.selection.moveToBookmark(b);
\r
3359 tinyMCE.triggerNodeChange();
\r
3362 case "mceReplaceContent":
\r
3363 // Force empty string
\r
3367 this.getWin().focus();
\r
3369 var selectedText = "";
\r
3371 if (tinyMCE.isIE) {
\r
3372 var rng = doc.selection.createRange();
\r
3373 selectedText = rng.text;
\r
3375 selectedText = this.getSel().toString();
\r
3377 if (selectedText.length > 0) {
\r
3378 value = tinyMCE.replaceVar(value, "selection", selectedText);
\r
3379 tinyMCE.execCommand('mceInsertContent', false, value);
\r
3382 this._addBogusBR();
\r
3383 tinyMCE.triggerNodeChange();
\r
3386 case "mceSetAttribute":
\r
3387 if (typeof(value) == 'object') {
\r
3388 var targetElms = (typeof(value.targets) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value.targets;
\r
3389 var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
\r
3392 targetNode.setAttribute(value.name, value.value);
\r
3393 tinyMCE.triggerNodeChange();
\r
3398 case "mceSetCSSClass":
\r
3399 this.execCommand("mceSetStyleInfo", false, {command : "setattrib", name : "class", value : value});
\r
3402 case "mceInsertRawHTML":
\r
3403 var key = 'tiny_mce_marker';
\r
3405 this.execCommand('mceBeginUndoLevel');
\r
3407 // Insert marker key
\r
3408 this.execCommand('mceInsertContent', false, key);
\r
3410 // Store away scroll pos
\r
3411 var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft;
\r
3412 var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop;
\r
3414 // Find marker and replace with RAW HTML
\r
3415 var html = this.getBody().innerHTML;
\r
3416 if ((pos = html.indexOf(key)) != -1)
\r
3417 tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
\r
3419 // Restore scoll pos
\r
3420 this.contentWindow.scrollTo(scrollX, scrollY);
\r
3422 this.execCommand('mceEndUndoLevel');
\r
3426 case "mceInsertContent":
\r
3427 // Force empty string
\r
3431 var insertHTMLFailed = false;
\r
3433 // Removed since it produced problems in IE
\r
3434 // this.getWin().focus();
\r
3436 if (tinyMCE.isGecko || tinyMCE.isOpera) {
\r
3438 // Is plain text or HTML, &, etc will be encoded wrong in FF
\r
3439 if (value.indexOf('<') == -1 && !value.match(/(&| |<|>)/g)) {
\r
3440 var r = this.getRng();
\r
3441 var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value));
\r
3442 var s = this.getSel();
\r
3443 var r2 = r.cloneRange();
\r
3445 // Insert text at cursor position
\r
3446 s.removeAllRanges();
\r
3447 r.deleteContents();
\r
3450 // Move the cursor to the end of text
\r
3452 r2.collapse(false);
\r
3453 s.removeAllRanges();
\r
3456 value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value);
\r
3457 this.getDoc().execCommand('inserthtml', false, value);
\r
3458 tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
\r
3461 insertHTMLFailed = true;
\r
3464 if (!insertHTMLFailed) {
\r
3465 tinyMCE.triggerNodeChange();
\r
3470 if (!tinyMCE.isIE) {
\r
3471 var isHTML = value.indexOf('<') != -1;
\r
3472 var sel = this.getSel();
\r
3473 var rng = this.getRng();
\r
3476 if (tinyMCE.isSafari) {
\r
3477 var tmpRng = this.getDoc().createRange();
\r
3479 tmpRng.setStart(this.getBody(), 0);
\r
3480 tmpRng.setEnd(this.getBody(), 0);
\r
3482 value = tmpRng.createContextualFragment(value);
\r
3484 value = rng.createContextualFragment(value);
\r
3486 // Setup text node
\r
3487 value = doc.createTextNode(tinyMCE.entityDecode(value));
\r
3490 // Insert plain text in Safari
\r
3491 if (tinyMCE.isSafari && !isHTML) {
\r
3492 this.execCommand('InsertText', false, value.nodeValue);
\r
3493 tinyMCE.triggerNodeChange();
\r
3495 } else if (tinyMCE.isSafari && isHTML) {
\r
3496 rng.deleteContents();
\r
3497 rng.insertNode(value);
\r
3498 tinyMCE.triggerNodeChange();
\r
3502 rng.deleteContents();
\r
3504 // If target node is text do special treatment, (Mozilla 1.3 fix)
\r
3505 if (rng.startContainer.nodeType == 3) {
\r
3506 var node = rng.startContainer.splitText(rng.startOffset);
\r
3507 node.parentNode.insertBefore(value, node);
\r
3509 rng.insertNode(value);
\r
3512 // Removes weird selection trails
\r
3513 sel.selectAllChildren(doc.body);
\r
3514 sel.removeAllRanges();
\r
3516 // Move cursor to end of content
\r
3517 var rng = doc.createRange();
\r
3519 rng.selectNode(value);
\r
3520 rng.collapse(false);
\r
3522 sel.addRange(rng);
\r
3524 rng.collapse(false);
\r
3526 tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
\r
3528 var rng = doc.selection.createRange(), tmpRng = null;
\r
3529 var c = value.indexOf('<!--') != -1;
\r
3531 // Fix comment bug, add tag before comments
\r
3533 value = tinyMCE.uniqueTag + value;
\r
3535 // tmpRng = rng.duplicate(); // Store away range (Fixes Undo bookmark bug in IE)
\r
3538 rng.item(0).outerHTML = value;
\r
3540 rng.pasteHTML(value);
\r
3543 // tmpRng.select(); // Restore range (Fixes Undo bookmark bug in IE)
\r
3545 // Remove unique tag
\r
3547 var e = this.getDoc().getElementById('mceTMPElement');
\r
3548 e.parentNode.removeChild(e);
\r
3552 tinyMCE.execCommand("mceAddUndoLevel");
\r
3553 tinyMCE.triggerNodeChange();
\r
3556 case "mceStartTyping":
\r
3557 if (tinyMCE.settings.custom_undo_redo && this.undoRedo.typingUndoIndex == -1) {
\r
3558 this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex;
\r
3559 tinyMCE.typingUndoIndex = tinyMCE.undoIndex;
\r
3560 this.execCommand('mceAddUndoLevel');
\r
3564 case "mceEndTyping":
\r
3565 if (tinyMCE.settings.custom_undo_redo && this.undoRedo.typingUndoIndex != -1) {
\r
3566 this.execCommand('mceAddUndoLevel');
\r
3567 this.undoRedo.typingUndoIndex = -1;
\r
3570 tinyMCE.typingUndoIndex = -1;
\r
3573 case "mceBeginUndoLevel":
\r
3574 this.undoRedoLevel = false;
\r
3577 case "mceEndUndoLevel":
\r
3578 this.undoRedoLevel = true;
\r
3579 this.execCommand('mceAddUndoLevel');
\r
3582 case "mceAddUndoLevel":
\r
3583 if (tinyMCE.settings.custom_undo_redo && this.undoRedoLevel) {
\r
3584 if (this.undoRedo.add())
\r
3585 tinyMCE.triggerNodeChange(false);
\r
3590 if (tinyMCE.settings.custom_undo_redo) {
\r
3591 tinyMCE.execCommand("mceEndTyping");
\r
3592 this.undoRedo.undo();
\r
3593 tinyMCE.triggerNodeChange();
\r
3595 this.getDoc().execCommand(command, user_interface, value);
\r
3599 if (tinyMCE.settings.custom_undo_redo) {
\r
3600 tinyMCE.execCommand("mceEndTyping");
\r
3601 this.undoRedo.redo();
\r
3602 tinyMCE.triggerNodeChange();
\r
3604 this.getDoc().execCommand(command, user_interface, value);
\r
3607 case "mceToggleVisualAid":
\r
3608 this.visualAid = !this.visualAid;
\r
3609 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
\r
3610 tinyMCE.triggerNodeChange();
\r
3614 this.getDoc().execCommand(command, user_interface, value);
\r
3615 tinyMCE.triggerNodeChange();
\r
3617 if (tinyMCE.isIE) {
\r
3618 var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
\r
3620 if (n && n.nodeName == "BLOCKQUOTE") {
\r
3621 n.removeAttribute("dir");
\r
3622 n.removeAttribute("style");
\r
3624 } while (n != null && (n = n.parentNode) != null);
\r
3628 case "RemoveFormat":
\r
3629 case "removeformat":
\r
3630 var text = this.selection.getSelectedText();
\r
3632 if (tinyMCE.isOpera) {
\r
3633 this.getDoc().execCommand("RemoveFormat", false, null);
\r
3637 if (tinyMCE.isIE) {
\r
3639 var rng = doc.selection.createRange();
\r
3640 rng.execCommand("RemoveFormat", false, null);
\r
3645 this.execCommand("mceSetStyleInfo", false, {command : "removeformat"});
\r
3647 this.getDoc().execCommand(command, user_interface, value);
\r
3649 this.execCommand("mceSetStyleInfo", false, {command : "removeformat"});
\r
3653 if (text.length == 0)
\r
3654 this.execCommand("mceSetCSSClass", false, "");
\r
3656 tinyMCE.triggerNodeChange();
\r
3660 this.getDoc().execCommand(command, user_interface, value);
\r
3662 if (tinyMCE.isGecko)
\r
3663 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
\r
3665 tinyMCE.triggerNodeChange();
\r
3668 // Add undo level after modification
\r
3669 if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceStartTyping" && command != "mceEndTyping")
\r
3670 tinyMCE.execCommand("mceAddUndoLevel");
\r
3673 queryCommandValue : function(c) {
\r
3675 return this.getDoc().queryCommandValue(c);
\r
3681 queryCommandState : function(c) {
\r
3682 return this.getDoc().queryCommandState(c);
\r
3685 _addBogusBR : function() {
\r
3686 var b = this.getBody();
\r
3688 if (tinyMCE.isGecko && !b.hasChildNodes())
\r
3689 b.innerHTML = '<br _moz_editor_bogus_node="TRUE" />';
\r
3692 _onAdd : function(replace_element, form_element_name, target_document) {
\r
3693 var hc, th, tos, editorTemplate, targetDoc, deltaWidth, deltaHeight, html, rng, fragment;
\r
3694 var dynamicIFrame, tElm, doc, parentElm;
\r
3696 th = this.settings.theme;
\r
3697 tos = tinyMCE.themes[th];
\r
3699 targetDoc = target_document ? target_document : document;
\r
3701 this.targetDoc = targetDoc;
\r
3703 tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings.theme;
\r
3704 this.settings.themeurl = tinyMCE.themeURL;
\r
3706 if (!replace_element) {
\r
3707 alert("Error: Could not find the target element.");
\r
3711 if (tos.getEditorTemplate)
\r
3712 editorTemplate = tos.getEditorTemplate(this.settings, this.editorId);
\r
3714 deltaWidth = editorTemplate.delta_width ? editorTemplate.delta_width : 0;
\r
3715 deltaHeight = editorTemplate.delta_height ? editorTemplate.delta_height : 0;
\r
3716 html = '<span id="' + this.editorId + '_parent" class="mceEditorContainer">' + editorTemplate.html;
\r
3718 html = tinyMCE.replaceVar(html, "editor_id", this.editorId);
\r
3720 if (!this.settings.default_document)
\r
3721 this.settings.default_document = tinyMCE.baseURL + "/blank.htm";
\r
3723 this.settings.old_width = this.settings.width;
\r
3724 this.settings.old_height = this.settings.height;
\r
3726 // Set default width, height
\r
3727 if (this.settings.width == -1)
\r
3728 this.settings.width = replace_element.offsetWidth;
\r
3730 if (this.settings.height == -1)
\r
3731 this.settings.height = replace_element.offsetHeight;
\r
3733 // Try the style width
\r
3734 if (this.settings.width == 0)
\r
3735 this.settings.width = replace_element.style.width;
\r
3737 // Try the style height
\r
3738 if (this.settings.height == 0)
\r
3739 this.settings.height = replace_element.style.height;
\r
3741 // If no width/height then default to 320x240, better than nothing
\r
3742 if (this.settings.width == 0)
\r
3743 this.settings.width = 320;
\r
3745 if (this.settings.height == 0)
\r
3746 this.settings.height = 240;
\r
3748 this.settings.area_width = parseInt(this.settings.width);
\r
3749 this.settings.area_height = parseInt(this.settings.height);
\r
3750 this.settings.area_width += deltaWidth;
\r
3751 this.settings.area_height += deltaHeight;
\r
3752 this.settings.width_style = "" + this.settings.width;
\r
3753 this.settings.height_style = "" + this.settings.height;
\r
3755 // Special % handling
\r
3756 if (("" + this.settings.width).indexOf('%') != -1)
\r
3757 this.settings.area_width = "100%";
\r
3759 this.settings.width_style += 'px';
\r
3761 if (("" + this.settings.height).indexOf('%') != -1)
\r
3762 this.settings.area_height = "100%";
\r
3764 this.settings.height_style += 'px';
\r
3766 if (("" + replace_element.style.width).indexOf('%') != -1) {
\r
3767 this.settings.width = replace_element.style.width;
\r
3768 this.settings.area_width = "100%";
\r
3769 this.settings.width_style = "100%";
\r
3772 if (("" + replace_element.style.height).indexOf('%') != -1) {
\r
3773 this.settings.height = replace_element.style.height;
\r
3774 this.settings.area_height = "100%";
\r
3775 this.settings.height_style = "100%";
\r
3778 html = tinyMCE.applyTemplate(html);
\r
3780 this.settings.width = this.settings.old_width;
\r
3781 this.settings.height = this.settings.old_height;
\r
3783 this.visualAid = this.settings.visual;
\r
3784 this.formTargetElementId = form_element_name;
\r
3786 // Get replace_element contents
\r
3787 if (replace_element.nodeName == "TEXTAREA" || replace_element.nodeName == "INPUT")
\r
3788 this.startContent = replace_element.value;
\r
3790 this.startContent = replace_element.innerHTML;
\r
3792 // If not text area or input
\r
3793 if (replace_element.nodeName != "TEXTAREA" && replace_element.nodeName != "INPUT") {
\r
3794 this.oldTargetElement = replace_element;
\r
3797 hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />';
\r
3798 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
\r
3799 this.oldTargetElement.style.display = "none";
\r
3801 html += '</span>';
\r
3803 if (tinyMCE.isGecko)
\r
3808 // Output HTML and set editable
\r
3809 if (tinyMCE.isGecko) {
\r
3810 rng = replace_element.ownerDocument.createRange();
\r
3811 rng.setStartBefore(replace_element);
\r
3813 fragment = rng.createContextualFragment(html);
\r
3814 tinyMCE.insertAfter(fragment, replace_element);
\r
3816 replace_element.insertAdjacentHTML("beforeBegin", html);
\r
3818 html += '</span>';
\r
3820 // Just hide the textarea element
\r
3821 this.oldTargetElement = replace_element;
\r
3823 this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline');
\r
3824 this.oldTargetElement.style.display = "none";
\r
3826 // Output HTML and set editable
\r
3827 if (tinyMCE.isGecko) {
\r
3828 rng = replace_element.ownerDocument.createRange();
\r
3829 rng.setStartBefore(replace_element);
\r
3831 fragment = rng.createContextualFragment(html);
\r
3832 tinyMCE.insertAfter(fragment, replace_element);
\r
3834 replace_element.insertAdjacentHTML("beforeBegin", html);
\r
3838 dynamicIFrame = false;
\r
3839 tElm = targetDoc.getElementById(this.editorId);
\r
3841 if (!tinyMCE.isIE) {
\r
3842 // Node case is preserved in XML strict mode
\r
3843 if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) {
\r
3844 tElm = tinyMCE._createIFrame(tElm, targetDoc);
\r
3845 dynamicIFrame = true;
\r
3848 this.targetElement = tElm;
\r
3849 this.iframeElement = tElm;
\r
3850 this.contentDocument = tElm.contentDocument;
\r
3851 this.contentWindow = tElm.contentWindow;
\r
3853 //this.getDoc().designMode = "on";
\r
3855 if (tElm && tElm.nodeName == "SPAN")
\r
3856 tElm = tinyMCE._createIFrame(tElm, targetDoc, targetDoc.parentWindow);
\r
3858 tElm = targetDoc.frames[this.editorId];
\r
3860 this.targetElement = tElm;
\r
3861 this.iframeElement = targetDoc.getElementById(this.editorId);
\r
3863 if (tinyMCE.isOpera) {
\r
3864 this.contentDocument = this.iframeElement.contentDocument;
\r
3865 this.contentWindow = this.iframeElement.contentWindow;
\r
3866 dynamicIFrame = true;
\r
3868 this.contentDocument = tElm.window.document;
\r
3869 this.contentWindow = tElm.window;
\r
3872 this.getDoc().designMode = "on";
\r
3875 // Setup base HTML
\r
3876 doc = this.contentDocument;
\r
3877 if (dynamicIFrame) {
\r
3878 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>';
\r
3881 if (!this.isHidden())
\r
3882 this.getDoc().designMode = "on";
\r
3888 // Failed Mozilla 1.3
\r
3889 this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm";
\r
3893 // This timeout is needed in MSIE 5.5 for some odd reason
\r
3894 // it seems that the document.frames isn't initialized yet?
\r
3896 window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
\r
3898 // Setup element references
\r
3899 parentElm = this.targetDoc.getElementById(this.editorId + '_parent');
\r
3900 this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
\r
3902 tinyMCE.setupContent(this.editorId, true);
\r
3907 setBaseHREF : function(u) {
\r
3910 d = this.getDoc();
\r
3911 nl = d.getElementsByTagName("base");
\r
3912 b = nl.length > 0 ? nl[0] : null;
\r
3915 nl = d.getElementsByTagName("head");
\r
3916 h = nl.length > 0 ? nl[0] : null;
\r
3918 b = d.createElement("base");
\r
3919 b.setAttribute('href', u);
\r
3922 if (u == '' || u == null)
\r
3923 b.parentNode.removeChild(b);
\r
3925 b.setAttribute('href', u);
\r
3929 getHTML : function(r) {
\r
3930 var h, d = this.getDoc(), b = this.getBody();
\r
3933 return b.innerHTML;
\r
3935 h = tinyMCE._cleanupHTML(this, d, this.settings, b, false, true, false, true);
\r
3937 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
3938 tinyMCE.convertSpansToFonts(d);
\r
3943 setHTML : function(h) {
\r
3944 this.execCommand('mceSetContent', false, h);
\r
3948 getFocusElement : function() {
\r
3949 return this.selection.getFocusElement();
\r
3952 getSel : function() {
\r
3953 return this.selection.getSel();
\r
3956 getRng : function() {
\r
3957 return this.selection.getRng();
\r
3960 triggerSave : function(skip_cleanup, skip_callback) {
\r
3961 var e, nl = [], i, s, content, htm;
\r
3963 if (!this.enabled)
\r
3966 this.switchSettings();
\r
3967 s = tinyMCE.settings;
\r
3969 // Force hidden tabs visible while serializing
\r
3970 if (tinyMCE.isRealIE) {
\r
3971 e = this.iframeElement;
\r
3974 if (e.style && e.style.display == 'none') {
\r
3975 e.style.display = 'block';
\r
3976 nl[nl.length] = {elm : e, type : 'style'};
\r
3979 if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
\r
3980 e.className = s.display_tab_class;
\r
3981 nl[nl.length] = {elm : e, type : 'class'};
\r
3983 } while ((e = e.parentNode) != null)
\r
3986 tinyMCE.settings.preformatted = false;
\r
3988 // Default to false
\r
3989 if (typeof(skip_cleanup) == "undefined")
\r
3990 skip_cleanup = false;
\r
3992 // Default to false
\r
3993 if (typeof(skip_callback) == "undefined")
\r
3994 skip_callback = false;
\r
3996 tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML);
\r
3998 // Remove visual aids when cleanup is disabled
\r
3999 if (this.settings.cleanup == false) {
\r
4000 tinyMCE.handleVisualAid(this.getBody(), true, false, this);
\r
4001 tinyMCE._setEventsEnabled(this.getBody(), true);
\r
4004 tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body);
\r
4005 htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);
\r
4006 htm = tinyMCE._customCleanup(this, "submit_content", htm);
\r
4008 if (!skip_callback && tinyMCE.settings.save_callback !== '')
\r
4009 content = tinyMCE.resolveDots(tinyMCE.settings.save_callback, window)(this.formTargetElementId,htm,this.getBody());
\r
4011 // Use callback content if available
\r
4012 if ((typeof(content) != "undefined") && content != null)
\r
4015 // Replace some weird entities (Bug: #1056343)
\r
4016 htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");
\r
4017 htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");
\r
4018 htm = tinyMCE.regexpReplace(htm, ";", ";", "gi");
\r
4019 htm = tinyMCE.regexpReplace(htm, """, """, "gi");
\r
4020 htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");
\r
4022 if (this.formElement)
\r
4023 this.formElement.value = htm;
\r
4025 if (tinyMCE.isSafari && this.formElement)
\r
4026 this.formElement.innerText = htm;
\r
4028 // Hide them again (tabs in MSIE)
\r
4029 for (i=0; i<nl.length; i++) {
\r
4030 if (nl[i].type == 'style')
\r
4031 nl[i].elm.style.display = 'none';
\r
4033 nl[i].elm.className = s.hidden_tab_class;
\r
4039 /* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
\r
4041 tinyMCE.add(TinyMCE_Engine, {
\r
4042 cleanupHTMLCode : function(s) {
\r
4043 s = s.replace(new RegExp('<p \\/>', 'gi'), '<p> </p>');
\r
4044 s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p> </p>');
\r
4046 // Fix close BR elements
\r
4047 s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />');
\r
4049 // Open closed tags like <b/> to <b></b>
\r
4050 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>');
\r
4052 // Remove trailing space <b > to <b>
\r
4053 s = s.replace(new RegExp('\\s+></', 'gi'), '></');
\r
4055 // Close tags <img></img> to <img/>
\r
4056 s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />');
\r
4058 // Weird MSIE bug, <p><hr /></p> breaks runtime?
\r
4060 s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");
\r
4062 // Weird tags will make IE error #bug: 1538495
\r
4064 s = s.replace(/<!(\s*)\/>/g, '');
\r
4066 // Convert relative anchors to absolute URLs ex: #something to file.htm#something
\r
4067 // Removed: Since local document anchors should never be forced absolute example edit.php?id=something
\r
4068 //if (tinyMCE.getParam('convert_urls'))
\r
4069 // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings.document_base_url + "#");
\r
4074 parseStyle : function(str) {
\r
4075 var ar = [], st, i, re, pa;
\r
4080 st = str.split(';');
\r
4082 tinyMCE.clearArray(ar);
\r
4084 for (i=0; i<st.length; i++) {
\r
4088 re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');
\r
4089 pa = st[i].replace(re, '$1||$2').split('||');
\r
4090 //tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2'));
\r
4091 if (pa.length == 2)
\r
4092 ar[pa[0].toLowerCase()] = pa[1];
\r
4098 compressStyle : function(ar, pr, sf, res) {
\r
4099 var box = [], i, a;
\r
4101 box[0] = ar[pr + '-top' + sf];
\r
4102 box[1] = ar[pr + '-left' + sf];
\r
4103 box[2] = ar[pr + '-right' + sf];
\r
4104 box[3] = ar[pr + '-bottom' + sf];
\r
4106 for (i=0; i<box.length; i++) {
\r
4107 if (box[i] == null)
\r
4110 for (a=0; a<box.length; a++) {
\r
4111 if (box[a] != box[i])
\r
4116 // They are all the same
\r
4118 ar[pr + '-top' + sf] = null;
\r
4119 ar[pr + '-left' + sf] = null;
\r
4120 ar[pr + '-right' + sf] = null;
\r
4121 ar[pr + '-bottom' + sf] = null;
\r
4124 serializeStyle : function(ar) {
\r
4125 var str = "", key, val, m;
\r
4128 tinyMCE.compressStyle(ar, "border", "", "border");
\r
4129 tinyMCE.compressStyle(ar, "border", "-width", "border-width");
\r
4130 tinyMCE.compressStyle(ar, "border", "-color", "border-color");
\r
4131 tinyMCE.compressStyle(ar, "border", "-style", "border-style");
\r
4132 tinyMCE.compressStyle(ar, "padding", "", "padding");
\r
4133 tinyMCE.compressStyle(ar, "margin", "", "margin");
\r
4138 if (typeof(val) == 'function')
\r
4141 if (key.indexOf('mso-') == 0)
\r
4144 if (val != null && val !== '') {
\r
4145 val = '' + val; // Force string
\r
4148 val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')");
\r
4151 if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) {
\r
4152 m = new RegExp("url\\('(.*?)'\\)").exec(val);
\r
4155 val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')";
\r
4158 // Force HEX colors
\r
4159 if (tinyMCE.getParam("force_hex_style_colors"))
\r
4160 val = tinyMCE.convertRGBToHex(val, true);
\r
4162 val = val.replace(/\"/g, '\'');
\r
4164 if (val != "url('')")
\r
4165 str += key.toLowerCase() + ": " + val + "; ";
\r
4169 if (new RegExp('; $').test(str))
\r
4170 str = str.substring(0, str.length - 2);
\r
4175 convertRGBToHex : function(s, k) {
\r
4178 if (s.toLowerCase().indexOf('rgb') != -1) {
\r
4179 re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
\r
4180 rgb = s.replace(re, "$1,$2,$3,$4,$5").split(',');
\r
4182 if (rgb.length == 5) {
\r
4183 r = parseInt(rgb[1]).toString(16);
\r
4184 g = parseInt(rgb[2]).toString(16);
\r
4185 b = parseInt(rgb[3]).toString(16);
\r
4187 r = r.length == 1 ? '0' + r : r;
\r
4188 g = g.length == 1 ? '0' + g : g;
\r
4189 b = b.length == 1 ? '0' + b : b;
\r
4191 s = "#" + r + g + b;
\r
4194 s = rgb[0] + s + rgb[4];
\r
4201 convertHexToRGB : function(s) {
\r
4202 if (s.indexOf('#') != -1) {
\r
4203 s = s.replace(new RegExp('[^0-9A-F]', 'gi'), '');
\r
4204 return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")";
\r
4210 convertSpansToFonts : function(doc) {
\r
4211 var s, i, size, fSize, x, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
\r
4213 s = tinyMCE.selectElements(doc, 'span,font');
\r
4214 for (i=0; i<s.length; i++) {
\r
4215 size = tinyMCE.trim(s[i].style.fontSize).toLowerCase();
\r
4218 for (x=0; x<sizes.length; x++) {
\r
4219 if (sizes[x] == size) {
\r
4226 tinyMCE.setAttrib(s[i], 'size', fSize);
\r
4227 s[i].style.fontSize = '';
\r
4230 fFace = s[i].style.fontFamily;
\r
4231 if (fFace != null && fFace !== '') {
\r
4232 tinyMCE.setAttrib(s[i], 'face', fFace);
\r
4233 s[i].style.fontFamily = '';
\r
4236 fColor = s[i].style.color;
\r
4237 if (fColor != null && fColor !== '') {
\r
4238 tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor));
\r
4239 s[i].style.color = '';
\r
4244 convertFontsToSpans : function(doc) {
\r
4245 var fsClasses, s, i, fSize, fFace, fColor, sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
\r
4247 fsClasses = tinyMCE.getParam('font_size_classes');
\r
4248 if (fsClasses !== '')
\r
4249 fsClasses = fsClasses.replace(/\s+/, '').split(',');
\r
4253 s = tinyMCE.selectElements(doc, 'span,font');
\r
4254 for (i=0; i<s.length; i++) {
\r
4255 fSize = tinyMCE.getAttrib(s[i], 'size');
\r
4256 fFace = tinyMCE.getAttrib(s[i], 'face');
\r
4257 fColor = tinyMCE.getAttrib(s[i], 'color');
\r
4259 if (fSize !== '') {
\r
4260 fSize = parseInt(fSize);
\r
4262 if (fSize > 0 && fSize < 8) {
\r
4263 if (fsClasses != null)
\r
4264 tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]);
\r
4266 s[i].style.fontSize = sizes[fSize-1];
\r
4269 s[i].removeAttribute('size');
\r
4272 if (fFace !== '') {
\r
4273 s[i].style.fontFamily = fFace;
\r
4274 s[i].removeAttribute('face');
\r
4277 if (fColor !== '') {
\r
4278 s[i].style.color = fColor;
\r
4279 s[i].removeAttribute('color');
\r
4284 cleanupAnchors : function(doc) {
\r
4285 var i, cn, x, an = doc.getElementsByTagName("a");
\r
4287 // Loops backwards due to bug #1467987
\r
4288 for (i=an.length-1; i>=0; i--) {
\r
4289 if (tinyMCE.getAttrib(an[i], "name") !== '' && tinyMCE.getAttrib(an[i], "href") == '') {
\r
4290 cn = an[i].childNodes;
\r
4292 for (x=cn.length-1; x>=0; x--)
\r
4293 tinyMCE.insertAfter(cn[x], an[i]);
\r
4298 getContent : function(editor_id) {
\r
4299 if (typeof(editor_id) != "undefined")
\r
4300 tinyMCE.getInstanceById(editor_id).select();
\r
4302 if (tinyMCE.selectedInstance)
\r
4303 return tinyMCE.selectedInstance.getHTML();
\r
4308 _fixListElements : function(d) {
\r
4309 var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np;
\r
4311 for (x=0; x<a.length; x++) {
\r
4312 nl = d.getElementsByTagName(a[x]);
\r
4314 for (i=0; i<nl.length; i++) {
\r
4318 if (r.test(p.nodeName)) {
\r
4319 np = tinyMCE.prevNode(n, 'LI');
\r
4322 np = d.createElement('li');
\r
4323 np.innerHTML = ' ';
\r
4324 np.appendChild(n);
\r
4325 p.insertBefore(np, p.firstChild);
\r
4327 np.appendChild(n);
\r
4333 _fixTables : function(d) {
\r
4334 var nl, i, n, p, np, x, t;
\r
4336 nl = d.getElementsByTagName('table');
\r
4337 for (i=0; i<nl.length; i++) {
\r
4340 if ((p = tinyMCE.getParentElement(n, 'p,h1,h2,h3,h4,h5,h6')) != null) {
\r
4341 np = p.cloneNode(false);
\r
4342 np.removeAttribute('id');
\r
4346 while ((n = n.nextSibling))
\r
4347 np.appendChild(n);
\r
4349 tinyMCE.insertAfter(np, p);
\r
4350 tinyMCE.insertAfter(t, p);
\r
4355 _cleanupHTML : function(inst, doc, config, elm, visual, on_save, on_submit, inn) {
\r
4356 var h, d, t1, t2, t3, t4, t5, c, s, nb;
\r
4358 if (!tinyMCE.getParam('cleanup'))
\r
4359 return elm.innerHTML;
\r
4361 on_save = typeof(on_save) == 'undefined' ? false : on_save;
\r
4364 s = inst.settings;
\r
4365 d = c.settings.debug;
\r
4368 t1 = new Date().getTime();
\r
4370 inst._fixRootBlocks();
\r
4372 if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
4373 tinyMCE.convertFontsToSpans(doc);
\r
4375 if (tinyMCE.getParam("fix_list_elements"))
\r
4376 tinyMCE._fixListElements(doc);
\r
4378 if (tinyMCE.getParam("fix_table_elements"))
\r
4379 tinyMCE._fixTables(doc);
\r
4381 // Call custom cleanup code
\r
4382 tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);
\r
4385 t2 = new Date().getTime();
\r
4387 c.settings.on_save = on_save;
\r
4390 c.serializationId = new Date().getTime().toString(32); // Unique ID needed for the content duplication bug
\r
4391 c.serializedNodes = [];
\r
4392 c.sourceIndex = -1;
\r
4394 if (s.cleanup_serializer == "xml")
\r
4395 h = c.serializeNodeAsXML(elm, inn);
\r
4397 h = c.serializeNodeAsHTML(elm, inn);
\r
4400 t3 = new Date().getTime();
\r
4402 // Post processing
\r
4403 nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? ' ' : ' ';
\r
4404 h = h.replace(/<\/?(body|head|html)[^>]*>/gi, '');
\r
4405 h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), '');
\r
4406 h = h.replace(/<p><hr \/><\/p>/g, '<hr />');
\r
4407 h = h.replace(/<p>( | )<\/p><hr \/><p>( | )<\/p>/g, '<hr />');
\r
4408 h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>');
\r
4409 h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
\r
4410 h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko
\r
4411 h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko
\r
4412 h = h.replace(/<p>\s*( | )\s*<br \/>\s*( | )\s*<\/p>/g, '<p>' + nb + '</p>');
\r
4413 h = h.replace(/<p>\s*( | )\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
\r
4414 h = h.replace(/<p>\s*<br \/>\s* \s*<\/p>/g, '<p>' + nb + '</p>');
\r
4415 h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1');
\r
4416 h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>');
\r
4419 if (/^\s*(<br \/>|<p> <\/p>|<p> <\/p>|<p><\/p>)\s*$/.test(h))
\r
4422 // If preformatted
\r
4423 if (s.preformatted) {
\r
4424 h = h.replace(/^<pre>/, '');
\r
4425 h = h.replace(/<\/pre>$/, '');
\r
4426 h = '<pre>' + h + '</pre>';
\r
4429 // Gecko specific processing
\r
4430 if (tinyMCE.isGecko) {
\r
4431 // Makes no sence but FF generates it!!
\r
4432 h = h.replace(/<br \/>\s*<\/li>/g, '</li>');
\r
4433 h = h.replace(/ \s*<\/(dd|dt)>/g, '</$1>');
\r
4434 h = h.replace(/<o:p _moz-userdefined="" \/>/g, '');
\r
4435 h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>');
\r
4438 if (s.force_br_newlines)
\r
4439 h = h.replace(/<p>( | )<\/p>/g, '<br />');
\r
4441 // Call custom cleanup code
\r
4442 h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h);
\r
4444 // Remove internal classes
\r
4446 h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), '');
\r
4447 h = h.replace(new RegExp(' ?class=""', 'g'), '');
\r
4450 if (s.remove_linebreaks && !c.settings.indent)
\r
4451 h = h.replace(/\n|\r/g, ' ');
\r
4454 t4 = new Date().getTime();
\r
4456 if (on_save && c.settings.indent)
\r
4457 h = c.formatHTML(h);
\r
4459 // If encoding (not recommended option)
\r
4460 if (on_submit && (s.encoding == "xml" || s.encoding == "html"))
\r
4461 h = c.xmlEncode(h);
\r
4464 t5 = new Date().getTime();
\r
4466 if (c.settings.debug)
\r
4467 tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + ".");
\r
4473 function TinyMCE_Cleanup() {
\r
4474 this.isIE = (navigator.appName == "Microsoft Internet Explorer");
\r
4475 this.rules = tinyMCE.clearArray([]);
\r
4479 indent_elements : 'head,table,tbody,thead,tfoot,form,tr,ul,ol,blockquote,object',
\r
4480 newline_before_elements : 'h1,h2,h3,h4,h5,h6,pre,address,div,ul,ol,li,meta,option,area,title,link,base,script,td',
\r
4481 newline_after_elements : 'br,hr,p,pre,address,div,ul,ol,meta,option,area,link,base,script',
\r
4482 newline_before_after_elements : 'html,head,body,table,thead,tbody,tfoot,tr,form,ul,ol,blockquote,p,object,param,hr,div',
\r
4483 indent_char : '\t',
\r
4484 indent_levels : 1,
\r
4485 entity_encoding : 'raw',
\r
4486 valid_elements : '*[*]',
\r
4488 url_converter : '',
\r
4489 invalid_elements : '',
\r
4490 verify_html : false
\r
4493 this.vElements = tinyMCE.clearArray([]);
\r
4494 this.vElementsRe = '';
\r
4495 this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/;
\r
4496 this.codeElementsRe = /^(SCRIPT|STYLE)$/;
\r
4497 this.serializationId = 0;
\r
4498 this.mceAttribs = {
\r
4499 href : 'mce_href',
\r
4505 TinyMCE_Cleanup.prototype = {
\r
4506 init : function(s) {
\r
4507 var n, a, i, ir, or, st;
\r
4510 this.settings[n] = s[n];
\r
4512 // Setup code formating
\r
4513 s = this.settings;
\r
4516 this.inRe = this._arrayToRe(s.indent_elements.split(','), '', '^<(', ')[^>]*');
\r
4517 this.ouRe = this._arrayToRe(s.indent_elements.split(','), '', '^<\\/(', ')[^>]*');
\r
4518 this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>');
\r
4519 this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>');
\r
4520 this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>');
\r
4521 this.serializedNodes = [];
\r
4523 if (s.invalid_elements !== '')
\r
4524 this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$');
\r
4526 this.iveRe = null;
\r
4528 // Setup separator
\r
4530 for (i=0; i<s.indent_levels; i++)
\r
4531 st += s.indent_char;
\r
4535 // If verify_html if false force *[*]
\r
4536 if (!s.verify_html) {
\r
4537 s.valid_elements = '*[*]';
\r
4538 s.extended_valid_elements = '';
\r
4541 this.fillStr = s.entity_encoding == "named" ? " " : " ";
\r
4543 this.xmlEncodeRe = new RegExp('[\u007F-\uFFFF<>&"]', 'g');
\r
4546 addRuleStr : function(s) {
\r
4547 var r = this.parseRuleStr(s), n;
\r
4551 this.rules[n] = r[n];
\r
4554 this.vElements = tinyMCE.clearArray([]);
\r
4556 for (n in this.rules) {
\r
4557 if (this.rules[n])
\r
4558 this.vElements[this.vElements.length] = this.rules[n].tag;
\r
4561 this.vElementsRe = this._arrayToRe(this.vElements, '');
\r
4564 isValid : function(n) {
\r
4565 if (!this.rulesDone)
\r
4566 this._setupRules(); // Will initialize cleanup rules
\r
4568 // Empty is true since it removes formatting
\r
4572 // Clean the name up a bit
\r
4573 n = n.replace(/[^a-z0-9]+/gi, '').toUpperCase();
\r
4575 return !tinyMCE.getParam('cleanup') || this.vElementsRe.test(n);
\r
4578 addChildRemoveRuleStr : function(s) {
\r
4579 var x, y, p, i, t, tn, ta, cl, r;
\r
4584 ta = s.split(',');
\r
4585 for (x=0; x<ta.length; x++) {
\r
4588 // Split tag/children
\r
4589 p = this.split(/\[|\]/, s);
\r
4590 if (p == null || p.length < 1)
\r
4591 t = s.toUpperCase();
\r
4593 t = p[0].toUpperCase();
\r
4595 // Handle all tag names
\r
4596 tn = this.split('/', t);
\r
4597 for (y=0; y<tn.length; y++) {
\r
4601 cl = this.split(/\|/, p[1]);
\r
4602 for (i=0; i<cl.length; i++) {
\r
4603 if (cl[i] == '%istrict')
\r
4604 r += tinyMCE.inlineStrict;
\r
4605 else if (cl[i] == '%itrans')
\r
4606 r += tinyMCE.inlineTransitional;
\r
4607 else if (cl[i] == '%istrict_na')
\r
4608 r += tinyMCE.inlineStrict.substring(2);
\r
4609 else if (cl[i] == '%itrans_na')
\r
4610 r += tinyMCE.inlineTransitional.substring(2);
\r
4611 else if (cl[i] == '%btrans')
\r
4612 r += tinyMCE.blockElms;
\r
4613 else if (cl[i] == '%strict')
\r
4614 r += tinyMCE.blockStrict;
\r
4616 r += (cl[i].charAt(0) != '#' ? cl[i].toUpperCase() : cl[i]);
\r
4618 r += (i != cl.length - 1 ? '|' : '');
\r
4623 if (this.childRules == null)
\r
4624 this.childRules = tinyMCE.clearArray([]);
\r
4626 this.childRules[tn[y]] = new RegExp(r);
\r
4629 this.childRules[tn[y]].wrapTag = p[2];
\r
4634 parseRuleStr : function(s) {
\r
4635 var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray([]), dv;
\r
4637 if (s == null || s.length == 0)
\r
4640 ta = s.split(',');
\r
4641 for (x=0; x<ta.length; x++) {
\r
4643 if (s.length == 0)
\r
4646 // Split tag/attrs
\r
4647 p = this.split(/\[|\]/, s);
\r
4648 if (p == null || p.length < 1)
\r
4649 t = s.toUpperCase();
\r
4651 t = p[0].toUpperCase();
\r
4653 // Handle all tag names
\r
4654 tn = this.split('/', t);
\r
4655 for (y=0; y<tn.length; y++) {
\r
4659 r.forceAttribs = null;
\r
4660 r.defaultAttribs = null;
\r
4661 r.validAttribValues = null;
\r
4663 // Handle prefixes
\r
4664 px = r.tag.charAt(0);
\r
4665 r.forceOpen = px == '+';
\r
4666 r.removeEmpty = px == '-';
\r
4667 r.fill = px == '#';
\r
4668 r.tag = r.tag.replace(/\+|-|#/g, '');
\r
4669 r.oTagName = tn[0].replace(/\+|-|#/g, '').toLowerCase();
\r
4670 r.isWild = new RegExp('\\*|\\?|\\+', 'g').test(r.tag);
\r
4671 r.validRe = new RegExp(this._wildcardToRe('^' + r.tag + '$'));
\r
4673 // Setup valid attributes
\r
4674 if (p.length > 1) {
\r
4675 r.vAttribsRe = '^(';
\r
4676 a = this.split(/\|/, p[1]);
\r
4678 for (i=0; i<a.length; i++) {
\r
4681 if (t.charAt(0) == '!') {
\r
4682 a[i] = t = t.substring(1);
\r
4684 if (!r.reqAttribsRe)
\r
4685 r.reqAttribsRe = '\\s+(' + t;
\r
4687 r.reqAttribsRe += '|' + t;
\r
4690 av = new RegExp('(=|:|<)(.*?)$').exec(t);
\r
4691 t = t.replace(new RegExp('(=|:|<).*?$'), '');
\r
4692 if (av && av.length > 0) {
\r
4693 if (av[0].charAt(0) == ':') {
\r
4694 if (!r.forceAttribs)
\r
4695 r.forceAttribs = tinyMCE.clearArray([]);
\r
4697 r.forceAttribs[t.toLowerCase()] = av[0].substring(1);
\r
4698 } else if (av[0].charAt(0) == '=') {
\r
4699 if (!r.defaultAttribs)
\r
4700 r.defaultAttribs = tinyMCE.clearArray([]);
\r
4702 dv = av[0].substring(1);
\r
4704 r.defaultAttribs[t.toLowerCase()] = dv == '' ? "mce_empty" : dv;
\r
4705 } else if (av[0].charAt(0) == '<') {
\r
4706 if (!r.validAttribValues)
\r
4707 r.validAttribValues = tinyMCE.clearArray([]);
\r
4709 r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i');
\r
4713 r.vAttribsRe += '' + t.toLowerCase() + (i != a.length - 1 ? '|' : '');
\r
4715 a[i] = t.toLowerCase();
\r
4718 if (r.reqAttribsRe)
\r
4719 r.reqAttribsRe = new RegExp(r.reqAttribsRe + ')=\"', 'g');
\r
4721 r.vAttribsRe += ')$';
\r
4722 r.vAttribsRe = this._wildcardToRe(r.vAttribsRe);
\r
4723 r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe);
\r
4724 r.vAttribsRe = new RegExp(r.vAttribsRe);
\r
4725 r.vAttribs = a.reverse();
\r
4727 //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC);
\r
4729 r.vAttribsRe = '';
\r
4730 r.vAttribs = tinyMCE.clearArray([]);
\r
4731 r.vAttribsReIsWild = false;
\r
4741 serializeNodeAsXML : function(n) {
\r
4744 if (!this.xmlDoc) {
\r
4746 try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
\r
4749 try {this.xmlDoc = new ActiveXObject('Microsoft.XmlDom');} catch (e) {}
\r
4751 this.xmlDoc = document.implementation.createDocument('', '', null);
\r
4754 alert("Error XML Parser could not be found.");
\r
4757 if (this.xmlDoc.firstChild)
\r
4758 this.xmlDoc.removeChild(this.xmlDoc.firstChild);
\r
4760 b = this.xmlDoc.createElement("html");
\r
4761 b = this.xmlDoc.appendChild(b);
\r
4763 this._convertToXML(n, b);
\r
4766 return this.xmlDoc.xml;
\r
4768 return new XMLSerializer().serializeToString(this.xmlDoc);
\r
4771 _convertToXML : function(n, xn) {
\r
4772 var xd, el, i, l, cn, at, no, hc = false;
\r
4774 if (tinyMCE.isRealIE && this._isDuplicate(n))
\r
4779 switch (n.nodeType) {
\r
4780 case 1: // Element
\r
4781 hc = n.hasChildNodes();
\r
4783 el = xd.createElement(n.nodeName.toLowerCase());
\r
4785 at = n.attributes;
\r
4786 for (i=at.length-1; i>-1; i--) {
\r
4789 if (no.specified && no.nodeValue)
\r
4790 el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue);
\r
4793 if (!hc && !this.closeElementsRe.test(n.nodeName))
\r
4794 el.appendChild(xd.createTextNode(""));
\r
4796 xn = xn.appendChild(el);
\r
4800 xn.appendChild(xd.createTextNode(n.nodeValue));
\r
4803 case 8: // Comment
\r
4804 xn.appendChild(xd.createComment(n.nodeValue));
\r
4809 cn = n.childNodes;
\r
4811 for (i=0, l=cn.length; i<l; i++)
\r
4812 this._convertToXML(cn[i], xn);
\r
4816 serializeNodeAsHTML : function(n, inn) {
\r
4817 var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr, nn;
\r
4819 if (!this.rulesDone)
\r
4820 this._setupRules(); // Will initialize cleanup rules
\r
4822 if (tinyMCE.isRealIE && this._isDuplicate(n))
\r
4825 // Skip non valid child elements
\r
4826 if (n.parentNode && this.childRules != null) {
\r
4827 cr = this.childRules[n.parentNode.nodeName];
\r
4829 if (typeof(cr) != "undefined" && !cr.test(n.nodeName)) {
\r
4835 switch (n.nodeType) {
\r
4836 case 1: // Element
\r
4837 hc = n.hasChildNodes();
\r
4844 if (tinyMCE.isRealIE) {
\r
4845 // MSIE sometimes produces <//tag>
\r
4846 if (n.nodeName.indexOf('/') != -1)
\r
4849 // MSIE has it's NS in a separate attrib
\r
4850 if (n.scopeName && n.scopeName != 'HTML')
\r
4851 nn = n.scopeName.toUpperCase() + ':' + nn.toUpperCase();
\r
4852 } else if (tinyMCE.isOpera && nn.indexOf(':') > 0)
\r
4853 nn = nn.toUpperCase();
\r
4855 // Convert fonts to spans
\r
4856 if (this.settings.convert_fonts_to_spans) {
\r
4857 // On get content FONT -> SPAN
\r
4858 if (this.settings.on_save && nn == 'FONT')
\r
4861 // On insert content SPAN -> FONT
\r
4862 if (!this.settings.on_save && nn == 'SPAN')
\r
4866 if (this.vElementsRe.test(nn) && (!this.iveRe || !this.iveRe.test(nn)) && !inn) {
\r
4869 r = this.rules[nn];
\r
4873 if (at[no] && at[no].validRe.test(nn)) {
\r
4880 en = r.isWild ? nn.toLowerCase() : r.oTagName;
\r
4883 if (r.removeEmpty && !hc)
\r
4888 if (r.vAttribsReIsWild) {
\r
4889 // Serialize wildcard attributes
\r
4890 at = n.attributes;
\r
4891 for (i=at.length-1; i>-1; i--) {
\r
4893 if (no.specified && r.vAttribsRe.test(no.nodeName))
\r
4894 t += this._serializeAttribute(n, r, no.nodeName);
\r
4897 // Serialize specific attributes
\r
4898 for (i=r.vAttribs.length-1; i>-1; i--)
\r
4899 t += this._serializeAttribute(n, r, r.vAttribs[i]);
\r
4902 // Serialize mce_ atts
\r
4903 if (!this.settings.on_save) {
\r
4904 at = this.mceAttribs;
\r
4908 t += this._serializeAttribute(n, r, at[no]);
\r
4912 // Check for required attribs
\r
4913 if (r.reqAttribsRe && !t.match(r.reqAttribsRe))
\r
4917 if (t != null && this.closeElementsRe.test(nn))
\r
4923 if (this.isIE && this.codeElementsRe.test(nn))
\r
4932 if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
\r
4933 return this.isIE ? '' : n.nodeValue;
\r
4935 return this.xmlEncode(n.nodeValue);
\r
4937 case 8: // Comment
\r
4941 return "<!--" + this._trimComment(n.nodeValue) + "-->";
\r
4945 cn = n.childNodes;
\r
4947 for (i=0, l=cn.length; i<l; i++)
\r
4948 h += this.serializeNodeAsHTML(cn[i]);
\r
4951 // Fill empty nodes
\r
4953 h += this.fillStr;
\r
4956 if (t != null && va)
\r
4957 h += '</' + en + '>';
\r
4962 _serializeAttribute : function(n, r, an) {
\r
4963 var av = '', t, os = this.settings.on_save;
\r
4965 if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0))
\r
4968 if (os && this.mceAttribs[an])
\r
4969 av = this._getAttrib(n, this.mceAttribs[an]);
\r
4971 if (av.length == 0)
\r
4972 av = this._getAttrib(n, an);
\r
4974 if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) {
\r
4977 if (av == "mce_empty")
\r
4978 return " " + an + '=""';
\r
4981 if (r.forceAttribs && (t = r.forceAttribs[an]))
\r
4984 if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an))
\r
4985 av = this._urlConverter(this, n, av);
\r
4987 if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
\r
4990 if (av.length != 0 && av == "{$uid}")
\r
4991 av = "uid_" + (this.idCount++);
\r
4993 if (av.length != 0) {
\r
4994 if (an.indexOf('on') != 0)
\r
4995 av = this.xmlEncode(av, 1);
\r
4997 return " " + an + "=" + '"' + av + '"';
\r
5003 formatHTML : function(h) {
\r
5004 var s = this.settings, p = '', i = 0, li = 0, o = '', l;
\r
5006 // Replace BR in pre elements to \n
\r
5007 h = h.replace(/<pre([^>]*)>(.*?)<\/pre>/gi, function (a, b, c) {
\r
5008 c = c.replace(/<br\s*\/>/gi, '\n');
\r
5009 return '<pre' + b + '>' + c + '</pre>';
\r
5012 h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :)
\r
5014 h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting
\r
5015 h = h.replace(this.nlBeforeRe, '\n<$1$2>');
\r
5016 h = h.replace(this.nlAfterRe, '<$1$2>\n');
\r
5017 h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n');
\r
5020 //tinyMCE.debug(h);
\r
5022 while ((i = h.indexOf('\n', i + 1)) != -1) {
\r
5023 if ((l = h.substring(li + 1, i)).length != 0) {
\r
5024 if (this.ouRe.test(l) && p.length >= s.indent_levels)
\r
5025 p = p.substring(s.indent_levels);
\r
5027 o += p + l + '\n';
\r
5029 if (this.inRe.test(l))
\r
5036 //tinyMCE.debug(h);
\r
5041 xmlEncode : function(s) {
\r
5042 var cl = this, re = this.xmlEncodeRe;
\r
5044 if (!this.entitiesDone)
\r
5045 this._setupEntities(); // Will intialize lookup table
\r
5047 switch (this.settings.entity_encoding) {
\r
5049 return tinyMCE.xmlEncode(s);
\r
5052 return s.replace(re, function (c) {
\r
5053 var b = cl.entities[c.charCodeAt(0)];
\r
5055 return b ? '&' + b + ';' : c;
\r
5059 return s.replace(re, function (c) {
\r
5060 return '&#' + c.charCodeAt(0) + ';';
\r
5067 split : function(re, s) {
\r
5068 var i, l, o = [], c = s.split(re);
\r
5070 for (i=0, l=c.length; i<l; i++) {
\r
5078 _trimComment : function(s) {
\r
5079 // Remove mce_src, mce_href
\r
5080 s = s.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
\r
5081 s = s.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
\r
5086 _getAttrib : function(e, n, d) {
\r
5089 if (typeof(d) == "undefined")
\r
5092 if (!e || e.nodeType != 1)
\r
5096 v = e.getAttribute(n, 0);
\r
5098 // IE 7 may cast exception on invalid attributes
\r
5099 v = e.getAttribute(n, 2);
\r
5102 if (n == "class" && !v)
\r
5106 if (n == "http-equiv")
\r
5111 // Skip the default values that IE returns
\r
5112 if (nn == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
\r
5115 if (nn == "INPUT" && n == "size" && v == "20")
\r
5118 if (nn == "INPUT" && n == "maxlength" && v == "2147483647")
\r
5122 if (n == "width" || n == "height")
\r
5123 v = e.getAttribute(n, 2);
\r
5126 if (n == 'style' && v) {
\r
5127 if (!tinyMCE.isOpera)
\r
5128 v = e.style.cssText;
\r
5130 v = tinyMCE.serializeStyle(tinyMCE.parseStyle(v));
\r
5133 if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v !== '')
\r
5134 v = tinyMCE.cleanupEventStr(v);
\r
5136 return (v && v !== '') ? '' + v : d;
\r
5139 _urlConverter : function(c, n, v) {
\r
5140 if (!c.settings.on_save)
\r
5141 return tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, v);
\r
5142 else if (tinyMCE.getParam('convert_urls')) {
\r
5143 if (!this.urlConverter)
\r
5144 this.urlConverter = eval(tinyMCE.settings.urlconverter_callback);
\r
5146 return this.urlConverter(v, n, true);
\r
5152 _arrayToRe : function(a, op, be, af) {
\r
5155 op = typeof(op) == "undefined" ? "gi" : op;
\r
5156 be = typeof(be) == "undefined" ? "^(" : be;
\r
5157 af = typeof(af) == "undefined" ? ")$" : af;
\r
5161 for (i=0; i<a.length; i++)
\r
5162 r += this._wildcardToRe(a[i]) + (i != a.length-1 ? "|" : "");
\r
5166 return new RegExp(r, op);
\r
5169 _wildcardToRe : function(s) {
\r
5170 s = s.replace(/\?/g, '(\\S?)');
\r
5171 s = s.replace(/\+/g, '(\\S+)');
\r
5172 s = s.replace(/\*/g, '(\\S*)');
\r
5177 _setupEntities : function() {
\r
5178 var n, a, i, s = this.settings;
\r
5181 if (s.entity_encoding == "named") {
\r
5182 n = tinyMCE.clearArray([]);
\r
5183 a = this.split(',', s.entities);
\r
5184 for (i=0; i<a.length; i+=2)
\r
5187 this.entities = n;
\r
5190 this.entitiesDone = true;
\r
5193 _setupRules : function() {
\r
5194 var s = this.settings;
\r
5196 // Setup default rule
\r
5197 this.addRuleStr(s.valid_elements);
\r
5198 this.addRuleStr(s.extended_valid_elements);
\r
5199 this.addChildRemoveRuleStr(s.valid_child_elements);
\r
5201 this.rulesDone = true;
\r
5204 _isDuplicate : function(n) {
\r
5207 if (!this.settings.fix_content_duplication)
\r
5210 if (tinyMCE.isRealIE && n.nodeType == 1) {
\r
5212 if (n.mce_serialized == this.serializationId)
\r
5215 n.setAttribute('mce_serialized', this.serializationId);
\r
5217 sn = this.serializedNodes;
\r
5219 // Search lookup table for text nodes and comments
\r
5220 for (i=0, l = sn.length; i<l; i++) {
\r
5233 /* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
\r
5235 tinyMCE.add(TinyMCE_Engine, {
\r
5236 createTagHTML : function(tn, a, h) {
\r
5237 var o = '', f = tinyMCE.xmlEncode, n;
\r
5243 if (typeof(a[n]) != 'function' && a[n] != null)
\r
5244 o += ' ' + f(n) + '="' + f('' + a[n]) + '"';
\r
5248 o += !h ? ' />' : '>' + h + '</' + tn + '>';
\r
5253 createTag : function(d, tn, a, h) {
\r
5254 var o = d.createElement(tn), n;
\r
5258 if (typeof(a[n]) != 'function' && a[n] != null)
\r
5259 tinyMCE.setAttrib(o, n, a[n]);
\r
5269 getElementByAttributeValue : function(n, e, a, v) {
\r
5270 return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];
\r
5273 getElementsByAttributeValue : function(n, e, a, v) {
\r
5274 var i, nl = n.getElementsByTagName(e), o = [];
\r
5276 for (i=0; i<nl.length; i++) {
\r
5277 if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)
\r
5278 o[o.length] = nl[i];
\r
5284 isBlockElement : function(n) {
\r
5285 return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);
\r
5288 getParentBlockElement : function(n, r) {
\r
5289 return this.getParentNode(n, function(n) {
\r
5290 return tinyMCE.isBlockElement(n);
\r
5296 insertAfter : function(n, r){
\r
5297 if (r.nextSibling)
\r
5298 r.parentNode.insertBefore(n, r.nextSibling);
\r
5300 r.parentNode.appendChild(n);
\r
5303 setInnerHTML : function(e, h) {
\r
5306 // Convert all strong/em to b/i in Gecko
\r
5307 if (tinyMCE.isGecko) {
\r
5308 h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>');
\r
5309 h = h.replace(/<em([^>]*)>/gi, '<i$1>');
\r
5310 h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>');
\r
5311 h = h.replace(/<strong([^>]*)>/gi, '<b$1>');
\r
5312 h = h.replace(/<\/strong>/gi, '</b>');
\r
5313 h = h.replace(/<\/em>/gi, '</i>');
\r
5316 if (tinyMCE.isRealIE) {
\r
5317 // Since MSIE handles invalid HTML better that valid XHTML we
\r
5318 // need to make some things invalid. <hr /> gets converted to <hr>.
\r
5319 h = h.replace(/\s\/>/g, '>');
\r
5321 // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones
\r
5322 h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs
\r
5323 h = h.replace(/<p([^>]*)>\s* \s*<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs
\r
5324 h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs
\r
5326 // Remove first comment
\r
5327 e.innerHTML = tinyMCE.uniqueTag + h;
\r
5328 e.firstChild.removeNode(true);
\r
5330 // Remove weird auto generated empty paragraphs unless it's supposed to be there
\r
5331 nl = e.getElementsByTagName("p");
\r
5332 for (i=nl.length-1; i>=0; i--) {
\r
5335 if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep)
\r
5336 n.parentNode.removeChild(n);
\r
5339 h = this.fixGeckoBaseHREFBug(1, e, h);
\r
5341 this.fixGeckoBaseHREFBug(2, e, h);
\r
5345 getOuterHTML : function(e) {
\r
5349 return e.outerHTML;
\r
5351 d = e.ownerDocument.createElement("body");
\r
5352 d.appendChild(e.cloneNode(true));
\r
5354 return d.innerHTML;
\r
5357 setOuterHTML : function(e, h, d) {
\r
5358 var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t;
\r
5360 if (tinyMCE.isIE && e.nodeType == 1)
\r
5363 t = d.createElement("body");
\r
5366 for (i=0, nl=t.childNodes; i<nl.length; i++)
\r
5367 e.parentNode.insertBefore(nl[i].cloneNode(true), e);
\r
5369 e.parentNode.removeChild(e);
\r
5373 _getElementById : function(id, d) {
\r
5376 if (typeof(d) == "undefined")
\r
5379 e = d.getElementById(id);
\r
5383 for (i=0; i<f.length; i++) {
\r
5384 for (j=0; j<f[i].elements.length; j++) {
\r
5385 if (f[i].elements[j].name == id) {
\r
5386 e = f[i].elements[j];
\r
5396 getNodeTree : function(n, na, t, nn) {
\r
5397 return this.selectNodes(n, function(n) {
\r
5398 return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
\r
5402 getParentElement : function(n, na, f, r) {
\r
5403 var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v;
\r
5405 // Compatiblity with old scripts where f param was a attribute string
\r
5406 if (f && typeof(f) == 'string')
\r
5407 return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) !== '';});
\r
5409 return this.getParentNode(n, function(n) {
\r
5410 return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n));
\r
5414 getParentNode : function(n, f, r) {
\r
5428 getAttrib : function(elm, name, dv) {
\r
5431 if (typeof(dv) == "undefined")
\r
5435 if (!elm || elm.nodeType != 1)
\r
5439 v = elm.getAttribute(name, 0);
\r
5441 // IE 7 may cast exception on invalid attributes
\r
5442 v = elm.getAttribute(name, 2);
\r
5445 // Try className for class attrib
\r
5446 if (name == "class" && !v)
\r
5447 v = elm.className;
\r
5449 // Workaround for a issue with Firefox 1.5rc2+
\r
5450 if (tinyMCE.isGecko) {
\r
5451 if (name == "src" && elm.src != null && elm.src !== '')
\r
5454 // Workaround for a issue with Firefox 1.5rc2+
\r
5455 if (name == "href" && elm.href != null && elm.href !== '')
\r
5457 } else if (tinyMCE.isIE) {
\r
5459 case "http-equiv":
\r
5460 v = elm.httpEquiv;
\r
5465 v = elm.getAttribute(name, 2);
\r
5470 if (name == "style" && !tinyMCE.isOpera)
\r
5471 v = elm.style.cssText;
\r
5473 return (v && v !== '') ? v : dv;
\r
5476 setAttrib : function(el, name, va, fix) {
\r
5477 if (typeof(va) == "number" && va != null)
\r
5484 va = va.replace(/[^0-9%]/g, '');
\r
5487 if (name == "style")
\r
5488 el.style.cssText = va;
\r
5490 if (name == "class")
\r
5491 el.className = va;
\r
5493 if (va != null && va !== '' && va != -1)
\r
5494 el.setAttribute(name, va);
\r
5496 el.removeAttribute(name);
\r
5499 setStyleAttrib : function(e, n, v) {
\r
5502 // Style attrib deleted in IE
\r
5503 if (tinyMCE.isIE && v == null || v == '') {
\r
5504 v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText));
\r
5505 e.style.cssText = v;
\r
5506 e.setAttribute("style", v);
\r
5510 switchClass : function(ei, c) {
\r
5513 if (tinyMCE.switchClassCache[ei])
\r
5514 e = tinyMCE.switchClassCache[ei];
\r
5516 e = tinyMCE.switchClassCache[ei] = document.getElementById(ei);
\r
5520 if (tinyMCE.settings.button_tile_map && e.className && e.className.indexOf('mceTiledButton') == 0)
\r
5521 c = 'mceTiledButton ' + c;
\r
5527 getAbsPosition : function(n, cn) {
\r
5530 while (n && n != cn) {
\r
5531 l += n.offsetLeft;
\r
5533 n = n.offsetParent;
\r
5536 return {absLeft : l, absTop : t};
\r
5539 prevNode : function(e, n) {
\r
5540 var a = n.split(','), i;
\r
5542 while ((e = e.previousSibling) != null) {
\r
5543 for (i=0; i<a.length; i++) {
\r
5544 if (e.nodeName == a[i])
\r
5552 nextNode : function(e, n) {
\r
5553 var a = n.split(','), i;
\r
5555 while ((e = e.nextSibling) != null) {
\r
5556 for (i=0; i<a.length; i++) {
\r
5557 if (e.nodeName == a[i])
\r
5565 selectElements : function(n, na, f) {
\r
5566 var i, a = [], nl, x;
\r
5568 for (x=0, na = na.split(','); x<na.length; x++)
\r
5569 for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
\r
5570 (!f || f(nl[i])) && a.push(nl[i]);
\r
5575 selectNodes : function(n, f, a) {
\r
5584 if (n.hasChildNodes()) {
\r
5585 for (i=0; i<n.childNodes.length; i++)
\r
5586 tinyMCE.selectNodes(n.childNodes[i], f, a);
\r
5592 addCSSClass : function(e, c, b) {
\r
5593 var o = this.removeCSSClass(e, c);
\r
5594 return e.className = b ? c + (o !== '' ? (' ' + o) : '') : (o !== '' ? (o + ' ') : '') + c;
\r
5597 removeCSSClass : function(e, c) {
\r
5598 c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
\r
5599 return e.className = c != ' ' ? c : '';
\r
5602 hasCSSClass : function(n, c) {
\r
5603 return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
\r
5606 renameElement : function(e, n, d) {
\r
5609 d = typeof(d) == "undefined" ? tinyMCE.selectedInstance.getDoc() : d;
\r
5612 ne = d.createElement(n);
\r
5614 ar = e.attributes;
\r
5615 for (i=ar.length-1; i>-1; i--) {
\r
5616 if (ar[i].specified && ar[i].nodeValue)
\r
5617 ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue);
\r
5620 ar = e.childNodes;
\r
5621 for (i=0; i<ar.length; i++)
\r
5622 ne.appendChild(ar[i].cloneNode(true));
\r
5624 e.parentNode.replaceChild(ne, e);
\r
5628 getViewPort : function(w) {
\r
5629 var d = w.document, m = d.compatMode == 'CSS1Compat', b = d.body, de = d.documentElement;
\r
5632 left : w.pageXOffset || (m ? de.scrollLeft : b.scrollLeft),
\r
5633 top : w.pageYOffset || (m ? de.scrollTop : b.scrollTop),
\r
5634 width : w.innerWidth || (m ? de.clientWidth : b.clientWidth),
\r
5635 height : w.innerHeight || (m ? de.clientHeight : b.clientHeight)
\r
5639 getStyle : function(n, na, d) {
\r
5644 if (tinyMCE.isGecko && n.ownerDocument.defaultView) {
\r
5646 return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na);
\r
5648 // Old safari might fail
\r
5653 // Camelcase it, if needed
\r
5654 na = na.replace(/-(\D)/g, function(a, b){
\r
5655 return b.toUpperCase();
\r
5659 if (n.currentStyle)
\r
5660 return n.currentStyle[na];
\r
5667 /* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
\r
5669 tinyMCE.add(TinyMCE_Engine, {
\r
5670 parseURL : function(url_str) {
\r
5671 var urlParts = [], i, pos, lastPos, chr;
\r
5674 // Parse protocol part
\r
5675 pos = url_str.indexOf('://');
\r
5677 urlParts.protocol = url_str.substring(0, pos);
\r
5678 lastPos = pos + 3;
\r
5681 // Find port or path start
\r
5682 for (i=lastPos; i<url_str.length; i++) {
\r
5683 chr = url_str.charAt(i);
\r
5694 urlParts.host = url_str.substring(lastPos, pos);
\r
5697 urlParts.port = "";
\r
5699 if (url_str.charAt(pos) == ':') {
\r
5700 pos = url_str.indexOf('/', lastPos);
\r
5701 urlParts.port = url_str.substring(lastPos+1, pos);
\r
5706 pos = url_str.indexOf('?', lastPos);
\r
5709 pos = url_str.indexOf('#', lastPos);
\r
5712 pos = url_str.length;
\r
5714 urlParts.path = url_str.substring(lastPos, pos);
\r
5718 if (url_str.charAt(pos) == '?') {
\r
5719 pos = url_str.indexOf('#');
\r
5720 pos = (pos == -1) ? url_str.length : pos;
\r
5721 urlParts.query = url_str.substring(lastPos+1, pos);
\r
5726 if (url_str.charAt(pos) == '#') {
\r
5727 pos = url_str.length;
\r
5728 urlParts.anchor = url_str.substring(lastPos+1, pos);
\r
5735 serializeURL : function(up) {
\r
5739 o += up.protocol + "://";
\r
5745 o += ":" + up.port;
\r
5751 o += "?" + up.query;
\r
5754 o += "#" + up.anchor;
\r
5759 convertAbsoluteURLToRelativeURL : function(base_url, url_to_relative) {
\r
5760 var baseURL = this.parseURL(base_url), targetURL = this.parseURL(url_to_relative);
\r
5761 var i, strTok1, strTok2, breakPoint = 0, outPath = "", forceSlash = false;
\r
5762 var fileName, pos;
\r
5764 if (targetURL.path == '')
\r
5765 targetURL.path = "/";
\r
5767 forceSlash = true;
\r
5769 // Crop away last path part
\r
5770 base_url = baseURL.path.substring(0, baseURL.path.lastIndexOf('/'));
\r
5771 strTok1 = base_url.split('/');
\r
5772 strTok2 = targetURL.path.split('/');
\r
5774 if (strTok1.length >= strTok2.length) {
\r
5775 for (i=0; i<strTok1.length; i++) {
\r
5776 if (i >= strTok2.length || strTok1[i] != strTok2[i]) {
\r
5777 breakPoint = i + 1;
\r
5783 if (strTok1.length < strTok2.length) {
\r
5784 for (i=0; i<strTok2.length; i++) {
\r
5785 if (i >= strTok1.length || strTok1[i] != strTok2[i]) {
\r
5786 breakPoint = i + 1;
\r
5792 if (breakPoint == 1)
\r
5793 return targetURL.path;
\r
5795 for (i=0; i<(strTok1.length-(breakPoint-1)); i++)
\r
5798 for (i=breakPoint-1; i<strTok2.length; i++) {
\r
5799 if (i != (breakPoint-1))
\r
5800 outPath += "/" + strTok2[i];
\r
5802 outPath += strTok2[i];
\r
5805 targetURL.protocol = null;
\r
5806 targetURL.host = null;
\r
5807 targetURL.port = null;
\r
5808 targetURL.path = outPath == '' && forceSlash ? "/" : outPath;
\r
5810 // Remove document prefix from local anchors
\r
5811 fileName = baseURL.path;
\r
5813 if ((pos = fileName.lastIndexOf('/')) != -1)
\r
5814 fileName = fileName.substring(pos + 1);
\r
5816 // Is local anchor
\r
5817 if (fileName == targetURL.path && targetURL.anchor !== '')
\r
5818 targetURL.path = "";
\r
5820 // If empty and not local anchor force filename or slash
\r
5821 if (targetURL.path == '' && !targetURL.anchor)
\r
5822 targetURL.path = fileName !== '' ? fileName : "/";
\r
5824 return this.serializeURL(targetURL);
\r
5827 convertRelativeToAbsoluteURL : function(base_url, relative_url) {
\r
5828 var baseURL = this.parseURL(base_url), baseURLParts, relURLParts, newRelURLParts, numBack, relURL = this.parseURL(relative_url), i;
\r
5829 var len, absPath, start, end, newBaseURLParts;
\r
5831 if (relative_url == '' || relative_url.indexOf('://') != -1 || /^(mailto:|javascript:|#|\/)/.test(relative_url))
\r
5832 return relative_url;
\r
5835 baseURLParts = baseURL.path.split('/');
\r
5836 relURLParts = relURL.path.split('/');
\r
5838 // Remove empty chunks
\r
5839 newBaseURLParts = [];
\r
5840 for (i=baseURLParts.length-1; i>=0; i--) {
\r
5841 if (baseURLParts[i].length == 0)
\r
5844 newBaseURLParts[newBaseURLParts.length] = baseURLParts[i];
\r
5846 baseURLParts = newBaseURLParts.reverse();
\r
5848 // Merge relURLParts chunks
\r
5849 newRelURLParts = [];
\r
5851 for (i=relURLParts.length-1; i>=0; i--) {
\r
5852 if (relURLParts[i].length == 0 || relURLParts[i] == ".")
\r
5855 if (relURLParts[i] == '..') {
\r
5860 if (numBack > 0) {
\r
5865 newRelURLParts[newRelURLParts.length] = relURLParts[i];
\r
5868 relURLParts = newRelURLParts.reverse();
\r
5870 // Remove end from absolute path
\r
5871 len = baseURLParts.length-numBack;
\r
5872 absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/');
\r
5876 // Build output URL
\r
5877 relURL.protocol = baseURL.protocol;
\r
5878 relURL.host = baseURL.host;
\r
5879 relURL.port = baseURL.port;
\r
5881 // Re-add trailing slash if it's removed
\r
5882 if (relURL.path.charAt(relURL.path.length-1) == "/")
\r
5885 relURL.path = absPath;
\r
5887 return this.serializeURL(relURL);
\r
5890 convertURL : function(url, node, on_save) {
\r
5891 var dl = document.location, start, portPart, urlParts, baseUrlParts, tmpUrlParts, curl;
\r
5892 var prot = dl.protocol, host = dl.hostname, port = dl.port;
\r
5894 // Pass through file protocol
\r
5895 if (prot == "file:")
\r
5898 // Something is wrong, remove weirdness
\r
5899 url = tinyMCE.regexpReplace(url, '(http|https):///', '/');
\r
5901 // Mailto link or anchor (Pass through)
\r
5902 if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || /^[ \t\r\n\+]*[#\?]/.test(url))
\r
5905 // Fix relative/Mozilla
\r
5906 if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
\r
5907 return tinyMCE.settings.base_href + url;
\r
5909 // Handle relative URLs
\r
5910 if (on_save && tinyMCE.getParam('relative_urls')) {
\r
5911 curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url);
\r
5912 if (curl.charAt(0) == '/')
\r
5913 curl = tinyMCE.settings.document_base_prefix + curl;
\r
5915 urlParts = tinyMCE.parseURL(curl);
\r
5916 tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings.document_base_url);
\r
5919 if (urlParts.host == tmpUrlParts.host && (urlParts.port == tmpUrlParts.port))
\r
5920 return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings.document_base_url, curl);
\r
5923 // Handle absolute URLs
\r
5924 if (!tinyMCE.getParam('relative_urls')) {
\r
5925 urlParts = tinyMCE.parseURL(url);
\r
5926 baseUrlParts = tinyMCE.parseURL(tinyMCE.settings.base_href);
\r
5928 // Force absolute URLs from relative URLs
\r
5929 url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url);
\r
5931 // If anchor and path is the same page
\r
5932 if (urlParts.anchor && urlParts.path == baseUrlParts.path)
\r
5933 return "#" + urlParts.anchor;
\r
5936 // Remove current domain
\r
5937 if (tinyMCE.getParam('remove_script_host')) {
\r
5942 portPart = ":" + port;
\r
5944 start = prot + "//" + host + portPart + "/";
\r
5946 if (url.indexOf(start) == 0)
\r
5947 url = url.substring(start.length-1);
\r
5953 convertAllRelativeURLs : function(body) {
\r
5954 var i, elms, src, href, mhref, msrc;
\r
5956 // Convert all image URL:s to absolute URL
\r
5957 elms = body.getElementsByTagName("img");
\r
5958 for (i=0; i<elms.length; i++) {
\r
5959 src = tinyMCE.getAttrib(elms[i], 'src');
\r
5961 msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
\r
5966 src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, src);
\r
5967 elms[i].setAttribute("src", src);
\r
5971 // Convert all link URL:s to absolute URL
\r
5972 elms = body.getElementsByTagName("a");
\r
5973 for (i=0; i<elms.length; i++) {
\r
5974 href = tinyMCE.getAttrib(elms[i], 'href');
\r
5976 mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
\r
5980 if (href && href !== '') {
\r
5981 href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, href);
\r
5982 elms[i].setAttribute("href", href);
\r
5989 /* file:jscripts/tiny_mce/classes/TinyMCE_Array.class.js */
\r
5991 tinyMCE.add(TinyMCE_Engine, {
\r
5992 clearArray : function(a) {
\r
6001 explode : function(d, s) {
\r
6002 var ar = s.split(d), oar = [], i;
\r
6004 for (i = 0; i<ar.length; i++) {
\r
6006 oar[oar.length] = ar[i];
\r
6013 /* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */
\r
6015 tinyMCE.add(TinyMCE_Engine, {
\r
6016 _setEventsEnabled : function(node, state) {
\r
6017 var evs, x, y, elms, i, event;
\r
6018 var events = ['onfocus','onblur','onclick','ondblclick',
\r
6019 'onmousedown','onmouseup','onmouseover','onmousemove',
\r
6020 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'];
\r
6022 evs = tinyMCE.settings.event_elements.split(',');
\r
6023 for (y=0; y<evs.length; y++){
\r
6024 elms = node.getElementsByTagName(evs[y]);
\r
6025 for (i=0; i<elms.length; i++) {
\r
6028 for (x=0; x<events.length; x++) {
\r
6029 if ((event = tinyMCE.getAttrib(elms[i], events[x])) !== '') {
\r
6030 event = tinyMCE.cleanupEventStr("" + event);
\r
6033 event = "return true;" + event;
\r
6035 event = event.replace(/^return true;/gi, '');
\r
6037 elms[i].removeAttribute(events[x]);
\r
6038 elms[i].setAttribute(events[x], event);
\r
6045 _eventPatch : function(editor_id) {
\r
6046 var n, inst, win, e;
\r
6048 // Remove odd, error
\r
6049 if (typeof(tinyMCE) == "undefined")
\r
6053 // Try selected instance first
\r
6054 if (tinyMCE.selectedInstance) {
\r
6055 win = tinyMCE.selectedInstance.getWin();
\r
6057 if (win && win.event) {
\r
6061 e.target = e.srcElement;
\r
6063 TinyMCE_Engine.prototype.handleEvent(e);
\r
6069 for (n in tinyMCE.instances) {
\r
6070 inst = tinyMCE.instances[n];
\r
6072 if (!tinyMCE.isInstance(inst))
\r
6076 win = inst.getWin();
\r
6078 if (win && win.event) {
\r
6082 e.target = e.srcElement;
\r
6084 TinyMCE_Engine.prototype.handleEvent(e);
\r
6089 // Ignore error if iframe is pointing to external URL
\r
6093 findEvent : function(e) {
\r
6099 for (n in tinyMCE.instances) {
\r
6100 inst = tinyMCE.instances[n];
\r
6102 if (tinyMCE.isInstance(inst) && inst.getWin().event)
\r
6103 return inst.getWin().event;
\r
6109 unloadHandler : function() {
\r
6110 tinyMCE.triggerSave(true, true);
\r
6113 addEventHandlers : function(inst) {
\r
6114 this.setEventHandlers(inst, 1);
\r
6117 setEventHandlers : function(inst, s) {
\r
6118 var doc = inst.getDoc(), ie, ot, i, f = s ? tinyMCE.addEvent : tinyMCE.removeEvent;
\r
6120 ie = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick'];
\r
6121 ot = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'focus', 'blur', 'dragdrop'];
\r
6123 inst.switchSettings();
\r
6125 if (tinyMCE.isIE) {
\r
6126 for (i=0; i<ie.length; i++)
\r
6127 f(doc, ie[i], TinyMCE_Engine.prototype._eventPatch);
\r
6129 for (i=0; i<ot.length; i++)
\r
6130 f(doc, ot[i], tinyMCE.handleEvent);
\r
6132 // Force designmode
\r
6134 doc.designMode = "On";
\r
6141 onMouseMove : function() {
\r
6144 // Fix for IE7 bug where it's not restoring hover on anchors correctly
\r
6145 if (tinyMCE.lastHover) {
\r
6146 lh = tinyMCE.lastHover;
\r
6148 // Call out on menus and refresh class on normal buttons
\r
6149 if (lh.className.indexOf('mceMenu') != -1)
\r
6150 tinyMCE._menuButtonEvent('out', lh);
\r
6152 lh.className = lh.className;
\r
6154 tinyMCE.lastHover = null;
\r
6157 if (!tinyMCE.hasMouseMoved) {
\r
6158 inst = tinyMCE.selectedInstance;
\r
6160 // Workaround for bug #1437457 (Odd MSIE bug)
\r
6161 if (inst.isFocused) {
\r
6162 inst.undoBookmark = inst.selection.getBookmark();
\r
6163 tinyMCE.hasMouseMoved = true;
\r
6167 // tinyMCE.cancelEvent(inst.getWin().event);
\r
6171 cancelEvent : function(e) {
\r
6175 if (tinyMCE.isIE) {
\r
6176 e.returnValue = false;
\r
6177 e.cancelBubble = true;
\r
6179 e.preventDefault();
\r
6180 e.stopPropagation && e.stopPropagation();
\r
6186 addEvent : function(o, n, h) {
\r
6187 // Add cleanup for all non unload events
\r
6188 if (n != 'unload') {
\r
6189 function clean() {
\r
6193 tinyMCE.removeEvent(o, n, h);
\r
6194 tinyMCE.removeEvent(window, 'unload', clean);
\r
6197 // IE may produce access denied exception on unload
\r
6201 // Add memory cleaner
\r
6202 tinyMCE.addEvent(window, 'unload', clean);
\r
6205 if (o.attachEvent)
\r
6206 o.attachEvent("on" + n, h);
\r
6208 o.addEventListener(n, h, false);
\r
6211 removeEvent : function(o, n, h) {
\r
6212 if (o.detachEvent)
\r
6213 o.detachEvent("on" + n, h);
\r
6215 o.removeEventListener(n, h, false);
\r
6218 addSelectAccessibility : function(e, s, w) {
\r
6219 // Add event handlers
\r
6220 if (!s._isAccessible) {
\r
6221 s.onkeydown = tinyMCE.accessibleEventHandler;
\r
6222 s.onblur = tinyMCE.accessibleEventHandler;
\r
6223 s._isAccessible = true;
\r
6230 accessibleEventHandler : function(e) {
\r
6231 var elm, win = this._win;
\r
6233 e = tinyMCE.isIE ? win.event : e;
\r
6234 elm = tinyMCE.isIE ? e.srcElement : e.target;
\r
6236 // Unpiggyback onchange on blur
\r
6237 if (e.type == "blur") {
\r
6238 if (elm.oldonchange) {
\r
6239 elm.onchange = elm.oldonchange;
\r
6240 elm.oldonchange = null;
\r
6246 // Piggyback onchange
\r
6247 if (elm.nodeName == "SELECT" && !elm.oldonchange) {
\r
6248 elm.oldonchange = elm.onchange;
\r
6249 elm.onchange = null;
\r
6252 // Execute onchange and remove piggyback
\r
6253 if (e.keyCode == 13 || e.keyCode == 32) {
\r
6254 elm.onchange = elm.oldonchange;
\r
6256 elm.oldonchange = null;
\r
6258 tinyMCE.cancelEvent(e);
\r
6265 _resetIframeHeight : function() {
\r
6268 if (tinyMCE.isRealIE) {
\r
6269 ife = tinyMCE.selectedInstance.iframeElement;
\r
6271 /* if (ife._oldWidth) {
\r
6272 ife.style.width = ife._oldWidth;
\r
6273 ife.width = ife._oldWidth;
\r
6276 if (ife._oldHeight) {
\r
6277 ife.style.height = ife._oldHeight;
\r
6278 ife.height = ife._oldHeight;
\r
6285 /* file:jscripts/tiny_mce/classes/TinyMCE_Selection.class.js */
\r
6287 function TinyMCE_Selection(inst) {
\r
6288 this.instance = inst;
\r
6291 TinyMCE_Selection.prototype = {
\r
6292 getSelectedHTML : function() {
\r
6293 var inst = this.instance, e, r = this.getRng(), h;
\r
6298 e = document.createElement("body");
\r
6300 if (r.cloneContents)
\r
6301 e.appendChild(r.cloneContents());
\r
6302 else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined')
\r
6303 e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
\r
6305 e.innerHTML = r.toString(); // Failed, use text for now
\r
6307 h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
\r
6309 // When editing always use fonts internaly
\r
6310 //if (tinyMCE.getParam("convert_fonts_to_spans"))
\r
6311 // tinyMCE.convertSpansToFonts(inst.getDoc());
\r
6316 getSelectedText : function() {
\r
6317 var inst = this.instance, d, r, s, t;
\r
6319 if (tinyMCE.isIE) {
\r
6320 d = inst.getDoc();
\r
6322 if (d.selection.type == "Text") {
\r
6323 r = d.selection.createRange();
\r
6328 s = this.getSel();
\r
6330 if (s && s.toString)
\r
6339 getBookmark : function(simple) {
\r
6340 var inst = this.instance, rng = this.getRng(), doc = inst.getDoc(), b = inst.getBody();
\r
6341 var trng, sx, sy, xx = -999999999, vp = inst.getViewPort();
\r
6342 var sp, le, s, e, nl, i, si, ei, w;
\r
6348 return {rng : rng, scrollX : sx, scrollY : sy};
\r
6350 if (tinyMCE.isRealIE) {
\r
6354 nl = b.getElementsByTagName(e.nodeName);
\r
6355 for (i=0; i<nl.length; i++) {
\r
6369 trng = doc.body.createTextRange();
\r
6370 trng.moveToElementText(inst.getBody());
\r
6371 trng.collapse(true);
\r
6372 bp = Math.abs(trng.move('character', xx));
\r
6374 trng = rng.duplicate();
\r
6375 trng.collapse(true);
\r
6376 sp = Math.abs(trng.move('character', xx));
\r
6378 trng = rng.duplicate();
\r
6379 trng.collapse(false);
\r
6380 le = Math.abs(trng.move('character', xx)) - sp;
\r
6390 s = this.getSel();
\r
6391 e = this.getFocusElement();
\r
6396 if (e && e.nodeName == 'IMG') {
\r
6397 /*nl = b.getElementsByTagName('IMG');
\r
6398 for (i=0; i<nl.length; i++) {
\r
6414 // Caret or selection
\r
6415 if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
\r
6416 e = this._getPosText(b, s.anchorNode, s.focusNode);
\r
6419 return {scrollX : sx, scrollY : sy};
\r
6422 start : e.start + s.anchorOffset,
\r
6423 end : e.end + s.focusOffset,
\r
6428 e = this._getPosText(b, rng.startContainer, rng.endContainer);
\r
6431 return {scrollX : sx, scrollY : sy};
\r
6434 start : e.start + rng.startOffset,
\r
6435 end : e.end + rng.endOffset,
\r
6445 moveToBookmark : function(bookmark) {
\r
6446 var inst = this.instance, rng, nl, i, ex, b = inst.getBody(), sd;
\r
6447 var doc = inst.getDoc(), win = inst.getWin(), sel = this.getSel();
\r
6452 if (tinyMCE.isSafari && bookmark.rng) {
\r
6453 sel.setBaseAndExtent(bookmark.rng.startContainer, bookmark.rng.startOffset, bookmark.rng.endContainer, bookmark.rng.endOffset);
\r
6457 if (tinyMCE.isRealIE) {
\r
6458 if (bookmark.rng) {
\r
6460 bookmark.rng.select();
\r
6470 if (bookmark.tag) {
\r
6471 rng = b.createControlRange();
\r
6473 nl = b.getElementsByTagName(bookmark.tag);
\r
6475 if (nl.length > bookmark.index) {
\r
6477 rng.addElement(nl[bookmark.index]);
\r
6479 // Might be thrown if the node no longer exists
\r
6483 // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
\r
6485 // Incorrect bookmark
\r
6486 if (bookmark.start < 0)
\r
6489 rng = inst.getSel().createRange();
\r
6490 rng.moveToElementText(inst.getBody());
\r
6491 rng.collapse(true);
\r
6492 rng.moveStart('character', bookmark.start);
\r
6493 rng.moveEnd('character', bookmark.length);
\r
6501 win.scrollTo(bookmark.scrollX, bookmark.scrollY);
\r
6505 if (tinyMCE.isGecko || tinyMCE.isOpera) {
\r
6509 if (bookmark.rng) {
\r
6510 sel.removeAllRanges();
\r
6511 sel.addRange(bookmark.rng);
\r
6514 if (bookmark.start != -1 && bookmark.end != -1) {
\r
6516 sd = this._getTextPos(b, bookmark.start, bookmark.end);
\r
6517 rng = doc.createRange();
\r
6518 rng.setStart(sd.startNode, sd.startOffset);
\r
6519 rng.setEnd(sd.endNode, sd.endOffset);
\r
6520 sel.removeAllRanges();
\r
6521 sel.addRange(rng);
\r
6523 if (!tinyMCE.isOpera)
\r
6531 if (typeof(bookmark.index) != 'undefined') {
\r
6532 tinyMCE.selectElements(b, 'IMG', function (n) {
\r
6533 if (bookmark.index-- == 0) {
\r
6534 // Select image in Gecko here
\r
6542 win.scrollTo(bookmark.scrollX, bookmark.scrollY);
\r
6549 _getPosText : function(r, sn, en) {
\r
6550 var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
\r
6552 while ((n = w.nextNode()) != null) {
\r
6561 p += n.nodeValue ? n.nodeValue.length : 0;
\r
6567 _getTextPos : function(r, sp, ep) {
\r
6568 var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
\r
6570 while ((n = w.nextNode()) != null) {
\r
6571 p += n.nodeValue ? n.nodeValue.length : 0;
\r
6573 if (p >= sp && !d.startNode) {
\r
6575 d.startOffset = sp - (p - n.nodeValue.length);
\r
6580 d.endOffset = ep - (p - n.nodeValue.length);
\r
6589 selectNode : function(node, collapse, select_text_node, to_start) {
\r
6590 var inst = this.instance, sel, rng, nodes;
\r
6595 if (typeof(collapse) == "undefined")
\r
6598 if (typeof(select_text_node) == "undefined")
\r
6599 select_text_node = false;
\r
6601 if (typeof(to_start) == "undefined")
\r
6604 if (inst.settings.auto_resize)
\r
6605 inst.resizeToContent();
\r
6607 if (tinyMCE.isRealIE) {
\r
6608 rng = inst.getDoc().body.createTextRange();
\r
6611 rng.moveToElementText(node);
\r
6614 rng.collapse(to_start);
\r
6618 // Throws illigal agrument in MSIE some times
\r
6621 sel = this.getSel();
\r
6626 if (tinyMCE.isSafari) {
\r
6627 sel.setBaseAndExtent(node, 0, node, node.innerText.length);
\r
6631 sel.collapseToStart();
\r
6633 sel.collapseToEnd();
\r
6636 this.scrollToNode(node);
\r
6641 rng = inst.getDoc().createRange();
\r
6643 if (select_text_node) {
\r
6644 // Find first textnode in tree
\r
6645 nodes = tinyMCE.getNodeTree(node, [], 3);
\r
6646 if (nodes.length > 0)
\r
6647 rng.selectNodeContents(nodes[0]);
\r
6649 rng.selectNodeContents(node);
\r
6651 rng.selectNode(node);
\r
6654 // Special treatment of textnode collapse
\r
6655 if (!to_start && node.nodeType == 3) {
\r
6656 rng.setStart(node, node.nodeValue.length);
\r
6657 rng.setEnd(node, node.nodeValue.length);
\r
6659 rng.collapse(to_start);
\r
6662 sel.removeAllRanges();
\r
6663 sel.addRange(rng);
\r
6666 this.scrollToNode(node);
\r
6668 // Set selected element
\r
6669 tinyMCE.selectedElement = null;
\r
6670 if (node.nodeType == 1)
\r
6671 tinyMCE.selectedElement = node;
\r
6674 scrollToNode : function(node) {
\r
6675 var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin;
\r
6677 // Only scroll if out of visible area
\r
6678 if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25))
\r
6679 w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25);
\r
6681 // Scroll container window
\r
6682 if (inst.settings.auto_resize) {
\r
6683 cwin = inst.getContainerWin();
\r
6684 cvp = tinyMCE.getViewPort(cwin);
\r
6685 p = this.getAbsPosition(node);
\r
6687 if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height)
\r
6688 cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25);
\r
6692 getAbsPosition : function(n) {
\r
6693 var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement);
\r
6696 absLeft : ipos.absLeft + pos.absLeft,
\r
6697 absTop : ipos.absTop + pos.absTop
\r
6701 getSel : function() {
\r
6702 var inst = this.instance;
\r
6704 if (tinyMCE.isRealIE)
\r
6705 return inst.getDoc().selection;
\r
6707 return inst.contentWindow.getSelection();
\r
6710 getRng : function() {
\r
6711 var s = this.getSel();
\r
6716 if (tinyMCE.isRealIE)
\r
6717 return s.createRange();
\r
6719 if (tinyMCE.isSafari && !s.getRangeAt)
\r
6720 return '' + window.getSelection();
\r
6722 if (s.rangeCount > 0)
\r
6723 return s.getRangeAt(0);
\r
6728 isCollapsed : function() {
\r
6729 var r = this.getRng();
\r
6734 return r.boundingWidth == 0 || this.getSel().isCollapsed;
\r
6737 collapse : function(b) {
\r
6738 var r = this.getRng(), s = this.getSel();
\r
6745 s.collapseToStart();
\r
6747 s.collapseToEnd();
\r
6751 getFocusElement : function() {
\r
6752 var inst = this.instance, doc, rng, sel, elm;
\r
6754 if (tinyMCE.isRealIE) {
\r
6755 doc = inst.getDoc();
\r
6756 rng = doc.selection.createRange();
\r
6758 // if (rng.collapse)
\r
6759 // rng.collapse(true);
\r
6761 elm = rng.item ? rng.item(0) : rng.parentElement();
\r
6763 if (!tinyMCE.isSafari && inst.isHidden())
\r
6764 return inst.getBody();
\r
6766 sel = this.getSel();
\r
6767 rng = this.getRng();
\r
6772 elm = rng.commonAncestorContainer;
\r
6773 //elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
\r
6775 // Handle selection a image or other control like element such as anchors
\r
6776 if (!rng.collapsed) {
\r
6777 // Is selection small
\r
6778 if (rng.startContainer == rng.endContainer) {
\r
6779 if (rng.startOffset - rng.endOffset < 2) {
\r
6780 if (rng.startContainer.hasChildNodes())
\r
6781 elm = rng.startContainer.childNodes[rng.startOffset];
\r
6786 // Get the element parent of the node
\r
6787 elm = tinyMCE.getParentElement(elm);
\r
6789 //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
\r
6790 // elm = tinyMCE.selectedElement;
\r
6798 /* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */
\r
6800 function TinyMCE_UndoRedo(inst) {
\r
6801 this.instance = inst;
\r
6802 this.undoLevels = [];
\r
6803 this.undoIndex = 0;
\r
6804 this.typingUndoIndex = -1;
\r
6805 this.undoRedo = true;
\r
6808 TinyMCE_UndoRedo.prototype = {
\r
6809 add : function(l) {
\r
6810 var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur;
\r
6813 this.undoLevels[this.undoLevels.length] = l;
\r
6817 if (this.typingUndoIndex != -1) {
\r
6818 this.undoIndex = this.typingUndoIndex;
\r
6820 if (tinyMCE.typingUndoIndex != -1)
\r
6821 tinyMCE.undoIndex = tinyMCE.typingUndoIndex;
\r
6824 newHTML = tinyMCE.trim(inst.getBody().innerHTML);
\r
6825 if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
\r
6826 //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content);
\r
6829 inst.isNotDirty = false;
\r
6831 tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
\r
6833 // Time to compress
\r
6834 customUndoLevels = tinyMCE.settings.custom_undo_redo_levels;
\r
6835 if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
\r
6836 for (i=0; i<this.undoLevels.length-1; i++)
\r
6837 this.undoLevels[i] = this.undoLevels[i+1];
\r
6839 this.undoLevels.length--;
\r
6842 // Todo: Implement global undo/redo logic here
\r
6845 b = inst.undoBookmark;
\r
6848 b = inst.selection.getBookmark();
\r
6851 this.undoLevels[this.undoIndex] = {
\r
6852 content : newHTML,
\r
6856 // Remove all above from global undo/redo
\r
6857 ul = tinyMCE.undoLevels;
\r
6858 for (i=tinyMCE.undoIndex + 1; i<ul.length; i++) {
\r
6859 ur = ul[i].undoRedo;
\r
6861 if (ur.undoIndex == ur.undoLevels.length -1)
\r
6864 ur.undoLevels.length--;
\r
6867 // Add global undo level
\r
6868 tinyMCE.undoLevels[tinyMCE.undoIndex++] = inst;
\r
6869 tinyMCE.undoLevels.length = tinyMCE.undoIndex;
\r
6871 this.undoLevels.length = this.undoIndex + 1;
\r
6879 undo : function() {
\r
6880 var inst = this.instance;
\r
6883 if (this.undoIndex > 0) {
\r
6886 tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
\r
6889 if (inst.settings.custom_undo_redo_restore_selection)
\r
6890 inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
\r
6894 redo : function() {
\r
6895 var inst = this.instance;
\r
6897 tinyMCE.execCommand("mceEndTyping");
\r
6899 if (this.undoIndex < (this.undoLevels.length-1)) {
\r
6902 tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
\r
6905 if (inst.settings.custom_undo_redo_restore_selection)
\r
6906 inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
\r
6909 tinyMCE.triggerNodeChange();
\r
6914 /* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
\r
6916 var TinyMCE_ForceParagraphs = {
\r
6917 _insertPara : function(inst, e) {
\r
6918 var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0);
\r
6919 var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock;
\r
6920 var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null;
\r
6921 var paraBefore, paraAfter, startChop, endChop, contents, i;
\r
6923 function isEmpty(para) {
\r
6926 function isEmptyHTML(html) {
\r
6927 return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == '';
\r
6930 // Check for images
\r
6931 if (para.getElementsByTagName("img").length > 0)
\r
6934 // Check for tables
\r
6935 if (para.getElementsByTagName("table").length > 0)
\r
6939 if (para.getElementsByTagName("hr").length > 0)
\r
6942 // Check all textnodes
\r
6943 nodes = tinyMCE.getNodeTree(para, [], 3);
\r
6944 for (i=0; i<nodes.length; i++) {
\r
6945 if (!isEmptyHTML(nodes[i].nodeValue))
\r
6949 // No images, no tables, no hrs, no text content then it's empty
\r
6953 // tinyMCE.debug(body.innerHTML);
\r
6955 // debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString());
\r
6957 // Setup before range
\r
6958 rngBefore = doc.createRange();
\r
6959 rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
\r
6960 rngBefore.collapse(true);
\r
6962 // Setup after range
\r
6963 rngAfter = doc.createRange();
\r
6964 rngAfter.setStart(sel.focusNode, sel.focusOffset);
\r
6965 rngAfter.collapse(true);
\r
6967 // Setup start/end points
\r
6968 direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
\r
6969 startNode = direct ? sel.anchorNode : sel.focusNode;
\r
6970 startOffset = direct ? sel.anchorOffset : sel.focusOffset;
\r
6971 endNode = direct ? sel.focusNode : sel.anchorNode;
\r
6972 endOffset = direct ? sel.focusOffset : sel.anchorOffset;
\r
6974 startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;
\r
6975 endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;
\r
6977 // Get block elements
\r
6978 startBlock = inst.getParentBlockElement(startNode);
\r
6979 endBlock = inst.getParentBlockElement(endNode);
\r
6981 // If absolute force paragraph generation within
\r
6982 if (startBlock && (startBlock.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(startBlock.style.position)))
\r
6983 startBlock = null;
\r
6985 if (endBlock && (endBlock.nodeName == 'CAPTION' || /absolute|relative|static/gi.test(endBlock.style.position)))
\r
6988 // Use current block name
\r
6989 if (startBlock != null) {
\r
6990 blockName = startBlock.nodeName;
\r
6993 if (/(TD|TABLE|TH|CAPTION)/.test(blockName) || (blockName == "DIV" && /left|right/gi.test(startBlock.style.cssFloat)))
\r
6997 // Within a list use normal behaviour
\r
6998 if (tinyMCE.getParentElement(startBlock, "OL,UL", null, body) != null)
\r
7001 // Within a table create new paragraphs
\r
7002 if ((startBlock != null && startBlock.nodeName == "TABLE") || (endBlock != null && endBlock.nodeName == "TABLE"))
\r
7003 startBlock = endBlock = null;
\r
7005 // Setup new paragraphs
\r
7006 paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
\r
7007 paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
\r
7009 // Is header, then force paragraph under
\r
7010 if (/^(H[1-6])$/.test(blockName))
\r
7011 paraAfter = doc.createElement("p");
\r
7013 // Setup chop nodes
\r
7014 startChop = startNode;
\r
7015 endChop = endNode;
\r
7017 // Get startChop node
\r
7020 if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
\r
7024 } while ((node = node.previousSibling ? node.previousSibling : node.parentNode));
\r
7026 // Get endChop node
\r
7029 if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
\r
7033 } while ((node = node.nextSibling ? node.nextSibling : node.parentNode));
\r
7035 // Fix when only a image is within the TD
\r
7036 if (startChop.nodeName == "TD")
\r
7037 startChop = startChop.firstChild;
\r
7039 if (endChop.nodeName == "TD")
\r
7040 endChop = endChop.lastChild;
\r
7042 // If not in a block element
\r
7043 if (startBlock == null) {
\r
7044 // Delete selection
\r
7045 rng.deleteContents();
\r
7047 if (!tinyMCE.isSafari)
\r
7048 sel.removeAllRanges();
\r
7050 if (startChop != rootElm && endChop != rootElm) {
\r
7051 // Insert paragraph before
\r
7052 rngBefore = rng.cloneRange();
\r
7054 if (startChop == body)
\r
7055 rngBefore.setStart(startChop, 0);
\r
7057 rngBefore.setStartBefore(startChop);
\r
7059 paraBefore.appendChild(rngBefore.cloneContents());
\r
7061 // Insert paragraph after
\r
7062 if (endChop.parentNode.nodeName == blockName)
\r
7063 endChop = endChop.parentNode;
\r
7065 // If not after image
\r
7066 //if (rng.startContainer.nodeName != "BODY" && rng.endContainer.nodeName != "BODY")
\r
7067 rng.setEndAfter(endChop);
\r
7069 if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")
\r
7070 rngBefore.setEndAfter(endChop);
\r
7072 contents = rng.cloneContents();
\r
7073 if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
\r
7074 paraAfter.innerHTML = contents.firstChild.innerHTML;
\r
7076 paraAfter.appendChild(contents);
\r
7078 // Check if it's a empty paragraph
\r
7079 if (isEmpty(paraBefore))
\r
7080 paraBefore.innerHTML = " ";
\r
7082 // Check if it's a empty paragraph
\r
7083 if (isEmpty(paraAfter))
\r
7084 paraAfter.innerHTML = " ";
\r
7086 // Delete old contents
\r
7087 rng.deleteContents();
\r
7088 rngAfter.deleteContents();
\r
7089 rngBefore.deleteContents();
\r
7091 // Insert new paragraphs
\r
7092 if (tinyMCE.isOpera) {
\r
7093 paraBefore.normalize();
\r
7094 rngBefore.insertNode(paraBefore);
\r
7095 paraAfter.normalize();
\r
7096 rngBefore.insertNode(paraAfter);
\r
7098 paraAfter.normalize();
\r
7099 rngBefore.insertNode(paraAfter);
\r
7100 paraBefore.normalize();
\r
7101 rngBefore.insertNode(paraBefore);
\r
7104 //tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
\r
7106 body.innerHTML = "<" + blockName + "> </" + blockName + "><" + blockName + "> </" + blockName + ">";
\r
7107 paraAfter = body.childNodes[1];
\r
7110 inst.selection.moveToBookmark(b);
\r
7111 inst.selection.selectNode(paraAfter, true, true);
\r
7116 // Place first part within new paragraph
\r
7117 if (startChop.nodeName == blockName)
\r
7118 rngBefore.setStart(startChop, 0);
\r
7120 rngBefore.setStartBefore(startChop);
\r
7122 rngBefore.setEnd(startNode, startOffset);
\r
7123 paraBefore.appendChild(rngBefore.cloneContents());
\r
7125 // Place secound part within new paragraph
\r
7126 rngAfter.setEndAfter(endChop);
\r
7127 rngAfter.setStart(endNode, endOffset);
\r
7128 contents = rngAfter.cloneContents();
\r
7130 if (contents.firstChild && contents.firstChild.nodeName == blockName) {
\r
7131 /* var nodes = contents.firstChild.childNodes;
\r
7132 for (i=0; i<nodes.length; i++) {
\r
7133 //tinyMCE.debug(nodes[i].nodeName);
\r
7134 if (nodes[i].nodeName != "BODY")
\r
7135 paraAfter.appendChild(nodes[i]);
\r
7138 paraAfter.innerHTML = contents.firstChild.innerHTML;
\r
7140 paraAfter.appendChild(contents);
\r
7142 // Check if it's a empty paragraph
\r
7143 if (isEmpty(paraBefore))
\r
7144 paraBefore.innerHTML = " ";
\r
7146 // Check if it's a empty paragraph
\r
7147 if (isEmpty(paraAfter))
\r
7148 paraAfter.innerHTML = " ";
\r
7150 // Create a range around everything
\r
7151 rng = doc.createRange();
\r
7153 if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
\r
7154 rng.setStartBefore(startChop.parentNode);
\r
7156 if (rngBefore.startContainer.nodeName.toUpperCase() == blockName && rngBefore.startOffset == 0)
\r
7157 rng.setStartBefore(rngBefore.startContainer);
\r
7159 rng.setStart(rngBefore.startContainer, rngBefore.startOffset);
\r
7162 if (!endChop.nextSibling && endChop.parentNode.nodeName.toUpperCase() == blockName)
\r
7163 rng.setEndAfter(endChop.parentNode);
\r
7165 rng.setEnd(rngAfter.endContainer, rngAfter.endOffset);
\r
7167 // Delete all contents and insert new paragraphs
\r
7168 rng.deleteContents();
\r
7170 if (tinyMCE.isOpera) {
\r
7171 rng.insertNode(paraBefore);
\r
7172 rng.insertNode(paraAfter);
\r
7174 rng.insertNode(paraAfter);
\r
7175 rng.insertNode(paraBefore);
\r
7178 //tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
\r
7181 paraAfter.normalize();
\r
7182 paraBefore.normalize();
\r
7184 inst.selection.moveToBookmark(b);
\r
7185 inst.selection.selectNode(paraAfter, true, true);
\r
7190 _handleBackSpace : function(inst) {
\r
7191 var r = inst.getRng(), sn = r.startContainer, nv, s = false;
\r
7193 // Added body check for bug #1527787
\r
7194 if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR" && sn.parentNode.nodeName != "BODY") {
\r
7195 nv = sn.nodeValue;
\r
7197 // Handle if a backspace is pressed after a space character #bug 1466054 removed since fix for #1527787
\r
7198 /*if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
\r
7201 // Only remove BRs if we are at the end of line #bug 1464152
\r
7202 if (nv != null && r.startOffset == nv.length)
\r
7203 sn.nextSibling.parentNode.removeChild(sn.nextSibling);
\r
7206 if (inst.settings.auto_resize)
\r
7207 inst.resizeToContent();
\r
7214 /* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */
\r
7216 function TinyMCE_Layer(id, bm) {
\r
7218 this.blockerElement = null;
\r
7219 this.events = false;
\r
7220 this.element = null;
\r
7221 this.blockMode = typeof(bm) != 'undefined' ? bm : true;
\r
7222 this.doc = document;
\r
7225 TinyMCE_Layer.prototype = {
\r
7226 moveRelativeTo : function(re, p) {
\r
7227 var rep = this.getAbsPosition(re), e = this.getElement(), x, y;
\r
7228 var w = parseInt(re.offsetWidth), h = parseInt(re.offsetHeight);
\r
7229 var ew = parseInt(e.offsetWidth), eh = parseInt(e.offsetHeight);
\r
7238 x = rep.absLeft + w;
\r
7244 y = rep.absTop + h;
\r
7248 x = rep.absLeft + w;
\r
7249 y = rep.absTop + h;
\r
7253 x = rep.absLeft + (w / 2) - (ew / 2);
\r
7254 y = rep.absTop + (h / 2) - (eh / 2);
\r
7258 this.moveTo(x, y);
\r
7261 moveBy : function(x, y) {
\r
7262 var e = this.getElement();
\r
7263 this.moveTo(parseInt(e.style.left) + x, parseInt(e.style.top) + y);
\r
7266 moveTo : function(x, y) {
\r
7267 var e = this.getElement();
\r
7269 e.style.left = x + "px";
\r
7270 e.style.top = y + "px";
\r
7272 this.updateBlocker();
\r
7275 resizeBy : function(w, h) {
\r
7276 var e = this.getElement();
\r
7277 this.resizeTo(parseInt(e.style.width) + w, parseInt(e.style.height) + h);
\r
7280 resizeTo : function(w, h) {
\r
7281 var e = this.getElement();
\r
7284 e.style.width = w + "px";
\r
7287 e.style.height = h + "px";
\r
7289 this.updateBlocker();
\r
7292 show : function() {
\r
7293 var el = this.getElement();
\r
7296 el.style.display = 'block';
\r
7297 this.updateBlocker();
\r
7301 hide : function() {
\r
7302 var el = this.getElement();
\r
7305 el.style.display = 'none';
\r
7306 this.updateBlocker();
\r
7310 isVisible : function() {
\r
7311 return this.getElement().style.display == 'block';
\r
7314 getElement : function() {
\r
7315 if (!this.element)
\r
7316 this.element = this.doc.getElementById(this.id);
\r
7318 return this.element;
\r
7321 setBlockMode : function(s) {
\r
7322 this.blockMode = s;
\r
7325 updateBlocker : function() {
\r
7326 var e, b, x, y, w, h;
\r
7328 b = this.getBlocker();
\r
7330 if (this.blockMode) {
\r
7331 e = this.getElement();
\r
7332 x = this.parseInt(e.style.left);
\r
7333 y = this.parseInt(e.style.top);
\r
7334 w = this.parseInt(e.offsetWidth);
\r
7335 h = this.parseInt(e.offsetHeight);
\r
7337 b.style.left = x + 'px';
\r
7338 b.style.top = y + 'px';
\r
7339 b.style.width = w + 'px';
\r
7340 b.style.height = h + 'px';
\r
7341 b.style.display = e.style.display;
\r
7343 b.style.display = 'none';
\r
7347 getBlocker : function() {
\r
7350 if (!this.blockerElement && this.blockMode) {
\r
7352 b = d.getElementById(this.id + "_blocker");
\r
7355 b = d.createElement("iframe");
\r
7357 b.setAttribute('id', this.id + "_blocker");
\r
7358 b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
\r
7359 b.src = 'javascript:false;';
\r
7360 b.frameBorder = '0';
\r
7361 b.scrolling = 'no';
\r
7363 d.body.appendChild(b);
\r
7366 this.blockerElement = b;
\r
7369 return this.blockerElement;
\r
7372 getAbsPosition : function(n) {
\r
7373 var p = {absLeft : 0, absTop : 0};
\r
7376 p.absLeft += n.offsetLeft;
\r
7377 p.absTop += n.offsetTop;
\r
7378 n = n.offsetParent;
\r
7384 create : function(n, c, p, h) {
\r
7385 var d = this.doc, e = d.createElement(n);
\r
7387 e.setAttribute('id', this.id);
\r
7400 return this.element = e;
\r
7403 exists : function() {
\r
7404 return this.doc.getElementById(this.id) != null;
\r
7407 parseInt : function(s) {
\r
7408 if (s == null || s == '')
\r
7411 return parseInt(s);
\r
7414 remove : function() {
\r
7415 var e = this.getElement(), b = this.getBlocker();
\r
7418 e.parentNode.removeChild(e);
\r
7421 b.parentNode.removeChild(b);
\r
7426 /* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */
\r
7428 function TinyMCE_Menu() {
\r
7431 if (typeof(tinyMCE.menuCounter) == "undefined")
\r
7432 tinyMCE.menuCounter = 0;
\r
7434 id = "mc_menu_" + tinyMCE.menuCounter++;
\r
7436 TinyMCE_Layer.call(this, id, true);
\r
7440 this.needsUpdate = true;
\r
7443 TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
\r
7444 init : function(s) {
\r
7449 separator_class : 'mceMenuSeparator',
\r
7450 title_class : 'mceMenuTitle',
\r
7451 disabled_class : 'mceMenuDisabled',
\r
7452 menu_class : 'mceMenu',
\r
7457 this.settings[n] = s[n];
\r
7459 this.create('div', this.settings.menu_class);
\r
7462 clear : function() {
\r
7466 addTitle : function(t) {
\r
7467 this.add({type : 'title', text : t});
\r
7470 addDisabled : function(t) {
\r
7471 this.add({type : 'disabled', text : t});
\r
7474 addSeparator : function() {
\r
7475 this.add({type : 'separator'});
\r
7478 addItem : function(t, js) {
\r
7479 this.add({text : t, js : js});
\r
7482 add : function(mi) {
\r
7483 this.items[this.items.length] = mi;
\r
7484 this.needsUpdate = true;
\r
7487 update : function() {
\r
7488 var e = this.getElement(), h = '', i, t, m = this.items, s = this.settings;
\r
7490 if (this.settings.drop_menu)
\r
7491 h += '<span class="mceMenuLine"></span>';
\r
7493 h += '<table border="0" cellpadding="0" cellspacing="0">';
\r
7495 for (i=0; i<m.length; i++) {
\r
7496 t = tinyMCE.xmlEncode(m[i].text);
\r
7497 c = m[i].class_name ? ' class="' + m[i].class_name + '"' : '';
\r
7499 switch (m[i].type) {
\r
7501 h += '<tr class="' + s.separator_class + '"><td>';
\r
7505 h += '<tr class="' + s.title_class + '"><td><span' + c +'>' + t + '</span>';
\r
7509 h += '<tr class="' + s.disabled_class + '"><td><span' + c +'>' + t + '</span>';
\r
7513 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>';
\r
7516 h += '</td></tr>';
\r
7523 this.needsUpdate = false;
\r
7524 this.updateBlocker();
\r
7527 show : function() {
\r
7530 if (tinyMCE.lastMenu == this)
\r
7533 if (this.needsUpdate)
\r
7536 if (tinyMCE.lastMenu && tinyMCE.lastMenu != this)
\r
7537 tinyMCE.lastMenu.hide();
\r
7539 TinyMCE_Layer.prototype.show.call(this);
\r
7541 if (!tinyMCE.isOpera) {
\r
7542 // Accessibility stuff
\r
7543 /* nl = this.getElement().getElementsByTagName("a");
\r
7544 if (nl.length > 0)
\r
7548 tinyMCE.lastMenu = this;
\r
7553 /* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
\r
7555 tinyMCE.add(TinyMCE_Engine, {
\r
7556 debug : function() {
\r
7557 var m = "", a, i, l = tinyMCE.log.length;
\r
7559 for (i=0, a = this.debug.arguments; i<a.length; i++) {
\r
7567 tinyMCE.log[l] = "[debug] " + m;
\r