author | Dan |
Sun, 26 Aug 2007 20:55:12 -0400 | |
changeset 104 | 9c17aacd5515 |
parent 40 | 723bb7acf914 |
child 117 | 7cfdbb2fd17a |
permissions | -rw-r--r-- |
1 | 1 |
|
2 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */ |
|
3 |
||
4 |
function TinyMCE_Engine() { |
|
5 |
var ua; |
|
6 |
||
7 |
this.majorVersion = "2"; |
|
8 |
this.minorVersion = "1.0"; |
|
9 |
this.releaseDate = "2007-02-13"; |
|
10 |
||
11 |
this.instances = new Array(); |
|
12 |
this.switchClassCache = new Array(); |
|
13 |
this.windowArgs = new Array(); |
|
14 |
this.loadedFiles = new Array(); |
|
15 |
this.pendingFiles = new Array(); |
|
16 |
this.loadingIndex = 0; |
|
17 |
this.configs = new Array(); |
|
18 |
this.currentConfig = 0; |
|
19 |
this.eventHandlers = new Array(); |
|
20 |
this.log = new Array(); |
|
21 |
this.undoLevels = []; |
|
22 |
this.undoIndex = 0; |
|
23 |
this.typingUndoIndex = -1; |
|
24 |
||
25 |
// Browser check |
|
26 |
ua = navigator.userAgent; |
|
27 |
this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); |
|
28 |
this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); |
|
29 |
this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); |
|
30 |
this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1); |
|
31 |
this.isGecko = ua.indexOf('Gecko') != -1; |
|
32 |
this.isSafari = ua.indexOf('Safari') != -1; |
|
33 |
this.isOpera = ua.indexOf('Opera') != -1; |
|
34 |
this.isMac = ua.indexOf('Mac') != -1; |
|
35 |
this.isNS7 = ua.indexOf('Netscape/7') != -1; |
|
36 |
this.isNS71 = ua.indexOf('Netscape/7.1') != -1; |
|
37 |
this.dialogCounter = 0; |
|
38 |
this.plugins = new Array(); |
|
39 |
this.themes = new Array(); |
|
40 |
this.menus = new Array(); |
|
41 |
this.loadedPlugins = new Array(); |
|
42 |
this.buttonMap = new Array(); |
|
43 |
this.isLoaded = false; |
|
44 |
||
45 |
// Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those |
|
46 |
if (this.isOpera) { |
|
47 |
this.isMSIE = true; |
|
48 |
this.isGecko = false; |
|
49 |
this.isSafari = false; |
|
50 |
} |
|
51 |
||
52 |
this.isIE = this.isMSIE; |
|
53 |
this.isRealIE = this.isMSIE && !this.isOpera; |
|
54 |
||
55 |
// TinyMCE editor id instance counter |
|
56 |
this.idCounter = 0; |
|
57 |
}; |
|
58 |
||
59 |
TinyMCE_Engine.prototype = { |
|
60 |
init : function(settings) { |
|
61 |
var theme, nl, baseHREF = "", i; |
|
62 |
||
63 |
// 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. |
|
64 |
if (this.isMSIE5_0) |
|
65 |
return; |
|
66 |
||
67 |
this.settings = settings; |
|
68 |
||
69 |
// Check if valid browser has execcommand support |
|
70 |
if (typeof(document.execCommand) == 'undefined') |
|
71 |
return; |
|
72 |
||
73 |
// Get script base path |
|
74 |
if (!tinyMCE.baseURL) { |
|
75 |
var elements = document.getElementsByTagName('script'); |
|
76 |
||
77 |
// If base element found, add that infront of baseURL |
|
78 |
nl = document.getElementsByTagName('base'); |
|
79 |
for (i=0; i<nl.length; i++) { |
|
80 |
if (nl[i].href) |
|
81 |
baseHREF = nl[i].href; |
|
82 |
} |
|
83 |
||
84 |
for (var i=0; i<elements.length; i++) { |
|
85 |
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)) { |
|
86 |
var src = elements[i].src; |
|
87 |
||
88 |
tinyMCE.srcMode = (src.indexOf('_src') != -1 || src.indexOf('_dev') != -1) ? '_src' : ''; |
|
89 |
tinyMCE.gzipMode = src.indexOf('_gzip') != -1; |
|
90 |
src = src.substring(0, src.lastIndexOf('/')); |
|
91 |
||
92 |
if (settings.exec_mode == "src" || settings.exec_mode == "normal") |
|
93 |
tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : ''; |
|
94 |
||
95 |
// Force it absolute if page has a base href |
|
96 |
if (baseHREF != "" && src.indexOf('://') == -1) |
|
97 |
tinyMCE.baseURL = baseHREF + src; |
|
98 |
else |
|
99 |
tinyMCE.baseURL = src; |
|
100 |
||
101 |
break; |
|
102 |
} |
|
103 |
} |
|
104 |
} |
|
105 |
||
106 |
// Get document base path |
|
107 |
this.documentBasePath = document.location.href; |
|
108 |
if (this.documentBasePath.indexOf('?') != -1) |
|
109 |
this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?')); |
|
110 |
this.documentURL = this.documentBasePath; |
|
111 |
this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/')); |
|
112 |
||
113 |
// If not HTTP absolute |
|
114 |
if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') { |
|
115 |
// If site absolute |
|
116 |
tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL; |
|
117 |
} |
|
118 |
||
119 |
// Set default values on settings |
|
120 |
this._def("mode", "none"); |
|
121 |
this._def("theme", "advanced"); |
|
122 |
this._def("plugins", "", true); |
|
123 |
this._def("language", "en"); |
|
124 |
this._def("docs_language", this.settings['language']); |
|
125 |
this._def("elements", ""); |
|
126 |
this._def("textarea_trigger", "mce_editable"); |
|
127 |
this._def("editor_selector", ""); |
|
128 |
this._def("editor_deselector", "mceNoEditor"); |
|
129 |
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]"); |
|
130 |
this._def("extended_valid_elements", ""); |
|
131 |
this._def("invalid_elements", ""); |
|
132 |
this._def("encoding", ""); |
|
133 |
this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL")); |
|
134 |
this._def("save_callback", ""); |
|
135 |
this._def("debug", false); |
|
136 |
this._def("force_br_newlines", false); |
|
137 |
this._def("force_p_newlines", true); |
|
138 |
this._def("add_form_submit_trigger", true); |
|
139 |
this._def("relative_urls", true); |
|
140 |
this._def("remove_script_host", true); |
|
141 |
this._def("focus_alert", true); |
|
142 |
this._def("document_base_url", this.documentURL); |
|
143 |
this._def("visual", true); |
|
144 |
this._def("visual_table_class", "mceVisualAid"); |
|
145 |
this._def("setupcontent_callback", ""); |
|
146 |
this._def("fix_content_duplication", true); |
|
147 |
this._def("custom_undo_redo", true); |
|
148 |
this._def("custom_undo_redo_levels", -1); |
|
149 |
this._def("custom_undo_redo_keyboard_shortcuts", true); |
|
150 |
this._def("custom_undo_redo_restore_selection", true); |
|
151 |
this._def("custom_undo_redo_global", false); |
|
152 |
this._def("verify_html", true); |
|
153 |
this._def("apply_source_formatting", false); |
|
154 |
this._def("directionality", "ltr"); |
|
155 |
this._def("cleanup_on_startup", false); |
|
156 |
this._def("inline_styles", false); |
|
157 |
this._def("convert_newlines_to_brs", false); |
|
158 |
this._def("auto_reset_designmode", true); |
|
159 |
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); |
|
160 |
this._def("entity_encoding", "named"); |
|
161 |
this._def("cleanup_callback", ""); |
|
162 |
this._def("add_unload_trigger", true); |
|
163 |
this._def("ask", false); |
|
164 |
this._def("nowrap", false); |
|
165 |
this._def("auto_resize", false); |
|
166 |
this._def("auto_focus", false); |
|
167 |
this._def("cleanup", true); |
|
168 |
this._def("remove_linebreaks", true); |
|
169 |
this._def("button_tile_map", false); |
|
170 |
this._def("submit_patch", true); |
|
171 |
this._def("browsers", "msie,safari,gecko,opera", true); |
|
172 |
this._def("dialog_type", "window"); |
|
173 |
this._def("accessibility_warnings", true); |
|
174 |
this._def("accessibility_focus", true); |
|
175 |
this._def("merge_styles_invalid_parents", ""); |
|
176 |
this._def("force_hex_style_colors", true); |
|
177 |
this._def("trim_span_elements", true); |
|
178 |
this._def("convert_fonts_to_spans", false); |
|
179 |
this._def("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'); |
|
180 |
this._def("font_size_classes", ''); |
|
181 |
this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true); |
|
182 |
this._def("event_elements", 'a,img', true); |
|
183 |
this._def("convert_urls", true); |
|
184 |
this._def("table_inline_editing", false); |
|
185 |
this._def("object_resizing", true); |
|
186 |
this._def("custom_shortcuts", true); |
|
187 |
this._def("convert_on_click", false); |
|
188 |
this._def("content_css", ''); |
|
189 |
this._def("fix_list_elements", true); |
|
190 |
this._def("fix_table_elements", false); |
|
191 |
this._def("strict_loading_mode", ( ( IE ) ? true : true ) ); // document.contentType == 'application/xhtml+xml'); |
|
192 |
this._def("hidden_tab_class", ''); |
|
193 |
this._def("display_tab_class", ''); |
|
194 |
this._def("gecko_spellcheck", false); |
|
195 |
this._def("hide_selects_on_submit", true); |
|
196 |
||
197 |
// Force strict loading mode to false on non Gecko browsers |
|
198 |
//if (this.isMSIE && !this.isOpera) |
|
199 |
// this.settings.strict_loading_mode = false; |
|
200 |
||
201 |
// Browser check IE |
|
202 |
if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1) |
|
203 |
return; |
|
204 |
||
205 |
// Browser check Gecko |
|
206 |
if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1) |
|
207 |
return; |
|
208 |
||
209 |
// Browser check Safari |
|
210 |
if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1) |
|
211 |
return; |
|
212 |
||
213 |
// Browser check Opera |
|
214 |
if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1) |
|
215 |
return; |
|
216 |
||
217 |
// If not super absolute make it so |
|
218 |
baseHREF = tinyMCE.settings['document_base_url']; |
|
219 |
var h = document.location.href; |
|
220 |
var p = h.indexOf('://'); |
|
221 |
if (p > 0 && document.location.protocol != "file:") { |
|
222 |
p = h.indexOf('/', p + 3); |
|
223 |
h = h.substring(0, p); |
|
224 |
||
225 |
if (baseHREF.indexOf('://') == -1) |
|
226 |
baseHREF = h + baseHREF; |
|
227 |
||
228 |
tinyMCE.settings['document_base_url'] = baseHREF; |
|
229 |
tinyMCE.settings['document_base_prefix'] = h; |
|
230 |
} |
|
231 |
||
232 |
// Trim away query part |
|
233 |
if (baseHREF.indexOf('?') != -1) |
|
234 |
baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); |
|
235 |
||
236 |
this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; |
|
237 |
||
238 |
theme = this.settings['theme']; |
|
239 |
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'; |
|
240 |
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'; |
|
241 |
this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; |
|
242 |
this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i"); |
|
243 |
this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); |
|
244 |
this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL |
|
245 |
this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>'; |
|
246 |
this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance'); |
|
247 |
||
248 |
// Theme url |
|
249 |
this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme; |
|
250 |
||
251 |
if (!tinyMCE.isIE || tinyMCE.isOpera) |
|
252 |
this.settings['force_br_newlines'] = false; |
|
253 |
||
254 |
if (tinyMCE.getParam("popups_css", false)) { |
|
255 |
var cssPath = tinyMCE.getParam("popups_css", ""); |
|
256 |
||
257 |
// Is relative |
|
258 |
if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') |
|
259 |
this.settings['popups_css'] = this.documentBasePath + "/" + cssPath; |
|
260 |
else |
|
261 |
this.settings['popups_css'] = cssPath; |
|
262 |
} else |
|
263 |
this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; |
|
264 |
||
265 |
if (tinyMCE.getParam("editor_css", false)) { |
|
266 |
var cssPath = tinyMCE.getParam("editor_css", ""); |
|
267 |
||
268 |
// Is relative |
|
269 |
if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') |
|
270 |
this.settings['editor_css'] = this.documentBasePath + "/" + cssPath; |
|
271 |
else |
|
272 |
this.settings['editor_css'] = cssPath; |
|
273 |
} else { |
|
274 |
if (this.settings.editor_css != '') |
|
275 |
this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; |
|
276 |
} |
|
277 |
||
278 |
if (tinyMCE.settings['debug']) { |
|
279 |
var msg = "Debug: \n"; |
|
280 |
||
281 |
msg += "baseURL: " + this.baseURL + "\n"; |
|
282 |
msg += "documentBasePath: " + this.documentBasePath + "\n"; |
|
283 |
msg += "content_css: " + this.settings['content_css'] + "\n"; |
|
284 |
msg += "popups_css: " + this.settings['popups_css'] + "\n"; |
|
285 |
msg += "editor_css: " + this.settings['editor_css'] + "\n"; |
|
286 |
||
287 |
alert(msg); |
|
288 |
} |
|
289 |
||
290 |
// Only do this once |
|
291 |
if (this.configs.length == 0) { |
|
292 |
if (typeof(TinyMCECompressed) == "undefined") { |
|
293 |
tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad); |
|
294 |
||
295 |
if (tinyMCE.isRealIE) { |
|
296 |
if (document.body) |
|
297 |
tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad); |
|
298 |
else |
|
299 |
tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad); |
|
300 |
} |
|
301 |
||
302 |
tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad); |
|
303 |
tinyMCE._addUnloadEvents(); |
|
304 |
} |
|
305 |
} |
|
306 |
||
307 |
this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js'); |
|
308 |
this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js'); |
|
309 |
this.loadCSS(this.settings['editor_css']); |
|
310 |
||
311 |
// Add plugins |
|
312 |
var p = tinyMCE.getParam('plugins', '', true, ','); |
|
313 |
if (p.length > 0) { |
|
314 |
for (var i=0; i<p.length; i++) { |
|
315 |
if (p[i].charAt(0) != '-') |
|
316 |
this.loadScript(tinyMCE.baseURL + '/plugins/' + p[i] + '/editor_plugin' + tinyMCE.srcMode + '.js'); |
|
317 |
} |
|
318 |
} |
|
319 |
||
320 |
// Setup entities |
|
321 |
if (tinyMCE.getParam('entity_encoding') == 'named') { |
|
322 |
settings['cleanup_entities'] = new Array(); |
|
323 |
var entities = tinyMCE.getParam('entities', '', true, ','); |
|
324 |
for (var i=0; i<entities.length; i+=2) |
|
325 |
settings['cleanup_entities']['c' + entities[i]] = entities[i+1]; |
|
326 |
} |
|
327 |
||
328 |
// Save away this config |
|
329 |
settings['index'] = this.configs.length; |
|
330 |
this.configs[this.configs.length] = settings; |
|
331 |
||
332 |
// Start loading first one in chain |
|
333 |
this.loadNextScript(); |
|
334 |
||
335 |
// Force flicker free CSS backgrounds in IE |
|
336 |
if (this.isIE && !this.isOpera) { |
|
337 |
try { |
|
338 |
document.execCommand('BackgroundImageCache', false, true); |
|
339 |
} catch (e) { |
|
340 |
} |
|
341 |
} |
|
342 |
||
343 |
// Setup XML encoding regexps |
|
344 |
this.xmlEncodeAposRe = new RegExp('[<>&"\']', 'g'); |
|
345 |
this.xmlEncodeRe = new RegExp('[<>&"]', 'g'); |
|
346 |
// this.xmlEncodeEnts = {'&':'&','"':'"',"'":''','<':'<','>':'>'}; |
|
347 |
}, |
|
348 |
||
349 |
_addUnloadEvents : function() { |
|
350 |
if (tinyMCE.isIE) { |
|
351 |
if (tinyMCE.settings['add_unload_trigger']) { |
|
352 |
tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler); |
|
353 |
tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler); |
|
354 |
} |
|
355 |
} else { |
|
356 |
if (tinyMCE.settings['add_unload_trigger']) |
|
357 |
tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); |
|
358 |
} |
|
359 |
}, |
|
360 |
||
361 |
_def : function(key, def_val, t) { |
|
362 |
var v = tinyMCE.getParam(key, def_val); |
|
363 |
||
364 |
v = t ? v.replace(/\s+/g, "") : v; |
|
365 |
||
366 |
this.settings[key] = v; |
|
367 |
}, |
|
368 |
||
369 |
hasPlugin : function(n) { |
|
370 |
return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; |
|
371 |
}, |
|
372 |
||
373 |
addPlugin : function(n, p) { |
|
374 |
var op = this.plugins[n]; |
|
375 |
||
376 |
// Use the previous plugin object base URL used when loading external plugins |
|
377 |
p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n; |
|
378 |
this.plugins[n] = p; |
|
379 |
||
380 |
this.loadNextScript(); |
|
381 |
}, |
|
382 |
||
383 |
setPluginBaseURL : function(n, u) { |
|
384 |
var op = this.plugins[n]; |
|
385 |
||
386 |
if (op) |
|
387 |
op.baseURL = u; |
|
388 |
else |
|
389 |
this.plugins[n] = {baseURL : u}; |
|
390 |
}, |
|
391 |
||
392 |
loadPlugin : function(n, u) { |
|
393 |
u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u; |
|
394 |
u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u; |
|
395 |
this.plugins[n] = {baseURL : u}; |
|
396 |
this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js"); |
|
397 |
}, |
|
398 |
||
399 |
hasTheme : function(n) { |
|
400 |
return typeof(this.themes[n]) != "undefined" && this.themes[n] != null; |
|
401 |
}, |
|
402 |
||
403 |
addTheme : function(n, t) { |
|
404 |
this.themes[n] = t; |
|
405 |
||
406 |
this.loadNextScript(); |
|
407 |
}, |
|
408 |
||
409 |
addMenu : function(n, m) { |
|
410 |
this.menus[n] = m; |
|
411 |
}, |
|
412 |
||
413 |
hasMenu : function(n) { |
|
414 |
return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; |
|
415 |
}, |
|
416 |
||
417 |
loadScript : function(url) { |
|
418 |
var i; |
|
419 |
||
420 |
for (i=0; i<this.loadedFiles.length; i++) { |
|
421 |
if (this.loadedFiles[i] == url) |
|
422 |
return; |
|
423 |
} |
|
424 |
||
425 |
if (tinyMCE.settings.strict_loading_mode) |
|
426 |
this.pendingFiles[this.pendingFiles.length] = url; |
|
427 |
else |
|
428 |
{ |
|
429 |
document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>'); |
|
430 |
} |
|
431 |
||
432 |
this.loadedFiles[this.loadedFiles.length] = url; |
|
433 |
}, |
|
434 |
||
435 |
loadNextScript : function() { |
|
436 |
var d = document, se; |
|
437 |
||
438 |
if (!tinyMCE.settings.strict_loading_mode) |
|
439 |
return; |
|
440 |
||
441 |
if (this.loadingIndex < this.pendingFiles.length) { |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
442 |
try { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
443 |
/* |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
444 |
se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
445 |
se.setAttribute('language', 'javascript'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
446 |
se.setAttribute('type', 'text/javascript'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
447 |
se.setAttribute('src', this.pendingFiles[this.loadingIndex++]); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
448 |
*/ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
449 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
450 |
se = d.createElement('script'); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
451 |
se.language = 'javascript'; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
452 |
se.type = 'text/javascript'; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
453 |
se.src = this.pendingFiles[this.loadingIndex++]; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
454 |
|
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
455 |
d.getElementsByTagName("head")[0].appendChild(se); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
456 |
} catch(e) { |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
457 |
var error = e.toString(); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
458 |
alert(error); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
459 |
} |
1 | 460 |
} else |
461 |
this.loadingIndex = -1; // Done with loading |
|
462 |
}, |
|
463 |
||
464 |
loadCSS : function(url) { |
|
465 |
var ar = url.replace(/\s+/, '').split(','); |
|
466 |
var lflen = 0, csslen = 0; |
|
467 |
var skip = false; |
|
468 |
var x = 0, i = 0, nl, le; |
|
469 |
||
470 |
for (x = 0,csslen = ar.length; x<csslen; x++) { |
|
471 |
if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) { |
|
472 |
/* Make sure it doesn't exist. */ |
|
473 |
for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) { |
|
474 |
if (this.loadedFiles[i] == ar[x]) { |
|
475 |
skip = true; |
|
476 |
break; |
|
477 |
} |
|
478 |
} |
|
479 |
||
480 |
if (!skip) { |
|
481 |
if (tinyMCE.settings.strict_loading_mode) { |
|
482 |
nl = document.getElementsByTagName("head"); |
|
483 |
||
484 |
le = document.createElement('link'); |
|
485 |
le.setAttribute('href', ar[x]); |
|
486 |
le.setAttribute('rel', 'stylesheet'); |
|
487 |
le.setAttribute('type', 'text/css'); |
|
488 |
||
489 |
nl[0].appendChild(le); |
|
490 |
} else |
|
491 |
{ |
|
492 |
document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />'); |
|
493 |
} |
|
494 |
||
495 |
this.loadedFiles[this.loadedFiles.length] = ar[x]; |
|
496 |
} |
|
497 |
} |
|
498 |
} |
|
499 |
}, |
|
500 |
||
501 |
importCSS : function(doc, css) { |
|
502 |
var css_ary = css.replace(/\s+/, '').split(','); |
|
503 |
var csslen, elm, headArr, x, css_file; |
|
504 |
||
505 |
for (x = 0, csslen = css_ary.length; x<csslen; x++) { |
|
506 |
css_file = css_ary[x]; |
|
507 |
||
508 |
if (css_file != null && css_file != 'null' && css_file.length > 0) { |
|
509 |
// Is relative, make absolute |
|
510 |
if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/') |
|
511 |
css_file = this.documentBasePath + "/" + css_file; |
|
512 |
||
513 |
if (typeof(doc.createStyleSheet) == "undefined") { |
|
514 |
elm = doc.createElement("link"); |
|
515 |
||
516 |
elm.rel = "stylesheet"; |
|
517 |
elm.href = css_file; |
|
518 |
||
519 |
if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0) |
|
520 |
headArr[0].appendChild(elm); |
|
521 |
} else |
|
522 |
doc.createStyleSheet(css_file); |
|
523 |
} |
|
524 |
} |
|
525 |
}, |
|
526 |
||
527 |
confirmAdd : function(e, settings) { |
|
528 |
var elm = tinyMCE.isIE ? event.srcElement : e.target; |
|
529 |
var elementId = elm.name ? elm.name : elm.id; |
|
530 |
||
531 |
tinyMCE.settings = settings; |
|
532 |
||
533 |
if (tinyMCE.settings['convert_on_click'] || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm']))) |
|
534 |
tinyMCE.addMCEControl(elm, elementId); |
|
535 |
||
536 |
elm.setAttribute('mce_noask', 'true'); |
|
537 |
}, |
|
538 |
||
539 |
updateContent : function(form_element_name) { |
|
540 |
// Find MCE instance linked to given form element and copy it's value |
|
541 |
var formElement = document.getElementById(form_element_name); |
|
542 |
for (var n in tinyMCE.instances) { |
|
543 |
var inst = tinyMCE.instances[n]; |
|
544 |
if (!tinyMCE.isInstance(inst)) |
|
545 |
continue; |
|
546 |
||
547 |
inst.switchSettings(); |
|
548 |
||
549 |
if (inst.formElement == formElement) { |
|
550 |
var doc = inst.getDoc(); |
|
551 |
||
552 |
tinyMCE._setHTML(doc, inst.formElement.value); |
|
553 |
||
554 |
if (!tinyMCE.isIE) |
|
555 |
doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); |
|
556 |
} |
|
557 |
} |
|
558 |
}, |
|
559 |
||
560 |
addMCEControl : function(replace_element, form_element_name, target_document) { |
|
561 |
var id = "mce_editor_" + tinyMCE.idCounter++; |
|
562 |
var inst = new TinyMCE_Control(tinyMCE.settings); |
|
563 |
||
564 |
inst.editorId = id; |
|
565 |
this.instances[id] = inst; |
|
566 |
||
567 |
inst._onAdd(replace_element, form_element_name, target_document); |
|
568 |
}, |
|
569 |
||
570 |
removeInstance : function(ti) { |
|
571 |
var t = [], n, i; |
|
572 |
||
573 |
// Remove from instances |
|
574 |
for (n in tinyMCE.instances) { |
|
575 |
i = tinyMCE.instances[n]; |
|
576 |
||
577 |
if (tinyMCE.isInstance(i) && ti != i) |
|
578 |
t[n] = i; |
|
579 |
} |
|
580 |
||
581 |
tinyMCE.instances = t; |
|
582 |
||
583 |
// Remove from global undo/redo |
|
584 |
n = []; |
|
585 |
t = tinyMCE.undoLevels; |
|
586 |
||
587 |
for (i=0; i<t.length; i++) { |
|
588 |
if (t[i] != ti) |
|
589 |
n.push(t[i]); |
|
590 |
} |
|
591 |
||
592 |
tinyMCE.undoLevels = n; |
|
593 |
tinyMCE.undoIndex = n.length; |
|
594 |
||
595 |
// Dispatch remove instance call |
|
596 |
tinyMCE.dispatchCallback(ti, 'remove_instance_callback', 'removeInstance', ti); |
|
597 |
||
598 |
return ti; |
|
599 |
}, |
|
600 |
||
601 |
removeMCEControl : function(editor_id) { |
|
602 |
var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn; |
|
603 |
||
604 |
if (inst) { |
|
605 |
inst.switchSettings(); |
|
606 |
||
607 |
editor_id = inst.editorId; |
|
608 |
h = tinyMCE.getContent(editor_id); |
|
609 |
||
610 |
this.removeInstance(inst); |
|
611 |
||
612 |
tinyMCE.selectedElement = null; |
|
613 |
tinyMCE.selectedInstance = null; |
|
614 |
||
615 |
// Remove element |
|
616 |
re = document.getElementById(editor_id + "_parent"); |
|
617 |
ot = inst.oldTargetElement; |
|
618 |
tn = ot.nodeName.toLowerCase(); |
|
619 |
||
620 |
if (tn == "textarea" || tn == "input") { |
|
621 |
re.parentNode.removeChild(re); |
|
622 |
ot.style.display = "inline"; |
|
623 |
ot.value = h; |
|
624 |
} else { |
|
625 |
ot.innerHTML = h; |
|
626 |
ot.style.display = 'block'; |
|
627 |
re.parentNode.insertBefore(ot, re); |
|
628 |
re.parentNode.removeChild(re); |
|
629 |
} |
|
630 |
} |
|
631 |
}, |
|
632 |
||
633 |
triggerSave : function(skip_cleanup, skip_callback) { |
|
634 |
var inst, n; |
|
635 |
||
636 |
// Default to false |
|
637 |
if (typeof(skip_cleanup) == "undefined") |
|
638 |
skip_cleanup = false; |
|
639 |
||
640 |
// Default to false |
|
641 |
if (typeof(skip_callback) == "undefined") |
|
642 |
skip_callback = false; |
|
643 |
||
644 |
// Cleanup and set all form fields |
|
645 |
for (n in tinyMCE.instances) { |
|
646 |
inst = tinyMCE.instances[n]; |
|
647 |
||
648 |
if (!tinyMCE.isInstance(inst)) |
|
649 |
continue; |
|
650 |
||
651 |
inst.triggerSave(skip_cleanup, skip_callback); |
|
652 |
} |
|
653 |
}, |
|
654 |
||
655 |
resetForm : function(form_index) { |
|
656 |
var i, inst, n, formObj = document.forms[form_index]; |
|
657 |
||
658 |
for (n in tinyMCE.instances) { |
|
659 |
inst = tinyMCE.instances[n]; |
|
660 |
||
661 |
if (!tinyMCE.isInstance(inst)) |
|
662 |
continue; |
|
663 |
||
664 |
inst.switchSettings(); |
|
665 |
||
666 |
for (i=0; i<formObj.elements.length; i++) { |
|
667 |
if (inst.formTargetElementId == formObj.elements[i].name) |
|
668 |
inst.getBody().innerHTML = inst.startContent; |
|
669 |
} |
|
670 |
} |
|
671 |
}, |
|
672 |
||
673 |
execInstanceCommand : function(editor_id, command, user_interface, value, focus) { |
|
674 |
var inst = tinyMCE.getInstanceById(editor_id), r; |
|
675 |
||
676 |
if (inst) { |
|
677 |
r = inst.selection.getRng(); |
|
678 |
||
679 |
if (typeof(focus) == "undefined") |
|
680 |
focus = true; |
|
681 |
||
682 |
// IE bug lost focus on images in absolute divs Bug #1534575 |
|
683 |
if (focus && (!r || !r.item)) |
|
684 |
inst.contentWindow.focus(); |
|
685 |
||
686 |
// Reset design mode if lost |
|
687 |
inst.autoResetDesignMode(); |
|
688 |
||
689 |
this.selectedElement = inst.getFocusElement(); |
|
690 |
inst.select(); |
|
691 |
tinyMCE.execCommand(command, user_interface, value); |
|
692 |
||
693 |
// Cancel event so it doesn't call onbeforeonunlaod |
|
694 |
if (tinyMCE.isIE && window.event != null) |
|
695 |
tinyMCE.cancelEvent(window.event); |
|
696 |
} |
|
697 |
}, |
|
698 |
||
699 |
execCommand : function(command, user_interface, value) { |
|
700 |
var inst = tinyMCE.selectedInstance; |
|
701 |
||
702 |
// Default input |
|
703 |
user_interface = user_interface ? user_interface : false; |
|
704 |
value = value ? value : null; |
|
705 |
||
706 |
if (inst) |
|
707 |
inst.switchSettings(); |
|
708 |
||
709 |
switch (command) { |
|
710 |
case "Undo": |
|
711 |
if (this.getParam('custom_undo_redo_global')) { |
|
712 |
if (this.undoIndex > 0) { |
|
713 |
tinyMCE.nextUndoRedoAction = 'Undo'; |
|
714 |
inst = this.undoLevels[--this.undoIndex]; |
|
715 |
inst.select(); |
|
716 |
||
717 |
if (!tinyMCE.nextUndoRedoInstanceId) |
|
718 |
inst.execCommand('Undo'); |
|
719 |
} |
|
720 |
} else |
|
721 |
inst.execCommand('Undo'); |
|
722 |
return true; |
|
723 |
||
724 |
case "Redo": |
|
725 |
if (this.getParam('custom_undo_redo_global')) { |
|
726 |
if (this.undoIndex <= this.undoLevels.length - 1) { |
|
727 |
tinyMCE.nextUndoRedoAction = 'Redo'; |
|
728 |
inst = this.undoLevels[this.undoIndex++]; |
|
729 |
inst.select(); |
|
730 |
||
731 |
if (!tinyMCE.nextUndoRedoInstanceId) |
|
732 |
inst.execCommand('Redo'); |
|
733 |
} |
|
734 |
} else |
|
735 |
inst.execCommand('Redo'); |
|
736 |
||
737 |
return true; |
|
738 |
||
739 |
case 'mceFocus': |
|
740 |
var inst = tinyMCE.getInstanceById(value); |
|
741 |
if (inst) |
|
742 |
inst.getWin().focus(); |
|
743 |
return; |
|
744 |
||
745 |
case "mceAddControl": |
|
746 |
case "mceAddEditor": |
|
747 |
tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); |
|
748 |
return; |
|
749 |
||
750 |
case "mceAddFrameControl": |
|
751 |
tinyMCE.addMCEControl(tinyMCE._getElementById(value['element'], value['document']), value['element'], value['document']); |
|
752 |
return; |
|
753 |
||
754 |
case "mceRemoveControl": |
|
755 |
case "mceRemoveEditor": |
|
756 |
tinyMCE.removeMCEControl(value); |
|
757 |
return; |
|
758 |
||
759 |
case "mceToggleEditor": |
|
760 |
var inst = tinyMCE.getInstanceById(value), pe, te; |
|
761 |
||
762 |
if (inst) { |
|
763 |
pe = document.getElementById(inst.editorId + '_parent'); |
|
764 |
te = inst.oldTargetElement; |
|
765 |
||
766 |
if (typeof(inst.enabled) == 'undefined') |
|
767 |
inst.enabled = true; |
|
768 |
||
769 |
inst.enabled = !inst.enabled; |
|
770 |
||
771 |
if (!inst.enabled) { |
|
772 |
pe.style.display = 'none'; |
|
773 |
te.value = inst.getHTML(); |
|
774 |
te.style.display = inst.oldTargetDisplay; |
|
775 |
tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); |
|
776 |
} else { |
|
777 |
pe.style.display = 'block'; |
|
778 |
te.style.display = 'none'; |
|
779 |
inst.setHTML(te.value); |
|
780 |
inst.useCSS = false; |
|
781 |
tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst); |
|
782 |
} |
|
783 |
} else |
|
784 |
tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); |
|
785 |
||
786 |
return; |
|
787 |
||
788 |
case "mceResetDesignMode": |
|
789 |
// Resets the designmode state of the editors in Gecko |
|
790 |
if (!tinyMCE.isIE) { |
|
791 |
for (var n in tinyMCE.instances) { |
|
792 |
if (!tinyMCE.isInstance(tinyMCE.instances[n])) |
|
793 |
continue; |
|
794 |
||
795 |
try { |
|
796 |
tinyMCE.instances[n].getDoc().designMode = "on"; |
|
797 |
} catch (e) { |
|
798 |
// Ignore any errors |
|
799 |
} |
|
800 |
} |
|
801 |
} |
|
802 |
||
803 |
return; |
|
804 |
} |
|
805 |
||
806 |
if (inst) { |
|
807 |
inst.execCommand(command, user_interface, value); |
|
808 |
} else if (tinyMCE.settings['focus_alert']) |
|
809 |
alert(tinyMCELang['lang_focus_alert']); |
|
810 |
}, |
|
811 |
||
812 |
_createIFrame : function(replace_element, doc, win) { |
|
813 |
var iframe, id = replace_element.getAttribute("id"); |
|
814 |
var aw, ah; |
|
815 |
||
816 |
if (typeof(doc) == "undefined") |
|
817 |
doc = document; |
|
818 |
||
819 |
if (typeof(win) == "undefined") |
|
820 |
win = window; |
|
821 |
||
822 |
iframe = doc.createElement("iframe"); |
|
823 |
||
824 |
aw = "" + tinyMCE.settings['area_width']; |
|
825 |
ah = "" + tinyMCE.settings['area_height']; |
|
826 |
||
827 |
if (aw.indexOf('%') == -1) { |
|
828 |
aw = parseInt(aw); |
|
829 |
aw = (isNaN(aw) || aw < 0) ? 300 : aw; |
|
830 |
aw = aw + "px"; |
|
831 |
} |
|
832 |
||
833 |
if (ah.indexOf('%') == -1) { |
|
834 |
ah = parseInt(ah); |
|
835 |
ah = (isNaN(ah) || ah < 0) ? 240 : ah; |
|
836 |
ah = ah + "px"; |
|
837 |
} |
|
838 |
||
839 |
iframe.setAttribute("id", id); |
|
840 |
iframe.setAttribute("name", id); |
|
841 |
iframe.setAttribute("class", "mceEditorIframe"); |
|
842 |
iframe.setAttribute("border", "0"); |
|
843 |
iframe.setAttribute("frameBorder", "0"); |
|
844 |
iframe.setAttribute("marginWidth", "0"); |
|
845 |
iframe.setAttribute("marginHeight", "0"); |
|
846 |
iframe.setAttribute("leftMargin", "0"); |
|
847 |
iframe.setAttribute("topMargin", "0"); |
|
848 |
iframe.setAttribute("width", aw); |
|
849 |
iframe.setAttribute("height", ah); |
|
850 |
iframe.setAttribute("allowtransparency", "true"); |
|
851 |
iframe.className = 'mceEditorIframe'; |
|
852 |
||
853 |
if (tinyMCE.settings["auto_resize"]) |
|
854 |
iframe.setAttribute("scrolling", "no"); |
|
855 |
||
856 |
// Must have a src element in MSIE HTTPs breaks aswell as absoute URLs |
|
857 |
if (tinyMCE.isRealIE) |
|
858 |
iframe.setAttribute("src", this.settings['default_document']); |
|
859 |
||
860 |
iframe.style.width = aw; |
|
861 |
iframe.style.height = ah; |
|
862 |
||
863 |
// Ugly hack for Gecko problem in strict mode |
|
864 |
if (tinyMCE.settings.strict_loading_mode) |
|
865 |
iframe.style.marginBottom = '-5px'; |
|
866 |
||
867 |
// MSIE 5.0 issue |
|
868 |
if (tinyMCE.isRealIE) |
|
869 |
replace_element.outerHTML = iframe.outerHTML; |
|
870 |
else |
|
871 |
replace_element.parentNode.replaceChild(iframe, replace_element); |
|
872 |
||
873 |
if (tinyMCE.isRealIE) |
|
874 |
return win.frames[id]; |
|
875 |
else |
|
876 |
return iframe; |
|
877 |
}, |
|
878 |
||
879 |
setupContent : function(editor_id) { |
|
880 |
var inst = tinyMCE.instances[editor_id], i; |
|
881 |
var doc = inst.getDoc(); |
|
882 |
var head = doc.getElementsByTagName('head').item(0); |
|
883 |
var content = inst.startContent; |
|
884 |
||
885 |
// HTML values get XML encoded in strict mode |
|
886 |
if (tinyMCE.settings.strict_loading_mode) { |
|
887 |
content = content.replace(/</g, '<'); |
|
888 |
content = content.replace(/>/g, '>'); |
|
889 |
content = content.replace(/"/g, '"'); |
|
890 |
content = content.replace(/&/g, '&'); |
|
891 |
} |
|
892 |
||
893 |
tinyMCE.selectedInstance = inst; |
|
894 |
inst.switchSettings(); |
|
895 |
||
896 |
// Not loaded correctly hit it again, Mozilla bug #997860 |
|
897 |
if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") { |
|
898 |
// This part will remove the designMode status |
|
899 |
// Failes first time in Firefox 1.5b2 on Mac |
|
900 |
try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {} |
|
901 |
window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000); |
|
902 |
return; |
|
903 |
} |
|
904 |
||
905 |
if (!head) { |
|
906 |
window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10); |
|
907 |
return; |
|
908 |
} |
|
909 |
||
910 |
// Import theme specific content CSS the user specific |
|
911 |
tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings['theme'] + "/css/editor_content.css"); |
|
912 |
tinyMCE.importCSS(inst.getDoc(), inst.settings['content_css']); |
|
913 |
tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst); |
|
914 |
||
915 |
// Setup keyboard shortcuts |
|
916 |
if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) { |
|
917 |
inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo'); |
|
918 |
inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo'); |
|
919 |
} |
|
920 |
||
921 |
// BlockFormat shortcuts keys |
|
922 |
for (i=1; i<=6; i++) |
|
923 |
inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, '<h' + i + '>'); |
|
924 |
||
925 |
inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '<p>'); |
|
926 |
inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '<div>'); |
|
927 |
inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '<address>'); |
|
928 |
||
929 |
// Add default shortcuts for gecko |
|
930 |
if (tinyMCE.isGecko) { |
|
931 |
inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold'); |
|
932 |
inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic'); |
|
933 |
inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline'); |
|
934 |
} |
|
935 |
||
936 |
// Setup span styles |
|
937 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
938 |
inst.getBody().setAttribute('id', 'mceSpanFonts'); |
|
939 |
||
940 |
if (tinyMCE.settings['nowrap']) |
|
941 |
doc.body.style.whiteSpace = "nowrap"; |
|
942 |
||
943 |
doc.body.dir = this.settings['directionality']; |
|
944 |
doc.editorId = editor_id; |
|
945 |
||
946 |
// Add on document element in Mozilla |
|
947 |
if (!tinyMCE.isIE) |
|
948 |
doc.documentElement.editorId = editor_id; |
|
949 |
||
950 |
inst.setBaseHREF(tinyMCE.settings['base_href']); |
|
951 |
||
952 |
// Replace new line characters to BRs |
|
953 |
if (tinyMCE.settings['convert_newlines_to_brs']) { |
|
954 |
content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi"); |
|
955 |
content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi"); |
|
956 |
content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi"); |
|
957 |
} |
|
958 |
||
959 |
// Open closed anchors |
|
960 |
// content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>'); |
|
961 |
||
962 |
// Call custom cleanup code |
|
963 |
content = tinyMCE.storeAwayURLs(content); |
|
964 |
content = tinyMCE._customCleanup(inst, "insert_to_editor", content); |
|
965 |
||
966 |
if (tinyMCE.isIE) { |
|
967 |
// Ugly!!! |
|
968 |
window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500); |
|
969 |
||
970 |
if (tinyMCE.settings["force_br_newlines"]) |
|
971 |
doc.styleSheets[0].addRule("p", "margin: 0;"); |
|
972 |
||
973 |
var body = inst.getBody(); |
|
974 |
body.editorId = editor_id; |
|
975 |
} |
|
976 |
||
977 |
content = tinyMCE.cleanupHTMLCode(content); |
|
978 |
||
979 |
// Fix for bug #958637 |
|
980 |
if (!tinyMCE.isIE) { |
|
981 |
var contentElement = inst.getDoc().createElement("body"); |
|
982 |
var doc = inst.getDoc(); |
|
983 |
||
984 |
contentElement.innerHTML = content; |
|
985 |
||
986 |
// Remove weridness! |
|
987 |
if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) |
|
988 |
content = content.replace(new RegExp('<>', 'g'), ""); |
|
989 |
||
990 |
if (tinyMCE.settings['cleanup_on_startup']) |
|
991 |
tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); |
|
992 |
else |
|
993 |
tinyMCE.setInnerHTML(inst.getBody(), content); |
|
994 |
||
995 |
tinyMCE.convertAllRelativeURLs(inst.getBody()); |
|
996 |
} else { |
|
997 |
if (tinyMCE.settings['cleanup_on_startup']) { |
|
998 |
tinyMCE._setHTML(inst.getDoc(), content); |
|
999 |
||
1000 |
// Produces permission denied error in MSIE 5.5 |
|
1001 |
eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}'); |
|
1002 |
} else |
|
1003 |
tinyMCE._setHTML(inst.getDoc(), content); |
|
1004 |
} |
|
1005 |
||
1006 |
// Fix for bug #957681 |
|
1007 |
//inst.getDoc().designMode = inst.getDoc().designMode; |
|
1008 |
||
1009 |
tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst); |
|
1010 |
tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); |
|
1011 |
||
1012 |
// Re-add design mode on mozilla |
|
1013 |
if (!tinyMCE.isIE) |
|
1014 |
tinyMCE.addEventHandlers(inst); |
|
1015 |
||
1016 |
// Add blur handler |
|
1017 |
if (tinyMCE.isIE) { |
|
1018 |
tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch); |
|
1019 |
tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953 |
|
1020 |
||
1021 |
// Workaround for drag drop/copy paste base href bug |
|
1022 |
if (!tinyMCE.isOpera) { |
|
1023 |
tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove); |
|
1024 |
tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch); |
|
1025 |
tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch); |
|
1026 |
} |
|
1027 |
} |
|
1028 |
||
1029 |
// Trigger node change, this call locks buttons for tables and so forth |
|
1030 |
inst.select(); |
|
1031 |
tinyMCE.selectedElement = inst.contentWindow.document.body; |
|
1032 |
||
1033 |
// Call custom DOM cleanup |
|
1034 |
tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody()); |
|
1035 |
tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody()); |
|
1036 |
tinyMCE._setEventsEnabled(inst.getBody(), false); |
|
1037 |
tinyMCE.cleanupAnchors(inst.getDoc()); |
|
1038 |
||
1039 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
1040 |
tinyMCE.convertSpansToFonts(inst.getDoc()); |
|
1041 |
||
1042 |
inst.startContent = tinyMCE.trim(inst.getBody().innerHTML); |
|
1043 |
inst.undoRedo.add({ content : inst.startContent }); |
|
1044 |
||
1045 |
// Cleanup any mess left from storyAwayURLs |
|
1046 |
if (tinyMCE.isGecko) { |
|
1047 |
// Remove mce_src from textnodes and comments |
|
1048 |
tinyMCE.selectNodes(inst.getBody(), function(n) { |
|
1049 |
if (n.nodeType == 3 || n.nodeType == 8) |
|
1050 |
n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), ""); |
|
1051 |
||
1052 |
return false; |
|
1053 |
}); |
|
1054 |
} |
|
1055 |
||
1056 |
// Remove Gecko spellchecking |
|
1057 |
if (tinyMCE.isGecko) |
|
1058 |
inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck"); |
|
1059 |
||
1060 |
// Cleanup any mess left from storyAwayURLs |
|
1061 |
tinyMCE._removeInternal(inst.getBody()); |
|
1062 |
||
1063 |
inst.select(); |
|
1064 |
tinyMCE.triggerNodeChange(false, true); |
|
1065 |
}, |
|
1066 |
||
1067 |
storeAwayURLs : function(s) { |
|
1068 |
// Remove all mce_src, mce_href and replace them with new ones |
|
1069 |
// s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); |
|
1070 |
// s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); |
|
1071 |
||
1072 |
if (!s.match(/(mce_src|mce_href)/gi, s)) { |
|
1073 |
s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"'); |
|
1074 |
s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"'); |
|
1075 |
} |
|
1076 |
||
1077 |
return s; |
|
1078 |
}, |
|
1079 |
||
1080 |
_removeInternal : function(n) { |
|
1081 |
if (tinyMCE.isGecko) { |
|
1082 |
// Remove mce_src from textnodes and comments |
|
1083 |
tinyMCE.selectNodes(n, function(n) { |
|
1084 |
if (n.nodeType == 3 || n.nodeType == 8) |
|
1085 |
n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), ""); |
|
1086 |
||
1087 |
return false; |
|
1088 |
}); |
|
1089 |
} |
|
1090 |
}, |
|
1091 |
||
1092 |
removeTinyMCEFormElements : function(form_obj) { |
|
1093 |
var i, elementId; |
|
1094 |
||
1095 |
// Skip form element removal |
|
1096 |
if (!tinyMCE.getParam('hide_selects_on_submit')) |
|
1097 |
return; |
|
1098 |
||
1099 |
// Check if form is valid |
|
1100 |
if (typeof(form_obj) == "undefined" || form_obj == null) |
|
1101 |
return; |
|
1102 |
||
1103 |
// If not a form, find the form |
|
1104 |
if (form_obj.nodeName != "FORM") { |
|
1105 |
if (form_obj.form) |
|
1106 |
form_obj = form_obj.form; |
|
1107 |
else |
|
1108 |
form_obj = tinyMCE.getParentElement(form_obj, "form"); |
|
1109 |
} |
|
1110 |
||
1111 |
// Still nothing |
|
1112 |
if (form_obj == null) |
|
1113 |
return; |
|
1114 |
||
1115 |
// Disable all UI form elements that TinyMCE created |
|
1116 |
for (i=0; i<form_obj.elements.length; i++) { |
|
1117 |
elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id; |
|
1118 |
||
1119 |
if (elementId.indexOf('mce_editor_') == 0) |
|
1120 |
form_obj.elements[i].disabled = true; |
|
1121 |
} |
|
1122 |
}, |
|
1123 |
||
1124 |
handleEvent : function(e) { |
|
1125 |
var inst = tinyMCE.selectedInstance; |
|
1126 |
||
1127 |
// Remove odd, error |
|
1128 |
if (typeof(tinyMCE) == "undefined") |
|
1129 |
return true; |
|
1130 |
||
1131 |
//tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : "")); |
|
1132 |
||
1133 |
if (tinyMCE.executeCallback(tinyMCE.selectedInstance, 'handle_event_callback', 'handleEvent', e)) |
|
1134 |
return false; |
|
1135 |
||
1136 |
switch (e.type) { |
|
1137 |
case "beforedeactivate": // Was added due to bug #1439953 |
|
1138 |
case "blur": |
|
1139 |
if (tinyMCE.selectedInstance) |
|
1140 |
tinyMCE.selectedInstance.execCommand('mceEndTyping'); |
|
1141 |
||
1142 |
tinyMCE.hideMenus(); |
|
1143 |
||
1144 |
return; |
|
1145 |
||
1146 |
// Workaround for drag drop/copy paste base href bug |
|
1147 |
case "drop": |
|
1148 |
case "beforepaste": |
|
1149 |
if (tinyMCE.selectedInstance) |
|
1150 |
tinyMCE.selectedInstance.setBaseHREF(null); |
|
1151 |
||
1152 |
// Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks |
|
1153 |
// This logic forces the width/height to be in pixels while the user is drag/dropping |
|
1154 |
if (tinyMCE.isRealIE) { |
|
1155 |
var ife = tinyMCE.selectedInstance.iframeElement; |
|
1156 |
||
1157 |
/*if (ife.style.width.indexOf('%') != -1) { |
|
1158 |
ife._oldWidth = ife.width.height; |
|
1159 |
ife.style.width = ife.clientWidth; |
|
1160 |
}*/ |
|
1161 |
||
1162 |
if (ife.style.height.indexOf('%') != -1) { |
|
1163 |
ife._oldHeight = ife.style.height; |
|
1164 |
ife.style.height = ife.clientHeight; |
|
1165 |
} |
|
1166 |
} |
|
1167 |
||
1168 |
window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);tinyMCE._resetIframeHeight();", 1); |
|
1169 |
return; |
|
1170 |
||
1171 |
case "submit": |
|
1172 |
tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target); |
|
1173 |
tinyMCE.triggerSave(); |
|
1174 |
tinyMCE.isNotDirty = true; |
|
1175 |
return; |
|
1176 |
||
1177 |
case "reset": |
|
1178 |
var formObj = tinyMCE.isIE ? window.event.srcElement : e.target; |
|
1179 |
||
1180 |
for (var i=0; i<document.forms.length; i++) { |
|
1181 |
if (document.forms[i] == formObj) |
|
1182 |
window.setTimeout('tinyMCE.resetForm(' + i + ');', 10); |
|
1183 |
} |
|
1184 |
||
1185 |
return; |
|
1186 |
||
1187 |
case "keypress": |
|
1188 |
if (inst && inst.handleShortcut(e)) |
|
1189 |
return false; |
|
1190 |
||
1191 |
if (e.target.editorId) { |
|
1192 |
tinyMCE.instances[e.target.editorId].select(); |
|
1193 |
} else { |
|
1194 |
if (e.target.ownerDocument.editorId) |
|
1195 |
tinyMCE.instances[e.target.ownerDocument.editorId].select(); |
|
1196 |
} |
|
1197 |
||
1198 |
if (tinyMCE.selectedInstance) |
|
1199 |
tinyMCE.selectedInstance.switchSettings(); |
|
1200 |
||
1201 |
// Insert P element |
|
1202 |
if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) { |
|
1203 |
// Insert P element instead of BR |
|
1204 |
if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) { |
|
1205 |
// Cancel event |
|
1206 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
1207 |
return tinyMCE.cancelEvent(e); |
|
1208 |
} |
|
1209 |
} |
|
1210 |
||
1211 |
// Handle backspace |
|
1212 |
if ((tinyMCE.isGecko && !tinyMCE.isSafari) && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { |
|
1213 |
// Insert P element instead of BR |
|
1214 |
if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { |
|
1215 |
// Cancel event |
|
1216 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
1217 |
return tinyMCE.cancelEvent(e); |
|
1218 |
} |
|
1219 |
} |
|
1220 |
||
1221 |
// Return key pressed |
|
1222 |
if (tinyMCE.isIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) { |
|
1223 |
if (e.target.editorId) |
|
1224 |
tinyMCE.instances[e.target.editorId].select(); |
|
1225 |
||
1226 |
if (tinyMCE.selectedInstance) { |
|
1227 |
var sel = tinyMCE.selectedInstance.getDoc().selection; |
|
1228 |
var rng = sel.createRange(); |
|
1229 |
||
1230 |
if (tinyMCE.getParentElement(rng.parentElement(), "li") != null) |
|
1231 |
return false; |
|
1232 |
||
1233 |
// Cancel event |
|
1234 |
e.returnValue = false; |
|
1235 |
e.cancelBubble = true; |
|
1236 |
||
1237 |
// Insert BR element |
|
1238 |
rng.pasteHTML("<br />"); |
|
1239 |
rng.collapse(false); |
|
1240 |
rng.select(); |
|
1241 |
||
1242 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
1243 |
tinyMCE.triggerNodeChange(false); |
|
1244 |
return false; |
|
1245 |
} |
|
1246 |
} |
|
1247 |
||
1248 |
// Backspace or delete |
|
1249 |
if (e.keyCode == 8 || e.keyCode == 46) { |
|
1250 |
tinyMCE.selectedElement = e.target; |
|
1251 |
tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a"); |
|
1252 |
tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img"); |
|
1253 |
tinyMCE.triggerNodeChange(false); |
|
1254 |
} |
|
1255 |
||
1256 |
return false; |
|
1257 |
break; |
|
1258 |
||
1259 |
case "keyup": |
|
1260 |
case "keydown": |
|
1261 |
tinyMCE.hideMenus(); |
|
1262 |
tinyMCE.hasMouseMoved = false; |
|
1263 |
||
1264 |
if (inst && inst.handleShortcut(e)) |
|
1265 |
return false; |
|
1266 |
||
1267 |
if (e.target.editorId) |
|
1268 |
tinyMCE.instances[e.target.editorId].select(); |
|
1269 |
||
1270 |
if (tinyMCE.selectedInstance) |
|
1271 |
tinyMCE.selectedInstance.switchSettings(); |
|
1272 |
||
1273 |
var inst = tinyMCE.selectedInstance; |
|
1274 |
||
1275 |
// Handle backspace |
|
1276 |
if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { |
|
1277 |
// Insert P element instead of BR |
|
1278 |
if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { |
|
1279 |
// Cancel event |
|
1280 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
1281 |
e.preventDefault(); |
|
1282 |
return false; |
|
1283 |
} |
|
1284 |
} |
|
1285 |
||
1286 |
tinyMCE.selectedElement = null; |
|
1287 |
tinyMCE.selectedNode = null; |
|
1288 |
var elm = tinyMCE.selectedInstance.getFocusElement(); |
|
1289 |
tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); |
|
1290 |
tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); |
|
1291 |
tinyMCE.selectedElement = elm; |
|
1292 |
||
1293 |
// Update visualaids on tabs |
|
1294 |
if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) |
|
1295 |
tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance); |
|
1296 |
||
1297 |
// Fix empty elements on return/enter, check where enter occured |
|
1298 |
if (tinyMCE.isIE && e.type == "keydown" && e.keyCode == 13) |
|
1299 |
tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement(); |
|
1300 |
||
1301 |
// Fix empty elements on return/enter |
|
1302 |
if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) { |
|
1303 |
var elm = tinyMCE.enterKeyElement; |
|
1304 |
if (elm) { |
|
1305 |
var re = new RegExp('^HR|IMG|BR$','g'); // Skip these |
|
1306 |
var dre = new RegExp('^H[1-6]$','g'); // Add double on these |
|
1307 |
||
1308 |
if (!elm.hasChildNodes() && !re.test(elm.nodeName)) { |
|
1309 |
if (dre.test(elm.nodeName)) |
|
1310 |
elm.innerHTML = " "; |
|
1311 |
else |
|
1312 |
elm.innerHTML = " "; |
|
1313 |
} |
|
1314 |
} |
|
1315 |
} |
|
1316 |
||
1317 |
// Check if it's a position key |
|
1318 |
var keys = tinyMCE.posKeyCodes; |
|
1319 |
var posKey = false; |
|
1320 |
for (var i=0; i<keys.length; i++) { |
|
1321 |
if (keys[i] == e.keyCode) { |
|
1322 |
posKey = true; |
|
1323 |
break; |
|
1324 |
} |
|
1325 |
} |
|
1326 |
||
1327 |
// MSIE custom key handling |
|
1328 |
if (tinyMCE.isIE && tinyMCE.settings['custom_undo_redo']) { |
|
1329 |
var keys = new Array(8,46); // Backspace,Delete |
|
1330 |
||
1331 |
for (var i=0; i<keys.length; i++) { |
|
1332 |
if (keys[i] == e.keyCode) { |
|
1333 |
if (e.type == "keyup") |
|
1334 |
tinyMCE.triggerNodeChange(false); |
|
1335 |
} |
|
1336 |
} |
|
1337 |
} |
|
1338 |
||
1339 |
// If Ctrl key |
|
1340 |
if (e.keyCode == 17) |
|
1341 |
return true; |
|
1342 |
||
1343 |
// Handle Undo/Redo when typing content |
|
1344 |
||
1345 |
if (tinyMCE.isGecko) { |
|
1346 |
// Start typing (not a position key or ctrl key, but ctrl+x and ctrl+p is ok) |
|
1347 |
if (!posKey && e.type == "keyup" && !e.ctrlKey || (e.ctrlKey && (e.keyCode == 86 || e.keyCode == 88))) |
|
1348 |
tinyMCE.execCommand("mceStartTyping"); |
|
1349 |
} else { |
|
1350 |
// IE seems to be working better with this setting |
|
1351 |
if (!posKey && e.type == "keyup") |
|
1352 |
tinyMCE.execCommand("mceStartTyping"); |
|
1353 |
} |
|
1354 |
||
1355 |
// Store undo bookmark |
|
1356 |
if (e.type == "keydown" && (posKey || e.ctrlKey) && inst) |
|
1357 |
inst.undoBookmark = inst.selection.getBookmark(); |
|
1358 |
||
1359 |
// End typing (position key) or some Ctrl event |
|
1360 |
if (e.type == "keyup" && (posKey || e.ctrlKey)) |
|
1361 |
tinyMCE.execCommand("mceEndTyping"); |
|
1362 |
||
1363 |
if (posKey && e.type == "keyup") |
|
1364 |
tinyMCE.triggerNodeChange(false); |
|
1365 |
||
1366 |
if (tinyMCE.isIE && e.ctrlKey) |
|
1367 |
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1); |
|
1368 |
break; |
|
1369 |
||
1370 |
case "mousedown": |
|
1371 |
case "mouseup": |
|
1372 |
case "click": |
|
1373 |
case "dblclick": |
|
1374 |
case "focus": |
|
1375 |
tinyMCE.hideMenus(); |
|
1376 |
||
1377 |
if (tinyMCE.selectedInstance) { |
|
1378 |
tinyMCE.selectedInstance.switchSettings(); |
|
1379 |
tinyMCE.selectedInstance.isFocused = true; |
|
1380 |
} |
|
1381 |
||
1382 |
// Check instance event trigged on |
|
1383 |
var targetBody = tinyMCE.getParentElement(e.target, "html"); |
|
1384 |
for (var instanceName in tinyMCE.instances) { |
|
1385 |
if (!tinyMCE.isInstance(tinyMCE.instances[instanceName])) |
|
1386 |
continue; |
|
1387 |
||
1388 |
var inst = tinyMCE.instances[instanceName]; |
|
1389 |
||
1390 |
// Reset design mode if lost (on everything just in case) |
|
1391 |
inst.autoResetDesignMode(); |
|
1392 |
||
1393 |
// Use HTML element since users might click outside of body element |
|
1394 |
if (inst.getBody().parentNode == targetBody) { |
|
1395 |
inst.select(); |
|
1396 |
tinyMCE.selectedElement = e.target; |
|
1397 |
tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a"); |
|
1398 |
tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img"); |
|
1399 |
break; |
|
1400 |
} |
|
1401 |
} |
|
1402 |
||
1403 |
// Add first bookmark location |
|
1404 |
if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark && (e.type == "mouseup" || e.type == "dblclick")) |
|
1405 |
tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark(); |
|
1406 |
||
1407 |
// Reset selected node |
|
1408 |
if (e.type != "focus") |
|
1409 |
tinyMCE.selectedNode = null; |
|
1410 |
||
1411 |
tinyMCE.triggerNodeChange(false); |
|
1412 |
tinyMCE.execCommand("mceEndTyping"); |
|
1413 |
||
1414 |
if (e.type == "mouseup") |
|
1415 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
1416 |
||
1417 |
// Just in case |
|
1418 |
if (!tinyMCE.selectedInstance && e.target.editorId) |
|
1419 |
tinyMCE.instances[e.target.editorId].select(); |
|
1420 |
||
1421 |
return false; |
|
1422 |
break; |
|
1423 |
} |
|
1424 |
}, |
|
1425 |
||
1426 |
getButtonHTML : function(id, lang, img, cmd, ui, val) { |
|
1427 |
var h = '', m, x, io = ''; |
|
1428 |
||
1429 |
cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\''; |
|
1430 |
||
1431 |
if (typeof(ui) != "undefined" && ui != null) |
|
1432 |
cmd += ',' + ui; |
|
1433 |
||
1434 |
if (typeof(val) != "undefined" && val != null) |
|
1435 |
cmd += ",'" + val + "'"; |
|
1436 |
||
1437 |
cmd += ');'; |
|
1438 |
||
1439 |
// Patch for IE7 bug with hover out not restoring correctly |
|
1440 |
if (tinyMCE.isRealIE) |
|
1441 |
io = 'onmouseover="tinyMCE.lastHover = this;"'; |
|
1442 |
||
1443 |
// Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled |
|
1444 |
if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) { |
|
1445 |
// Tiled button |
|
1446 |
x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20); |
|
1447 |
h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceTiledButton mceButtonNormal" target="_self">'; |
|
1448 |
h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />'; |
|
1449 |
h += '</a>'; |
|
1450 |
} else { |
|
1451 |
// Normal button |
|
1452 |
h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">'; |
|
1453 |
h += '<img src="' + img + '" title="{$' + lang + '}" />'; |
|
1454 |
h += '</a>'; |
|
1455 |
} |
|
1456 |
||
1457 |
return h; |
|
1458 |
}, |
|
1459 |
||
1460 |
getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) { |
|
1461 |
var h = '', m, x; |
|
1462 |
||
1463 |
mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');'; |
|
1464 |
cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\''; |
|
1465 |
||
1466 |
if (typeof(ui) != "undefined" && ui != null) |
|
1467 |
cmd += ',' + ui; |
|
1468 |
||
1469 |
if (typeof(val) != "undefined" && val != null) |
|
1470 |
cmd += ",'" + val + "'"; |
|
1471 |
||
1472 |
cmd += ');'; |
|
1473 |
||
1474 |
// Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled |
|
1475 |
if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) { |
|
1476 |
x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20); |
|
1477 |
||
1478 |
if (tinyMCE.isRealIE) |
|
1479 |
h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">'; |
|
1480 |
else |
|
1481 |
h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">'; |
|
1482 |
||
1483 |
h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceMenuButtonNormal" target="_self">'; |
|
1484 |
h += '<img src="{$themeurl}/images/spacer.gif" style="width: 20px; height: 20px; background-position: ' + x + 'px 0" title="{$' + lang + '}" /></a>'; |
|
1485 |
h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />'; |
|
1486 |
h += '</a></span>'; |
|
1487 |
} else { |
|
1488 |
if (tinyMCE.isRealIE) |
|
1489 |
h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">'; |
|
1490 |
else |
|
1491 |
h += '<span id="{$editor_id}_' + id + '" dir="ltr" class="mceMenuButton">'; |
|
1492 |
||
1493 |
h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">'; |
|
1494 |
h += '<img src="' + img + '" title="{$' + lang + '}" /></a>'; |
|
1495 |
h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />'; |
|
1496 |
h += '</a></span>'; |
|
1497 |
} |
|
1498 |
||
1499 |
return h; |
|
1500 |
}, |
|
1501 |
||
1502 |
_menuButtonEvent : function(e, o) { |
|
1503 |
if (o.className == 'mceMenuButtonFocus') |
|
1504 |
return; |
|
1505 |
||
1506 |
if (e == 'over') |
|
1507 |
o.className = o.className + ' mceMenuHover'; |
|
1508 |
else |
|
1509 |
o.className = o.className.replace(/\s.*$/, ''); |
|
1510 |
}, |
|
1511 |
||
1512 |
addButtonMap : function(m) { |
|
1513 |
var i, a = m.replace(/\s+/, '').split(','); |
|
1514 |
||
1515 |
for (i=0; i<a.length; i++) |
|
1516 |
this.buttonMap[a[i]] = i; |
|
1517 |
}, |
|
1518 |
||
1519 |
submitPatch : function() { |
|
1520 |
tinyMCE.removeTinyMCEFormElements(this); |
|
1521 |
tinyMCE.triggerSave(); |
|
1522 |
tinyMCE.isNotDirty = true; |
|
1523 |
this.mceOldSubmit(); |
|
1524 |
}, |
|
1525 |
||
1526 |
onLoad : function() { |
|
1527 |
var r; |
|
1528 |
||
1529 |
// Wait for everything to be loaded first |
|
1530 |
if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) { |
|
1531 |
window.setTimeout('tinyMCE.onLoad();', 1); |
|
1532 |
return; |
|
1533 |
} |
|
1534 |
||
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1535 |
if (tinyMCE.isRealIE) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1536 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1537 |
try |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1538 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1539 |
if ( typeof(window.event) == 'object' && window.event != null ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1540 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1541 |
try |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1542 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1543 |
if ( window.event.type == "onreadystatechange" ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1544 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1545 |
try |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1546 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1547 |
if ( document.readyState != "complete" ) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1548 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1549 |
return true; |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1550 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1551 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1552 |
catch(e) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1553 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1554 |
alert('inner error: ' + e.description); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1555 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1556 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1557 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1558 |
catch(e) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1559 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1560 |
alert('middle error: ' + e.description); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1561 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1562 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1563 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1564 |
catch(e) |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1565 |
{ |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1566 |
alert('Outer error: ' + e.description); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1567 |
} |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
1
diff
changeset
|
1568 |
} |
1 | 1569 |
|
1570 |
if (tinyMCE.isLoaded) |
|
1571 |
return true; |
|
1572 |
||
1573 |
tinyMCE.isLoaded = true; |
|
1574 |
||
1575 |
// IE produces JS error if TinyMCE is placed in a frame |
|
1576 |
// It seems to have something to do with the selection not beeing |
|
1577 |
// correctly initialized in IE so this hack solves the problem |
|
1578 |
if (tinyMCE.isRealIE && document.body) { |
|
1579 |
r = document.body.createTextRange(); |
|
1580 |
r.collapse(true); |
|
1581 |
r.select(); |
|
1582 |
} |
|
1583 |
||
1584 |
tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad'); |
|
1585 |
||
1586 |
for (var c=0; c<tinyMCE.configs.length; c++) { |
|
1587 |
tinyMCE.settings = tinyMCE.configs[c]; |
|
1588 |
||
1589 |
var selector = tinyMCE.getParam("editor_selector"); |
|
1590 |
var deselector = tinyMCE.getParam("editor_deselector"); |
|
1591 |
var elementRefAr = new Array(); |
|
1592 |
||
1593 |
// Add submit triggers |
|
1594 |
if (document.forms && tinyMCE.settings['add_form_submit_trigger'] && !tinyMCE.submitTriggers) { |
|
1595 |
for (var i=0; i<document.forms.length; i++) { |
|
1596 |
var form = document.forms[i]; |
|
1597 |
||
1598 |
tinyMCE.addEvent(form, "submit", TinyMCE_Engine.prototype.handleEvent); |
|
1599 |
tinyMCE.addEvent(form, "reset", TinyMCE_Engine.prototype.handleEvent); |
|
1600 |
tinyMCE.submitTriggers = true; // Do it only once |
|
1601 |
||
1602 |
// Patch the form.submit function |
|
1603 |
if (tinyMCE.settings['submit_patch']) { |
|
1604 |
try { |
|
1605 |
form.mceOldSubmit = form.submit; |
|
1606 |
form.submit = TinyMCE_Engine.prototype.submitPatch; |
|
1607 |
} catch (e) { |
|
1608 |
// Do nothing |
|
1609 |
} |
|
1610 |
} |
|
1611 |
} |
|
1612 |
} |
|
1613 |
||
1614 |
// Add editor instances based on mode |
|
1615 |
var mode = tinyMCE.settings['mode']; |
|
1616 |
switch (mode) { |
|
1617 |
case "exact": |
|
1618 |
var elements = tinyMCE.getParam('elements', '', true, ','); |
|
1619 |
||
1620 |
for (var i=0; i<elements.length; i++) { |
|
1621 |
var element = tinyMCE._getElementById(elements[i]); |
|
1622 |
var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : ""; |
|
1623 |
||
1624 |
if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class"))) |
|
1625 |
continue; |
|
1626 |
||
1627 |
if (trigger == "false") |
|
1628 |
continue; |
|
1629 |
||
1630 |
if ((tinyMCE.settings['ask'] || tinyMCE.settings['convert_on_click']) && element) { |
|
1631 |
elementRefAr[elementRefAr.length] = element; |
|
1632 |
continue; |
|
1633 |
} |
|
1634 |
||
1635 |
if (element) |
|
1636 |
tinyMCE.addMCEControl(element, elements[i]); |
|
1637 |
else if (tinyMCE.settings['debug']) |
|
1638 |
alert("Error: Could not find element by id or name: " + elements[i]); |
|
1639 |
} |
|
1640 |
break; |
|
1641 |
||
1642 |
case "specific_textareas": |
|
1643 |
case "textareas": |
|
1644 |
var nodeList = document.getElementsByTagName("textarea"); |
|
1645 |
||
1646 |
for (var i=0; i<nodeList.length; i++) { |
|
1647 |
var elm = nodeList.item(i); |
|
1648 |
var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']); |
|
1649 |
||
1650 |
if (selector != '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class"))) |
|
1651 |
continue; |
|
1652 |
||
1653 |
if (selector != '') |
|
1654 |
trigger = selector != "" ? "true" : ""; |
|
1655 |
||
1656 |
if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class"))) |
|
1657 |
continue; |
|
1658 |
||
1659 |
if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false")) |
|
1660 |
elementRefAr[elementRefAr.length] = elm; |
|
1661 |
} |
|
1662 |
break; |
|
1663 |
} |
|
1664 |
||
1665 |
for (var i=0; i<elementRefAr.length; i++) { |
|
1666 |
var element = elementRefAr[i]; |
|
1667 |
var elementId = element.name ? element.name : element.id; |
|
1668 |
||
1669 |
if (tinyMCE.settings['ask'] || tinyMCE.settings['convert_on_click']) { |
|
1670 |
// Focus breaks in Mozilla |
|
1671 |
if (tinyMCE.isGecko) { |
|
1672 |
var settings = tinyMCE.settings; |
|
1673 |
||
1674 |
tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); |
|
1675 |
||
1676 |
if (element.nodeName != "TEXTAREA" && element.nodeName != "INPUT") |
|
1677 |
tinyMCE.addEvent(element, "click", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); |
|
1678 |
// tinyMCE.addEvent(element, "mouseover", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);}); |
|
1679 |
} else { |
|
1680 |
var settings = tinyMCE.settings; |
|
1681 |
||
1682 |
tinyMCE.addEvent(element, "focus", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); |
|
1683 |
tinyMCE.addEvent(element, "click", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); |
|
1684 |
// tinyMCE.addEvent(element, "mouseenter", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); }); |
|
1685 |
} |
|
1686 |
} else |
|
1687 |
tinyMCE.addMCEControl(element, elementId); |
|
1688 |
} |
|
1689 |
||
1690 |
// Handle auto focus |
|
1691 |
if (tinyMCE.settings['auto_focus']) { |
|
1692 |
window.setTimeout(function () { |
|
1693 |
var inst = tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']); |
|
1694 |
inst.selection.selectNode(inst.getBody(), true, true); |
|
1695 |
inst.contentWindow.focus(); |
|
1696 |
}, 100); |
|
1697 |
} |
|
1698 |
||
1699 |
tinyMCE.dispatchCallback(null, 'oninit', 'onInit'); |
|
1700 |
} |
|
1701 |
}, |
|
1702 |
||
1703 |
isInstance : function(o) { |
|
1704 |
return o != null && typeof(o) == "object" && o.isTinyMCE_Control; |
|
1705 |
}, |
|
1706 |
||
1707 |
getParam : function(name, default_value, strip_whitespace, split_chr) { |
|
1708 |
var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; |
|
1709 |
||
1710 |
// Fix bool values |
|
1711 |
if (value == "true" || value == "false") |
|
1712 |
return (value == "true"); |
|
1713 |
||
1714 |
if (strip_whitespace) |
|
1715 |
value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "") + ''; |
|
1716 |
||
1717 |
if (typeof(split_chr) != "undefined" && split_chr != null) { |
|
1718 |
value = value.split(split_chr); |
|
1719 |
var outArray = new Array(); |
|
1720 |
||
1721 |
for (var i=0; i<value.length; i++) { |
|
1722 |
if (value[i] && value[i] != "") |
|
1723 |
outArray[outArray.length] = value[i]; |
|
1724 |
} |
|
1725 |
||
1726 |
value = outArray; |
|
1727 |
} |
|
1728 |
||
1729 |
return value; |
|
1730 |
}, |
|
1731 |
||
1732 |
getLang : function(name, default_value, parse_entities, va) { |
|
1733 |
var v = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name], n; |
|
1734 |
||
1735 |
if (parse_entities) |
|
1736 |
v = tinyMCE.entityDecode(v); |
|
1737 |
||
1738 |
if (va) { |
|
1739 |
for (n in va) |
|
1740 |
v = this.replaceVar(v, n, va[n]); |
|
1741 |
} |
|
1742 |
||
1743 |
return v; |
|
1744 |
}, |
|
1745 |
||
1746 |
entityDecode : function(s) { |
|
1747 |
var e = document.createElement("div"); |
|
1748 |
||
1749 |
e.innerHTML = s; |
|
1750 |
||
1751 |
return e.firstChild.nodeValue; |
|
1752 |
}, |
|
1753 |
||
1754 |
addToLang : function(prefix, ar) { |
|
1755 |
for (var key in ar) { |
|
1756 |
if (typeof(ar[key]) == 'function') |
|
1757 |
continue; |
|
1758 |
||
1759 |
tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key]; |
|
1760 |
} |
|
1761 |
||
1762 |
this.loadNextScript(); |
|
1763 |
||
1764 |
// for (var key in ar) |
|
1765 |
// tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|"; |
|
1766 |
}, |
|
1767 |
||
1768 |
triggerNodeChange : function(focus, setup_content) { |
|
1769 |
var elm, inst, editorId, undoIndex = -1, undoLevels = -1, doc, anySelection = false, st; |
|
1770 |
||
1771 |
if (tinyMCE.selectedInstance) { |
|
1772 |
inst = tinyMCE.selectedInstance; |
|
1773 |
elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement(); |
|
1774 |
||
1775 |
/* if (elm == inst.lastTriggerEl) |
|
1776 |
return; |
|
1777 |
||
1778 |
inst.lastTriggerEl = elm;*/ |
|
1779 |
||
1780 |
editorId = inst.editorId; |
|
1781 |
st = inst.selection.getSelectedText(); |
|
1782 |
||
1783 |
if (tinyMCE.settings.auto_resize) |
|
1784 |
inst.resizeToContent(); |
|
1785 |
||
1786 |
if (setup_content && tinyMCE.isGecko && inst.isHidden()) |
|
1787 |
elm = inst.getBody(); |
|
1788 |
||
1789 |
inst.switchSettings(); |
|
1790 |
||
1791 |
if (tinyMCE.selectedElement) |
|
1792 |
anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (st && st.length > 0); |
|
1793 |
||
1794 |
if (tinyMCE.settings['custom_undo_redo']) { |
|
1795 |
undoIndex = inst.undoRedo.undoIndex; |
|
1796 |
undoLevels = inst.undoRedo.undoLevels.length; |
|
1797 |
} |
|
1798 |
||
1799 |
tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content); |
|
1800 |
} |
|
1801 |
||
1802 |
if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) |
|
1803 |
this.selectedInstance.contentWindow.focus(); |
|
1804 |
}, |
|
1805 |
||
1806 |
_customCleanup : function(inst, type, content) { |
|
1807 |
var pl, po, i; |
|
1808 |
||
1809 |
// Call custom cleanup |
|
1810 |
var customCleanup = tinyMCE.settings['cleanup_callback']; |
|
1811 |
if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") |
|
1812 |
content = eval(customCleanup + "(type, content, inst);"); |
|
1813 |
||
1814 |
// Trigger theme cleanup |
|
1815 |
po = tinyMCE.themes[tinyMCE.settings['theme']]; |
|
1816 |
if (po && po.cleanup) |
|
1817 |
content = po.cleanup(type, content, inst); |
|
1818 |
||
1819 |
// Trigger plugin cleanups |
|
1820 |
pl = inst.plugins; |
|
1821 |
for (i=0; i<pl.length; i++) { |
|
1822 |
po = tinyMCE.plugins[pl[i]]; |
|
1823 |
||
1824 |
if (po && po.cleanup) |
|
1825 |
content = po.cleanup(type, content, inst); |
|
1826 |
} |
|
1827 |
||
1828 |
return content; |
|
1829 |
}, |
|
1830 |
||
1831 |
setContent : function(h) { |
|
1832 |
if (tinyMCE.selectedInstance) { |
|
1833 |
tinyMCE.selectedInstance.execCommand('mceSetContent', false, h); |
|
1834 |
tinyMCE.selectedInstance.repaint(); |
|
1835 |
} |
|
1836 |
}, |
|
1837 |
||
1838 |
importThemeLanguagePack : function(name) { |
|
1839 |
if (typeof(name) == "undefined") |
|
1840 |
name = tinyMCE.settings['theme']; |
|
1841 |
||
1842 |
tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js'); |
|
1843 |
}, |
|
1844 |
||
1845 |
importPluginLanguagePack : function(name) { |
|
1846 |
var b = tinyMCE.baseURL + '/plugins/' + name; |
|
1847 |
||
1848 |
if (this.plugins[name]) |
|
1849 |
b = this.plugins[name].baseURL; |
|
1850 |
||
1851 |
tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings['language'] + '.js'); |
|
1852 |
}, |
|
1853 |
||
1854 |
applyTemplate : function(h, as) { |
|
1855 |
return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) { |
|
1856 |
if (s.indexOf('lang_') == 0 && tinyMCELang[s]) |
|
1857 |
return tinyMCELang[s]; |
|
1858 |
||
1859 |
if (as && as[s]) |
|
1860 |
return as[s]; |
|
1861 |
||
1862 |
if (tinyMCE.settings[s]) |
|
1863 |
return tinyMCE.settings[s]; |
|
1864 |
||
1865 |
if (m == 'themeurl') |
|
1866 |
return tinyMCE.themeURL; |
|
1867 |
||
1868 |
return m; |
|
1869 |
}); |
|
1870 |
}, |
|
1871 |
||
1872 |
replaceVar : function(h, r, v) { |
|
1873 |
return h.replace(new RegExp('{\\\$' + r + '}', 'g'), v); |
|
1874 |
}, |
|
1875 |
||
1876 |
openWindow : function(template, args) { |
|
1877 |
var html, width, height, x, y, resizable, scrollbars, url; |
|
1878 |
||
1879 |
args = !args ? {} : args; |
|
1880 |
||
1881 |
args['mce_template_file'] = template['file']; |
|
1882 |
args['mce_width'] = template['width']; |
|
1883 |
args['mce_height'] = template['height']; |
|
1884 |
tinyMCE.windowArgs = args; |
|
1885 |
||
1886 |
html = template['html']; |
|
1887 |
if (!(width = parseInt(template['width']))) |
|
1888 |
width = 320; |
|
1889 |
||
1890 |
if (!(height = parseInt(template['height']))) |
|
1891 |
height = 200; |
|
1892 |
||
1893 |
// Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! |
|
1894 |
if (tinyMCE.isIE) |
|
1895 |
height += 40; |
|
1896 |
else |
|
1897 |
height += 20; |
|
1898 |
||
1899 |
x = parseInt(screen.width / 2.0) - (width / 2.0); |
|
1900 |
y = parseInt(screen.height / 2.0) - (height / 2.0); |
|
1901 |
||
1902 |
resizable = (args && args['resizable']) ? args['resizable'] : "no"; |
|
1903 |
scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; |
|
1904 |
||
1905 |
if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1) |
|
1906 |
url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; |
|
1907 |
else |
|
1908 |
url = template['file']; |
|
1909 |
||
1910 |
// Replace all args as variables in URL |
|
1911 |
for (var name in args) { |
|
1912 |
if (typeof(args[name]) == 'function') |
|
1913 |
continue; |
|
1914 |
||
1915 |
url = tinyMCE.replaceVar(url, name, escape(args[name])); |
|
1916 |
} |
|
1917 |
||
1918 |
if (html) { |
|
1919 |
html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']); |
|
1920 |
html = tinyMCE.applyTemplate(html, args); |
|
1921 |
||
1922 |
var 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); |
|
1923 |
if (win == null) { |
|
1924 |
alert(tinyMCELang['lang_popup_blocked']); |
|
1925 |
return; |
|
1926 |
} |
|
1927 |
||
1928 |
//alert('docwrite 2'); |
|
1929 |
win.document.write(html); |
|
1930 |
win.document.close(); |
|
1931 |
win.resizeTo(width, height); |
|
1932 |
win.focus(); |
|
1933 |
} else { |
|
1934 |
if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") { |
|
1935 |
height += 10; |
|
1936 |
||
1937 |
var features = "resizable:" + resizable |
|
1938 |
+ ";scroll:" |
|
1939 |
+ scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" |
|
1940 |
+ width + "px;dialogHeight:" + height + "px;"; |
|
1941 |
||
1942 |
window.showModalDialog(url, window, features); |
|
1943 |
} else { |
|
1944 |
var modal = (resizable == "yes") ? "no" : "yes"; |
|
1945 |
||
1946 |
if (tinyMCE.isGecko && tinyMCE.isMac) |
|
1947 |
modal = "no"; |
|
1948 |
||
1949 |
if (template['close_previous'] != "no") |
|
1950 |
try {tinyMCE.lastWindow.close();} catch (ex) {} |
|
1951 |
||
1952 |
var 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); |
|
1953 |
if (win == null) { |
|
1954 |
alert(tinyMCELang['lang_popup_blocked']); |
|
1955 |
return; |
|
1956 |
} |
|
1957 |
||
1958 |
if (template['close_previous'] != "no") |
|
1959 |
tinyMCE.lastWindow = win; |
|
1960 |
||
1961 |
eval('try { win.resizeTo(width, height); } catch(e) { }'); |
|
1962 |
||
1963 |
// Make it bigger if statusbar is forced |
|
1964 |
if (tinyMCE.isGecko) { |
|
1965 |
if (win.document.defaultView.statusbar.visible) |
|
1966 |
win.resizeBy(0, tinyMCE.isMac ? 10 : 24); |
|
1967 |
} |
|
1968 |
||
1969 |
win.focus(); |
|
1970 |
} |
|
1971 |
} |
|
1972 |
}, |
|
1973 |
||
1974 |
closeWindow : function(win) { |
|
1975 |
win.close(); |
|
1976 |
}, |
|
1977 |
||
1978 |
getVisualAidClass : function(class_name, state) { |
|
1979 |
var aidClass = tinyMCE.settings['visual_table_class']; |
|
1980 |
||
1981 |
if (typeof(state) == "undefined") |
|
1982 |
state = tinyMCE.settings['visual']; |
|
1983 |
||
1984 |
// Split |
|
1985 |
var classNames = new Array(); |
|
1986 |
var ar = class_name.split(' '); |
|
1987 |
for (var i=0; i<ar.length; i++) { |
|
1988 |
if (ar[i] == aidClass) |
|
1989 |
ar[i] = ""; |
|
1990 |
||
1991 |
if (ar[i] != "") |
|
1992 |
classNames[classNames.length] = ar[i]; |
|
1993 |
} |
|
1994 |
||
1995 |
if (state) |
|
1996 |
classNames[classNames.length] = aidClass; |
|
1997 |
||
1998 |
// Glue |
|
1999 |
var className = ""; |
|
2000 |
for (var i=0; i<classNames.length; i++) { |
|
2001 |
if (i > 0) |
|
2002 |
className += " "; |
|
2003 |
||
2004 |
className += classNames[i]; |
|
2005 |
} |
|
2006 |
||
2007 |
return className; |
|
2008 |
}, |
|
2009 |
||
2010 |
handleVisualAid : function(el, deep, state, inst, skip_dispatch) { |
|
2011 |
if (!el) |
|
2012 |
return; |
|
2013 |
||
2014 |
if (!skip_dispatch) |
|
2015 |
tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst); |
|
2016 |
||
2017 |
var tableElement = null; |
|
2018 |
||
2019 |
switch (el.nodeName) { |
|
2020 |
case "TABLE": |
|
2021 |
var oldW = el.style.width; |
|
2022 |
var oldH = el.style.height; |
|
2023 |
var bo = tinyMCE.getAttrib(el, "border"); |
|
2024 |
||
2025 |
bo = bo == "" || bo == "0" ? true : false; |
|
2026 |
||
2027 |
tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); |
|
2028 |
||
2029 |
el.style.width = oldW; |
|
2030 |
el.style.height = oldH; |
|
2031 |
||
2032 |
for (var y=0; y<el.rows.length; y++) { |
|
2033 |
for (var x=0; x<el.rows[y].cells.length; x++) { |
|
2034 |
var cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo); |
|
2035 |
tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn); |
|
2036 |
} |
|
2037 |
} |
|
2038 |
||
2039 |
break; |
|
2040 |
||
2041 |
case "A": |
|
2042 |
var anchorName = tinyMCE.getAttrib(el, "name"); |
|
2043 |
||
2044 |
if (anchorName != '' && state) { |
|
2045 |
el.title = anchorName; |
|
2046 |
tinyMCE.addCSSClass(el, 'mceItemAnchor'); |
|
2047 |
} else if (anchorName != '' && !state) |
|
2048 |
el.className = ''; |
|
2049 |
||
2050 |
break; |
|
2051 |
} |
|
2052 |
||
2053 |
if (deep && el.hasChildNodes()) { |
|
2054 |
for (var i=0; i<el.childNodes.length; i++) |
|
2055 |
tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true); |
|
2056 |
} |
|
2057 |
}, |
|
2058 |
||
2059 |
/* |
|
2060 |
applyClassesToFonts : function(doc, size) { |
|
2061 |
var f = doc.getElementsByTagName("font"); |
|
2062 |
for (var i=0; i<f.length; i++) { |
|
2063 |
var s = tinyMCE.getAttrib(f[i], "size"); |
|
2064 |
||
2065 |
if (s != "") |
|
2066 |
tinyMCE.setAttrib(f[i], 'class', "mceItemFont" + s); |
|
2067 |
} |
|
2068 |
||
2069 |
if (typeof(size) != "undefined") { |
|
2070 |
var css = ""; |
|
2071 |
||
2072 |
for (var x=0; x<doc.styleSheets.length; x++) { |
|
2073 |
for (var i=0; i<doc.styleSheets[x].rules.length; i++) { |
|
2074 |
if (doc.styleSheets[x].rules[i].selectorText == '#mceSpanFonts .mceItemFont' + size) { |
|
2075 |
css = doc.styleSheets[x].rules[i].style.cssText; |
|
2076 |
break; |
|
2077 |
} |
|
2078 |
} |
|
2079 |
||
2080 |
if (css != "") |
|
2081 |
break; |
|
2082 |
} |
|
2083 |
||
2084 |
if (doc.styleSheets[0].rules[0].selectorText == "FONT") |
|
2085 |
doc.styleSheets[0].removeRule(0); |
|
2086 |
||
2087 |
doc.styleSheets[0].addRule("FONT", css, 0); |
|
2088 |
} |
|
2089 |
}, |
|
2090 |
*/ |
|
2091 |
||
2092 |
fixGeckoBaseHREFBug : function(m, e, h) { |
|
2093 |
var xsrc, xhref; |
|
2094 |
||
2095 |
if (tinyMCE.isGecko) { |
|
2096 |
if (m == 1) { |
|
2097 |
h = h.replace(/\ssrc=/gi, " mce_tsrc="); |
|
2098 |
h = h.replace(/\shref=/gi, " mce_thref="); |
|
2099 |
||
2100 |
return h; |
|
2101 |
} else { |
|
2102 |
// Why bother if there is no src or href broken |
|
2103 |
if (!new RegExp('(src|href)=', 'g').test(h)) |
|
2104 |
return h; |
|
2105 |
||
2106 |
// Restore src and href that gets messed up by Gecko |
|
2107 |
tinyMCE.selectElements(e, 'A,IMG,SELECT,AREA,IFRAME,BASE,INPUT,SCRIPT,EMBED,OBJECT,LINK', function (n) { |
|
2108 |
xsrc = tinyMCE.getAttrib(n, "mce_tsrc"); |
|
2109 |
xhref = tinyMCE.getAttrib(n, "mce_thref"); |
|
2110 |
||
2111 |
if (xsrc != "") { |
|
2112 |
try { |
|
2113 |
n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc); |
|
2114 |
} catch (e) { |
|
2115 |
// Ignore, Firefox cast exception if local file wasn't found |
|
2116 |
} |
|
2117 |
||
2118 |
n.removeAttribute("mce_tsrc"); |
|
2119 |
} |
|
2120 |
||
2121 |
if (xhref != "") { |
|
2122 |
try { |
|
2123 |
n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref); |
|
2124 |
} catch (e) { |
|
2125 |
// Ignore, Firefox cast exception if local file wasn't found |
|
2126 |
} |
|
2127 |
||
2128 |
n.removeAttribute("mce_thref"); |
|
2129 |
} |
|
2130 |
||
2131 |
return false; |
|
2132 |
}); |
|
2133 |
||
2134 |
// Restore text/comment nodes |
|
2135 |
tinyMCE.selectNodes(e, function(n) { |
|
2136 |
if (n.nodeType == 3 || n.nodeType == 8) { |
|
2137 |
n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src="); |
|
2138 |
n.nodeValue = n.nodeValue.replace(/\smce_thref=/gi, " href="); |
|
2139 |
} |
|
2140 |
||
2141 |
return false; |
|
2142 |
}); |
|
2143 |
} |
|
2144 |
} |
|
2145 |
||
2146 |
return h; |
|
2147 |
}, |
|
2148 |
||
2149 |
_setHTML : function(doc, html_content) { |
|
2150 |
// Force closed anchors open |
|
2151 |
//html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>'); |
|
2152 |
||
2153 |
html_content = tinyMCE.cleanupHTMLCode(html_content); |
|
2154 |
||
2155 |
// Try innerHTML if it fails use pasteHTML in MSIE |
|
2156 |
try { |
|
2157 |
tinyMCE.setInnerHTML(doc.body, html_content); |
|
2158 |
} catch (e) { |
|
2159 |
if (this.isMSIE) |
|
2160 |
doc.body.createTextRange().pasteHTML(html_content); |
|
2161 |
} |
|
2162 |
||
2163 |
// Content duplication bug fix |
|
2164 |
if (tinyMCE.isIE && tinyMCE.settings['fix_content_duplication']) { |
|
2165 |
// Remove P elements in P elements |
|
2166 |
var paras = doc.getElementsByTagName("P"); |
|
2167 |
for (var i=0; i<paras.length; i++) { |
|
2168 |
var node = paras[i]; |
|
2169 |
while ((node = node.parentNode) != null) { |
|
2170 |
if (node.nodeName == "P") |
|
2171 |
node.outerHTML = node.innerHTML; |
|
2172 |
} |
|
2173 |
} |
|
2174 |
||
2175 |
// Content duplication bug fix (Seems to be word crap) |
|
2176 |
var html = doc.body.innerHTML; |
|
2177 |
/* |
|
2178 |
if (html.indexOf('="mso') != -1) { |
|
2179 |
for (var i=0; i<doc.body.all.length; i++) { |
|
2180 |
var el = doc.body.all[i]; |
|
2181 |
el.removeAttribute("className","",0); |
|
2182 |
el.removeAttribute("style","",0); |
|
2183 |
} |
|
2184 |
||
2185 |
html = doc.body.innerHTML; |
|
2186 |
html = tinyMCE.regexpReplace(html, "<o:p><\/o:p>", "<br />"); |
|
2187 |
html = tinyMCE.regexpReplace(html, "<o:p> <\/o:p>", ""); |
|
2188 |
html = tinyMCE.regexpReplace(html, "<st1:.*?>", ""); |
|
2189 |
html = tinyMCE.regexpReplace(html, "<p><\/p>", ""); |
|
2190 |
html = tinyMCE.regexpReplace(html, "<p><\/p>\r\n<p><\/p>", ""); |
|
2191 |
html = tinyMCE.regexpReplace(html, "<p> <\/p>", "<br />"); |
|
2192 |
html = tinyMCE.regexpReplace(html, "<p>\s*(<p>\s*)?", "<p>"); |
|
2193 |
html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "</p>"); |
|
2194 |
}*/ |
|
2195 |
||
2196 |
// Always set the htmlText output |
|
2197 |
tinyMCE.setInnerHTML(doc.body, html); |
|
2198 |
} |
|
2199 |
||
2200 |
tinyMCE.cleanupAnchors(doc); |
|
2201 |
||
2202 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
2203 |
tinyMCE.convertSpansToFonts(doc); |
|
2204 |
}, |
|
2205 |
||
2206 |
getEditorId : function(form_element) { |
|
2207 |
var inst = this.getInstanceById(form_element); |
|
2208 |
if (!inst) |
|
2209 |
return null; |
|
2210 |
||
2211 |
return inst.editorId; |
|
2212 |
}, |
|
2213 |
||
2214 |
getInstanceById : function(editor_id) { |
|
2215 |
var inst = this.instances[editor_id]; |
|
2216 |
if (!inst) { |
|
2217 |
for (var n in tinyMCE.instances) { |
|
2218 |
var instance = tinyMCE.instances[n]; |
|
2219 |
if (!tinyMCE.isInstance(instance)) |
|
2220 |
continue; |
|
2221 |
||
2222 |
if (instance.formTargetElementId == editor_id) { |
|
2223 |
inst = instance; |
|
2224 |
break; |
|
2225 |
} |
|
2226 |
} |
|
2227 |
} |
|
2228 |
||
2229 |
return inst; |
|
2230 |
}, |
|
2231 |
||
2232 |
queryInstanceCommandValue : function(editor_id, command) { |
|
2233 |
var inst = tinyMCE.getInstanceById(editor_id); |
|
2234 |
if (inst) |
|
2235 |
return inst.queryCommandValue(command); |
|
2236 |
||
2237 |
return false; |
|
2238 |
}, |
|
2239 |
||
2240 |
queryInstanceCommandState : function(editor_id, command) { |
|
2241 |
var inst = tinyMCE.getInstanceById(editor_id); |
|
2242 |
if (inst) |
|
2243 |
return inst.queryCommandState(command); |
|
2244 |
||
2245 |
return null; |
|
2246 |
}, |
|
2247 |
||
2248 |
setWindowArg : function(n, v) { |
|
2249 |
this.windowArgs[n] = v; |
|
2250 |
}, |
|
2251 |
||
2252 |
getWindowArg : function(n, d) { |
|
2253 |
return (typeof(this.windowArgs[n]) == "undefined") ? d : this.windowArgs[n]; |
|
2254 |
}, |
|
2255 |
||
2256 |
getCSSClasses : function(editor_id, doc) { |
|
2257 |
var inst = tinyMCE.getInstanceById(editor_id); |
|
2258 |
||
2259 |
// Is cached, use that |
|
2260 |
if (inst && inst.cssClasses.length > 0) |
|
2261 |
return inst.cssClasses; |
|
2262 |
||
2263 |
if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") { |
|
2264 |
var instance; |
|
2265 |
||
2266 |
for (var instanceName in tinyMCE.instances) { |
|
2267 |
instance = tinyMCE.instances[instanceName]; |
|
2268 |
if (!tinyMCE.isInstance(instance)) |
|
2269 |
continue; |
|
2270 |
||
2271 |
break; |
|
2272 |
} |
|
2273 |
||
2274 |
doc = instance.getDoc(); |
|
2275 |
} |
|
2276 |
||
2277 |
if (typeof(doc) == "undefined") { |
|
2278 |
var instance = tinyMCE.getInstanceById(editor_id); |
|
2279 |
doc = instance.getDoc(); |
|
2280 |
} |
|
2281 |
||
2282 |
if (doc) { |
|
2283 |
var styles = doc.styleSheets; |
|
2284 |
||
2285 |
if (styles && styles.length > 0) { |
|
2286 |
for (var x=0; x<styles.length; x++) { |
|
2287 |
var csses = null; |
|
2288 |
||
2289 |
// Just ignore any errors |
|
2290 |
eval("try {var csses = tinyMCE.isIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}"); |
|
2291 |
if (!csses) |
|
2292 |
return new Array(); |
|
2293 |
||
2294 |
for (var i=0; i<csses.length; i++) { |
|
2295 |
var selectorText = csses[i].selectorText; |
|
2296 |
||
2297 |
// Can be multiple rules per selector |
|
2298 |
if (selectorText) { |
|
2299 |
var rules = selectorText.split(','); |
|
2300 |
for (var c=0; c<rules.length; c++) { |
|
2301 |
var rule = rules[c]; |
|
2302 |
||
2303 |
// Strip spaces between selectors |
|
2304 |
while (rule.indexOf(' ') == 0) |
|
2305 |
rule = rule.substring(1); |
|
2306 |
||
2307 |
// Invalid rule |
|
2308 |
if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1) |
|
2309 |
continue; |
|
2310 |
||
2311 |
if (rule.indexOf(tinyMCE.settings['visual_table_class']) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1) |
|
2312 |
continue; |
|
2313 |
||
2314 |
// Is class rule |
|
2315 |
if (rule.indexOf('.') != -1) { |
|
2316 |
var cssClass = rule.substring(rule.indexOf('.') + 1); |
|
2317 |
var addClass = true; |
|
2318 |
||
2319 |
for (var p=0; p<inst.cssClasses.length && addClass; p++) { |
|
2320 |
if (inst.cssClasses[p] == cssClass) |
|
2321 |
addClass = false; |
|
2322 |
} |
|
2323 |
||
2324 |
if (addClass) |
|
2325 |
inst.cssClasses[inst.cssClasses.length] = cssClass; |
|
2326 |
} |
|
2327 |
} |
|
2328 |
} |
|
2329 |
} |
|
2330 |
} |
|
2331 |
} |
|
2332 |
} |
|
2333 |
||
2334 |
return inst.cssClasses; |
|
2335 |
}, |
|
2336 |
||
2337 |
regexpReplace : function(in_str, reg_exp, replace_str, opts) { |
|
2338 |
if (in_str == null) |
|
2339 |
return in_str; |
|
2340 |
||
2341 |
if (typeof(opts) == "undefined") |
|
2342 |
opts = 'g'; |
|
2343 |
||
2344 |
var re = new RegExp(reg_exp, opts); |
|
2345 |
return in_str.replace(re, replace_str); |
|
2346 |
}, |
|
2347 |
||
2348 |
trim : function(s) { |
|
2349 |
return s.replace(/^\s*|\s*$/g, ""); |
|
2350 |
}, |
|
2351 |
||
2352 |
cleanupEventStr : function(s) { |
|
2353 |
s = "" + s; |
|
2354 |
s = s.replace('function anonymous()\n{\n', ''); |
|
2355 |
s = s.replace('\n}', ''); |
|
2356 |
s = s.replace(/^return true;/gi, ''); // Remove event blocker |
|
2357 |
||
2358 |
return s; |
|
2359 |
}, |
|
2360 |
||
2361 |
getControlHTML : function(c) { |
|
2362 |
var i, l, n, o, v, rtl = tinyMCE.getLang('lang_dir') == 'rtl'; |
|
2363 |
||
2364 |
l = tinyMCE.plugins; |
|
2365 |
for (n in l) { |
|
2366 |
o = l[n]; |
|
2367 |
||
2368 |
if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { |
|
2369 |
if (rtl) |
|
2370 |
return '<span dir="rtl">' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + '</span>'; |
|
2371 |
||
2372 |
return tinyMCE.replaceVar(v, "pluginurl", o.baseURL); |
|
2373 |
} |
|
2374 |
} |
|
2375 |
||
2376 |
o = tinyMCE.themes[tinyMCE.settings['theme']]; |
|
2377 |
if (o.getControlHTML && (v = o.getControlHTML(c)) != '') { |
|
2378 |
if (rtl) |
|
2379 |
return '<span dir="rtl">' + v + '</span>'; |
|
2380 |
||
2381 |
return v; |
|
2382 |
} |
|
2383 |
||
2384 |
return ''; |
|
2385 |
}, |
|
2386 |
||
2387 |
evalFunc : function(f, idx, a, o) { |
|
2388 |
o = !o ? window : o; |
|
2389 |
f = typeof(f) == 'function' ? f : o[f]; |
|
2390 |
||
2391 |
return f.apply(o, Array.prototype.slice.call(a, idx)); |
|
2392 |
}, |
|
2393 |
||
2394 |
dispatchCallback : function(i, p, n) { |
|
2395 |
return this.callFunc(i, p, n, 0, this.dispatchCallback.arguments); |
|
2396 |
}, |
|
2397 |
||
2398 |
executeCallback : function(i, p, n) { |
|
2399 |
return this.callFunc(i, p, n, 1, this.executeCallback.arguments); |
|
2400 |
}, |
|
2401 |
||
2402 |
execCommandCallback : function(i, p, n) { |
|
2403 |
return this.callFunc(i, p, n, 2, this.execCommandCallback.arguments); |
|
2404 |
}, |
|
2405 |
||
2406 |
callFunc : function(ins, p, n, m, a) { |
|
2407 |
var l, i, on, o, s, v; |
|
2408 |
||
2409 |
s = m == 2; |
|
2410 |
||
2411 |
l = tinyMCE.getParam(p, ''); |
|
2412 |
||
2413 |
if (l != '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) |
|
2414 |
return true; |
|
2415 |
||
2416 |
if (ins != null) { |
|
2417 |
for (i=0, l = ins.plugins; i<l.length; i++) { |
|
2418 |
o = tinyMCE.plugins[l[i]]; |
|
2419 |
||
2420 |
if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0) |
|
2421 |
return true; |
|
2422 |
} |
|
2423 |
} |
|
2424 |
||
2425 |
l = tinyMCE.themes; |
|
2426 |
for (on in l) { |
|
2427 |
o = l[on]; |
|
2428 |
||
2429 |
if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0) |
|
2430 |
return true; |
|
2431 |
} |
|
2432 |
||
2433 |
return false; |
|
2434 |
}, |
|
2435 |
||
2436 |
xmlEncode : function(s, skip_apos) { |
|
2437 |
return s ? ('' + s).replace(!skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe, function (c, b) { |
|
2438 |
switch (c) { |
|
2439 |
case '&': |
|
2440 |
return '&'; |
|
2441 |
||
2442 |
case '"': |
|
2443 |
return '"'; |
|
2444 |
||
2445 |
case '\'': |
|
2446 |
return '''; // ' is not working in MSIE |
|
2447 |
||
2448 |
case '<': |
|
2449 |
return '<'; |
|
2450 |
||
2451 |
case '>': |
|
2452 |
return '>'; |
|
2453 |
} |
|
2454 |
||
2455 |
return c; |
|
2456 |
}) : s; |
|
2457 |
}, |
|
2458 |
||
2459 |
extend : function(p, np) { |
|
2460 |
var o = {}; |
|
2461 |
||
2462 |
o.parent = p; |
|
2463 |
||
2464 |
for (n in p) |
|
2465 |
o[n] = p[n]; |
|
2466 |
||
2467 |
for (n in np) |
|
2468 |
o[n] = np[n]; |
|
2469 |
||
2470 |
return o; |
|
2471 |
}, |
|
2472 |
||
2473 |
hideMenus : function() { |
|
2474 |
var e = tinyMCE.lastSelectedMenuBtn; |
|
2475 |
||
2476 |
if (tinyMCE.lastMenu) { |
|
2477 |
tinyMCE.lastMenu.hide(); |
|
2478 |
tinyMCE.lastMenu = null; |
|
2479 |
} |
|
2480 |
||
2481 |
if (e) { |
|
2482 |
tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass); |
|
2483 |
tinyMCE.lastSelectedMenuBtn = null; |
|
2484 |
} |
|
2485 |
} |
|
2486 |
||
2487 |
}; |
|
2488 |
||
2489 |
// Global instances |
|
2490 |
var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors |
|
2491 |
var tinyMCE = new TinyMCE_Engine(); |
|
2492 |
var tinyMCELang = {}; |
|
2493 |
||
2494 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */ |
|
2495 |
||
2496 |
function TinyMCE_Control(settings) { |
|
2497 |
var t, i, to, fu, p, x, fn, fu, pn, s = settings; |
|
2498 |
||
2499 |
this.undoRedoLevel = true; |
|
2500 |
this.isTinyMCE_Control = true; |
|
2501 |
||
2502 |
// Default settings |
|
2503 |
this.settings = s; |
|
2504 |
this.settings['theme'] = tinyMCE.getParam("theme", "default"); |
|
2505 |
this.settings['width'] = tinyMCE.getParam("width", -1); |
|
2506 |
this.settings['height'] = tinyMCE.getParam("height", -1); |
|
2507 |
this.selection = new TinyMCE_Selection(this); |
|
2508 |
this.undoRedo = new TinyMCE_UndoRedo(this); |
|
2509 |
this.cleanup = new TinyMCE_Cleanup(); |
|
2510 |
this.shortcuts = new Array(); |
|
2511 |
this.hasMouseMoved = false; |
|
2512 |
this.foreColor = this.backColor = "#999999"; |
|
2513 |
this.data = {}; |
|
2514 |
this.cssClasses = []; |
|
2515 |
||
2516 |
this.cleanup.init({ |
|
2517 |
valid_elements : s.valid_elements, |
|
2518 |
extended_valid_elements : s.extended_valid_elements, |
|
2519 |
valid_child_elements : s.valid_child_elements, |
|
2520 |
entities : s.entities, |
|
2521 |
entity_encoding : s.entity_encoding, |
|
2522 |
debug : s.cleanup_debug, |
|
2523 |
indent : s.apply_source_formatting, |
|
2524 |
invalid_elements : s.invalid_elements, |
|
2525 |
verify_html : s.verify_html, |
|
2526 |
fix_content_duplication : s.fix_content_duplication, |
|
2527 |
convert_fonts_to_spans : s.convert_fonts_to_spans |
|
2528 |
}); |
|
2529 |
||
2530 |
// Wrap old theme |
|
2531 |
t = this.settings['theme']; |
|
2532 |
if (!tinyMCE.hasTheme(t)) { |
|
2533 |
fn = tinyMCE.callbacks; |
|
2534 |
to = {}; |
|
2535 |
||
2536 |
for (i=0; i<fn.length; i++) { |
|
2537 |
if ((fu = window['TinyMCE_' + t + "_" + fn[i]])) |
|
2538 |
to[fn[i]] = fu; |
|
2539 |
} |
|
2540 |
||
2541 |
tinyMCE.addTheme(t, to); |
|
2542 |
} |
|
2543 |
||
2544 |
// Wrap old plugins |
|
2545 |
this.plugins = new Array(); |
|
2546 |
p = tinyMCE.getParam('plugins', '', true, ','); |
|
2547 |
if (p.length > 0) { |
|
2548 |
for (i=0; i<p.length; i++) { |
|
2549 |
pn = p[i]; |
|
2550 |
||
2551 |
if (pn.charAt(0) == '-') |
|
2552 |
pn = pn.substring(1); |
|
2553 |
||
2554 |
if (!tinyMCE.hasPlugin(pn)) { |
|
2555 |
fn = tinyMCE.callbacks; |
|
2556 |
to = {}; |
|
2557 |
||
2558 |
for (x=0; x<fn.length; x++) { |
|
2559 |
if ((fu = window['TinyMCE_' + pn + "_" + fn[x]])) |
|
2560 |
to[fn[x]] = fu; |
|
2561 |
} |
|
2562 |
||
2563 |
tinyMCE.addPlugin(pn, to); |
|
2564 |
} |
|
2565 |
||
2566 |
this.plugins[this.plugins.length] = pn; |
|
2567 |
} |
|
2568 |
} |
|
2569 |
}; |
|
2570 |
||
2571 |
TinyMCE_Control.prototype = { |
|
2572 |
selection : null, |
|
2573 |
||
2574 |
settings : null, |
|
2575 |
||
2576 |
cleanup : null, |
|
2577 |
||
2578 |
getData : function(na) { |
|
2579 |
var o = this.data[na]; |
|
2580 |
||
2581 |
if (!o) |
|
2582 |
o = this.data[na] = {}; |
|
2583 |
||
2584 |
return o; |
|
2585 |
}, |
|
2586 |
||
2587 |
hasPlugin : function(n) { |
|
2588 |
var i; |
|
2589 |
||
2590 |
for (i=0; i<this.plugins.length; i++) { |
|
2591 |
if (this.plugins[i] == n) |
|
2592 |
return true; |
|
2593 |
} |
|
2594 |
||
2595 |
return false; |
|
2596 |
}, |
|
2597 |
||
2598 |
addPlugin : function(n, p) { |
|
2599 |
if (!this.hasPlugin(n)) { |
|
2600 |
tinyMCE.addPlugin(n, p); |
|
2601 |
this.plugins[this.plugins.length] = n; |
|
2602 |
} |
|
2603 |
}, |
|
2604 |
||
2605 |
repaint : function() { |
|
2606 |
var s, b, ex; |
|
2607 |
||
2608 |
if (tinyMCE.isRealIE) |
|
2609 |
return; |
|
2610 |
||
2611 |
try { |
|
2612 |
s = this.selection; |
|
2613 |
b = s.getBookmark(true); |
|
2614 |
this.getBody().style.display = 'none'; |
|
2615 |
this.getDoc().execCommand('selectall', false, null); |
|
2616 |
this.getSel().collapseToStart(); |
|
2617 |
this.getBody().style.display = 'block'; |
|
2618 |
s.moveToBookmark(b); |
|
2619 |
} catch (ex) { |
|
2620 |
// Ignore |
|
2621 |
} |
|
2622 |
}, |
|
2623 |
||
2624 |
switchSettings : function() { |
|
2625 |
if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings['index']) { |
|
2626 |
tinyMCE.settings = this.settings; |
|
2627 |
tinyMCE.currentConfig = this.settings['index']; |
|
2628 |
} |
|
2629 |
}, |
|
2630 |
||
2631 |
select : function() { |
|
2632 |
var oldInst = tinyMCE.selectedInstance; |
|
2633 |
||
2634 |
if (oldInst != this) { |
|
2635 |
if (oldInst) |
|
2636 |
oldInst.execCommand('mceEndTyping'); |
|
2637 |
||
2638 |
tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst); |
|
2639 |
tinyMCE.selectedInstance = this; |
|
2640 |
} |
|
2641 |
}, |
|
2642 |
||
2643 |
getBody : function() { |
|
2644 |
return this.contentBody ? this.contentBody : this.getDoc().body; |
|
2645 |
}, |
|
2646 |
||
2647 |
getDoc : function() { |
|
2648 |
// return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ? |
|
2649 |
return this.contentWindow.document; |
|
2650 |
}, |
|
2651 |
||
2652 |
getWin : function() { |
|
2653 |
return this.contentWindow; |
|
2654 |
}, |
|
2655 |
||
2656 |
getContainerWin : function() { |
|
2657 |
return this.containerWindow ? this.containerWindow : window; |
|
2658 |
}, |
|
2659 |
||
2660 |
getViewPort : function() { |
|
2661 |
return tinyMCE.getViewPort(this.getWin()); |
|
2662 |
}, |
|
2663 |
||
2664 |
getParentNode : function(n, f) { |
|
2665 |
return tinyMCE.getParentNode(n, f, this.getBody()); |
|
2666 |
}, |
|
2667 |
||
2668 |
getParentElement : function(n, na, f) { |
|
2669 |
return tinyMCE.getParentElement(n, na, f, this.getBody()); |
|
2670 |
}, |
|
2671 |
||
2672 |
getParentBlockElement : function(n) { |
|
2673 |
return tinyMCE.getParentBlockElement(n, this.getBody()); |
|
2674 |
}, |
|
2675 |
||
2676 |
resizeToContent : function() { |
|
2677 |
var d = this.getDoc(), b = d.body, de = d.documentElement; |
|
2678 |
||
2679 |
this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px'; |
|
2680 |
}, |
|
2681 |
||
2682 |
addShortcut : function(m, k, d, cmd, ui, va) { |
|
2683 |
var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts; |
|
2684 |
||
2685 |
if (!tinyMCE.getParam('custom_shortcuts')) |
|
2686 |
return false; |
|
2687 |
||
2688 |
m = m.toLowerCase(); |
|
2689 |
k = ie && !n ? k.toUpperCase() : k; |
|
2690 |
c = n ? null : k.charCodeAt(0); |
|
2691 |
d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d; |
|
2692 |
||
2693 |
sc = { |
|
2694 |
alt : m.indexOf('alt') != -1, |
|
2695 |
ctrl : m.indexOf('ctrl') != -1, |
|
2696 |
shift : m.indexOf('shift') != -1, |
|
2697 |
charCode : c, |
|
2698 |
keyCode : n ? k : (ie ? c : null), |
|
2699 |
desc : d, |
|
2700 |
cmd : cmd, |
|
2701 |
ui : ui, |
|
2702 |
val : va |
|
2703 |
}; |
|
2704 |
||
2705 |
for (i=0; i<scl.length; i++) { |
|
2706 |
if (sc.alt == scl[i].alt && sc.ctrl == scl[i].ctrl && sc.shift == scl[i].shift |
|
2707 |
&& sc.charCode == scl[i].charCode && sc.keyCode == scl[i].keyCode) { |
|
2708 |
return false; |
|
2709 |
} |
|
2710 |
} |
|
2711 |
||
2712 |
scl[scl.length] = sc; |
|
2713 |
||
2714 |
return true; |
|
2715 |
}, |
|
2716 |
||
2717 |
handleShortcut : function(e) { |
|
2718 |
var i, s, o; |
|
2719 |
||
2720 |
// Normal key press, then ignore it |
|
2721 |
if (!e.altKey && !e.ctrlKey) |
|
2722 |
return false; |
|
2723 |
||
2724 |
s = this.shortcuts; |
|
2725 |
||
2726 |
for (i=0; i<s.length; i++) { |
|
2727 |
o = s[i]; |
|
2728 |
||
2729 |
if (o.alt == e.altKey && o.ctrl == e.ctrlKey && (o.keyCode == e.keyCode || o.charCode == e.charCode)) { |
|
2730 |
if (o.cmd && (e.type == "keydown" || (e.type == "keypress" && !tinyMCE.isOpera))) |
|
2731 |
tinyMCE.execCommand(o.cmd, o.ui, o.val); |
|
2732 |
||
2733 |
tinyMCE.cancelEvent(e); |
|
2734 |
return true; |
|
2735 |
} |
|
2736 |
} |
|
2737 |
||
2738 |
return false; |
|
2739 |
}, |
|
2740 |
||
2741 |
autoResetDesignMode : function() { |
|
2742 |
// Add fix for tab/style.display none/block problems in Gecko |
|
2743 |
if (!tinyMCE.isIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode')) |
|
2744 |
eval('try { this.getDoc().designMode = "On"; this.useCSS = false; } catch(e) {}'); |
|
2745 |
}, |
|
2746 |
||
2747 |
isHidden : function() { |
|
2748 |
var s; |
|
2749 |
||
2750 |
if (tinyMCE.isIE) |
|
2751 |
return false; |
|
2752 |
||
2753 |
s = this.getSel(); |
|
2754 |
||
2755 |
// Weird, wheres that cursor selection? |
|
2756 |
return (!s || !s.rangeCount || s.rangeCount == 0); |
|
2757 |
}, |
|
2758 |
||
2759 |
isDirty : function() { |
|
2760 |
// Is content modified and not in a submit procedure |
|
2761 |
return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty; |
|
2762 |
}, |
|
2763 |
||
2764 |
_mergeElements : function(scmd, pa, ch, override) { |
|
2765 |
if (scmd == "removeformat") { |
|
2766 |
pa.className = ""; |
|
2767 |
pa.style.cssText = ""; |
|
2768 |
ch.className = ""; |
|
2769 |
ch.style.cssText = ""; |
|
2770 |
return; |
|
2771 |
} |
|
2772 |
||
2773 |
var st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style")); |
|
2774 |
var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style")); |
|
2775 |
var className = tinyMCE.getAttrib(pa, "class"); |
|
2776 |
||
2777 |
// Removed class adding due to bug #1478272 |
|
2778 |
className = tinyMCE.getAttrib(ch, "class"); |
|
2779 |
||
2780 |
if (override) { |
|
2781 |
for (var n in st) { |
|
2782 |
if (typeof(st[n]) == 'function') |
|
2783 |
continue; |
|
2784 |
||
2785 |
stc[n] = st[n]; |
|
2786 |
} |
|
2787 |
} else { |
|
2788 |
for (var n in stc) { |
|
2789 |
if (typeof(stc[n]) == 'function') |
|
2790 |
continue; |
|
2791 |
||
2792 |
st[n] = stc[n]; |
|
2793 |
} |
|
2794 |
} |
|
2795 |
||
2796 |
tinyMCE.setAttrib(pa, "style", tinyMCE.serializeStyle(st)); |
|
2797 |
tinyMCE.setAttrib(pa, "class", tinyMCE.trim(className)); |
|
2798 |
ch.className = ""; |
|
2799 |
ch.style.cssText = ""; |
|
2800 |
ch.removeAttribute("class"); |
|
2801 |
ch.removeAttribute("style"); |
|
2802 |
}, |
|
2803 |
||
2804 |
_setUseCSS : function(b) { |
|
2805 |
var d = this.getDoc(); |
|
2806 |
||
2807 |
try {d.execCommand("useCSS", false, !b);} catch (ex) {} |
|
2808 |
try {d.execCommand("styleWithCSS", false, b);} catch (ex) {} |
|
2809 |
||
2810 |
if (!tinyMCE.getParam("table_inline_editing")) |
|
2811 |
try {d.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {} |
|
2812 |
||
2813 |
if (!tinyMCE.getParam("object_resizing")) |
|
2814 |
try {d.execCommand('enableObjectResizing', false, "false");} catch (ex) {} |
|
2815 |
}, |
|
2816 |
||
2817 |
execCommand : function(command, user_interface, value) { |
|
2818 |
var doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement(); |
|
2819 |
||
2820 |
// Is not a undo specific command |
|
2821 |
if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) |
|
2822 |
this.undoBookmark = null; |
|
2823 |
||
2824 |
// Mozilla issue |
|
2825 |
if (!tinyMCE.isIE && !this.useCSS) { |
|
2826 |
this._setUseCSS(false); |
|
2827 |
this.useCSS = true; |
|
2828 |
} |
|
2829 |
||
2830 |
//debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value); |
|
2831 |
this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks |
|
2832 |
||
2833 |
// Don't dispatch key commands |
|
2834 |
if (!/mceStartTyping|mceEndTyping/.test(command)) { |
|
2835 |
if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value)) |
|
2836 |
return; |
|
2837 |
} |
|
2838 |
||
2839 |
// Fix align on images |
|
2840 |
if (focusElm && focusElm.nodeName == "IMG") { |
|
2841 |
var align = focusElm.getAttribute('align'); |
|
2842 |
var img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm; |
|
2843 |
||
2844 |
switch (command) { |
|
2845 |
case "JustifyLeft": |
|
2846 |
if (align == 'left') |
|
2847 |
img.removeAttribute('align'); |
|
2848 |
else |
|
2849 |
img.setAttribute('align', 'left'); |
|
2850 |
||
2851 |
// Remove the div |
|
2852 |
var div = focusElm.parentNode; |
|
2853 |
if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) |
|
2854 |
div.parentNode.replaceChild(img, div); |
|
2855 |
||
2856 |
this.selection.selectNode(img); |
|
2857 |
this.repaint(); |
|
2858 |
tinyMCE.triggerNodeChange(); |
|
2859 |
return; |
|
2860 |
||
2861 |
case "JustifyCenter": |
|
2862 |
img.removeAttribute('align'); |
|
2863 |
||
2864 |
// Is centered |
|
2865 |
var div = tinyMCE.getParentElement(focusElm, "div"); |
|
2866 |
if (div && div.style.textAlign == "center") { |
|
2867 |
// Remove div |
|
2868 |
if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) |
|
2869 |
div.parentNode.replaceChild(img, div); |
|
2870 |
} else { |
|
2871 |
// Add div |
|
2872 |
var div = this.getDoc().createElement("div"); |
|
2873 |
div.style.textAlign = 'center'; |
|
2874 |
div.appendChild(img); |
|
2875 |
focusElm.parentNode.replaceChild(div, focusElm); |
|
2876 |
} |
|
2877 |
||
2878 |
this.selection.selectNode(img); |
|
2879 |
this.repaint(); |
|
2880 |
tinyMCE.triggerNodeChange(); |
|
2881 |
return; |
|
2882 |
||
2883 |
case "JustifyRight": |
|
2884 |
if (align == 'right') |
|
2885 |
img.removeAttribute('align'); |
|
2886 |
else |
|
2887 |
img.setAttribute('align', 'right'); |
|
2888 |
||
2889 |
// Remove the div |
|
2890 |
var div = focusElm.parentNode; |
|
2891 |
if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) |
|
2892 |
div.parentNode.replaceChild(img, div); |
|
2893 |
||
2894 |
this.selection.selectNode(img); |
|
2895 |
this.repaint(); |
|
2896 |
tinyMCE.triggerNodeChange(); |
|
2897 |
return; |
|
2898 |
} |
|
2899 |
} |
|
2900 |
||
2901 |
if (tinyMCE.settings['force_br_newlines']) { |
|
2902 |
var alignValue = ""; |
|
2903 |
||
2904 |
if (doc.selection.type != "Control") { |
|
2905 |
switch (command) { |
|
2906 |
case "JustifyLeft": |
|
2907 |
alignValue = "left"; |
|
2908 |
break; |
|
2909 |
||
2910 |
case "JustifyCenter": |
|
2911 |
alignValue = "center"; |
|
2912 |
break; |
|
2913 |
||
2914 |
case "JustifyFull": |
|
2915 |
alignValue = "justify"; |
|
2916 |
break; |
|
2917 |
||
2918 |
case "JustifyRight": |
|
2919 |
alignValue = "right"; |
|
2920 |
break; |
|
2921 |
} |
|
2922 |
||
2923 |
if (alignValue != "") { |
|
2924 |
var rng = doc.selection.createRange(); |
|
2925 |
||
2926 |
if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) |
|
2927 |
divElm.setAttribute("align", alignValue); |
|
2928 |
else if (rng.pasteHTML && rng.htmlText.length > 0) |
|
2929 |
rng.pasteHTML('<div align="' + alignValue + '">' + rng.htmlText + "</div>"); |
|
2930 |
||
2931 |
tinyMCE.triggerNodeChange(); |
|
2932 |
return; |
|
2933 |
} |
|
2934 |
} |
|
2935 |
} |
|
2936 |
||
2937 |
switch (command) { |
|
2938 |
case "mceRepaint": |
|
2939 |
this.repaint(); |
|
2940 |
return true; |
|
2941 |
||
2942 |
case "unlink": |
|
2943 |
// Unlink if caret is inside link |
|
2944 |
if (tinyMCE.isGecko && this.getSel().isCollapsed) { |
|
2945 |
focusElm = tinyMCE.getParentElement(focusElm, 'A'); |
|
2946 |
||
2947 |
if (focusElm) |
|
2948 |
this.selection.selectNode(focusElm, false); |
|
2949 |
} |
|
2950 |
||
2951 |
this.getDoc().execCommand(command, user_interface, value); |
|
2952 |
||
2953 |
tinyMCE.isGecko && this.getSel().collapseToEnd(); |
|
2954 |
||
2955 |
tinyMCE.triggerNodeChange(); |
|
2956 |
||
2957 |
return true; |
|
2958 |
||
2959 |
case "InsertUnorderedList": |
|
2960 |
case "InsertOrderedList": |
|
2961 |
this.getDoc().execCommand(command, user_interface, value); |
|
2962 |
tinyMCE.triggerNodeChange(); |
|
2963 |
break; |
|
2964 |
||
2965 |
case "Strikethrough": |
|
2966 |
this.getDoc().execCommand(command, user_interface, value); |
|
2967 |
tinyMCE.triggerNodeChange(); |
|
2968 |
break; |
|
2969 |
||
2970 |
case "mceSelectNode": |
|
2971 |
this.selection.selectNode(value); |
|
2972 |
tinyMCE.triggerNodeChange(); |
|
2973 |
tinyMCE.selectedNode = value; |
|
2974 |
break; |
|
2975 |
||
2976 |
case "FormatBlock": |
|
2977 |
if (value == null || value == "") { |
|
2978 |
var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp"); |
|
2979 |
||
2980 |
if (elm) |
|
2981 |
this.execCommand("mceRemoveNode", false, elm); |
|
2982 |
} else { |
|
2983 |
if (!this.cleanup.isValid(value)) |
|
2984 |
return true; |
|
2985 |
||
2986 |
if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value)) |
|
2987 |
value = value.replace(/[^a-z]/gi, ''); |
|
2988 |
||
2989 |
if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) { |
|
2990 |
var b = this.selection.getBookmark(); |
|
2991 |
this.getDoc().execCommand("FormatBlock", false, '<p>'); |
|
2992 |
tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value); |
|
2993 |
this.selection.moveToBookmark(b); |
|
2994 |
} else |
|
2995 |
this.getDoc().execCommand("FormatBlock", false, value); |
|
2996 |
} |
|
2997 |
||
2998 |
tinyMCE.triggerNodeChange(); |
|
2999 |
||
3000 |
break; |
|
3001 |
||
3002 |
case "mceRemoveNode": |
|
3003 |
if (!value) |
|
3004 |
value = tinyMCE.getParentElement(this.getFocusElement()); |
|
3005 |
||
3006 |
if (tinyMCE.isIE) { |
|
3007 |
value.outerHTML = value.innerHTML; |
|
3008 |
} else { |
|
3009 |
var rng = value.ownerDocument.createRange(); |
|
3010 |
rng.setStartBefore(value); |
|
3011 |
rng.setEndAfter(value); |
|
3012 |
rng.deleteContents(); |
|
3013 |
rng.insertNode(rng.createContextualFragment(value.innerHTML)); |
|
3014 |
} |
|
3015 |
||
3016 |
tinyMCE.triggerNodeChange(); |
|
3017 |
||
3018 |
break; |
|
3019 |
||
3020 |
case "mceSelectNodeDepth": |
|
3021 |
var parentNode = this.getFocusElement(); |
|
3022 |
for (var i=0; parentNode; i++) { |
|
3023 |
if (parentNode.nodeName.toLowerCase() == "body") |
|
3024 |
break; |
|
3025 |
||
3026 |
if (parentNode.nodeName.toLowerCase() == "#text") { |
|
3027 |
i--; |
|
3028 |
parentNode = parentNode.parentNode; |
|
3029 |
continue; |
|
3030 |
} |
|
3031 |
||
3032 |
if (i == value) { |
|
3033 |
this.selection.selectNode(parentNode, false); |
|
3034 |
tinyMCE.triggerNodeChange(); |
|
3035 |
tinyMCE.selectedNode = parentNode; |
|
3036 |
return; |
|
3037 |
} |
|
3038 |
||
3039 |
parentNode = parentNode.parentNode; |
|
3040 |
} |
|
3041 |
||
3042 |
break; |
|
3043 |
||
3044 |
case "mceSetStyleInfo": |
|
3045 |
case "SetStyleInfo": |
|
3046 |
var rng = this.getRng(); |
|
3047 |
var sel = this.getSel(); |
|
3048 |
var scmd = value['command']; |
|
3049 |
var sname = value['name']; |
|
3050 |
var svalue = value['value'] == null ? '' : value['value']; |
|
3051 |
//var svalue = value['value'] == null ? '' : value['value']; |
|
3052 |
var wrapper = value['wrapper'] ? value['wrapper'] : "span"; |
|
3053 |
var parentElm = null; |
|
3054 |
var invalidRe = new RegExp("^BODY|HTML$", "g"); |
|
3055 |
var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null; |
|
3056 |
||
3057 |
// Whole element selected check |
|
3058 |
if (tinyMCE.isIE) { |
|
3059 |
// Control range |
|
3060 |
if (rng.item) |
|
3061 |
parentElm = rng.item(0); |
|
3062 |
else { |
|
3063 |
var pelm = rng.parentElement(); |
|
3064 |
var prng = doc.selection.createRange(); |
|
3065 |
prng.moveToElementText(pelm); |
|
3066 |
||
3067 |
if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) { |
|
3068 |
if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName)) |
|
3069 |
parentElm = pelm; |
|
3070 |
} |
|
3071 |
} |
|
3072 |
} else { |
|
3073 |
var felm = this.getFocusElement(); |
|
3074 |
if (sel.isCollapsed || (new RegExp('td|tr|tbody|table', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode)) |
|
3075 |
parentElm = felm; |
|
3076 |
} |
|
3077 |
||
3078 |
// Whole element selected |
|
3079 |
if (parentElm && !invalidRe.test(parentElm.nodeName)) { |
|
3080 |
if (scmd == "setstyle") |
|
3081 |
tinyMCE.setStyleAttrib(parentElm, sname, svalue); |
|
3082 |
||
3083 |
if (scmd == "setattrib") |
|
3084 |
tinyMCE.setAttrib(parentElm, sname, svalue); |
|
3085 |
||
3086 |
if (scmd == "removeformat") { |
|
3087 |
parentElm.style.cssText = ''; |
|
3088 |
tinyMCE.setAttrib(parentElm, 'class', ''); |
|
3089 |
} |
|
3090 |
||
3091 |
// Remove style/attribs from all children |
|
3092 |
var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1); |
|
3093 |
for (var z=0; z<ch.length; z++) { |
|
3094 |
if (ch[z] == parentElm) |
|
3095 |
continue; |
|
3096 |
||
3097 |
if (scmd == "setstyle") |
|
3098 |
tinyMCE.setStyleAttrib(ch[z], sname, ''); |
|
3099 |
||
3100 |
if (scmd == "setattrib") |
|
3101 |
tinyMCE.setAttrib(ch[z], sname, ''); |
|
3102 |
||
3103 |
if (scmd == "removeformat") { |
|
3104 |
ch[z].style.cssText = ''; |
|
3105 |
tinyMCE.setAttrib(ch[z], 'class', ''); |
|
3106 |
} |
|
3107 |
} |
|
3108 |
} else { |
|
3109 |
this._setUseCSS(false); // Bug in FF when running in fullscreen |
|
3110 |
doc.execCommand("FontName", false, "#mce_temp_font#"); |
|
3111 |
var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#"); |
|
3112 |
||
3113 |
// Change them all |
|
3114 |
for (var x=0; x<elementArray.length; x++) { |
|
3115 |
elm = elementArray[x]; |
|
3116 |
if (elm) { |
|
3117 |
var spanElm = doc.createElement(wrapper); |
|
3118 |
||
3119 |
if (scmd == "setstyle") |
|
3120 |
tinyMCE.setStyleAttrib(spanElm, sname, svalue); |
|
3121 |
||
3122 |
if (scmd == "setattrib") |
|
3123 |
tinyMCE.setAttrib(spanElm, sname, svalue); |
|
3124 |
||
3125 |
if (scmd == "removeformat") { |
|
3126 |
spanElm.style.cssText = ''; |
|
3127 |
tinyMCE.setAttrib(spanElm, 'class', ''); |
|
3128 |
} |
|
3129 |
||
3130 |
if (elm.hasChildNodes()) { |
|
3131 |
for (var i=0; i<elm.childNodes.length; i++) |
|
3132 |
spanElm.appendChild(elm.childNodes[i].cloneNode(true)); |
|
3133 |
} |
|
3134 |
||
3135 |
spanElm.setAttribute("mce_new", "true"); |
|
3136 |
elm.parentNode.replaceChild(spanElm, elm); |
|
3137 |
||
3138 |
// Remove style/attribs from all children |
|
3139 |
var ch = tinyMCE.getNodeTree(spanElm, new Array(), 1); |
|
3140 |
for (var z=0; z<ch.length; z++) { |
|
3141 |
if (ch[z] == spanElm) |
|
3142 |
continue; |
|
3143 |
||
3144 |
if (scmd == "setstyle") |
|
3145 |
tinyMCE.setStyleAttrib(ch[z], sname, ''); |
|
3146 |
||
3147 |
if (scmd == "setattrib") |
|
3148 |
tinyMCE.setAttrib(ch[z], sname, ''); |
|
3149 |
||
3150 |
if (scmd == "removeformat") { |
|
3151 |
ch[z].style.cssText = ''; |
|
3152 |
tinyMCE.setAttrib(ch[z], 'class', ''); |
|
3153 |
} |
|
3154 |
} |
|
3155 |
} |
|
3156 |
} |
|
3157 |
} |
|
3158 |
||
3159 |
// Cleaup wrappers |
|
3160 |
var nodes = doc.getElementsByTagName(wrapper); |
|
3161 |
for (var i=nodes.length-1; i>=0; i--) { |
|
3162 |
var elm = nodes[i]; |
|
3163 |
var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; |
|
3164 |
||
3165 |
elm.removeAttribute("mce_new"); |
|
3166 |
||
3167 |
// Is only child a element |
|
3168 |
if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) { |
|
3169 |
//tinyMCE.debug("merge1" + isNew); |
|
3170 |
this._mergeElements(scmd, elm, elm.childNodes[0], isNew); |
|
3171 |
continue; |
|
3172 |
} |
|
3173 |
||
3174 |
// Is I the only child |
|
3175 |
if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) { |
|
3176 |
//tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName); |
|
3177 |
if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName)) |
|
3178 |
this._mergeElements(scmd, elm.parentNode, elm, false); |
|
3179 |
} |
|
3180 |
} |
|
3181 |
||
3182 |
// Remove empty wrappers |
|
3183 |
var nodes = doc.getElementsByTagName(wrapper); |
|
3184 |
for (var i=nodes.length-1; i>=0; i--) { |
|
3185 |
var elm = nodes[i]; |
|
3186 |
var isEmpty = true; |
|
3187 |
||
3188 |
// Check if it has any attribs |
|
3189 |
var tmp = doc.createElement("body"); |
|
3190 |
tmp.appendChild(elm.cloneNode(false)); |
|
3191 |
||
3192 |
// Is empty span, remove it |
|
3193 |
tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); |
|
3194 |
//tinyMCE.debug(tmp.innerHTML); |
|
3195 |
if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) { |
|
3196 |
for (var x=0; x<elm.childNodes.length; x++) { |
|
3197 |
if (elm.parentNode != null) |
|
3198 |
elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm); |
|
3199 |
} |
|
3200 |
||
3201 |
elm.parentNode.removeChild(elm); |
|
3202 |
} |
|
3203 |
} |
|
3204 |
||
3205 |
// Re add the visual aids |
|
3206 |
if (scmd == "removeformat") |
|
3207 |
tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this); |
|
3208 |
||
3209 |
tinyMCE.triggerNodeChange(); |
|
3210 |
||
3211 |
break; |
|
3212 |
||
3213 |
case "FontName": |
|
3214 |
if (value == null) { |
|
3215 |
var s = this.getSel(); |
|
3216 |
||
3217 |
// Find font and select it |
|
3218 |
if (tinyMCE.isGecko && s.isCollapsed) { |
|
3219 |
var f = tinyMCE.getParentElement(this.getFocusElement(), "font"); |
|
3220 |
||
3221 |
if (f != null) |
|
3222 |
this.selection.selectNode(f, false); |
|
3223 |
} |
|
3224 |
||
3225 |
// Remove format |
|
3226 |
this.getDoc().execCommand("RemoveFormat", false, null); |
|
3227 |
||
3228 |
// Collapse range if font was found |
|
3229 |
if (f != null && tinyMCE.isGecko) { |
|
3230 |
var r = this.getRng().cloneRange(); |
|
3231 |
r.collapse(true); |
|
3232 |
s.removeAllRanges(); |
|
3233 |
s.addRange(r); |
|
3234 |
} |
|
3235 |
} else |
|
3236 |
this.getDoc().execCommand('FontName', false, value); |
|
3237 |
||
3238 |
if (tinyMCE.isGecko) |
|
3239 |
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1); |
|
3240 |
||
3241 |
return; |
|
3242 |
||
3243 |
case "FontSize": |
|
3244 |
this.getDoc().execCommand('FontSize', false, value); |
|
3245 |
||
3246 |
if (tinyMCE.isGecko) |
|
3247 |
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1); |
|
3248 |
||
3249 |
return; |
|
3250 |
||
3251 |
case "forecolor": |
|
3252 |
value = value == null ? this.foreColor : value; |
|
3253 |
value = tinyMCE.trim(value); |
|
3254 |
value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value; |
|
3255 |
||
3256 |
this.foreColor = value; |
|
3257 |
this.getDoc().execCommand('forecolor', false, value); |
|
3258 |
break; |
|
3259 |
||
3260 |
case "HiliteColor": |
|
3261 |
value = value == null ? this.backColor : value; |
|
3262 |
value = tinyMCE.trim(value); |
|
3263 |
value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value; |
|
3264 |
this.backColor = value; |
|
3265 |
||
3266 |
if (tinyMCE.isGecko) { |
|
3267 |
this._setUseCSS(true); |
|
3268 |
this.getDoc().execCommand('hilitecolor', false, value); |
|
3269 |
this._setUseCSS(false); |
|
3270 |
} else |
|
3271 |
this.getDoc().execCommand('BackColor', false, value); |
|
3272 |
break; |
|
3273 |
||
3274 |
case "Cut": |
|
3275 |
case "Copy": |
|
3276 |
case "Paste": |
|
3277 |
var cmdFailed = false; |
|
3278 |
||
3279 |
// Try executing command |
|
3280 |
eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}'); |
|
3281 |
||
3282 |
if (tinyMCE.isOpera && cmdFailed) |
|
3283 |
alert('Currently not supported by your browser, use keyboard shortcuts instead.'); |
|
3284 |
||
3285 |
// Alert error in gecko if command failed |
|
3286 |
if (tinyMCE.isGecko && cmdFailed) { |
|
3287 |
// Confirm more info |
|
3288 |
if (confirm(tinyMCE.entityDecode(tinyMCE.getLang('lang_clipboard_msg')))) |
|
3289 |
window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal'); |
|
3290 |
||
3291 |
return; |
|
3292 |
} else |
|
3293 |
tinyMCE.triggerNodeChange(); |
|
3294 |
break; |
|
3295 |
||
3296 |
case "mceSetContent": |
|
3297 |
if (!value) |
|
3298 |
value = ""; |
|
3299 |
||
3300 |
// Call custom cleanup code |
|
3301 |
value = tinyMCE.storeAwayURLs(value); |
|
3302 |
value = tinyMCE._customCleanup(this, "insert_to_editor", value); |
|
3303 |
||
3304 |
if (this.getBody().nodeName == 'BODY') |
|
3305 |
tinyMCE._setHTML(doc, value); |
|
3306 |
else |
|
3307 |
this.getBody().innerHTML = value; |
|
3308 |
||
3309 |
tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, doc, this.settings, this.getBody(), false, false, false, true)); |
|
3310 |
tinyMCE.convertAllRelativeURLs(this.getBody()); |
|
3311 |
||
3312 |
// Cleanup any mess left from storyAwayURLs |
|
3313 |
tinyMCE._removeInternal(this.getBody()); |
|
3314 |
||
3315 |
// When editing always use fonts internaly |
|
3316 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
3317 |
tinyMCE.convertSpansToFonts(doc); |
|
3318 |
||
3319 |
tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this); |
|
3320 |
tinyMCE._setEventsEnabled(this.getBody(), false); |
|
3321 |
return true; |
|
3322 |
||
3323 |
case "mceCleanup": |
|
3324 |
var b = this.selection.getBookmark(); |
|
3325 |
tinyMCE._setHTML(this.contentDocument, this.getBody().innerHTML); |
|
3326 |
tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, this.getBody(), this.visualAid)); |
|
3327 |
tinyMCE.convertAllRelativeURLs(doc.body); |
|
3328 |
||
3329 |
// When editing always use fonts internaly |
|
3330 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
3331 |
tinyMCE.convertSpansToFonts(doc); |
|
3332 |
||
3333 |
tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this); |
|
3334 |
tinyMCE._setEventsEnabled(this.getBody(), false); |
|
3335 |
this.repaint(); |
|
3336 |
this.selection.moveToBookmark(b); |
|
3337 |
tinyMCE.triggerNodeChange(); |
|
3338 |
break; |
|
3339 |
||
3340 |
case "mceReplaceContent": |
|
3341 |
// Force empty string |
|
3342 |
if (!value) |
|
3343 |
value = ''; |
|
3344 |
||
3345 |
this.getWin().focus(); |
|
3346 |
||
3347 |
var selectedText = ""; |
|
3348 |
||
3349 |
if (tinyMCE.isIE) { |
|
3350 |
var rng = doc.selection.createRange(); |
|
3351 |
selectedText = rng.text; |
|
3352 |
} else |
|
3353 |
selectedText = this.getSel().toString(); |
|
3354 |
||
3355 |
if (selectedText.length > 0) { |
|
3356 |
value = tinyMCE.replaceVar(value, "selection", selectedText); |
|
3357 |
tinyMCE.execCommand('mceInsertContent', false, value); |
|
3358 |
} |
|
3359 |
||
3360 |
tinyMCE.triggerNodeChange(); |
|
3361 |
break; |
|
3362 |
||
3363 |
case "mceSetAttribute": |
|
3364 |
if (typeof(value) == 'object') { |
|
3365 |
var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets']; |
|
3366 |
var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); |
|
3367 |
||
3368 |
if (targetNode) { |
|
3369 |
targetNode.setAttribute(value['name'], value['value']); |
|
3370 |
tinyMCE.triggerNodeChange(); |
|
3371 |
} |
|
3372 |
} |
|
3373 |
break; |
|
3374 |
||
3375 |
case "mceSetCSSClass": |
|
3376 |
this.execCommand("mceSetStyleInfo", false, {command : "setattrib", name : "class", value : value}); |
|
3377 |
break; |
|
3378 |
||
3379 |
case "mceInsertRawHTML": |
|
3380 |
var key = 'tiny_mce_marker'; |
|
3381 |
||
3382 |
this.execCommand('mceBeginUndoLevel'); |
|
3383 |
||
3384 |
// Insert marker key |
|
3385 |
this.execCommand('mceInsertContent', false, key); |
|
3386 |
||
3387 |
// Store away scroll pos |
|
3388 |
var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft; |
|
3389 |
var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop; |
|
3390 |
||
3391 |
// Find marker and replace with RAW HTML |
|
3392 |
var html = this.getBody().innerHTML; |
|
3393 |
if ((pos = html.indexOf(key)) != -1) |
|
3394 |
tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length)); |
|
3395 |
||
3396 |
// Restore scoll pos |
|
3397 |
this.contentWindow.scrollTo(scrollX, scrollY); |
|
3398 |
||
3399 |
this.execCommand('mceEndUndoLevel'); |
|
3400 |
||
3401 |
break; |
|
3402 |
||
3403 |
case "mceInsertContent": |
|
3404 |
// Force empty string |
|
3405 |
if (!value) |
|
3406 |
value = ''; |
|
3407 |
||
3408 |
var insertHTMLFailed = false; |
|
3409 |
||
3410 |
// Removed since it produced problems in IE |
|
3411 |
// this.getWin().focus(); |
|
3412 |
||
3413 |
if (tinyMCE.isGecko || tinyMCE.isOpera) { |
|
3414 |
try { |
|
3415 |
// Is plain text or HTML, &, etc will be encoded wrong in FF |
|
3416 |
if (value.indexOf('<') == -1 && !value.match(/(&| |<|>)/g)) { |
|
3417 |
var r = this.getRng(); |
|
3418 |
var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value)); |
|
3419 |
var s = this.getSel(); |
|
3420 |
var r2 = r.cloneRange(); |
|
3421 |
||
3422 |
// Insert text at cursor position |
|
3423 |
s.removeAllRanges(); |
|
3424 |
r.deleteContents(); |
|
3425 |
r.insertNode(n); |
|
3426 |
||
3427 |
// Move the cursor to the end of text |
|
3428 |
r2.selectNode(n); |
|
3429 |
r2.collapse(false); |
|
3430 |
s.removeAllRanges(); |
|
3431 |
s.addRange(r2); |
|
3432 |
} else { |
|
3433 |
value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value); |
|
3434 |
this.getDoc().execCommand('inserthtml', false, value); |
|
3435 |
tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); |
|
3436 |
} |
|
3437 |
} catch (ex) { |
|
3438 |
insertHTMLFailed = true; |
|
3439 |
} |
|
3440 |
||
3441 |
if (!insertHTMLFailed) { |
|
3442 |
tinyMCE.triggerNodeChange(); |
|
3443 |
return; |
|
3444 |
} |
|
3445 |
} |
|
3446 |
||
3447 |
if (!tinyMCE.isIE) { |
|
3448 |
var isHTML = value.indexOf('<') != -1; |
|
3449 |
var sel = this.getSel(); |
|
3450 |
var rng = this.getRng(); |
|
3451 |
||
3452 |
if (isHTML) { |
|
3453 |
if (tinyMCE.isSafari) { |
|
3454 |
var tmpRng = this.getDoc().createRange(); |
|
3455 |
||
3456 |
tmpRng.setStart(this.getBody(), 0); |
|
3457 |
tmpRng.setEnd(this.getBody(), 0); |
|
3458 |
||
3459 |
value = tmpRng.createContextualFragment(value); |
|
3460 |
} else |
|
3461 |
value = rng.createContextualFragment(value); |
|
3462 |
} else { |
|
3463 |
// Setup text node |
|
3464 |
var el = document.createElement("div"); |
|
3465 |
el.innerHTML = value; |
|
3466 |
value = el.firstChild.nodeValue; |
|
3467 |
value = doc.createTextNode(value); |
|
3468 |
} |
|
3469 |
||
3470 |
// Insert plain text in Safari |
|
3471 |
if (tinyMCE.isSafari && !isHTML) { |
|
3472 |
this.execCommand('InsertText', false, value.nodeValue); |
|
3473 |
tinyMCE.triggerNodeChange(); |
|
3474 |
return true; |
|
3475 |
} else if (tinyMCE.isSafari && isHTML) { |
|
3476 |
rng.deleteContents(); |
|
3477 |
rng.insertNode(value); |
|
3478 |
tinyMCE.triggerNodeChange(); |
|
3479 |
return true; |
|
3480 |
} |
|
3481 |
||
3482 |
rng.deleteContents(); |
|
3483 |
||
3484 |
// If target node is text do special treatment, (Mozilla 1.3 fix) |
|
3485 |
if (rng.startContainer.nodeType == 3) { |
|
3486 |
var node = rng.startContainer.splitText(rng.startOffset); |
|
3487 |
node.parentNode.insertBefore(value, node); |
|
3488 |
} else |
|
3489 |
rng.insertNode(value); |
|
3490 |
||
3491 |
if (!isHTML) { |
|
3492 |
// Removes weird selection trails |
|
3493 |
sel.selectAllChildren(doc.body); |
|
3494 |
sel.removeAllRanges(); |
|
3495 |
||
3496 |
// Move cursor to end of content |
|
3497 |
var rng = doc.createRange(); |
|
3498 |
||
3499 |
rng.selectNode(value); |
|
3500 |
rng.collapse(false); |
|
3501 |
||
3502 |
sel.addRange(rng); |
|
3503 |
} else |
|
3504 |
rng.collapse(false); |
|
3505 |
||
3506 |
tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); |
|
3507 |
} else { |
|
3508 |
var rng = doc.selection.createRange(), tmpRng = null; |
|
3509 |
var c = value.indexOf('<!--') != -1; |
|
3510 |
||
3511 |
// Fix comment bug, add tag before comments |
|
3512 |
if (c) |
|
3513 |
value = tinyMCE.uniqueTag + value; |
|
3514 |
||
3515 |
// tmpRng = rng.duplicate(); // Store away range (Fixes Undo bookmark bug in IE) |
|
3516 |
||
3517 |
if (rng.item) |
|
3518 |
rng.item(0).outerHTML = value; |
|
3519 |
else |
|
3520 |
rng.pasteHTML(value); |
|
3521 |
||
3522 |
//if (tmpRng) |
|
3523 |
// tmpRng.select(); // Restore range (Fixes Undo bookmark bug in IE) |
|
3524 |
||
3525 |
// Remove unique tag |
|
3526 |
if (c) { |
|
3527 |
var e = this.getDoc().getElementById('mceTMPElement'); |
|
3528 |
e.parentNode.removeChild(e); |
|
3529 |
} |
|
3530 |
} |
|
3531 |
||
3532 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
3533 |
tinyMCE.triggerNodeChange(); |
|
3534 |
break; |
|
3535 |
||
3536 |
case "mceStartTyping": |
|
3537 |
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex == -1) { |
|
3538 |
this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex; |
|
3539 |
tinyMCE.typingUndoIndex = tinyMCE.undoIndex; |
|
3540 |
this.execCommand('mceAddUndoLevel'); |
|
3541 |
} |
|
3542 |
break; |
|
3543 |
||
3544 |
case "mceEndTyping": |
|
3545 |
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex != -1) { |
|
3546 |
this.execCommand('mceAddUndoLevel'); |
|
3547 |
this.undoRedo.typingUndoIndex = -1; |
|
3548 |
} |
|
3549 |
||
3550 |
tinyMCE.typingUndoIndex = -1; |
|
3551 |
break; |
|
3552 |
||
3553 |
case "mceBeginUndoLevel": |
|
3554 |
this.undoRedoLevel = false; |
|
3555 |
break; |
|
3556 |
||
3557 |
case "mceEndUndoLevel": |
|
3558 |
this.undoRedoLevel = true; |
|
3559 |
this.execCommand('mceAddUndoLevel'); |
|
3560 |
break; |
|
3561 |
||
3562 |
case "mceAddUndoLevel": |
|
3563 |
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedoLevel) { |
|
3564 |
if (this.undoRedo.add()) |
|
3565 |
tinyMCE.triggerNodeChange(false); |
|
3566 |
} |
|
3567 |
break; |
|
3568 |
||
3569 |
case "Undo": |
|
3570 |
if (tinyMCE.settings['custom_undo_redo']) { |
|
3571 |
tinyMCE.execCommand("mceEndTyping"); |
|
3572 |
this.undoRedo.undo(); |
|
3573 |
tinyMCE.triggerNodeChange(); |
|
3574 |
} else |
|
3575 |
this.getDoc().execCommand(command, user_interface, value); |
|
3576 |
break; |
|
3577 |
||
3578 |
case "Redo": |
|
3579 |
if (tinyMCE.settings['custom_undo_redo']) { |
|
3580 |
tinyMCE.execCommand("mceEndTyping"); |
|
3581 |
this.undoRedo.redo(); |
|
3582 |
tinyMCE.triggerNodeChange(); |
|
3583 |
} else |
|
3584 |
this.getDoc().execCommand(command, user_interface, value); |
|
3585 |
break; |
|
3586 |
||
3587 |
case "mceToggleVisualAid": |
|
3588 |
this.visualAid = !this.visualAid; |
|
3589 |
tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this); |
|
3590 |
tinyMCE.triggerNodeChange(); |
|
3591 |
break; |
|
3592 |
||
3593 |
case "Indent": |
|
3594 |
this.getDoc().execCommand(command, user_interface, value); |
|
3595 |
tinyMCE.triggerNodeChange(); |
|
3596 |
||
3597 |
if (tinyMCE.isIE) { |
|
3598 |
var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote"); |
|
3599 |
do { |
|
3600 |
if (n && n.nodeName == "BLOCKQUOTE") { |
|
3601 |
n.removeAttribute("dir"); |
|
3602 |
n.removeAttribute("style"); |
|
3603 |
} |
|
3604 |
} while (n != null && (n = n.parentNode) != null); |
|
3605 |
} |
|
3606 |
break; |
|
3607 |
||
3608 |
case "RemoveFormat": |
|
3609 |
case "removeformat": |
|
3610 |
var text = this.selection.getSelectedText(); |
|
3611 |
||
3612 |
if (tinyMCE.isOpera) { |
|
3613 |
this.getDoc().execCommand("RemoveFormat", false, null); |
|
3614 |
return; |
|
3615 |
} |
|
3616 |
||
3617 |
if (tinyMCE.isIE) { |
|
3618 |
try { |
|
3619 |
var rng = doc.selection.createRange(); |
|
3620 |
rng.execCommand("RemoveFormat", false, null); |
|
3621 |
} catch (e) { |
|
3622 |
// Do nothing |
|
3623 |
} |
|
3624 |
||
3625 |
this.execCommand("mceSetStyleInfo", false, {command : "removeformat"}); |
|
3626 |
} else { |
|
3627 |
this.getDoc().execCommand(command, user_interface, value); |
|
3628 |
||
3629 |
this.execCommand("mceSetStyleInfo", false, {command : "removeformat"}); |
|
3630 |
} |
|
3631 |
||
3632 |
// Remove class |
|
3633 |
if (text.length == 0) |
|
3634 |
this.execCommand("mceSetCSSClass", false, ""); |
|
3635 |
||
3636 |
tinyMCE.triggerNodeChange(); |
|
3637 |
break; |
|
3638 |
||
3639 |
default: |
|
3640 |
this.getDoc().execCommand(command, user_interface, value); |
|
3641 |
||
3642 |
if (tinyMCE.isGecko) |
|
3643 |
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1); |
|
3644 |
else |
|
3645 |
tinyMCE.triggerNodeChange(); |
|
3646 |
} |
|
3647 |
||
3648 |
// Add undo level after modification |
|
3649 |
if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceStartTyping" && command != "mceEndTyping") |
|
3650 |
tinyMCE.execCommand("mceAddUndoLevel"); |
|
3651 |
}, |
|
3652 |
||
3653 |
queryCommandValue : function(c) { |
|
3654 |
try { |
|
3655 |
return this.getDoc().queryCommandValue(c); |
|
3656 |
} catch (e) { |
|
3657 |
return null; |
|
3658 |
} |
|
3659 |
}, |
|
3660 |
||
3661 |
queryCommandState : function(c) { |
|
3662 |
return this.getDoc().queryCommandState(c); |
|
3663 |
}, |
|
3664 |
||
3665 |
_onAdd : function(replace_element, form_element_name, target_document) { |
|
3666 |
var hc, th, to, editorTemplate; |
|
3667 |
||
3668 |
th = this.settings['theme']; |
|
3669 |
to = tinyMCE.themes[th]; |
|
3670 |
||
3671 |
var targetDoc = target_document ? target_document : document; |
|
3672 |
||
3673 |
this.targetDoc = targetDoc; |
|
3674 |
||
3675 |
tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings['theme']; |
|
3676 |
this.settings['themeurl'] = tinyMCE.themeURL; |
|
3677 |
||
3678 |
if (!replace_element) { |
|
3679 |
alert("Error: Could not find the target element."); |
|
3680 |
return false; |
|
3681 |
} |
|
3682 |
||
3683 |
if (to.getEditorTemplate) |
|
3684 |
editorTemplate = to.getEditorTemplate(this.settings, this.editorId); |
|
3685 |
||
3686 |
var deltaWidth = editorTemplate['delta_width'] ? editorTemplate['delta_width'] : 0; |
|
3687 |
var deltaHeight = editorTemplate['delta_height'] ? editorTemplate['delta_height'] : 0; |
|
3688 |
var html = '<span id="' + this.editorId + '_parent" class="mceEditorContainer">' + editorTemplate['html']; |
|
3689 |
||
3690 |
html = tinyMCE.replaceVar(html, "editor_id", this.editorId); |
|
3691 |
this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm"; |
|
3692 |
||
3693 |
this.settings['old_width'] = this.settings['width']; |
|
3694 |
this.settings['old_height'] = this.settings['height']; |
|
3695 |
||
3696 |
// Set default width, height |
|
3697 |
if (this.settings['width'] == -1) |
|
3698 |
this.settings['width'] = replace_element.offsetWidth; |
|
3699 |
||
3700 |
if (this.settings['height'] == -1) |
|
3701 |
this.settings['height'] = replace_element.offsetHeight; |
|
3702 |
||
3703 |
// Try the style width |
|
3704 |
if (this.settings['width'] == 0) |
|
3705 |
this.settings['width'] = replace_element.style.width; |
|
3706 |
||
3707 |
// Try the style height |
|
3708 |
if (this.settings['height'] == 0) |
|
3709 |
this.settings['height'] = replace_element.style.height; |
|
3710 |
||
3711 |
// If no width/height then default to 320x240, better than nothing |
|
3712 |
if (this.settings['width'] == 0) |
|
3713 |
this.settings['width'] = 320; |
|
3714 |
||
3715 |
if (this.settings['height'] == 0) |
|
3716 |
this.settings['height'] = 240; |
|
3717 |
||
3718 |
this.settings['area_width'] = parseInt(this.settings['width']); |
|
3719 |
this.settings['area_height'] = parseInt(this.settings['height']); |
|
3720 |
this.settings['area_width'] += deltaWidth; |
|
3721 |
this.settings['area_height'] += deltaHeight; |
|
3722 |
||
3723 |
this.settings['width_style'] = "" + this.settings['width']; |
|
3724 |
this.settings['height_style'] = "" + this.settings['height']; |
|
3725 |
||
3726 |
// Special % handling |
|
3727 |
if (("" + this.settings['width']).indexOf('%') != -1) |
|
3728 |
this.settings['area_width'] = "100%"; |
|
3729 |
else |
|
3730 |
this.settings['width_style'] += 'px'; |
|
3731 |
||
3732 |
if (("" + this.settings['height']).indexOf('%') != -1) |
|
3733 |
this.settings['area_height'] = "100%"; |
|
3734 |
else |
|
3735 |
this.settings['height_style'] += 'px'; |
|
3736 |
||
3737 |
if (("" + replace_element.style.width).indexOf('%') != -1) { |
|
3738 |
this.settings['width'] = replace_element.style.width; |
|
3739 |
this.settings['area_width'] = "100%"; |
|
3740 |
this.settings['width_style'] = "100%"; |
|
3741 |
} |
|
3742 |
||
3743 |
if (("" + replace_element.style.height).indexOf('%') != -1) { |
|
3744 |
this.settings['height'] = replace_element.style.height; |
|
3745 |
this.settings['area_height'] = "100%"; |
|
3746 |
this.settings['height_style'] = "100%"; |
|
3747 |
} |
|
3748 |
||
3749 |
html = tinyMCE.applyTemplate(html); |
|
3750 |
||
3751 |
this.settings['width'] = this.settings['old_width']; |
|
3752 |
this.settings['height'] = this.settings['old_height']; |
|
3753 |
||
3754 |
this.visualAid = this.settings['visual']; |
|
3755 |
this.formTargetElementId = form_element_name; |
|
3756 |
||
3757 |
// Get replace_element contents |
|
3758 |
if (replace_element.nodeName == "TEXTAREA" || replace_element.nodeName == "INPUT") |
|
3759 |
this.startContent = replace_element.value; |
|
3760 |
else |
|
3761 |
this.startContent = replace_element.innerHTML; |
|
3762 |
||
3763 |
// If not text area or input |
|
3764 |
if (replace_element.nodeName != "TEXTAREA" && replace_element.nodeName != "INPUT") { |
|
3765 |
this.oldTargetElement = replace_element; |
|
3766 |
||
3767 |
// Debug mode |
|
3768 |
if (tinyMCE.settings['debug']) { |
|
3769 |
hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>'; |
|
3770 |
} else { |
|
3771 |
hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />'; |
|
3772 |
this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); |
|
3773 |
this.oldTargetElement.style.display = "none"; |
|
3774 |
} |
|
3775 |
||
3776 |
html += '</span>'; |
|
3777 |
||
3778 |
if (tinyMCE.isGecko) |
|
3779 |
html = hc + html; |
|
3780 |
else |
|
3781 |
html += hc; |
|
3782 |
||
3783 |
// Output HTML and set editable |
|
3784 |
if (tinyMCE.isGecko) { |
|
3785 |
var rng = replace_element.ownerDocument.createRange(); |
|
3786 |
rng.setStartBefore(replace_element); |
|
3787 |
||
3788 |
var fragment = rng.createContextualFragment(html); |
|
3789 |
tinyMCE.insertAfter(fragment, replace_element); |
|
3790 |
} else |
|
3791 |
replace_element.insertAdjacentHTML("beforeBegin", html); |
|
3792 |
} else { |
|
3793 |
html += '</span>'; |
|
3794 |
||
3795 |
// Just hide the textarea element |
|
3796 |
this.oldTargetElement = replace_element; |
|
3797 |
||
3798 |
if (!tinyMCE.settings['debug']) { |
|
3799 |
this.oldTargetDisplay = tinyMCE.getStyle(this.oldTargetElement, 'display', 'inline'); |
|
3800 |
this.oldTargetElement.style.display = "none"; |
|
3801 |
} |
|
3802 |
||
3803 |
// Output HTML and set editable |
|
3804 |
if (tinyMCE.isGecko) { |
|
3805 |
var rng = replace_element.ownerDocument.createRange(); |
|
3806 |
rng.setStartBefore(replace_element); |
|
3807 |
||
3808 |
var fragment = rng.createContextualFragment(html); |
|
3809 |
tinyMCE.insertAfter(fragment, replace_element); |
|
3810 |
} else |
|
3811 |
replace_element.insertAdjacentHTML("beforeBegin", html); |
|
3812 |
} |
|
3813 |
||
3814 |
// Setup iframe |
|
3815 |
var dynamicIFrame = false; |
|
3816 |
var tElm = targetDoc.getElementById(this.editorId); |
|
3817 |
||
3818 |
if (!tinyMCE.isIE) { |
|
3819 |
// Node case is preserved in XML strict mode |
|
3820 |
if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) { |
|
3821 |
tElm = tinyMCE._createIFrame(tElm, targetDoc); |
|
3822 |
dynamicIFrame = true; |
|
3823 |
} |
|
3824 |
||
3825 |
this.targetElement = tElm; |
|
3826 |
this.iframeElement = tElm; |
|
3827 |
this.contentDocument = tElm.contentDocument; |
|
3828 |
this.contentWindow = tElm.contentWindow; |
|
3829 |
||
3830 |
//this.getDoc().designMode = "on"; |
|
3831 |
} else { |
|
3832 |
if (tElm && tElm.nodeName == "SPAN") |
|
3833 |
tElm = tinyMCE._createIFrame(tElm, targetDoc, targetDoc.parentWindow); |
|
3834 |
else |
|
3835 |
tElm = targetDoc.frames[this.editorId]; |
|
3836 |
||
3837 |
this.targetElement = tElm; |
|
3838 |
this.iframeElement = targetDoc.getElementById(this.editorId); |
|
3839 |
||
3840 |
if (tinyMCE.isOpera) { |
|
3841 |
this.contentDocument = this.iframeElement.contentDocument; |
|
3842 |
this.contentWindow = this.iframeElement.contentWindow; |
|
3843 |
dynamicIFrame = true; |
|
3844 |
} else { |
|
3845 |
this.contentDocument = tElm.window.document; |
|
3846 |
this.contentWindow = tElm.window; |
|
3847 |
} |
|
3848 |
||
3849 |
this.getDoc().designMode = "on"; |
|
3850 |
} |
|
3851 |
||
3852 |
// Setup base HTML |
|
3853 |
var doc = this.contentDocument; |
|
3854 |
if (dynamicIFrame) { |
|
3855 |
var 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>'; |
|
3856 |
||
3857 |
try { |
|
3858 |
if (!this.isHidden()) |
|
3859 |
this.getDoc().designMode = "on"; |
|
3860 |
||
3861 |
doc.open(); |
|
3862 |
//alert('docwrite 3'); |
|
3863 |
doc.write(html); |
|
3864 |
doc.close(); |
|
3865 |
} catch (e) { |
|
3866 |
// Failed Mozilla 1.3 |
|
3867 |
this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm"; |
|
3868 |
} |
|
3869 |
} |
|
3870 |
||
3871 |
// This timeout is needed in MSIE 5.5 for some odd reason |
|
3872 |
// it seems that the document.frames isn't initialized yet? |
|
3873 |
if (tinyMCE.isIE) |
|
3874 |
window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1); |
|
3875 |
||
3876 |
// Setup element references |
|
3877 |
var parentElm = this.targetDoc.getElementById(this.editorId + '_parent'); |
|
3878 |
this.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; |
|
3879 |
||
3880 |
tinyMCE.setupContent(this.editorId, true); |
|
3881 |
||
3882 |
return true; |
|
3883 |
}, |
|
3884 |
||
3885 |
setBaseHREF : function(u) { |
|
3886 |
var h, b, d, nl; |
|
3887 |
||
3888 |
d = this.getDoc(); |
|
3889 |
nl = d.getElementsByTagName("base"); |
|
3890 |
b = nl.length > 0 ? nl[0] : null; |
|
3891 |
||
3892 |
if (!b) { |
|
3893 |
nl = d.getElementsByTagName("head"); |
|
3894 |
h = nl.length > 0 ? nl[0] : null; |
|
3895 |
||
3896 |
b = d.createElement("base"); |
|
3897 |
b.setAttribute('href', u); |
|
3898 |
h.appendChild(b); |
|
3899 |
} else { |
|
3900 |
if (u == "" || u == null) |
|
3901 |
b.parentNode.removeChild(b); |
|
3902 |
else |
|
3903 |
b.setAttribute('href', u); |
|
3904 |
} |
|
3905 |
}, |
|
3906 |
||
3907 |
getHTML : function(r) { |
|
3908 |
var h, d = this.getDoc(), b = this.getBody(); |
|
3909 |
||
3910 |
if (r) |
|
3911 |
return b.innerHTML; |
|
3912 |
||
3913 |
h = tinyMCE._cleanupHTML(this, d, this.settings, b, false, true, false, true); |
|
3914 |
||
3915 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
3916 |
tinyMCE.convertSpansToFonts(d); |
|
3917 |
||
3918 |
return h; |
|
3919 |
}, |
|
3920 |
||
3921 |
setHTML : function(h) { |
|
3922 |
this.execCommand('mceSetContent', false, h); |
|
3923 |
this.repaint(); |
|
3924 |
}, |
|
3925 |
||
3926 |
getFocusElement : function() { |
|
3927 |
return this.selection.getFocusElement(); |
|
3928 |
}, |
|
3929 |
||
3930 |
getSel : function() { |
|
3931 |
return this.selection.getSel(); |
|
3932 |
}, |
|
3933 |
||
3934 |
getRng : function() { |
|
3935 |
return this.selection.getRng(); |
|
3936 |
}, |
|
3937 |
||
3938 |
triggerSave : function(skip_cleanup, skip_callback) { |
|
3939 |
var e, nl = [], i, s; |
|
3940 |
||
3941 |
this.switchSettings(); |
|
3942 |
s = tinyMCE.settings; |
|
3943 |
||
3944 |
// Force hidden tabs visible while serializing |
|
3945 |
if (tinyMCE.isRealIE) { |
|
3946 |
e = this.iframeElement; |
|
3947 |
||
3948 |
do { |
|
3949 |
if (e.style && e.style.display == 'none') { |
|
3950 |
e.style.display = 'block'; |
|
3951 |
nl[nl.length] = {elm : e, type : 'style'}; |
|
3952 |
} |
|
3953 |
||
3954 |
if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) { |
|
3955 |
e.className = s.display_tab_class; |
|
3956 |
nl[nl.length] = {elm : e, type : 'class'}; |
|
3957 |
} |
|
3958 |
} while ((e = e.parentNode) != null) |
|
3959 |
} |
|
3960 |
||
3961 |
tinyMCE.settings['preformatted'] = false; |
|
3962 |
||
3963 |
// Default to false |
|
3964 |
if (typeof(skip_cleanup) == "undefined") |
|
3965 |
skip_cleanup = false; |
|
3966 |
||
3967 |
// Default to false |
|
3968 |
if (typeof(skip_callback) == "undefined") |
|
3969 |
skip_callback = false; |
|
3970 |
||
3971 |
tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML); |
|
3972 |
||
3973 |
// Remove visual aids when cleanup is disabled |
|
3974 |
if (this.settings['cleanup'] == false) { |
|
3975 |
tinyMCE.handleVisualAid(this.getBody(), true, false, this); |
|
3976 |
tinyMCE._setEventsEnabled(this.getBody(), true); |
|
3977 |
} |
|
3978 |
||
3979 |
tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body); |
|
3980 |
var htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true); |
|
3981 |
htm = tinyMCE._customCleanup(this, "submit_content", htm); |
|
3982 |
||
3983 |
if (!skip_callback && tinyMCE.settings['save_callback'] != "") |
|
3984 |
var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());"); |
|
3985 |
||
3986 |
// Use callback content if available |
|
3987 |
if ((typeof(content) != "undefined") && content != null) |
|
3988 |
htm = content; |
|
3989 |
||
3990 |
// Replace some weird entities (Bug: #1056343) |
|
3991 |
htm = tinyMCE.regexpReplace(htm, "(", "(", "gi"); |
|
3992 |
htm = tinyMCE.regexpReplace(htm, ")", ")", "gi"); |
|
3993 |
htm = tinyMCE.regexpReplace(htm, ";", ";", "gi"); |
|
3994 |
htm = tinyMCE.regexpReplace(htm, """, """, "gi"); |
|
3995 |
htm = tinyMCE.regexpReplace(htm, "^", "^", "gi"); |
|
3996 |
||
3997 |
if (this.formElement) |
|
3998 |
this.formElement.value = htm; |
|
3999 |
||
4000 |
if (tinyMCE.isSafari && this.formElement) |
|
4001 |
this.formElement.innerText = htm; |
|
4002 |
||
4003 |
// Hide them again (tabs in MSIE) |
|
4004 |
for (i=0; i<nl.length; i++) { |
|
4005 |
if (nl[i].type == 'style') |
|
4006 |
nl[i].elm.style.display = 'none'; |
|
4007 |
else |
|
4008 |
nl[i].elm.className = s.hidden_tab_class; |
|
4009 |
} |
|
4010 |
} |
|
4011 |
||
4012 |
}; |
|
4013 |
||
4014 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */ |
|
4015 |
||
4016 |
TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) { |
|
4017 |
s = s.replace(new RegExp('<p \\/>', 'gi'), '<p> </p>'); |
|
4018 |
s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p> </p>'); |
|
4019 |
||
4020 |
// Fix close BR elements |
|
4021 |
s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />'); |
|
4022 |
||
4023 |
// Open closed tags like <b/> to <b></b> |
|
4024 |
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>'); |
|
4025 |
||
4026 |
// Remove trailing space <b > to <b> |
|
4027 |
s = s.replace(new RegExp('\\s+></', 'gi'), '></'); |
|
4028 |
||
4029 |
// Close tags <img></img> to <img/> |
|
4030 |
s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />'); |
|
4031 |
||
4032 |
// Weird MSIE bug, <p><hr /></p> breaks runtime? |
|
4033 |
if (tinyMCE.isIE) |
|
4034 |
s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>"); |
|
4035 |
||
4036 |
// Weird tags will make IE error #bug: 1538495 |
|
4037 |
if (tinyMCE.isIE) |
|
4038 |
s = s.replace(/<!(\s*)\/>/g, ''); |
|
4039 |
||
4040 |
// Convert relative anchors to absolute URLs ex: #something to file.htm#something |
|
4041 |
// Removed: Since local document anchors should never be forced absolute example edit.php?id=something |
|
4042 |
//if (tinyMCE.getParam('convert_urls')) |
|
4043 |
// s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#"); |
|
4044 |
||
4045 |
return s; |
|
4046 |
}; |
|
4047 |
||
4048 |
TinyMCE_Engine.prototype.parseStyle = function(str) { |
|
4049 |
var ar = new Array(); |
|
4050 |
||
4051 |
if (str == null) |
|
4052 |
return ar; |
|
4053 |
||
4054 |
var st = str.split(';'); |
|
4055 |
||
4056 |
tinyMCE.clearArray(ar); |
|
4057 |
||
4058 |
for (var i=0; i<st.length; i++) { |
|
4059 |
if (st[i] == '') |
|
4060 |
continue; |
|
4061 |
||
4062 |
var re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$'); |
|
4063 |
var pa = st[i].replace(re, '$1||$2').split('||'); |
|
4064 |
//tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2')); |
|
4065 |
if (pa.length == 2) |
|
4066 |
ar[pa[0].toLowerCase()] = pa[1]; |
|
4067 |
} |
|
4068 |
||
4069 |
return ar; |
|
4070 |
}; |
|
4071 |
||
4072 |
TinyMCE_Engine.prototype.compressStyle = function(ar, pr, sf, res) { |
|
4073 |
var box = new Array(); |
|
4074 |
||
4075 |
box[0] = ar[pr + '-top' + sf]; |
|
4076 |
box[1] = ar[pr + '-left' + sf]; |
|
4077 |
box[2] = ar[pr + '-right' + sf]; |
|
4078 |
box[3] = ar[pr + '-bottom' + sf]; |
|
4079 |
||
4080 |
for (var i=0; i<box.length; i++) { |
|
4081 |
if (box[i] == null) |
|
4082 |
return; |
|
4083 |
||
4084 |
for (var a=0; a<box.length; a++) { |
|
4085 |
if (box[a] != box[i]) |
|
4086 |
return; |
|
4087 |
} |
|
4088 |
} |
|
4089 |
||
4090 |
// They are all the same |
|
4091 |
ar[res] = box[0]; |
|
4092 |
ar[pr + '-top' + sf] = null; |
|
4093 |
ar[pr + '-left' + sf] = null; |
|
4094 |
ar[pr + '-right' + sf] = null; |
|
4095 |
ar[pr + '-bottom' + sf] = null; |
|
4096 |
}; |
|
4097 |
||
4098 |
TinyMCE_Engine.prototype.serializeStyle = function(ar) { |
|
4099 |
var str = ""; |
|
4100 |
||
4101 |
// Compress box |
|
4102 |
tinyMCE.compressStyle(ar, "border", "", "border"); |
|
4103 |
tinyMCE.compressStyle(ar, "border", "-width", "border-width"); |
|
4104 |
tinyMCE.compressStyle(ar, "border", "-color", "border-color"); |
|
4105 |
tinyMCE.compressStyle(ar, "border", "-style", "border-style"); |
|
4106 |
tinyMCE.compressStyle(ar, "padding", "", "padding"); |
|
4107 |
tinyMCE.compressStyle(ar, "margin", "", "margin"); |
|
4108 |
||
4109 |
for (var key in ar) { |
|
4110 |
var val = ar[key]; |
|
4111 |
||
4112 |
if (typeof(val) == 'function') |
|
4113 |
continue; |
|
4114 |
||
4115 |
if (key.indexOf('mso-') == 0) |
|
4116 |
continue; |
|
4117 |
||
4118 |
if (val != null && val != '') { |
|
4119 |
val = '' + val; // Force string |
|
4120 |
||
4121 |
// Fix style URL |
|
4122 |
val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')"); |
|
4123 |
||
4124 |
// Convert URL |
|
4125 |
if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) { |
|
4126 |
var m = new RegExp("url\\('(.*?)'\\)").exec(val); |
|
4127 |
||
4128 |
if (m.length > 1) |
|
4129 |
val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')"; |
|
4130 |
} |
|
4131 |
||
4132 |
// Force HEX colors |
|
4133 |
if (tinyMCE.getParam("force_hex_style_colors")) |
|
4134 |
val = tinyMCE.convertRGBToHex(val, true); |
|
4135 |
||
4136 |
val = val.replace(/\"/g, '\''); |
|
4137 |
||
4138 |
if (val != "url('')") |
|
4139 |
str += key.toLowerCase() + ": " + val + "; "; |
|
4140 |
} |
|
4141 |
} |
|
4142 |
||
4143 |
if (new RegExp('; $').test(str)) |
|
4144 |
str = str.substring(0, str.length - 2); |
|
4145 |
||
4146 |
return str; |
|
4147 |
}; |
|
4148 |
||
4149 |
TinyMCE_Engine.prototype.convertRGBToHex = function(s, k) { |
|
4150 |
if (s.toLowerCase().indexOf('rgb') != -1) { |
|
4151 |
var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); |
|
4152 |
var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); |
|
4153 |
if (rgb.length == 5) { |
|
4154 |
r = parseInt(rgb[1]).toString(16); |
|
4155 |
g = parseInt(rgb[2]).toString(16); |
|
4156 |
b = parseInt(rgb[3]).toString(16); |
|
4157 |
||
4158 |
r = r.length == 1 ? '0' + r : r; |
|
4159 |
g = g.length == 1 ? '0' + g : g; |
|
4160 |
b = b.length == 1 ? '0' + b : b; |
|
4161 |
||
4162 |
s = "#" + r + g + b; |
|
4163 |
||
4164 |
if (k) |
|
4165 |
s = rgb[0] + s + rgb[4]; |
|
4166 |
} |
|
4167 |
} |
|
4168 |
||
4169 |
return s; |
|
4170 |
}; |
|
4171 |
||
4172 |
TinyMCE_Engine.prototype.convertHexToRGB = function(s) { |
|
4173 |
if (s.indexOf('#') != -1) { |
|
4174 |
s = s.replace(new RegExp('[^0-9A-F]', 'gi'), ''); |
|
4175 |
return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")"; |
|
4176 |
} |
|
4177 |
||
4178 |
return s; |
|
4179 |
}; |
|
4180 |
||
4181 |
TinyMCE_Engine.prototype.convertSpansToFonts = function(doc) { |
|
4182 |
var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); |
|
4183 |
||
4184 |
/*var h = doc.body.innerHTML; |
|
4185 |
h = h.replace(/<span/gi, '<font'); |
|
4186 |
h = h.replace(/<\/span/gi, '</font'); |
|
4187 |
tinyMCE.setInnerHTML(doc.body, h);*/ |
|
4188 |
||
4189 |
var s = tinyMCE.selectElements(doc, 'span,font'); |
|
4190 |
for (var i=0; i<s.length; i++) { |
|
4191 |
var size = tinyMCE.trim(s[i].style.fontSize).toLowerCase(); |
|
4192 |
var fSize = 0; |
|
4193 |
||
4194 |
for (var x=0; x<sizes.length; x++) { |
|
4195 |
if (sizes[x] == size) { |
|
4196 |
fSize = x + 1; |
|
4197 |
break; |
|
4198 |
} |
|
4199 |
} |
|
4200 |
||
4201 |
if (fSize > 0) { |
|
4202 |
tinyMCE.setAttrib(s[i], 'size', fSize); |
|
4203 |
s[i].style.fontSize = ''; |
|
4204 |
} |
|
4205 |
||
4206 |
var fFace = s[i].style.fontFamily; |
|
4207 |
if (fFace != null && fFace != "") { |
|
4208 |
tinyMCE.setAttrib(s[i], 'face', fFace); |
|
4209 |
s[i].style.fontFamily = ''; |
|
4210 |
} |
|
4211 |
||
4212 |
var fColor = s[i].style.color; |
|
4213 |
if (fColor != null && fColor != "") { |
|
4214 |
tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); |
|
4215 |
s[i].style.color = ''; |
|
4216 |
} |
|
4217 |
} |
|
4218 |
}; |
|
4219 |
||
4220 |
TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) { |
|
4221 |
var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); |
|
4222 |
||
4223 |
/* var h = doc.body.innerHTML; |
|
4224 |
h = h.replace(/<font/gi, '<span'); |
|
4225 |
h = h.replace(/<\/font/gi, '</span'); |
|
4226 |
tinyMCE.setInnerHTML(doc.body, h);*/ |
|
4227 |
||
4228 |
var fsClasses = tinyMCE.getParam('font_size_classes'); |
|
4229 |
if (fsClasses != '') |
|
4230 |
fsClasses = fsClasses.replace(/\s+/, '').split(','); |
|
4231 |
else |
|
4232 |
fsClasses = null; |
|
4233 |
||
4234 |
var s = tinyMCE.selectElements(doc, 'span,font'); |
|
4235 |
for (var i=0; i<s.length; i++) { |
|
4236 |
var fSize, fFace, fColor; |
|
4237 |
||
4238 |
fSize = tinyMCE.getAttrib(s[i], 'size'); |
|
4239 |
fFace = tinyMCE.getAttrib(s[i], 'face'); |
|
4240 |
fColor = tinyMCE.getAttrib(s[i], 'color'); |
|
4241 |
||
4242 |
if (fSize != "") { |
|
4243 |
fSize = parseInt(fSize); |
|
4244 |
||
4245 |
if (fSize > 0 && fSize < 8) { |
|
4246 |
if (fsClasses != null) |
|
4247 |
tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); |
|
4248 |
else |
|
4249 |
s[i].style.fontSize = sizes[fSize-1]; |
|
4250 |
} |
|
4251 |
||
4252 |
s[i].removeAttribute('size'); |
|
4253 |
} |
|
4254 |
||
4255 |
if (fFace != "") { |
|
4256 |
s[i].style.fontFamily = fFace; |
|
4257 |
s[i].removeAttribute('face'); |
|
4258 |
} |
|
4259 |
||
4260 |
if (fColor != "") { |
|
4261 |
s[i].style.color = fColor; |
|
4262 |
s[i].removeAttribute('color'); |
|
4263 |
} |
|
4264 |
} |
|
4265 |
}; |
|
4266 |
||
4267 |
TinyMCE_Engine.prototype.cleanupAnchors = function(doc) { |
|
4268 |
var i, cn, x, an = doc.getElementsByTagName("a"); |
|
4269 |
||
4270 |
// Loops backwards due to bug #1467987 |
|
4271 |
for (i=an.length-1; i>=0; i--) { |
|
4272 |
if (tinyMCE.getAttrib(an[i], "name") != "" && tinyMCE.getAttrib(an[i], "href") == "") { |
|
4273 |
cn = an[i].childNodes; |
|
4274 |
||
4275 |
for (x=cn.length-1; x>=0; x--) |
|
4276 |
tinyMCE.insertAfter(cn[x], an[i]); |
|
4277 |
} |
|
4278 |
} |
|
4279 |
}; |
|
4280 |
||
4281 |
TinyMCE_Engine.prototype.getContent = function(editor_id) { |
|
4282 |
if (typeof(editor_id) != "undefined") |
|
4283 |
tinyMCE.getInstanceById(editor_id).select(); |
|
4284 |
||
4285 |
if (tinyMCE.selectedInstance) |
|
4286 |
return tinyMCE.selectedInstance.getHTML(); |
|
4287 |
||
4288 |
return null; |
|
4289 |
}; |
|
4290 |
||
4291 |
TinyMCE_Engine.prototype._fixListElements = function(d) { |
|
4292 |
var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np; |
|
4293 |
||
4294 |
for (x=0; x<a.length; x++) { |
|
4295 |
nl = d.getElementsByTagName(a[x]); |
|
4296 |
||
4297 |
for (i=0; i<nl.length; i++) { |
|
4298 |
n = nl[i]; |
|
4299 |
p = n.parentNode; |
|
4300 |
||
4301 |
if (r.test(p.nodeName)) { |
|
4302 |
np = tinyMCE.prevNode(n, 'LI'); |
|
4303 |
||
4304 |
if (!np) { |
|
4305 |
np = d.createElement('li'); |
|
4306 |
np.innerHTML = ' '; |
|
4307 |
np.appendChild(n); |
|
4308 |
p.insertBefore(np, p.firstChild); |
|
4309 |
} else |
|
4310 |
np.appendChild(n); |
|
4311 |
} |
|
4312 |
} |
|
4313 |
} |
|
4314 |
}; |
|
4315 |
||
4316 |
TinyMCE_Engine.prototype._fixTables = function(d) { |
|
4317 |
var nl, i, n, p, np, x, t; |
|
4318 |
||
4319 |
nl = d.getElementsByTagName('table'); |
|
4320 |
for (i=0; i<nl.length; i++) { |
|
4321 |
n = nl[i]; |
|
4322 |
||
4323 |
if ((p = tinyMCE.getParentElement(n, 'p,h1,h2,h3,h4,h5,h6')) != null) { |
|
4324 |
np = p.cloneNode(false); |
|
4325 |
np.removeAttribute('id'); |
|
4326 |
||
4327 |
t = n; |
|
4328 |
||
4329 |
while ((n = n.nextSibling)) |
|
4330 |
np.appendChild(n); |
|
4331 |
||
4332 |
tinyMCE.insertAfter(np, p); |
|
4333 |
tinyMCE.insertAfter(t, p); |
|
4334 |
} |
|
4335 |
} |
|
4336 |
}; |
|
4337 |
||
4338 |
TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit, inn) { |
|
4339 |
var h, d, t1, t2, t3, t4, t5, c, s, nb; |
|
4340 |
||
4341 |
if (!tinyMCE.getParam('cleanup')) |
|
4342 |
return elm.innerHTML; |
|
4343 |
||
4344 |
on_save = typeof(on_save) == 'undefined' ? false : on_save; |
|
4345 |
||
4346 |
c = inst.cleanup; |
|
4347 |
s = inst.settings; |
|
4348 |
d = c.settings.debug; |
|
4349 |
||
4350 |
if (d) |
|
4351 |
t1 = new Date().getTime(); |
|
4352 |
||
4353 |
if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
4354 |
tinyMCE.convertFontsToSpans(doc); |
|
4355 |
||
4356 |
if (tinyMCE.getParam("fix_list_elements")) |
|
4357 |
tinyMCE._fixListElements(doc); |
|
4358 |
||
4359 |
if (tinyMCE.getParam("fix_table_elements")) |
|
4360 |
tinyMCE._fixTables(doc); |
|
4361 |
||
4362 |
// Call custom cleanup code |
|
4363 |
tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body); |
|
4364 |
||
4365 |
if (d) |
|
4366 |
t2 = new Date().getTime(); |
|
4367 |
||
4368 |
c.settings.on_save = on_save; |
|
4369 |
//for (var i=0; i<100; i++) |
|
4370 |
||
4371 |
c.idCount = 0; |
|
4372 |
c.serializationId++; |
|
4373 |
c.serializedNodes = new Array(); |
|
4374 |
c.sourceIndex = -1; |
|
4375 |
||
4376 |
if (s.cleanup_serializer == "xml") |
|
4377 |
h = c.serializeNodeAsXML(elm, inn); |
|
4378 |
else |
|
4379 |
h = c.serializeNodeAsHTML(elm, inn); |
|
4380 |
||
4381 |
if (d) |
|
4382 |
t3 = new Date().getTime(); |
|
4383 |
||
4384 |
// Post processing |
|
4385 |
nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? ' ' : ' '; |
|
4386 |
h = h.replace(/<\/?(body|head|html)[^>]*>/gi, ''); |
|
4387 |
h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), ''); |
|
4388 |
h = h.replace(/<p><hr \/><\/p>/g, '<hr />'); |
|
4389 |
h = h.replace(/<p>( | )<\/p><hr \/><p>( | )<\/p>/g, '<hr />'); |
|
4390 |
h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>'); |
|
4391 |
h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>'); |
|
4392 |
h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko |
|
4393 |
h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko |
|
4394 |
h = h.replace(/<p>\s*( | )\s*<br \/>\s*( | )\s*<\/p>/g, '<p>' + nb + '</p>'); |
|
4395 |
h = h.replace(/<p>\s*( | )\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>'); |
|
4396 |
h = h.replace(/<p>\s*<br \/>\s* \s*<\/p>/g, '<p>' + nb + '</p>'); |
|
4397 |
h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1'); |
|
4398 |
h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>'); |
|
4399 |
||
4400 |
// Clean body |
|
4401 |
if (/^\s*(<br \/>|<p> <\/p>|<p> <\/p>|<p><\/p>)\s*$/.test(h)) |
|
4402 |
h = ''; |
|
4403 |
||
4404 |
// If preformatted |
|
4405 |
if (s.preformatted) { |
|
4406 |
h = h.replace(/^<pre>/, ''); |
|
4407 |
h = h.replace(/<\/pre>$/, ''); |
|
4408 |
h = '<pre>' + h + '</pre>'; |
|
4409 |
} |
|
4410 |
||
4411 |
// Gecko specific processing |
|
4412 |
if (tinyMCE.isGecko) { |
|
4413 |
h = h.replace(/<o:p _moz-userdefined="" \/>/g, ''); |
|
4414 |
h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>'); |
|
4415 |
} |
|
4416 |
||
4417 |
if (s.force_br_newlines) |
|
4418 |
h = h.replace(/<p>( | )<\/p>/g, '<br />'); |
|
4419 |
||
4420 |
// Call custom cleanup code |
|
4421 |
h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h); |
|
4422 |
||
4423 |
// Remove internal classes |
|
4424 |
if (on_save) { |
|
4425 |
h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), ''); |
|
4426 |
h = h.replace(new RegExp(' ?class=""', 'g'), ''); |
|
4427 |
} |
|
4428 |
||
4429 |
if (s.remove_linebreaks && !c.settings.indent) |
|
4430 |
h = h.replace(/\n|\r/g, ' '); |
|
4431 |
||
4432 |
if (d) |
|
4433 |
t4 = new Date().getTime(); |
|
4434 |
||
4435 |
if (on_save && c.settings.indent) |
|
4436 |
h = c.formatHTML(h); |
|
4437 |
||
4438 |
// If encoding (not recommended option) |
|
4439 |
if (on_submit && (s.encoding == "xml" || s.encoding == "html")) |
|
4440 |
h = c.xmlEncode(h); |
|
4441 |
||
4442 |
if (d) |
|
4443 |
t5 = new Date().getTime(); |
|
4444 |
||
4445 |
if (c.settings.debug) |
|
4446 |
tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + "."); |
|
4447 |
||
4448 |
return h; |
|
4449 |
}; |
|
4450 |
||
4451 |
function TinyMCE_Cleanup() { |
|
4452 |
this.isIE = (navigator.appName == "Microsoft Internet Explorer"); |
|
4453 |
this.rules = tinyMCE.clearArray(new Array()); |
|
4454 |
||
4455 |
// Default config |
|
4456 |
this.settings = { |
|
4457 |
indent_elements : 'head,table,tbody,thead,tfoot,form,tr,ul,ol,blockquote,object', |
|
4458 |
newline_before_elements : 'h1,h2,h3,h4,h5,h6,pre,address,div,ul,ol,li,meta,option,area,title,link,base,script,td', |
|
4459 |
newline_after_elements : 'br,hr,p,pre,address,div,ul,ol,meta,option,area,link,base,script', |
|
4460 |
newline_before_after_elements : 'html,head,body,table,thead,tbody,tfoot,tr,form,ul,ol,blockquote,p,object,param,hr,div', |
|
4461 |
indent_char : '\t', |
|
4462 |
indent_levels : 1, |
|
4463 |
entity_encoding : 'raw', |
|
4464 |
valid_elements : '*[*]', |
|
4465 |
entities : '', |
|
4466 |
url_converter : '', |
|
4467 |
invalid_elements : '', |
|
4468 |
verify_html : false |
|
4469 |
}; |
|
4470 |
||
4471 |
this.vElements = tinyMCE.clearArray(new Array()); |
|
4472 |
this.vElementsRe = ''; |
|
4473 |
this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/; |
|
4474 |
this.codeElementsRe = /^(SCRIPT|STYLE)$/; |
|
4475 |
this.serializationId = 0; |
|
4476 |
this.mceAttribs = { |
|
4477 |
href : 'mce_href', |
|
4478 |
src : 'mce_src', |
|
4479 |
type : 'mce_type' |
|
4480 |
}; |
|
4481 |
} |
|
4482 |
||
4483 |
TinyMCE_Cleanup.prototype = { |
|
4484 |
init : function(s) { |
|
4485 |
var n, a, i, ir, or, st; |
|
4486 |
||
4487 |
for (n in s) |
|
4488 |
this.settings[n] = s[n]; |
|
4489 |
||
4490 |
// Setup code formating |
|
4491 |
s = this.settings; |
|
4492 |
||
4493 |
// Setup regexps |
|
4494 |
this.inRe = this._arrayToRe(s.indent_elements.split(','), '', '^<(', ')[^>]*'); |
|
4495 |
this.ouRe = this._arrayToRe(s.indent_elements.split(','), '', '^<\\/(', ')[^>]*'); |
|
4496 |
this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>'); |
|
4497 |
this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>'); |
|
4498 |
this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>'); |
|
4499 |
this.serializedNodes = []; |
|
4500 |
||
4501 |
if (s.invalid_elements != '') |
|
4502 |
this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$'); |
|
4503 |
else |
|
4504 |
this.iveRe = null; |
|
4505 |
||
4506 |
// Setup separator |
|
4507 |
st = ''; |
|
4508 |
for (i=0; i<s.indent_levels; i++) |
|
4509 |
st += s.indent_char; |
|
4510 |
||
4511 |
this.inStr = st; |
|
4512 |
||
4513 |
// If verify_html if false force *[*] |
|
4514 |
if (!s.verify_html) { |
|
4515 |
s.valid_elements = '*[*]'; |
|
4516 |
s.extended_valid_elements = ''; |
|
4517 |
} |
|
4518 |
||
4519 |
this.fillStr = s.entity_encoding == "named" ? " " : " "; |
|
4520 |
this.idCount = 0; |
|
4521 |
this.xmlEncodeRe = new RegExp('[\u007F-\uFFFF<>&"]', 'g'); |
|
4522 |
this.xmlEncodeAposRe = new RegExp('[\u007F-\uFFFF<>&"\']', 'g'); |
|
4523 |
}, |
|
4524 |
||
4525 |
addRuleStr : function(s) { |
|
4526 |
var r = this.parseRuleStr(s); |
|
4527 |
var n; |
|
4528 |
||
4529 |
for (n in r) { |
|
4530 |
if (r[n]) |
|
4531 |
this.rules[n] = r[n]; |
|
4532 |
} |
|
4533 |
||
4534 |
this.vElements = tinyMCE.clearArray(new Array()); |
|
4535 |
||
4536 |
for (n in this.rules) { |
|
4537 |
if (this.rules[n]) |
|
4538 |
this.vElements[this.vElements.length] = this.rules[n].tag; |
|
4539 |
} |
|
4540 |
||
4541 |
this.vElementsRe = this._arrayToRe(this.vElements, ''); |
|
4542 |
}, |
|
4543 |
||
4544 |
isValid : function(n) { |
|
4545 |
this._setupRules(); // Will initialize cleanup rules |
|
4546 |
||
4547 |
// Empty is true since it removes formatting |
|
4548 |
if (!n) |
|
4549 |
return true; |
|
4550 |
||
4551 |
// Clean the name up a bit |
|
4552 |
n = n.replace(/[^a-z0-9]+/gi, '').toUpperCase(); |
|
4553 |
||
4554 |
return !tinyMCE.getParam('cleanup') || this.vElementsRe.test(n); |
|
4555 |
}, |
|
4556 |
||
4557 |
addChildRemoveRuleStr : function(s) { |
|
4558 |
var x, y, p, i, t, tn, ta, cl, r; |
|
4559 |
||
4560 |
if (!s) |
|
4561 |
return; |
|
4562 |
||
4563 |
ta = s.split(','); |
|
4564 |
for (x=0; x<ta.length; x++) { |
|
4565 |
s = ta[x]; |
|
4566 |
||
4567 |
// Split tag/children |
|
4568 |
p = this.split(/\[|\]/, s); |
|
4569 |
if (p == null || p.length < 1) |
|
4570 |
t = s.toUpperCase(); |
|
4571 |
else |
|
4572 |
t = p[0].toUpperCase(); |
|
4573 |
||
4574 |
// Handle all tag names |
|
4575 |
tn = this.split('/', t); |
|
4576 |
for (y=0; y<tn.length; y++) { |
|
4577 |
r = "^("; |
|
4578 |
||
4579 |
// Build regex |
|
4580 |
cl = this.split(/\|/, p[1]); |
|
4581 |
for (i=0; i<cl.length; i++) { |
|
4582 |
if (cl[i] == '%istrict') |
|
4583 |
r += tinyMCE.inlineStrict; |
|
4584 |
else if (cl[i] == '%itrans') |
|
4585 |
r += tinyMCE.inlineTransitional; |
|
4586 |
else if (cl[i] == '%istrict_na') |
|
4587 |
r += tinyMCE.inlineStrict.substring(2); |
|
4588 |
else if (cl[i] == '%itrans_na') |
|
4589 |
r += tinyMCE.inlineTransitional.substring(2); |
|
4590 |
else if (cl[i] == '%btrans') |
|
4591 |
r += tinyMCE.blockElms; |
|
4592 |
else if (cl[i] == '%strict') |
|
4593 |
r += tinyMCE.blockStrict; |
|
4594 |
else |
|
4595 |
r += (cl[i].charAt(0) != '#' ? cl[i].toUpperCase() : cl[i]); |
|
4596 |
||
4597 |
r += (i != cl.length - 1 ? '|' : ''); |
|
4598 |
} |
|
4599 |
||
4600 |
r += ')$'; |
|
4601 |
//tinyMCE.debug(t + "=" + r); |
|
4602 |
if (this.childRules == null) |
|
4603 |
this.childRules = tinyMCE.clearArray(new Array()); |
|
4604 |
||
4605 |
this.childRules[tn[y]] = new RegExp(r); |
|
4606 |
||
4607 |
if (p.length > 1) |
|
4608 |
this.childRules[tn[y]].wrapTag = p[2]; |
|
4609 |
} |
|
4610 |
} |
|
4611 |
}, |
|
4612 |
||
4613 |
parseRuleStr : function(s) { |
|
4614 |
var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray(new Array()), dv; |
|
4615 |
||
4616 |
if (s == null || s.length == 0) |
|
4617 |
return or; |
|
4618 |
||
4619 |
ta = s.split(','); |
|
4620 |
for (x=0; x<ta.length; x++) { |
|
4621 |
s = ta[x]; |
|
4622 |
if (s.length == 0) |
|
4623 |
continue; |
|
4624 |
||
4625 |
// Split tag/attrs |
|
4626 |
p = this.split(/\[|\]/, s); |
|
4627 |
if (p == null || p.length < 1) |
|
4628 |
t = s.toUpperCase(); |
|
4629 |
else |
|
4630 |
t = p[0].toUpperCase(); |
|
4631 |
||
4632 |
// Handle all tag names |
|
4633 |
tn = this.split('/', t); |
|
4634 |
for (y=0; y<tn.length; y++) { |
|
4635 |
r = {}; |
|
4636 |
||
4637 |
r.tag = tn[y]; |
|
4638 |
r.forceAttribs = null; |
|
4639 |
r.defaultAttribs = null; |
|
4640 |
r.validAttribValues = null; |
|
4641 |
||
4642 |
// Handle prefixes |
|
4643 |
px = r.tag.charAt(0); |
|
4644 |
r.forceOpen = px == '+'; |
|
4645 |
r.removeEmpty = px == '-'; |
|
4646 |
r.fill = px == '#'; |
|
4647 |
r.tag = r.tag.replace(/\+|-|#/g, ''); |
|
4648 |
r.oTagName = tn[0].replace(/\+|-|#/g, '').toLowerCase(); |
|
4649 |
r.isWild = new RegExp('\\*|\\?|\\+', 'g').test(r.tag); |
|
4650 |
r.validRe = new RegExp(this._wildcardToRe('^' + r.tag + '$')); |
|
4651 |
||
4652 |
// Setup valid attributes |
|
4653 |
if (p.length > 1) { |
|
4654 |
r.vAttribsRe = '^('; |
|
4655 |
a = this.split(/\|/, p[1]); |
|
4656 |
||
4657 |
for (i=0; i<a.length; i++) { |
|
4658 |
t = a[i]; |
|
4659 |
||
4660 |
if (t.charAt(0) == '!') { |
|
4661 |
a[i] = t = t.substring(1); |
|
4662 |
||
4663 |
if (!r.reqAttribsRe) |
|
4664 |
r.reqAttribsRe = '\\s+(' + t; |
|
4665 |
else |
|
4666 |
r.reqAttribsRe += '|' + t; |
|
4667 |
} |
|
4668 |
||
4669 |
av = new RegExp('(=|:|<)(.*?)$').exec(t); |
|
4670 |
t = t.replace(new RegExp('(=|:|<).*?$'), ''); |
|
4671 |
if (av && av.length > 0) { |
|
4672 |
if (av[0].charAt(0) == ':') { |
|
4673 |
if (!r.forceAttribs) |
|
4674 |
r.forceAttribs = tinyMCE.clearArray(new Array()); |
|
4675 |
||
4676 |
r.forceAttribs[t.toLowerCase()] = av[0].substring(1); |
|
4677 |
} else if (av[0].charAt(0) == '=') { |
|
4678 |
if (!r.defaultAttribs) |
|
4679 |
r.defaultAttribs = tinyMCE.clearArray(new Array()); |
|
4680 |
||
4681 |
dv = av[0].substring(1); |
|
4682 |
||
4683 |
r.defaultAttribs[t.toLowerCase()] = dv == "" ? "mce_empty" : dv; |
|
4684 |
} else if (av[0].charAt(0) == '<') { |
|
4685 |
if (!r.validAttribValues) |
|
4686 |
r.validAttribValues = tinyMCE.clearArray(new Array()); |
|
4687 |
||
4688 |
r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i'); |
|
4689 |
} |
|
4690 |
} |
|
4691 |
||
4692 |
r.vAttribsRe += '' + t.toLowerCase() + (i != a.length - 1 ? '|' : ''); |
|
4693 |
||
4694 |
a[i] = t.toLowerCase(); |
|
4695 |
} |
|
4696 |
||
4697 |
if (r.reqAttribsRe) |
|
4698 |
r.reqAttribsRe = new RegExp(r.reqAttribsRe + ')=\"', 'g'); |
|
4699 |
||
4700 |
r.vAttribsRe += ')$'; |
|
4701 |
r.vAttribsRe = this._wildcardToRe(r.vAttribsRe); |
|
4702 |
r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe); |
|
4703 |
r.vAttribsRe = new RegExp(r.vAttribsRe); |
|
4704 |
r.vAttribs = a.reverse(); |
|
4705 |
||
4706 |
//tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC); |
|
4707 |
} else { |
|
4708 |
r.vAttribsRe = ''; |
|
4709 |
r.vAttribs = tinyMCE.clearArray(new Array()); |
|
4710 |
r.vAttribsReIsWild = false; |
|
4711 |
} |
|
4712 |
||
4713 |
or[r.tag] = r; |
|
4714 |
} |
|
4715 |
} |
|
4716 |
||
4717 |
return or; |
|
4718 |
}, |
|
4719 |
||
4720 |
serializeNodeAsXML : function(n) { |
|
4721 |
var s, b; |
|
4722 |
||
4723 |
if (!this.xmlDoc) { |
|
4724 |
if (this.isIE) { |
|
4725 |
try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {} |
|
4726 |
||
4727 |
if (!this.xmlDoc) |
|
4728 |
try {this.xmlDoc = new ActiveXObject('Microsoft.XmlDom');} catch (e) {} |
|
4729 |
} else |
|
4730 |
this.xmlDoc = document.implementation.createDocument('', '', null); |
|
4731 |
||
4732 |
if (!this.xmlDoc) |
|
4733 |
alert("Error XML Parser could not be found."); |
|
4734 |
} |
|
4735 |
||
4736 |
if (this.xmlDoc.firstChild) |
|
4737 |
this.xmlDoc.removeChild(this.xmlDoc.firstChild); |
|
4738 |
||
4739 |
b = this.xmlDoc.createElement("html"); |
|
4740 |
b = this.xmlDoc.appendChild(b); |
|
4741 |
||
4742 |
this._convertToXML(n, b); |
|
4743 |
||
4744 |
if (this.isIE) |
|
4745 |
return this.xmlDoc.xml; |
|
4746 |
else |
|
4747 |
return new XMLSerializer().serializeToString(this.xmlDoc); |
|
4748 |
}, |
|
4749 |
||
4750 |
_convertToXML : function(n, xn) { |
|
4751 |
var xd, el, i, l, cn, at, no, hc = false; |
|
4752 |
||
4753 |
if (tinyMCE.isRealIE && this._isDuplicate(n)) |
|
4754 |
return; |
|
4755 |
||
4756 |
xd = this.xmlDoc; |
|
4757 |
||
4758 |
switch (n.nodeType) { |
|
4759 |
case 1: // Element |
|
4760 |
hc = n.hasChildNodes(); |
|
4761 |
||
4762 |
el = xd.createElement(n.nodeName.toLowerCase()); |
|
4763 |
||
4764 |
at = n.attributes; |
|
4765 |
for (i=at.length-1; i>-1; i--) { |
|
4766 |
no = at[i]; |
|
4767 |
||
4768 |
if (no.specified && no.nodeValue) |
|
4769 |
el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue); |
|
4770 |
} |
|
4771 |
||
4772 |
if (!hc && !this.closeElementsRe.test(n.nodeName)) |
|
4773 |
el.appendChild(xd.createTextNode("")); |
|
4774 |
||
4775 |
xn = xn.appendChild(el); |
|
4776 |
break; |
|
4777 |
||
4778 |
case 3: // Text |
|
4779 |
xn.appendChild(xd.createTextNode(n.nodeValue)); |
|
4780 |
return; |
|
4781 |
||
4782 |
case 8: // Comment |
|
4783 |
xn.appendChild(xd.createComment(n.nodeValue)); |
|
4784 |
return; |
|
4785 |
} |
|
4786 |
||
4787 |
if (hc) { |
|
4788 |
cn = n.childNodes; |
|
4789 |
||
4790 |
for (i=0, l=cn.length; i<l; i++) |
|
4791 |
this._convertToXML(cn[i], xn); |
|
4792 |
} |
|
4793 |
}, |
|
4794 |
||
4795 |
serializeNodeAsHTML : function(n, inn) { |
|
4796 |
var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr, nn; |
|
4797 |
||
4798 |
this._setupRules(); // Will initialize cleanup rules |
|
4799 |
||
4800 |
if (tinyMCE.isRealIE && this._isDuplicate(n)) |
|
4801 |
return ''; |
|
4802 |
||
4803 |
// Skip non valid child elements |
|
4804 |
if (n.parentNode && this.childRules != null) { |
|
4805 |
cr = this.childRules[n.parentNode.nodeName]; |
|
4806 |
||
4807 |
if (typeof(cr) != "undefined" && !cr.test(n.nodeName)) { |
|
4808 |
st = true; |
|
4809 |
t = null; |
|
4810 |
} |
|
4811 |
} |
|
4812 |
||
4813 |
switch (n.nodeType) { |
|
4814 |
case 1: // Element |
|
4815 |
hc = n.hasChildNodes(); |
|
4816 |
||
4817 |
if (st) |
|
4818 |
break; |
|
4819 |
||
4820 |
// MSIE sometimes produces <//tag> |
|
4821 |
if ((tinyMCE.isRealIE) && n.nodeName.indexOf('/') != -1) |
|
4822 |
break; |
|
4823 |
||
4824 |
nn = n.nodeName; |
|
4825 |
||
4826 |
// Convert fonts to spans |
|
4827 |
if (this.settings.convert_fonts_to_spans) { |
|
4828 |
// On get content FONT -> SPAN |
|
4829 |
if (this.settings.on_save && nn == 'FONT') |
|
4830 |
nn = 'SPAN'; |
|
4831 |
||
4832 |
// On insert content SPAN -> FONT |
|
4833 |
if (!this.settings.on_save && nn == 'SPAN') |
|
4834 |
nn = 'FONT'; |
|
4835 |
} |
|
4836 |
||
4837 |
if (this.vElementsRe.test(nn) && (!this.iveRe || !this.iveRe.test(nn)) && !inn) { |
|
4838 |
va = true; |
|
4839 |
||
4840 |
r = this.rules[nn]; |
|
4841 |
if (!r) { |
|
4842 |
at = this.rules; |
|
4843 |
for (no in at) { |
|
4844 |
if (at[no] && at[no].validRe.test(nn)) { |
|
4845 |
r = at[no]; |
|
4846 |
break; |
|
4847 |
} |
|
4848 |
} |
|
4849 |
} |
|
4850 |
||
4851 |
en = r.isWild ? nn.toLowerCase() : r.oTagName; |
|
4852 |
f = r.fill; |
|
4853 |
||
4854 |
if (r.removeEmpty && !hc) |
|
4855 |
return ""; |
|
4856 |
||
4857 |
t = '<' + en; |
|
4858 |
||
4859 |
if (r.vAttribsReIsWild) { |
|
4860 |
// Serialize wildcard attributes |
|
4861 |
at = n.attributes; |
|
4862 |
for (i=at.length-1; i>-1; i--) { |
|
4863 |
no = at[i]; |
|
4864 |
if (no.specified && r.vAttribsRe.test(no.nodeName)) |
|
4865 |
t += this._serializeAttribute(n, r, no.nodeName); |
|
4866 |
} |
|
4867 |
} else { |
|
4868 |
// Serialize specific attributes |
|
4869 |
for (i=r.vAttribs.length-1; i>-1; i--) |
|
4870 |
t += this._serializeAttribute(n, r, r.vAttribs[i]); |
|
4871 |
} |
|
4872 |
||
4873 |
// Serialize mce_ atts |
|
4874 |
if (!this.settings.on_save) { |
|
4875 |
at = this.mceAttribs; |
|
4876 |
||
4877 |
for (no in at) { |
|
4878 |
if (at[no]) |
|
4879 |
t += this._serializeAttribute(n, r, at[no]); |
|
4880 |
} |
|
4881 |
} |
|
4882 |
||
4883 |
// Check for required attribs |
|
4884 |
if (r.reqAttribsRe && !t.match(r.reqAttribsRe)) |
|
4885 |
t = null; |
|
4886 |
||
4887 |
// Close these |
|
4888 |
if (t != null && this.closeElementsRe.test(nn)) |
|
4889 |
return t + ' />'; |
|
4890 |
||
4891 |
if (t != null) |
|
4892 |
h += t + '>'; |
|
4893 |
||
4894 |
if (this.isIE && this.codeElementsRe.test(nn)) |
|
4895 |
h += n.innerHTML; |
|
4896 |
} |
|
4897 |
break; |
|
4898 |
||
4899 |
case 3: // Text |
|
4900 |
if (st) |
|
4901 |
break; |
|
4902 |
||
4903 |
if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName)) |
|
4904 |
return this.isIE ? '' : n.nodeValue; |
|
4905 |
||
4906 |
return this.xmlEncode(n.nodeValue); |
|
4907 |
||
4908 |
case 8: // Comment |
|
4909 |
if (st) |
|
4910 |
break; |
|
4911 |
||
4912 |
return "<!--" + this._trimComment(n.nodeValue) + "-->"; |
|
4913 |
} |
|
4914 |
||
4915 |
if (hc) { |
|
4916 |
cn = n.childNodes; |
|
4917 |
||
4918 |
for (i=0, l=cn.length; i<l; i++) |
|
4919 |
h += this.serializeNodeAsHTML(cn[i]); |
|
4920 |
} |
|
4921 |
||
4922 |
// Fill empty nodes |
|
4923 |
if (f && !hc) |
|
4924 |
h += this.fillStr; |
|
4925 |
||
4926 |
// End element |
|
4927 |
if (t != null && va) |
|
4928 |
h += '</' + en + '>'; |
|
4929 |
||
4930 |
return h; |
|
4931 |
}, |
|
4932 |
||
4933 |
_serializeAttribute : function(n, r, an) { |
|
4934 |
var av = '', t, os = this.settings.on_save; |
|
4935 |
||
4936 |
if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0)) |
|
4937 |
return ''; |
|
4938 |
||
4939 |
if (os && this.mceAttribs[an]) |
|
4940 |
av = this._getAttrib(n, this.mceAttribs[an]); |
|
4941 |
||
4942 |
if (av.length == 0) |
|
4943 |
av = this._getAttrib(n, an); |
|
4944 |
||
4945 |
if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) { |
|
4946 |
av = t; |
|
4947 |
||
4948 |
if (av == "mce_empty") |
|
4949 |
return " " + an + '=""'; |
|
4950 |
} |
|
4951 |
||
4952 |
if (r.forceAttribs && (t = r.forceAttribs[an])) |
|
4953 |
av = t; |
|
4954 |
||
4955 |
if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an)) |
|
4956 |
av = this._urlConverter(this, n, av); |
|
4957 |
||
4958 |
if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av)) |
|
4959 |
return ""; |
|
4960 |
||
4961 |
if (av.length != 0 && av == "{$uid}") |
|
4962 |
av = "uid_" + (this.idCount++); |
|
4963 |
||
4964 |
if (av.length != 0) { |
|
4965 |
if (an.indexOf('on') != 0) |
|
4966 |
av = this.xmlEncode(av, 1); |
|
4967 |
||
4968 |
return " " + an + "=" + '"' + av + '"'; |
|
4969 |
} |
|
4970 |
||
4971 |
return ""; |
|
4972 |
}, |
|
4973 |
||
4974 |
formatHTML : function(h) { |
|
4975 |
var s = this.settings, p = '', i = 0, li = 0, o = '', l; |
|
4976 |
||
4977 |
// Replace BR in pre elements to \n |
|
4978 |
h = h.replace(/<pre([^>]*)>(.*?)<\/pre>/gi, function (a, b, c) { |
|
4979 |
c = c.replace(/<br\s*\/>/gi, '\n'); |
|
4980 |
return '<pre' + b + '>' + c + '</pre>'; |
|
4981 |
}); |
|
4982 |
||
4983 |
h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :) |
|
4984 |
h = '\n' + h; |
|
4985 |
h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting |
|
4986 |
h = h.replace(this.nlBeforeRe, '\n<$1$2>'); |
|
4987 |
h = h.replace(this.nlAfterRe, '<$1$2>\n'); |
|
4988 |
h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n'); |
|
4989 |
h += '\n'; |
|
4990 |
||
4991 |
//tinyMCE.debug(h); |
|
4992 |
||
4993 |
while ((i = h.indexOf('\n', i + 1)) != -1) { |
|
4994 |
if ((l = h.substring(li + 1, i)).length != 0) { |
|
4995 |
if (this.ouRe.test(l) && p.length >= s.indent_levels) |
|
4996 |
p = p.substring(s.indent_levels); |
|
4997 |
||
4998 |
o += p + l + '\n'; |
|
4999 |
||
5000 |
if (this.inRe.test(l)) |
|
5001 |
p += this.inStr; |
|
5002 |
} |
|
5003 |
||
5004 |
li = i; |
|
5005 |
} |
|
5006 |
||
5007 |
//tinyMCE.debug(h); |
|
5008 |
||
5009 |
return o; |
|
5010 |
}, |
|
5011 |
||
5012 |
xmlEncode : function(s, skip_apos) { |
|
5013 |
var cl = this, re = !skip_apos ? this.xmlEncodeAposRe : this.xmlEncodeRe; |
|
5014 |
||
5015 |
this._setupEntities(); // Will intialize lookup table |
|
5016 |
||
5017 |
switch (this.settings.entity_encoding) { |
|
5018 |
case "raw": |
|
5019 |
return tinyMCE.xmlEncode(s, skip_apos); |
|
5020 |
||
5021 |
case "named": |
|
5022 |
return s.replace(re, function (c, b) { |
|
5023 |
b = cl.entities[c.charCodeAt(0)]; |
|
5024 |
||
5025 |
return b ? '&' + b + ';' : c; |
|
5026 |
}); |
|
5027 |
||
5028 |
case "numeric": |
|
5029 |
return s.replace(re, function (c, b) { |
|
5030 |
return b ? '&#' + c.charCodeAt(0) + ';' : c; |
|
5031 |
}); |
|
5032 |
} |
|
5033 |
||
5034 |
return s; |
|
5035 |
}, |
|
5036 |
||
5037 |
split : function(re, s) { |
|
5038 |
var c = s.split(re); |
|
5039 |
var i, l, o = new Array(); |
|
5040 |
||
5041 |
for (i=0, l=c.length; i<l; i++) { |
|
5042 |
if (c[i] != '') |
|
5043 |
o[i] = c[i]; |
|
5044 |
} |
|
5045 |
||
5046 |
return o; |
|
5047 |
}, |
|
5048 |
||
5049 |
_trimComment : function(s) { |
|
5050 |
// Remove mce_src, mce_href |
|
5051 |
s = s.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), ""); |
|
5052 |
s = s.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), ""); |
|
5053 |
||
5054 |
return s; |
|
5055 |
}, |
|
5056 |
||
5057 |
_getAttrib : function(e, n, d) { |
|
5058 |
var v, ex, nn; |
|
5059 |
||
5060 |
if (typeof(d) == "undefined") |
|
5061 |
d = ""; |
|
5062 |
||
5063 |
if (!e || e.nodeType != 1) |
|
5064 |
return d; |
|
5065 |
||
5066 |
try { |
|
5067 |
v = e.getAttribute(n, 0); |
|
5068 |
} catch (ex) { |
|
5069 |
// IE 7 may cast exception on invalid attributes |
|
5070 |
v = e.getAttribute(n, 2); |
|
5071 |
} |
|
5072 |
||
5073 |
if (n == "class" && !v) |
|
5074 |
v = e.className; |
|
5075 |
||
5076 |
if (this.isIE) { |
|
5077 |
if (n == "http-equiv") |
|
5078 |
v = e.httpEquiv; |
|
5079 |
||
5080 |
nn = e.nodeName; |
|
5081 |
||
5082 |
// Skip the default values that IE returns |
|
5083 |
if (nn == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded") |
|
5084 |
v = ""; |
|
5085 |
||
5086 |
if (nn == "INPUT" && n == "size" && v == "20") |
|
5087 |
v = ""; |
|
5088 |
||
5089 |
if (nn == "INPUT" && n == "maxlength" && v == "2147483647") |
|
5090 |
v = ""; |
|
5091 |
} |
|
5092 |
||
5093 |
if (n == 'style' && v) { |
|
5094 |
if (!tinyMCE.isOpera) |
|
5095 |
v = e.style.cssText; |
|
5096 |
||
5097 |
v = tinyMCE.serializeStyle(tinyMCE.parseStyle(v)); |
|
5098 |
} |
|
5099 |
||
5100 |
if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v != "") |
|
5101 |
v = tinyMCE.cleanupEventStr(v); |
|
5102 |
||
5103 |
return (v && v != "") ? '' + v : d; |
|
5104 |
}, |
|
5105 |
||
5106 |
_urlConverter : function(c, n, v) { |
|
5107 |
if (!c.settings.on_save) |
|
5108 |
return tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, v); |
|
5109 |
else if (tinyMCE.getParam('convert_urls')) { |
|
5110 |
if (!this.urlConverter) |
|
5111 |
this.urlConverter = eval(tinyMCE.settings.urlconverter_callback); |
|
5112 |
||
5113 |
return this.urlConverter(v, n, true); |
|
5114 |
} |
|
5115 |
||
5116 |
return v; |
|
5117 |
}, |
|
5118 |
||
5119 |
_arrayToRe : function(a, op, be, af) { |
|
5120 |
var i, r; |
|
5121 |
||
5122 |
op = typeof(op) == "undefined" ? "gi" : op; |
|
5123 |
be = typeof(be) == "undefined" ? "^(" : be; |
|
5124 |
af = typeof(af) == "undefined" ? ")$" : af; |
|
5125 |
||
5126 |
r = be; |
|
5127 |
||
5128 |
for (i=0; i<a.length; i++) |
|
5129 |
r += this._wildcardToRe(a[i]) + (i != a.length-1 ? "|" : ""); |
|
5130 |
||
5131 |
r += af; |
|
5132 |
||
5133 |
return new RegExp(r, op); |
|
5134 |
}, |
|
5135 |
||
5136 |
_wildcardToRe : function(s) { |
|
5137 |
s = s.replace(/\?/g, '(\\S?)'); |
|
5138 |
s = s.replace(/\+/g, '(\\S+)'); |
|
5139 |
s = s.replace(/\*/g, '(\\S*)'); |
|
5140 |
||
5141 |
return s; |
|
5142 |
}, |
|
5143 |
||
5144 |
_setupEntities : function() { |
|
5145 |
var n, a, i, s = this.settings; |
|
5146 |
||
5147 |
// Setup entities |
|
5148 |
if (!this.entitiesDone) { |
|
5149 |
if (s.entity_encoding == "named") { |
|
5150 |
n = tinyMCE.clearArray(new Array()); |
|
5151 |
a = this.split(',', s.entities); |
|
5152 |
for (i=0; i<a.length; i+=2) |
|
5153 |
n[a[i]] = a[i+1]; |
|
5154 |
||
5155 |
this.entities = n; |
|
5156 |
} |
|
5157 |
||
5158 |
this.entitiesDone = true; |
|
5159 |
} |
|
5160 |
}, |
|
5161 |
||
5162 |
_setupRules : function() { |
|
5163 |
var s = this.settings; |
|
5164 |
||
5165 |
// Setup default rule |
|
5166 |
if (!this.rulesDone) { |
|
5167 |
this.addRuleStr(s.valid_elements); |
|
5168 |
this.addRuleStr(s.extended_valid_elements); |
|
5169 |
this.addChildRemoveRuleStr(s.valid_child_elements); |
|
5170 |
||
5171 |
this.rulesDone = true; |
|
5172 |
} |
|
5173 |
}, |
|
5174 |
||
5175 |
_isDuplicate : function(n) { |
|
5176 |
var i; |
|
5177 |
||
5178 |
if (!this.settings.fix_content_duplication) |
|
5179 |
return false; |
|
5180 |
||
5181 |
if (tinyMCE.isRealIE && n.nodeType == 1) { |
|
5182 |
// Mark elements |
|
5183 |
if (n.mce_serialized == this.serializationId) |
|
5184 |
return true; |
|
5185 |
||
5186 |
n.setAttribute('mce_serialized', this.serializationId); |
|
5187 |
} else { |
|
5188 |
// Search lookup table for text nodes and comments |
|
5189 |
for (i=0; i<this.serializedNodes.length; i++) { |
|
5190 |
if (this.serializedNodes[i] == n) |
|
5191 |
return true; |
|
5192 |
} |
|
5193 |
||
5194 |
this.serializedNodes[this.serializedNodes.length] = n; |
|
5195 |
} |
|
5196 |
||
5197 |
return false; |
|
5198 |
} |
|
5199 |
||
5200 |
}; |
|
5201 |
||
5202 |
/* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */ |
|
5203 |
||
5204 |
TinyMCE_Engine.prototype.createTagHTML = function(tn, a, h) { |
|
5205 |
var o = '', f = tinyMCE.xmlEncode; |
|
5206 |
||
5207 |
o = '<' + tn; |
|
5208 |
||
5209 |
if (a) { |
|
5210 |
for (n in a) { |
|
5211 |
if (typeof(a[n]) != 'function' && a[n] != null) |
|
5212 |
o += ' ' + f(n) + '="' + f('' + a[n]) + '"'; |
|
5213 |
} |
|
5214 |
} |
|
5215 |
||
5216 |
o += !h ? ' />' : '>' + h + '</' + tn + '>'; |
|
5217 |
||
5218 |
return o; |
|
5219 |
}; |
|
5220 |
||
5221 |
TinyMCE_Engine.prototype.createTag = function(d, tn, a, h) { |
|
5222 |
var o = d.createElement(tn); |
|
5223 |
||
5224 |
if (a) { |
|
5225 |
for (n in a) { |
|
5226 |
if (typeof(a[n]) != 'function' && a[n] != null) |
|
5227 |
tinyMCE.setAttrib(o, n, a[n]); |
|
5228 |
} |
|
5229 |
} |
|
5230 |
||
5231 |
if (h) |
|
5232 |
o.innerHTML = h; |
|
5233 |
||
5234 |
return o; |
|
5235 |
}; |
|
5236 |
||
5237 |
TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) { |
|
5238 |
return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0]; |
|
5239 |
}; |
|
5240 |
||
5241 |
TinyMCE_Engine.prototype.getElementsByAttributeValue = function(n, e, a, v) { |
|
5242 |
var i, nl = n.getElementsByTagName(e), o = new Array(); |
|
5243 |
||
5244 |
for (i=0; i<nl.length; i++) { |
|
5245 |
if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1) |
|
5246 |
o[o.length] = nl[i]; |
|
5247 |
} |
|
5248 |
||
5249 |
return o; |
|
5250 |
}; |
|
5251 |
||
5252 |
TinyMCE_Engine.prototype.isBlockElement = function(n) { |
|
5253 |
return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName); |
|
5254 |
}; |
|
5255 |
||
5256 |
TinyMCE_Engine.prototype.getParentBlockElement = function(n, r) { |
|
5257 |
return this.getParentNode(n, function(n) { |
|
5258 |
return tinyMCE.isBlockElement(n); |
|
5259 |
}, r); |
|
5260 |
||
5261 |
return null; |
|
5262 |
}; |
|
5263 |
||
5264 |
TinyMCE_Engine.prototype.insertAfter = function(n, r){ |
|
5265 |
if (r.nextSibling) |
|
5266 |
r.parentNode.insertBefore(n, r.nextSibling); |
|
5267 |
else |
|
5268 |
r.parentNode.appendChild(n); |
|
5269 |
}; |
|
5270 |
||
5271 |
TinyMCE_Engine.prototype.setInnerHTML = function(e, h) { |
|
5272 |
var i, nl, n; |
|
5273 |
||
5274 |
// Convert all strong/em to b/i in Gecko |
|
5275 |
if (tinyMCE.isGecko) { |
|
5276 |
h = h.replace(/<embed([^>]*)>/gi, '<tmpembed$1>'); |
|
5277 |
h = h.replace(/<em([^>]*)>/gi, '<i$1>'); |
|
5278 |
h = h.replace(/<tmpembed([^>]*)>/gi, '<embed$1>'); |
|
5279 |
h = h.replace(/<strong([^>]*)>/gi, '<b$1>'); |
|
5280 |
h = h.replace(/<\/strong>/gi, '</b>'); |
|
5281 |
h = h.replace(/<\/em>/gi, '</i>'); |
|
5282 |
} |
|
5283 |
||
5284 |
if (tinyMCE.isRealIE) { |
|
5285 |
// Since MSIE handles invalid HTML better that valid XHTML we |
|
5286 |
// need to make some things invalid. <hr /> gets converted to <hr>. |
|
5287 |
h = h.replace(/\s\/>/g, '>'); |
|
5288 |
||
5289 |
// Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones |
|
5290 |
h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs |
|
5291 |
h = h.replace(/<p([^>]*)>\s* \s*<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs |
|
5292 |
h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs |
|
5293 |
||
5294 |
// Remove first comment |
|
5295 |
e.innerHTML = tinyMCE.uniqueTag + h; |
|
5296 |
e.firstChild.removeNode(true); |
|
5297 |
||
5298 |
// Remove weird auto generated empty paragraphs unless it's supposed to be there |
|
5299 |
nl = e.getElementsByTagName("p"); |
|
5300 |
for (i=nl.length-1; i>=0; i--) { |
|
5301 |
n = nl[i]; |
|
5302 |
||
5303 |
if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) |
|
5304 |
n.parentNode.removeChild(n); |
|
5305 |
} |
|
5306 |
} else { |
|
5307 |
h = this.fixGeckoBaseHREFBug(1, e, h); |
|
5308 |
e.innerHTML = h; |
|
5309 |
this.fixGeckoBaseHREFBug(2, e, h); |
|
5310 |
} |
|
5311 |
}; |
|
5312 |
||
5313 |
TinyMCE_Engine.prototype.getOuterHTML = function(e) { |
|
5314 |
if (tinyMCE.isIE) |
|
5315 |
return e.outerHTML; |
|
5316 |
||
5317 |
var d = e.ownerDocument.createElement("body"); |
|
5318 |
d.appendChild(e.cloneNode(true)); |
|
5319 |
return d.innerHTML; |
|
5320 |
}; |
|
5321 |
||
5322 |
TinyMCE_Engine.prototype.setOuterHTML = function(e, h, d) { |
|
5323 |
var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t; |
|
5324 |
||
5325 |
if (tinyMCE.isIE && e.nodeType == 1) |
|
5326 |
e.outerHTML = h; |
|
5327 |
else { |
|
5328 |
t = d.createElement("body"); |
|
5329 |
t.innerHTML = h; |
|
5330 |
||
5331 |
for (i=0, nl=t.childNodes; i<nl.length; i++) |
|
5332 |
e.parentNode.insertBefore(nl[i].cloneNode(true), e); |
|
5333 |
||
5334 |
e.parentNode.removeChild(e); |
|
5335 |
} |
|
5336 |
}; |
|
5337 |
||
5338 |
TinyMCE_Engine.prototype._getElementById = function(id, d) { |
|
5339 |
var e, i, j, f; |
|
5340 |
||
5341 |
if (typeof(d) == "undefined") |
|
5342 |
d = document; |
|
5343 |
||
5344 |
e = d.getElementById(id); |
|
5345 |
if (!e) { |
|
5346 |
f = d.forms; |
|
5347 |
||
5348 |
for (i=0; i<f.length; i++) { |
|
5349 |
for (j=0; j<f[i].elements.length; j++) { |
|
5350 |
if (f[i].elements[j].name == id) { |
|
5351 |
e = f[i].elements[j]; |
|
5352 |
break; |
|
5353 |
} |
|
5354 |
} |
|
5355 |
} |
|
5356 |
} |
|
5357 |
||
5358 |
return e; |
|
5359 |
}; |
|
5360 |
||
5361 |
TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) { |
|
5362 |
return this.selectNodes(n, function(n) { |
|
5363 |
return (!t || n.nodeType == t) && (!nn || n.nodeName == nn); |
|
5364 |
}, na ? na : new Array()); |
|
5365 |
}; |
|
5366 |
||
5367 |
TinyMCE_Engine.prototype.getParentElement = function(n, na, f, r) { |
|
5368 |
var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v; |
|
5369 |
||
5370 |
// Compatiblity with old scripts where f param was a attribute string |
|
5371 |
if (f && typeof(f) == 'string') |
|
5372 |
return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) != '';}); |
|
5373 |
||
5374 |
return this.getParentNode(n, function(n) { |
|
5375 |
return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n)); |
|
5376 |
}, r); |
|
5377 |
}; |
|
5378 |
||
5379 |
TinyMCE_Engine.prototype.getParentNode = function(n, f, r) { |
|
5380 |
while (n) { |
|
5381 |
if (n == r) |
|
5382 |
return null; |
|
5383 |
||
5384 |
if (f(n)) |
|
5385 |
return n; |
|
5386 |
||
5387 |
n = n.parentNode; |
|
5388 |
} |
|
5389 |
||
5390 |
return null; |
|
5391 |
}; |
|
5392 |
||
5393 |
TinyMCE_Engine.prototype.getAttrib = function(elm, name, dv) { |
|
5394 |
var v; |
|
5395 |
||
5396 |
if (typeof(dv) == "undefined") |
|
5397 |
dv = ""; |
|
5398 |
||
5399 |
// Not a element |
|
5400 |
if (!elm || elm.nodeType != 1) |
|
5401 |
return dv; |
|
5402 |
||
5403 |
try { |
|
5404 |
v = elm.getAttribute(name, 0); |
|
5405 |
} catch (ex) { |
|
5406 |
// IE 7 may cast exception on invalid attributes |
|
5407 |
v = elm.getAttribute(name, 2); |
|
5408 |
} |
|
5409 |
||
5410 |
// Try className for class attrib |
|
5411 |
if (name == "class" && !v) |
|
5412 |
v = elm.className; |
|
5413 |
||
5414 |
// Workaround for a issue with Firefox 1.5rc2+ |
|
5415 |
if (tinyMCE.isGecko && name == "src" && elm.src != null && elm.src != "") |
|
5416 |
v = elm.src; |
|
5417 |
||
5418 |
// Workaround for a issue with Firefox 1.5rc2+ |
|
5419 |
if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "") |
|
5420 |
v = elm.href; |
|
5421 |
||
5422 |
if (name == "http-equiv" && tinyMCE.isIE) |
|
5423 |
v = elm.httpEquiv; |
|
5424 |
||
5425 |
if (name == "style" && !tinyMCE.isOpera) |
|
5426 |
v = elm.style.cssText; |
|
5427 |
||
5428 |
return (v && v != "") ? v : dv; |
|
5429 |
}; |
|
5430 |
||
5431 |
TinyMCE_Engine.prototype.setAttrib = function(el, name, va, fix) { |
|
5432 |
if (typeof(va) == "number" && va != null) |
|
5433 |
va = "" + va; |
|
5434 |
||
5435 |
if (fix) { |
|
5436 |
if (va == null) |
|
5437 |
va = ""; |
|
5438 |
||
5439 |
va = va.replace(/[^0-9%]/g, ''); |
|
5440 |
} |
|
5441 |
||
5442 |
if (name == "style") |
|
5443 |
el.style.cssText = va; |
|
5444 |
||
5445 |
if (name == "class") |
|
5446 |
el.className = va; |
|
5447 |
||
5448 |
if (va != null && va != "" && va != -1) |
|
5449 |
el.setAttribute(name, va); |
|
5450 |
else |
|
5451 |
el.removeAttribute(name); |
|
5452 |
}; |
|
5453 |
||
5454 |
TinyMCE_Engine.prototype.setStyleAttrib = function(e, n, v) { |
|
5455 |
e.style[n] = v; |
|
5456 |
||
5457 |
// Style attrib deleted in IE |
|
5458 |
if (tinyMCE.isIE && v == null || v == '') { |
|
5459 |
v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText)); |
|
5460 |
e.style.cssText = v; |
|
5461 |
e.setAttribute("style", v); |
|
5462 |
} |
|
5463 |
}; |
|
5464 |
||
5465 |
TinyMCE_Engine.prototype.switchClass = function(ei, c) { |
|
5466 |
var e; |
|
5467 |
||
5468 |
if (tinyMCE.switchClassCache[ei]) |
|
5469 |
e = tinyMCE.switchClassCache[ei]; |
|
5470 |
else |
|
5471 |
e = tinyMCE.switchClassCache[ei] = document.getElementById(ei); |
|
5472 |
||
5473 |
if (e) { |
|
5474 |
// Keep tile mode |
|
5475 |
if (tinyMCE.settings.button_tile_map && e.className && e.className.indexOf('mceTiledButton') == 0) |
|
5476 |
c = 'mceTiledButton ' + c; |
|
5477 |
||
5478 |
e.className = c; |
|
5479 |
} |
|
5480 |
}; |
|
5481 |
||
5482 |
TinyMCE_Engine.prototype.getAbsPosition = function(n, cn) { |
|
5483 |
var l = 0, t = 0; |
|
5484 |
||
5485 |
while (n && n != cn) { |
|
5486 |
l += n.offsetLeft; |
|
5487 |
t += n.offsetTop; |
|
5488 |
n = n.offsetParent; |
|
5489 |
} |
|
5490 |
||
5491 |
return {absLeft : l, absTop : t}; |
|
5492 |
}; |
|
5493 |
||
5494 |
TinyMCE_Engine.prototype.prevNode = function(e, n) { |
|
5495 |
var a = n.split(','), i; |
|
5496 |
||
5497 |
while ((e = e.previousSibling) != null) { |
|
5498 |
for (i=0; i<a.length; i++) { |
|
5499 |
if (e.nodeName == a[i]) |
|
5500 |
return e; |
|
5501 |
} |
|
5502 |
} |
|
5503 |
||
5504 |
return null; |
|
5505 |
}; |
|
5506 |
||
5507 |
TinyMCE_Engine.prototype.nextNode = function(e, n) { |
|
5508 |
var a = n.split(','), i; |
|
5509 |
||
5510 |
while ((e = e.nextSibling) != null) { |
|
5511 |
for (i=0; i<a.length; i++) { |
|
5512 |
if (e.nodeName == a[i]) |
|
5513 |
return e; |
|
5514 |
} |
|
5515 |
} |
|
5516 |
||
5517 |
return null; |
|
5518 |
}; |
|
5519 |
||
5520 |
TinyMCE_Engine.prototype.selectElements = function(n, na, f) { |
|
5521 |
var i, a = [], nl, x; |
|
5522 |
||
5523 |
for (x=0, na = na.split(','); x<na.length; x++) |
|
5524 |
for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++) |
|
5525 |
(!f || f(nl[i])) && a.push(nl[i]); |
|
5526 |
||
5527 |
return a; |
|
5528 |
}; |
|
5529 |
||
5530 |
TinyMCE_Engine.prototype.selectNodes = function(n, f, a) { |
|
5531 |
var i; |
|
5532 |
||
5533 |
if (!a) |
|
5534 |
a = new Array(); |
|
5535 |
||
5536 |
if (f(n)) |
|
5537 |
a[a.length] = n; |
|
5538 |
||
5539 |
if (n.hasChildNodes()) { |
|
5540 |
for (i=0; i<n.childNodes.length; i++) |
|
5541 |
tinyMCE.selectNodes(n.childNodes[i], f, a); |
|
5542 |
} |
|
5543 |
||
5544 |
return a; |
|
5545 |
}; |
|
5546 |
||
5547 |
TinyMCE_Engine.prototype.addCSSClass = function(e, c, b) { |
|
5548 |
var o = this.removeCSSClass(e, c); |
|
5549 |
return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c; |
|
5550 |
}; |
|
5551 |
||
5552 |
TinyMCE_Engine.prototype.removeCSSClass = function(e, c) { |
|
5553 |
c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' '); |
|
5554 |
return e.className = c != ' ' ? c : ''; |
|
5555 |
}; |
|
5556 |
||
5557 |
TinyMCE_Engine.prototype.hasCSSClass = function(n, c) { |
|
5558 |
return new RegExp('\\b' + c + '\\b', 'g').test(n.className); |
|
5559 |
}; |
|
5560 |
||
5561 |
TinyMCE_Engine.prototype.renameElement = function(e, n, d) { |
|
5562 |
var ne, i, ar; |
|
5563 |
||
5564 |
d = typeof(d) == "undefined" ? tinyMCE.selectedInstance.getDoc() : d; |
|
5565 |
||
5566 |
if (e) { |
|
5567 |
ne = d.createElement(n); |
|
5568 |
||
5569 |
ar = e.attributes; |
|
5570 |
for (i=ar.length-1; i>-1; i--) { |
|
5571 |
if (ar[i].specified && ar[i].nodeValue) |
|
5572 |
ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); |
|
5573 |
} |
|
5574 |
||
5575 |
ar = e.childNodes; |
|
5576 |
for (i=0; i<ar.length; i++) |
|
5577 |
ne.appendChild(ar[i].cloneNode(true)); |
|
5578 |
||
5579 |
e.parentNode.replaceChild(ne, e); |
|
5580 |
} |
|
5581 |
}; |
|
5582 |
||
5583 |
TinyMCE_Engine.prototype.getViewPort = function(w) { |
|
5584 |
var d = w.document, m = d.compatMode == 'CSS1Compat', b = d.body, de = d.documentElement; |
|
5585 |
||
5586 |
return { |
|
5587 |
left : w.pageXOffset || (m ? de.scrollLeft : b.scrollLeft), |
|
5588 |
top : w.pageYOffset || (m ? de.scrollTop : b.scrollTop), |
|
5589 |
width : w.innerWidth || (m ? de.clientWidth : b.clientWidth), |
|
5590 |
height : w.innerHeight || (m ? de.clientHeight : b.clientHeight) |
|
5591 |
}; |
|
5592 |
}; |
|
5593 |
||
5594 |
TinyMCE_Engine.prototype.getStyle = function(n, na, d) { |
|
5595 |
if (!n) |
|
5596 |
return false; |
|
5597 |
||
5598 |
// Gecko |
|
5599 |
if (tinyMCE.isGecko && n.ownerDocument.defaultView) { |
|
5600 |
try { |
|
5601 |
return n.ownerDocument.defaultView.getComputedStyle(n, null).getPropertyValue(na); |
|
5602 |
} catch (n) { |
|
5603 |
// Old safari might fail |
|
5604 |
return null; |
|
5605 |
} |
|
5606 |
} |
|
5607 |
||
5608 |
// Camelcase it, if needed |
|
5609 |
na = na.replace(/-(\D)/g, function(a, b){ |
|
5610 |
return b.toUpperCase(); |
|
5611 |
}); |
|
5612 |
||
5613 |
// IE & Opera |
|
5614 |
if (n.currentStyle) |
|
5615 |
return n.currentStyle[na]; |
|
5616 |
||
5617 |
return false; |
|
5618 |
}; |
|
5619 |
||
5620 |
/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */ |
|
5621 |
||
5622 |
TinyMCE_Engine.prototype.parseURL = function(url_str) { |
|
5623 |
var urlParts = new Array(); |
|
5624 |
||
5625 |
if (url_str) { |
|
5626 |
var pos, lastPos; |
|
5627 |
||
5628 |
// Parse protocol part |
|
5629 |
pos = url_str.indexOf('://'); |
|
5630 |
if (pos != -1) { |
|
5631 |
urlParts['protocol'] = url_str.substring(0, pos); |
|
5632 |
lastPos = pos + 3; |
|
5633 |
} |
|
5634 |
||
5635 |
// Find port or path start |
|
5636 |
for (var i=lastPos; i<url_str.length; i++) { |
|
5637 |
var chr = url_str.charAt(i); |
|
5638 |
||
5639 |
if (chr == ':') |
|
5640 |
break; |
|
5641 |
||
5642 |
if (chr == '/') |
|
5643 |
break; |
|
5644 |
} |
|
5645 |
pos = i; |
|
5646 |
||
5647 |
// Get host |
|
5648 |
urlParts['host'] = url_str.substring(lastPos, pos); |
|
5649 |
||
5650 |
// Get port |
|
5651 |
urlParts['port'] = ""; |
|
5652 |
lastPos = pos; |
|
5653 |
if (url_str.charAt(pos) == ':') { |
|
5654 |
pos = url_str.indexOf('/', lastPos); |
|
5655 |
urlParts['port'] = url_str.substring(lastPos+1, pos); |
|
5656 |
} |
|
5657 |
||
5658 |
// Get path |
|
5659 |
lastPos = pos; |
|
5660 |
pos = url_str.indexOf('?', lastPos); |
|
5661 |
||
5662 |
if (pos == -1) |
|
5663 |
pos = url_str.indexOf('#', lastPos); |
|
5664 |
||
5665 |
if (pos == -1) |
|
5666 |
pos = url_str.length; |
|
5667 |
||
5668 |
urlParts['path'] = url_str.substring(lastPos, pos); |
|
5669 |
||
5670 |
// Get query |
|
5671 |
lastPos = pos; |
|
5672 |
if (url_str.charAt(pos) == '?') { |
|
5673 |
pos = url_str.indexOf('#'); |
|
5674 |
pos = (pos == -1) ? url_str.length : pos; |
|
5675 |
urlParts['query'] = url_str.substring(lastPos+1, pos); |
|
5676 |
} |
|
5677 |
||
5678 |
// Get anchor |
|
5679 |
lastPos = pos; |
|
5680 |
if (url_str.charAt(pos) == '#') { |
|
5681 |
pos = url_str.length; |
|
5682 |
urlParts['anchor'] = url_str.substring(lastPos+1, pos); |
|
5683 |
} |
|
5684 |
} |
|
5685 |
||
5686 |
return urlParts; |
|
5687 |
}; |
|
5688 |
||
5689 |
TinyMCE_Engine.prototype.serializeURL = function(up) { |
|
5690 |
var o = ""; |
|
5691 |
||
5692 |
if (up['protocol']) |
|
5693 |
o += up['protocol'] + "://"; |
|
5694 |
||
5695 |
if (up['host']) |
|
5696 |
o += up['host']; |
|
5697 |
||
5698 |
if (up['port']) |
|
5699 |
o += ":" + up['port']; |
|
5700 |
||
5701 |
if (up['path']) |
|
5702 |
o += up['path']; |
|
5703 |
||
5704 |
if (up['query']) |
|
5705 |
o += "?" + up['query']; |
|
5706 |
||
5707 |
if (up['anchor']) |
|
5708 |
o += "#" + up['anchor']; |
|
5709 |
||
5710 |
return o; |
|
5711 |
}; |
|
5712 |
||
5713 |
TinyMCE_Engine.prototype.convertAbsoluteURLToRelativeURL = function(base_url, url_to_relative) { |
|
5714 |
var baseURL = this.parseURL(base_url); |
|
5715 |
var targetURL = this.parseURL(url_to_relative); |
|
5716 |
var strTok1; |
|
5717 |
var strTok2; |
|
5718 |
var breakPoint = 0; |
|
5719 |
var outPath = ""; |
|
5720 |
var forceSlash = false; |
|
5721 |
||
5722 |
if (targetURL.path == "") |
|
5723 |
targetURL.path = "/"; |
|
5724 |
else |
|
5725 |
forceSlash = true; |
|
5726 |
||
5727 |
// Crop away last path part |
|
5728 |
base_url = baseURL.path.substring(0, baseURL.path.lastIndexOf('/')); |
|
5729 |
strTok1 = base_url.split('/'); |
|
5730 |
strTok2 = targetURL.path.split('/'); |
|
5731 |
||
5732 |
if (strTok1.length >= strTok2.length) { |
|
5733 |
for (var i=0; i<strTok1.length; i++) { |
|
5734 |
if (i >= strTok2.length || strTok1[i] != strTok2[i]) { |
|
5735 |
breakPoint = i + 1; |
|
5736 |
break; |
|
5737 |
} |
|
5738 |
} |
|
5739 |
} |
|
5740 |
||
5741 |
if (strTok1.length < strTok2.length) { |
|
5742 |
for (var i=0; i<strTok2.length; i++) { |
|
5743 |
if (i >= strTok1.length || strTok1[i] != strTok2[i]) { |
|
5744 |
breakPoint = i + 1; |
|
5745 |
break; |
|
5746 |
} |
|
5747 |
} |
|
5748 |
} |
|
5749 |
||
5750 |
if (breakPoint == 1) |
|
5751 |
return targetURL.path; |
|
5752 |
||
5753 |
for (var i=0; i<(strTok1.length-(breakPoint-1)); i++) |
|
5754 |
outPath += "../"; |
|
5755 |
||
5756 |
for (var i=breakPoint-1; i<strTok2.length; i++) { |
|
5757 |
if (i != (breakPoint-1)) |
|
5758 |
outPath += "/" + strTok2[i]; |
|
5759 |
else |
|
5760 |
outPath += strTok2[i]; |
|
5761 |
} |
|
5762 |
||
5763 |
targetURL.protocol = null; |
|
5764 |
targetURL.host = null; |
|
5765 |
targetURL.port = null; |
|
5766 |
targetURL.path = outPath == "" && forceSlash ? "/" : outPath; |
|
5767 |
||
5768 |
// Remove document prefix from local anchors |
|
5769 |
var fileName = baseURL.path; |
|
5770 |
var pos; |
|
5771 |
||
5772 |
if ((pos = fileName.lastIndexOf('/')) != -1) |
|
5773 |
fileName = fileName.substring(pos + 1); |
|
5774 |
||
5775 |
// Is local anchor |
|
5776 |
if (fileName == targetURL.path && targetURL.anchor != "") |
|
5777 |
targetURL.path = ""; |
|
5778 |
||
5779 |
// If empty and not local anchor force filename or slash |
|
5780 |
if (targetURL.path == "" && !targetURL.anchor) |
|
5781 |
targetURL.path = fileName != "" ? fileName : "/"; |
|
5782 |
||
5783 |
return this.serializeURL(targetURL); |
|
5784 |
}; |
|
5785 |
||
5786 |
TinyMCE_Engine.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) { |
|
5787 |
var baseURL = this.parseURL(base_url), baseURLParts, relURLParts; |
|
5788 |
var relURL = this.parseURL(relative_url); |
|
5789 |
||
5790 |
if (relative_url == "" || relative_url.indexOf('://') != -1 || /^(mailto:|javascript:|#|\/)/.test(relative_url)) |
|
5791 |
return relative_url; |
|
5792 |
||
5793 |
// Split parts |
|
5794 |
baseURLParts = baseURL['path'].split('/'); |
|
5795 |
relURLParts = relURL['path'].split('/'); |
|
5796 |
||
5797 |
// Remove empty chunks |
|
5798 |
var newBaseURLParts = new Array(); |
|
5799 |
for (var i=baseURLParts.length-1; i>=0; i--) { |
|
5800 |
if (baseURLParts[i].length == 0) |
|
5801 |
continue; |
|
5802 |
||
5803 |
newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; |
|
5804 |
} |
|
5805 |
baseURLParts = newBaseURLParts.reverse(); |
|
5806 |
||
5807 |
// Merge relURLParts chunks |
|
5808 |
var newRelURLParts = new Array(); |
|
5809 |
var numBack = 0; |
|
5810 |
for (var i=relURLParts.length-1; i>=0; i--) { |
|
5811 |
if (relURLParts[i].length == 0 || relURLParts[i] == ".") |
|
5812 |
continue; |
|
5813 |
||
5814 |
if (relURLParts[i] == '..') { |
|
5815 |
numBack++; |
|
5816 |
continue; |
|
5817 |
} |
|
5818 |
||
5819 |
if (numBack > 0) { |
|
5820 |
numBack--; |
|
5821 |
continue; |
|
5822 |
} |
|
5823 |
||
5824 |
newRelURLParts[newRelURLParts.length] = relURLParts[i]; |
|
5825 |
} |
|
5826 |
||
5827 |
relURLParts = newRelURLParts.reverse(); |
|
5828 |
||
5829 |
// Remove end from absolute path |
|
5830 |
var len = baseURLParts.length-numBack; |
|
5831 |
var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); |
|
5832 |
var start = "", end = ""; |
|
5833 |
||
5834 |
// Build output URL |
|
5835 |
relURL.protocol = baseURL.protocol; |
|
5836 |
relURL.host = baseURL.host; |
|
5837 |
relURL.port = baseURL.port; |
|
5838 |
||
5839 |
// Re-add trailing slash if it's removed |
|
5840 |
if (relURL.path.charAt(relURL.path.length-1) == "/") |
|
5841 |
absPath += "/"; |
|
5842 |
||
5843 |
relURL.path = absPath; |
|
5844 |
||
5845 |
return this.serializeURL(relURL); |
|
5846 |
}; |
|
5847 |
||
5848 |
TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) { |
|
5849 |
var prot = document.location.protocol; |
|
5850 |
var host = document.location.hostname; |
|
5851 |
var port = document.location.port; |
|
5852 |
||
5853 |
// Pass through file protocol |
|
5854 |
if (prot == "file:") |
|
5855 |
return url; |
|
5856 |
||
5857 |
// Something is wrong, remove weirdness |
|
5858 |
url = tinyMCE.regexpReplace(url, '(http|https):///', '/'); |
|
5859 |
||
5860 |
// Mailto link or anchor (Pass through) |
|
5861 |
if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || tinyMCE.regexpReplace(url,'[ \t\r\n\+]|%20','').charAt(0) == "#") |
|
5862 |
return url; |
|
5863 |
||
5864 |
// Fix relative/Mozilla |
|
5865 |
if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/') |
|
5866 |
return tinyMCE.settings['base_href'] + url; |
|
5867 |
||
5868 |
// Handle relative URLs |
|
5869 |
if (on_save && tinyMCE.getParam('relative_urls')) { |
|
5870 |
var curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url); |
|
5871 |
if (curl.charAt(0) == '/') |
|
5872 |
curl = tinyMCE.settings['document_base_prefix'] + curl; |
|
5873 |
||
5874 |
var urlParts = tinyMCE.parseURL(curl); |
|
5875 |
var tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings['document_base_url']); |
|
5876 |
||
5877 |
// Force relative |
|
5878 |
if (urlParts['host'] == tmpUrlParts['host'] && (urlParts['port'] == tmpUrlParts['port'])) |
|
5879 |
return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings['document_base_url'], curl); |
|
5880 |
} |
|
5881 |
||
5882 |
// Handle absolute URLs |
|
5883 |
if (!tinyMCE.getParam('relative_urls')) { |
|
5884 |
var urlParts = tinyMCE.parseURL(url); |
|
5885 |
var baseUrlParts = tinyMCE.parseURL(tinyMCE.settings['base_href']); |
|
5886 |
||
5887 |
// Force absolute URLs from relative URLs |
|
5888 |
url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url); |
|
5889 |
||
5890 |
// If anchor and path is the same page |
|
5891 |
if (urlParts['anchor'] && urlParts['path'] == baseUrlParts['path']) |
|
5892 |
return "#" + urlParts['anchor']; |
|
5893 |
} |
|
5894 |
||
5895 |
// Remove current domain |
|
5896 |
if (tinyMCE.getParam('remove_script_host')) { |
|
5897 |
var start = "", portPart = ""; |
|
5898 |
||
5899 |
if (port != "") |
|
5900 |
portPart = ":" + port; |
|
5901 |
||
5902 |
start = prot + "//" + host + portPart + "/"; |
|
5903 |
||
5904 |
if (url.indexOf(start) == 0) |
|
5905 |
url = url.substring(start.length-1); |
|
5906 |
} |
|
5907 |
||
5908 |
return url; |
|
5909 |
}; |
|
5910 |
||
5911 |
TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) { |
|
5912 |
var i, elms, src, href, mhref, msrc; |
|
5913 |
||
5914 |
// Convert all image URL:s to absolute URL |
|
5915 |
elms = body.getElementsByTagName("img"); |
|
5916 |
for (i=0; i<elms.length; i++) { |
|
5917 |
src = tinyMCE.getAttrib(elms[i], 'src'); |
|
5918 |
||
5919 |
msrc = tinyMCE.getAttrib(elms[i], 'mce_src'); |
|
5920 |
if (msrc != "") |
|
5921 |
src = msrc; |
|
5922 |
||
5923 |
if (src != "") { |
|
5924 |
src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src); |
|
5925 |
elms[i].setAttribute("src", src); |
|
5926 |
} |
|
5927 |
} |
|
5928 |
||
5929 |
// Convert all link URL:s to absolute URL |
|
5930 |
elms = body.getElementsByTagName("a"); |
|
5931 |
for (i=0; i<elms.length; i++) { |
|
5932 |
href = tinyMCE.getAttrib(elms[i], 'href'); |
|
5933 |
||
5934 |
mhref = tinyMCE.getAttrib(elms[i], 'mce_href'); |
|
5935 |
if (mhref != "") |
|
5936 |
href = mhref; |
|
5937 |
||
5938 |
if (href && href != "") { |
|
5939 |
href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], href); |
|
5940 |
elms[i].setAttribute("href", href); |
|
5941 |
} |
|
5942 |
} |
|
5943 |
}; |
|
5944 |
||
5945 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Array.class.js */ |
|
5946 |
||
5947 |
TinyMCE_Engine.prototype.clearArray = function(a) { |
|
5948 |
var n; |
|
5949 |
||
5950 |
for (n in a) |
|
5951 |
a[n] = null; |
|
5952 |
||
5953 |
return a; |
|
5954 |
}; |
|
5955 |
||
5956 |
TinyMCE_Engine.prototype.explode = function(d, s) { |
|
5957 |
var ar = s.split(d), oar = new Array(), i; |
|
5958 |
||
5959 |
for (i = 0; i<ar.length; i++) { |
|
5960 |
if (ar[i] != "") |
|
5961 |
oar[oar.length] = ar[i]; |
|
5962 |
} |
|
5963 |
||
5964 |
return oar; |
|
5965 |
}; |
|
5966 |
||
5967 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */ |
|
5968 |
||
5969 |
TinyMCE_Engine.prototype._setEventsEnabled = function(node, state) { |
|
5970 |
var evs, x, y, elms, i, event; |
|
5971 |
var events = ['onfocus','onblur','onclick','ondblclick', |
|
5972 |
'onmousedown','onmouseup','onmouseover','onmousemove', |
|
5973 |
'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup']; |
|
5974 |
||
5975 |
evs = tinyMCE.settings['event_elements'].split(','); |
|
5976 |
for (y=0; y<evs.length; y++){ |
|
5977 |
elms = node.getElementsByTagName(evs[y]); |
|
5978 |
for (i=0; i<elms.length; i++) { |
|
5979 |
event = ""; |
|
5980 |
||
5981 |
for (x=0; x<events.length; x++) { |
|
5982 |
if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') { |
|
5983 |
event = tinyMCE.cleanupEventStr("" + event); |
|
5984 |
||
5985 |
if (!state) |
|
5986 |
event = "return true;" + event; |
|
5987 |
else |
|
5988 |
event = event.replace(/^return true;/gi, ''); |
|
5989 |
||
5990 |
elms[i].removeAttribute(events[x]); |
|
5991 |
elms[i].setAttribute(events[x], event); |
|
5992 |
} |
|
5993 |
} |
|
5994 |
} |
|
5995 |
} |
|
5996 |
}; |
|
5997 |
||
5998 |
TinyMCE_Engine.prototype._eventPatch = function(editor_id) { |
|
5999 |
var n, inst, win, e; |
|
6000 |
||
6001 |
// Remove odd, error |
|
6002 |
if (typeof(tinyMCE) == "undefined") |
|
6003 |
return true; |
|
6004 |
||
6005 |
try { |
|
6006 |
// Try selected instance first |
|
6007 |
if (tinyMCE.selectedInstance) { |
|
6008 |
win = tinyMCE.selectedInstance.getWin(); |
|
6009 |
||
6010 |
if (win && win.event) { |
|
6011 |
e = win.event; |
|
6012 |
||
6013 |
if (!e.target) |
|
6014 |
e.target = e.srcElement; |
|
6015 |
||
6016 |
TinyMCE_Engine.prototype.handleEvent(e); |
|
6017 |
return; |
|
6018 |
} |
|
6019 |
} |
|
6020 |
||
6021 |
// Search for it |
|
6022 |
for (n in tinyMCE.instances) { |
|
6023 |
inst = tinyMCE.instances[n]; |
|
6024 |
||
6025 |
if (!tinyMCE.isInstance(inst)) |
|
6026 |
continue; |
|
6027 |
||
6028 |
inst.select(); |
|
6029 |
win = inst.getWin(); |
|
6030 |
||
6031 |
if (win && win.event) { |
|
6032 |
e = win.event; |
|
6033 |
||
6034 |
if (!e.target) |
|
6035 |
e.target = e.srcElement; |
|
6036 |
||
6037 |
TinyMCE_Engine.prototype.handleEvent(e); |
|
6038 |
return; |
|
6039 |
} |
|
6040 |
} |
|
6041 |
} catch (ex) { |
|
6042 |
// Ignore error if iframe is pointing to external URL |
|
6043 |
} |
|
6044 |
}; |
|
6045 |
||
6046 |
TinyMCE_Engine.prototype.findEvent = function(e) { |
|
6047 |
var n, inst; |
|
6048 |
||
6049 |
if (e) |
|
6050 |
return e; |
|
6051 |
||
6052 |
for (n in tinyMCE.instances) { |
|
6053 |
inst = tinyMCE.instances[n]; |
|
6054 |
||
6055 |
if (tinyMCE.isInstance(inst) && inst.getWin().event) |
|
6056 |
return inst.getWin().event; |
|
6057 |
} |
|
6058 |
||
6059 |
return null; |
|
6060 |
}; |
|
6061 |
||
6062 |
TinyMCE_Engine.prototype.unloadHandler = function() { |
|
6063 |
tinyMCE.triggerSave(true, true); |
|
6064 |
}; |
|
6065 |
||
6066 |
TinyMCE_Engine.prototype.addEventHandlers = function(inst) { |
|
6067 |
this.setEventHandlers(inst, 1); |
|
6068 |
}; |
|
6069 |
||
6070 |
TinyMCE_Engine.prototype.setEventHandlers = function(inst, s) { |
|
6071 |
var doc = inst.getDoc(), ie, ot, i, f = s ? tinyMCE.addEvent : tinyMCE.removeEvent; |
|
6072 |
||
6073 |
ie = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick']; |
|
6074 |
ot = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'focus', 'blur', 'dragdrop']; |
|
6075 |
||
6076 |
inst.switchSettings(); |
|
6077 |
||
6078 |
if (tinyMCE.isIE) { |
|
6079 |
for (i=0; i<ie.length; i++) |
|
6080 |
f(doc, ie[i], TinyMCE_Engine.prototype._eventPatch); |
|
6081 |
} else { |
|
6082 |
for (i=0; i<ot.length; i++) |
|
6083 |
f(doc, ot[i], tinyMCE.handleEvent); |
|
6084 |
||
6085 |
// Force designmode |
|
6086 |
try { |
|
6087 |
doc.designMode = "On"; |
|
6088 |
} catch (e) { |
|
6089 |
// Ignore |
|
6090 |
} |
|
6091 |
} |
|
6092 |
}; |
|
6093 |
||
6094 |
TinyMCE_Engine.prototype.onMouseMove = function() { |
|
6095 |
var inst, lh; |
|
6096 |
||
6097 |
// Fix for IE7 bug where it's not restoring hover on anchors correctly |
|
6098 |
if (tinyMCE.lastHover) { |
|
6099 |
lh = tinyMCE.lastHover; |
|
6100 |
||
6101 |
// Call out on menus and refresh class on normal buttons |
|
6102 |
if (lh.className.indexOf('mceMenu') != -1) |
|
6103 |
tinyMCE._menuButtonEvent('out', lh); |
|
6104 |
else |
|
6105 |
lh.className = lh.className; |
|
6106 |
||
6107 |
tinyMCE.lastHover = null; |
|
6108 |
} |
|
6109 |
||
6110 |
if (!tinyMCE.hasMouseMoved) { |
|
6111 |
inst = tinyMCE.selectedInstance; |
|
6112 |
||
6113 |
// Workaround for bug #1437457 (Odd MSIE bug) |
|
6114 |
if (inst.isFocused) { |
|
6115 |
inst.undoBookmark = inst.selection.getBookmark(); |
|
6116 |
tinyMCE.hasMouseMoved = true; |
|
6117 |
} |
|
6118 |
} |
|
6119 |
||
6120 |
// tinyMCE.cancelEvent(inst.getWin().event); |
|
6121 |
// return false; |
|
6122 |
}; |
|
6123 |
||
6124 |
TinyMCE_Engine.prototype.cancelEvent = function(e) { |
|
6125 |
if (!e) |
|
6126 |
return false; |
|
6127 |
||
6128 |
if (tinyMCE.isIE) { |
|
6129 |
e.returnValue = false; |
|
6130 |
e.cancelBubble = true; |
|
6131 |
} else { |
|
6132 |
e.preventDefault(); |
|
6133 |
e.stopPropagation && e.stopPropagation(); |
|
6134 |
} |
|
6135 |
||
6136 |
return false; |
|
6137 |
}; |
|
6138 |
||
6139 |
TinyMCE_Engine.prototype.addEvent = function(o, n, h) { |
|
6140 |
// Add cleanup for all non unload events |
|
6141 |
if (n != 'unload') { |
|
6142 |
function clean() { |
|
6143 |
var ex; |
|
6144 |
||
6145 |
try { |
|
6146 |
tinyMCE.removeEvent(o, n, h); |
|
6147 |
tinyMCE.removeEvent(window, 'unload', clean); |
|
6148 |
o = n = h = null; |
|
6149 |
} catch (ex) { |
|
6150 |
// IE may produce access denied exception on unload |
|
6151 |
} |
|
6152 |
} |
|
6153 |
||
6154 |
// Add memory cleaner |
|
6155 |
tinyMCE.addEvent(window, 'unload', clean); |
|
6156 |
} |
|
6157 |
||
6158 |
if (o.attachEvent) |
|
6159 |
o.attachEvent("on" + n, h); |
|
6160 |
else |
|
6161 |
o.addEventListener(n, h, false); |
|
6162 |
}; |
|
6163 |
||
6164 |
TinyMCE_Engine.prototype.removeEvent = function(o, n, h) { |
|
6165 |
if (o.detachEvent) |
|
6166 |
o.detachEvent("on" + n, h); |
|
6167 |
else |
|
6168 |
o.removeEventListener(n, h, false); |
|
6169 |
}; |
|
6170 |
||
6171 |
TinyMCE_Engine.prototype.addSelectAccessibility = function(e, s, w) { |
|
6172 |
// Add event handlers |
|
6173 |
if (!s._isAccessible) { |
|
6174 |
s.onkeydown = tinyMCE.accessibleEventHandler; |
|
6175 |
s.onblur = tinyMCE.accessibleEventHandler; |
|
6176 |
s._isAccessible = true; |
|
6177 |
s._win = w; |
|
6178 |
} |
|
6179 |
||
6180 |
return false; |
|
6181 |
}; |
|
6182 |
||
6183 |
TinyMCE_Engine.prototype.accessibleEventHandler = function(e) { |
|
6184 |
var win = this._win; |
|
6185 |
e = tinyMCE.isIE ? win.event : e; |
|
6186 |
var elm = tinyMCE.isIE ? e.srcElement : e.target; |
|
6187 |
||
6188 |
// Unpiggyback onchange on blur |
|
6189 |
if (e.type == "blur") { |
|
6190 |
if (elm.oldonchange) { |
|
6191 |
elm.onchange = elm.oldonchange; |
|
6192 |
elm.oldonchange = null; |
|
6193 |
} |
|
6194 |
||
6195 |
return true; |
|
6196 |
} |
|
6197 |
||
6198 |
// Piggyback onchange |
|
6199 |
if (elm.nodeName == "SELECT" && !elm.oldonchange) { |
|
6200 |
elm.oldonchange = elm.onchange; |
|
6201 |
elm.onchange = null; |
|
6202 |
} |
|
6203 |
||
6204 |
// Execute onchange and remove piggyback |
|
6205 |
if (e.keyCode == 13 || e.keyCode == 32) { |
|
6206 |
elm.onchange = elm.oldonchange; |
|
6207 |
elm.onchange(); |
|
6208 |
elm.oldonchange = null; |
|
6209 |
||
6210 |
tinyMCE.cancelEvent(e); |
|
6211 |
return false; |
|
6212 |
} |
|
6213 |
||
6214 |
return true; |
|
6215 |
}; |
|
6216 |
||
6217 |
TinyMCE_Engine.prototype._resetIframeHeight = function() { |
|
6218 |
var ife; |
|
6219 |
||
6220 |
if (tinyMCE.isRealIE) { |
|
6221 |
ife = tinyMCE.selectedInstance.iframeElement; |
|
6222 |
||
6223 |
/* if (ife._oldWidth) { |
|
6224 |
ife.style.width = ife._oldWidth; |
|
6225 |
ife.width = ife._oldWidth; |
|
6226 |
}*/ |
|
6227 |
||
6228 |
if (ife._oldHeight) { |
|
6229 |
ife.style.height = ife._oldHeight; |
|
6230 |
ife.height = ife._oldHeight; |
|
6231 |
} |
|
6232 |
} |
|
6233 |
}; |
|
6234 |
||
6235 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Selection.class.js */ |
|
6236 |
||
6237 |
function TinyMCE_Selection(inst) { |
|
6238 |
this.instance = inst; |
|
6239 |
}; |
|
6240 |
||
6241 |
TinyMCE_Selection.prototype = { |
|
6242 |
getSelectedHTML : function() { |
|
6243 |
var inst = this.instance; |
|
6244 |
var e, r = this.getRng(), h; |
|
6245 |
||
6246 |
if (!r) |
|
6247 |
return null; |
|
6248 |
||
6249 |
e = document.createElement("body"); |
|
6250 |
||
6251 |
if (r.cloneContents) |
|
6252 |
e.appendChild(r.cloneContents()); |
|
6253 |
else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined') |
|
6254 |
e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText; |
|
6255 |
else |
|
6256 |
e.innerHTML = r.toString(); // Failed, use text for now |
|
6257 |
||
6258 |
h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false); |
|
6259 |
||
6260 |
// When editing always use fonts internaly |
|
6261 |
//if (tinyMCE.getParam("convert_fonts_to_spans")) |
|
6262 |
// tinyMCE.convertSpansToFonts(inst.getDoc()); |
|
6263 |
||
6264 |
return h; |
|
6265 |
}, |
|
6266 |
||
6267 |
getSelectedText : function() { |
|
6268 |
var inst = this.instance; |
|
6269 |
var d, r, s, t; |
|
6270 |
||
6271 |
if (tinyMCE.isIE) { |
|
6272 |
d = inst.getDoc(); |
|
6273 |
||
6274 |
if (d.selection.type == "Text") { |
|
6275 |
r = d.selection.createRange(); |
|
6276 |
t = r.text; |
|
6277 |
} else |
|
6278 |
t = ''; |
|
6279 |
} else { |
|
6280 |
s = this.getSel(); |
|
6281 |
||
6282 |
if (s && s.toString) |
|
6283 |
t = s.toString(); |
|
6284 |
else |
|
6285 |
t = ''; |
|
6286 |
} |
|
6287 |
||
6288 |
return t; |
|
6289 |
}, |
|
6290 |
||
6291 |
getBookmark : function(simple) { |
|
6292 |
var inst = this.instance; |
|
6293 |
var rng = this.getRng(); |
|
6294 |
var doc = inst.getDoc(), b = inst.getBody(); |
|
6295 |
var sp, le, s, e, nl, i, si, ei, w; |
|
6296 |
var trng, sx, sy, xx = -999999999, vp = inst.getViewPort(); |
|
6297 |
||
6298 |
sx = vp.left; |
|
6299 |
sy = vp.top; |
|
6300 |
||
6301 |
if (tinyMCE.isSafari || tinyMCE.isOpera || simple) |
|
6302 |
return {rng : rng, scrollX : sx, scrollY : sy}; |
|
6303 |
||
6304 |
if (tinyMCE.isIE) { |
|
6305 |
if (rng.item) { |
|
6306 |
e = rng.item(0); |
|
6307 |
||
6308 |
nl = b.getElementsByTagName(e.nodeName); |
|
6309 |
for (i=0; i<nl.length; i++) { |
|
6310 |
if (e == nl[i]) { |
|
6311 |
sp = i; |
|
6312 |
break; |
|
6313 |
} |
|
6314 |
} |
|
6315 |
||
6316 |
return { |
|
6317 |
tag : e.nodeName, |
|
6318 |
index : sp, |
|
6319 |
scrollX : sx, |
|
6320 |
scrollY : sy |
|
6321 |
}; |
|
6322 |
} else { |
|
6323 |
trng = doc.body.createTextRange(); |
|
6324 |
trng.moveToElementText(inst.getBody()); |
|
6325 |
trng.collapse(true); |
|
6326 |
bp = Math.abs(trng.move('character', xx)); |
|
6327 |
||
6328 |
trng = rng.duplicate(); |
|
6329 |
trng.collapse(true); |
|
6330 |
sp = Math.abs(trng.move('character', xx)); |
|
6331 |
||
6332 |
trng = rng.duplicate(); |
|
6333 |
trng.collapse(false); |
|
6334 |
le = Math.abs(trng.move('character', xx)) - sp; |
|
6335 |
||
6336 |
return { |
|
6337 |
start : sp - bp, |
|
6338 |
length : le, |
|
6339 |
scrollX : sx, |
|
6340 |
scrollY : sy |
|
6341 |
}; |
|
6342 |
} |
|
6343 |
} |
|
6344 |
||
6345 |
if (tinyMCE.isGecko) { |
|
6346 |
s = this.getSel(); |
|
6347 |
e = this.getFocusElement(); |
|
6348 |
||
6349 |
if (!s) |
|
6350 |
return null; |
|
6351 |
||
6352 |
if (e && e.nodeName == 'IMG') { |
|
6353 |
/*nl = b.getElementsByTagName('IMG'); |
|
6354 |
for (i=0; i<nl.length; i++) { |
|
6355 |
if (e == nl[i]) { |
|
6356 |
sp = i; |
|
6357 |
break; |
|
6358 |
} |
|
6359 |
}*/ |
|
6360 |
||
6361 |
return { |
|
6362 |
start : -1, |
|
6363 |
end : -1, |
|
6364 |
index : sp, |
|
6365 |
scrollX : sx, |
|
6366 |
scrollY : sy |
|
6367 |
}; |
|
6368 |
} |
|
6369 |
||
6370 |
// Caret or selection |
|
6371 |
if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) { |
|
6372 |
e = this._getPosText(b, s.anchorNode, s.focusNode); |
|
6373 |
||
6374 |
if (!e) |
|
6375 |
return {scrollX : sx, scrollY : sy}; |
|
6376 |
||
6377 |
return { |
|
6378 |
start : e.start + s.anchorOffset, |
|
6379 |
end : e.end + s.focusOffset, |
|
6380 |
scrollX : sx, |
|
6381 |
scrollY : sy |
|
6382 |
}; |
|
6383 |
} else { |
|
6384 |
e = this._getPosText(b, rng.startContainer, rng.endContainer); |
|
6385 |
||
6386 |
if (!e) |
|
6387 |
return {scrollX : sx, scrollY : sy}; |
|
6388 |
||
6389 |
return { |
|
6390 |
start : e.start + rng.startOffset, |
|
6391 |
end : e.end + rng.endOffset, |
|
6392 |
scrollX : sx, |
|
6393 |
scrollY : sy |
|
6394 |
}; |
|
6395 |
} |
|
6396 |
} |
|
6397 |
||
6398 |
return null; |
|
6399 |
}, |
|
6400 |
||
6401 |
moveToBookmark : function(bookmark) { |
|
6402 |
var inst = this.instance; |
|
6403 |
var rng, nl, i, ex, b = inst.getBody(), sd; |
|
6404 |
var doc = inst.getDoc(); |
|
6405 |
var win = inst.getWin(); |
|
6406 |
var sel = this.getSel(); |
|
6407 |
||
6408 |
if (!bookmark) |
|
6409 |
return false; |
|
6410 |
||
6411 |
if (tinyMCE.isSafari) { |
|
6412 |
sel.setBaseAndExtent(bookmark.rng.startContainer, bookmark.rng.startOffset, bookmark.rng.endContainer, bookmark.rng.endOffset); |
|
6413 |
return true; |
|
6414 |
} |
|
6415 |
||
6416 |
if (tinyMCE.isRealIE) { |
|
6417 |
if (bookmark.rng) { |
|
6418 |
try { |
|
6419 |
bookmark.rng.select(); |
|
6420 |
} catch (ex) { |
|
6421 |
// Ignore |
|
6422 |
} |
|
6423 |
||
6424 |
return true; |
|
6425 |
} |
|
6426 |
||
6427 |
win.focus(); |
|
6428 |
||
6429 |
if (bookmark.tag) { |
|
6430 |
rng = b.createControlRange(); |
|
6431 |
||
6432 |
nl = b.getElementsByTagName(bookmark.tag); |
|
6433 |
||
6434 |
if (nl.length > bookmark.index) { |
|
6435 |
try { |
|
6436 |
rng.addElement(nl[bookmark.index]); |
|
6437 |
} catch (ex) { |
|
6438 |
// Might be thrown if the node no longer exists |
|
6439 |
} |
|
6440 |
} |
|
6441 |
} else { |
|
6442 |
// Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs |
|
6443 |
try { |
|
6444 |
// Incorrect bookmark |
|
6445 |
if (bookmark.start < 0) |
|
6446 |
return true; |
|
6447 |
||
6448 |
rng = inst.getSel().createRange(); |
|
6449 |
rng.moveToElementText(inst.getBody()); |
|
6450 |
rng.collapse(true); |
|
6451 |
rng.moveStart('character', bookmark.start); |
|
6452 |
rng.moveEnd('character', bookmark.length); |
|
6453 |
} catch (ex) { |
|
6454 |
return true; |
|
6455 |
} |
|
6456 |
} |
|
6457 |
||
6458 |
rng.select(); |
|
6459 |
||
6460 |
win.scrollTo(bookmark.scrollX, bookmark.scrollY); |
|
6461 |
return true; |
|
6462 |
} |
|
6463 |
||
6464 |
if (tinyMCE.isGecko || tinyMCE.isOpera) { |
|
6465 |
if (!sel) |
|
6466 |
return false; |
|
6467 |
||
6468 |
if (bookmark.rng) { |
|
6469 |
sel.removeAllRanges(); |
|
6470 |
sel.addRange(bookmark.rng); |
|
6471 |
} |
|
6472 |
||
6473 |
if (bookmark.start != -1 && bookmark.end != -1) { |
|
6474 |
try { |
|
6475 |
sd = this._getTextPos(b, bookmark.start, bookmark.end); |
|
6476 |
rng = doc.createRange(); |
|
6477 |
rng.setStart(sd.startNode, sd.startOffset); |
|
6478 |
rng.setEnd(sd.endNode, sd.endOffset); |
|
6479 |
sel.removeAllRanges(); |
|
6480 |
sel.addRange(rng); |
|
6481 |
win.focus(); |
|
6482 |
} catch (ex) { |
|
6483 |
// Ignore |
|
6484 |
} |
|
6485 |
} |
|
6486 |
||
6487 |
/* |
|
6488 |
if (typeof(bookmark.index) != 'undefined') { |
|
6489 |
tinyMCE.selectElements(b, 'IMG', function (n) { |
|
6490 |
if (bookmark.index-- == 0) { |
|
6491 |
// Select image in Gecko here |
|
6492 |
} |
|
6493 |
||
6494 |
return false; |
|
6495 |
}); |
|
6496 |
} |
|
6497 |
*/ |
|
6498 |
||
6499 |
win.scrollTo(bookmark.scrollX, bookmark.scrollY); |
|
6500 |
return true; |
|
6501 |
} |
|
6502 |
||
6503 |
return false; |
|
6504 |
}, |
|
6505 |
||
6506 |
_getPosText : function(r, sn, en) { |
|
6507 |
var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; |
|
6508 |
||
6509 |
while ((n = w.nextNode()) != null) { |
|
6510 |
if (n == sn) |
|
6511 |
d.start = p; |
|
6512 |
||
6513 |
if (n == en) { |
|
6514 |
d.end = p; |
|
6515 |
return d; |
|
6516 |
} |
|
6517 |
||
6518 |
p += n.nodeValue ? n.nodeValue.length : 0; |
|
6519 |
} |
|
6520 |
||
6521 |
return null; |
|
6522 |
}, |
|
6523 |
||
6524 |
_getTextPos : function(r, sp, ep) { |
|
6525 |
var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; |
|
6526 |
||
6527 |
while ((n = w.nextNode()) != null) { |
|
6528 |
p += n.nodeValue ? n.nodeValue.length : 0; |
|
6529 |
||
6530 |
if (p >= sp && !d.startNode) { |
|
6531 |
d.startNode = n; |
|
6532 |
d.startOffset = sp - (p - n.nodeValue.length); |
|
6533 |
} |
|
6534 |
||
6535 |
if (p >= ep) { |
|
6536 |
d.endNode = n; |
|
6537 |
d.endOffset = ep - (p - n.nodeValue.length); |
|
6538 |
||
6539 |
return d; |
|
6540 |
} |
|
6541 |
} |
|
6542 |
||
6543 |
return null; |
|
6544 |
}, |
|
6545 |
||
6546 |
selectNode : function(node, collapse, select_text_node, to_start) { |
|
6547 |
var inst = this.instance, sel, rng, nodes; |
|
6548 |
||
6549 |
if (!node) |
|
6550 |
return; |
|
6551 |
||
6552 |
if (typeof(collapse) == "undefined") |
|
6553 |
collapse = true; |
|
6554 |
||
6555 |
if (typeof(select_text_node) == "undefined") |
|
6556 |
select_text_node = false; |
|
6557 |
||
6558 |
if (typeof(to_start) == "undefined") |
|
6559 |
to_start = true; |
|
6560 |
||
6561 |
if (inst.settings.auto_resize) |
|
6562 |
inst.resizeToContent(); |
|
6563 |
||
6564 |
if (tinyMCE.isRealIE) { |
|
6565 |
rng = inst.getDoc().body.createTextRange(); |
|
6566 |
||
6567 |
try { |
|
6568 |
rng.moveToElementText(node); |
|
6569 |
||
6570 |
if (collapse) |
|
6571 |
rng.collapse(to_start); |
|
6572 |
||
6573 |
rng.select(); |
|
6574 |
} catch (e) { |
|
6575 |
// Throws illigal agrument in MSIE some times |
|
6576 |
} |
|
6577 |
} else { |
|
6578 |
sel = this.getSel(); |
|
6579 |
||
6580 |
if (!sel) |
|
6581 |
return; |
|
6582 |
||
6583 |
if (tinyMCE.isSafari) { |
|
6584 |
sel.setBaseAndExtent(node, 0, node, node.innerText.length); |
|
6585 |
||
6586 |
if (collapse) { |
|
6587 |
if (to_start) |
|
6588 |
sel.collapseToStart(); |
|
6589 |
else |
|
6590 |
sel.collapseToEnd(); |
|
6591 |
} |
|
6592 |
||
6593 |
this.scrollToNode(node); |
|
6594 |
||
6595 |
return; |
|
6596 |
} |
|
6597 |
||
6598 |
rng = inst.getDoc().createRange(); |
|
6599 |
||
6600 |
if (select_text_node) { |
|
6601 |
// Find first textnode in tree |
|
6602 |
nodes = tinyMCE.getNodeTree(node, new Array(), 3); |
|
6603 |
if (nodes.length > 0) |
|
6604 |
rng.selectNodeContents(nodes[0]); |
|
6605 |
else |
|
6606 |
rng.selectNodeContents(node); |
|
6607 |
} else |
|
6608 |
rng.selectNode(node); |
|
6609 |
||
6610 |
if (collapse) { |
|
6611 |
// Special treatment of textnode collapse |
|
6612 |
if (!to_start && node.nodeType == 3) { |
|
6613 |
rng.setStart(node, node.nodeValue.length); |
|
6614 |
rng.setEnd(node, node.nodeValue.length); |
|
6615 |
} else |
|
6616 |
rng.collapse(to_start); |
|
6617 |
} |
|
6618 |
||
6619 |
sel.removeAllRanges(); |
|
6620 |
sel.addRange(rng); |
|
6621 |
} |
|
6622 |
||
6623 |
this.scrollToNode(node); |
|
6624 |
||
6625 |
// Set selected element |
|
6626 |
tinyMCE.selectedElement = null; |
|
6627 |
if (node.nodeType == 1) |
|
6628 |
tinyMCE.selectedElement = node; |
|
6629 |
}, |
|
6630 |
||
6631 |
scrollToNode : function(node) { |
|
6632 |
var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin; |
|
6633 |
||
6634 |
// Only scroll if out of visible area |
|
6635 |
if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25)) |
|
6636 |
w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25); |
|
6637 |
||
6638 |
// Scroll container window |
|
6639 |
if (inst.settings.auto_resize) { |
|
6640 |
cwin = inst.getContainerWin(); |
|
6641 |
cvp = tinyMCE.getViewPort(cwin); |
|
6642 |
p = this.getAbsPosition(node); |
|
6643 |
||
6644 |
if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height) |
|
6645 |
cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25); |
|
6646 |
} |
|
6647 |
}, |
|
6648 |
||
6649 |
getAbsPosition : function(n) { |
|
6650 |
var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement); |
|
6651 |
||
6652 |
return { |
|
6653 |
absLeft : ipos.absLeft + pos.absLeft, |
|
6654 |
absTop : ipos.absTop + pos.absTop |
|
6655 |
}; |
|
6656 |
}, |
|
6657 |
||
6658 |
getSel : function() { |
|
6659 |
var inst = this.instance; |
|
6660 |
||
6661 |
if (tinyMCE.isRealIE) |
|
6662 |
return inst.getDoc().selection; |
|
6663 |
||
6664 |
return inst.contentWindow.getSelection(); |
|
6665 |
}, |
|
6666 |
||
6667 |
getRng : function() { |
|
6668 |
var s = this.getSel(); |
|
6669 |
||
6670 |
if (s == null) |
|
6671 |
return null; |
|
6672 |
||
6673 |
if (tinyMCE.isRealIE) |
|
6674 |
return s.createRange(); |
|
6675 |
||
6676 |
if (tinyMCE.isSafari && !s.getRangeAt) |
|
6677 |
return '' + window.getSelection(); |
|
6678 |
||
6679 |
if (s.rangeCount > 0) |
|
6680 |
return s.getRangeAt(0); |
|
6681 |
||
6682 |
return null; |
|
6683 |
}, |
|
6684 |
||
6685 |
isCollapsed : function() { |
|
6686 |
var r = this.getRng(); |
|
6687 |
||
6688 |
if (r.item) |
|
6689 |
return false; |
|
6690 |
||
6691 |
return r.boundingWidth == 0 || this.getSel().isCollapsed; |
|
6692 |
}, |
|
6693 |
||
6694 |
collapse : function(b) { |
|
6695 |
var r = this.getRng(), s = this.getSel(); |
|
6696 |
||
6697 |
if (r.select) { |
|
6698 |
r.collapse(b); |
|
6699 |
r.select(); |
|
6700 |
} else { |
|
6701 |
if (b) |
|
6702 |
s.collapseToStart(); |
|
6703 |
else |
|
6704 |
s.collapseToEnd(); |
|
6705 |
} |
|
6706 |
}, |
|
6707 |
||
6708 |
getFocusElement : function() { |
|
6709 |
var inst = this.instance, doc, rng, sel, elm; |
|
6710 |
||
6711 |
if (tinyMCE.isRealIE) { |
|
6712 |
doc = inst.getDoc(); |
|
6713 |
rng = doc.selection.createRange(); |
|
6714 |
||
6715 |
// if (rng.collapse) |
|
6716 |
// rng.collapse(true); |
|
6717 |
||
6718 |
elm = rng.item ? rng.item(0) : rng.parentElement(); |
|
6719 |
} else { |
|
6720 |
if (!tinyMCE.isSafari && inst.isHidden()) |
|
6721 |
return inst.getBody(); |
|
6722 |
||
6723 |
sel = this.getSel(); |
|
6724 |
rng = this.getRng(); |
|
6725 |
||
6726 |
if (!sel || !rng) |
|
6727 |
return null; |
|
6728 |
||
6729 |
elm = rng.commonAncestorContainer; |
|
6730 |
//elm = (sel && sel.anchorNode) ? sel.anchorNode : null; |
|
6731 |
||
6732 |
// Handle selection a image or other control like element such as anchors |
|
6733 |
if (!rng.collapsed) { |
|
6734 |
// Is selection small |
|
6735 |
if (rng.startContainer == rng.endContainer) { |
|
6736 |
if (rng.startOffset - rng.endOffset < 2) { |
|
6737 |
if (rng.startContainer.hasChildNodes()) |
|
6738 |
elm = rng.startContainer.childNodes[rng.startOffset]; |
|
6739 |
} |
|
6740 |
} |
|
6741 |
} |
|
6742 |
||
6743 |
// Get the element parent of the node |
|
6744 |
elm = tinyMCE.getParentElement(elm); |
|
6745 |
||
6746 |
//if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") |
|
6747 |
// elm = tinyMCE.selectedElement; |
|
6748 |
} |
|
6749 |
||
6750 |
return elm; |
|
6751 |
} |
|
6752 |
||
6753 |
}; |
|
6754 |
||
6755 |
/* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */ |
|
6756 |
||
6757 |
function TinyMCE_UndoRedo(inst) { |
|
6758 |
this.instance = inst; |
|
6759 |
this.undoLevels = new Array(); |
|
6760 |
this.undoIndex = 0; |
|
6761 |
this.typingUndoIndex = -1; |
|
6762 |
this.undoRedo = true; |
|
6763 |
}; |
|
6764 |
||
6765 |
TinyMCE_UndoRedo.prototype = { |
|
6766 |
add : function(l) { |
|
6767 |
var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur; |
|
6768 |
||
6769 |
if (l) { |
|
6770 |
this.undoLevels[this.undoLevels.length] = l; |
|
6771 |
return true; |
|
6772 |
} |
|
6773 |
||
6774 |
if (this.typingUndoIndex != -1) { |
|
6775 |
this.undoIndex = this.typingUndoIndex; |
|
6776 |
||
6777 |
if (tinyMCE.typingUndoIndex != -1) |
|
6778 |
tinyMCE.undoIndex = tinyMCE.typingUndoIndex; |
|
6779 |
} |
|
6780 |
||
6781 |
newHTML = tinyMCE.trim(inst.getBody().innerHTML); |
|
6782 |
if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) { |
|
6783 |
//tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content); |
|
6784 |
||
6785 |
tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst); |
|
6786 |
||
6787 |
// Time to compress |
|
6788 |
customUndoLevels = tinyMCE.settings['custom_undo_redo_levels']; |
|
6789 |
if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) { |
|
6790 |
for (i=0; i<this.undoLevels.length-1; i++) |
|
6791 |
this.undoLevels[i] = this.undoLevels[i+1]; |
|
6792 |
||
6793 |
this.undoLevels.length--; |
|
6794 |
this.undoIndex--; |
|
6795 |
||
6796 |
// Todo: Implement global undo/redo logic here |
|
6797 |
} |
|
6798 |
||
6799 |
b = inst.undoBookmark; |
|
6800 |
||
6801 |
if (!b) |
|
6802 |
b = inst.selection.getBookmark(); |
|
6803 |
||
6804 |
this.undoIndex++; |
|
6805 |
this.undoLevels[this.undoIndex] = { |
|
6806 |
content : newHTML, |
|
6807 |
bookmark : b |
|
6808 |
}; |
|
6809 |
||
6810 |
// Remove all above from global undo/redo |
|
6811 |
ul = tinyMCE.undoLevels; |
|
6812 |
for (i=tinyMCE.undoIndex + 1; i<ul.length; i++) { |
|
6813 |
ur = ul[i].undoRedo; |
|
6814 |
||
6815 |
if (ur.undoIndex == ur.undoLevels.length -1) |
|
6816 |
ur.undoIndex--; |
|
6817 |
||
6818 |
ur.undoLevels.length--; |
|
6819 |
} |
|
6820 |
||
6821 |
// Add global undo level |
|
6822 |
tinyMCE.undoLevels[tinyMCE.undoIndex++] = inst; |
|
6823 |
tinyMCE.undoLevels.length = tinyMCE.undoIndex; |
|
6824 |
||
6825 |
this.undoLevels.length = this.undoIndex + 1; |
|
6826 |
||
6827 |
return true; |
|
6828 |
} |
|
6829 |
||
6830 |
return false; |
|
6831 |
}, |
|
6832 |
||
6833 |
undo : function() { |
|
6834 |
var inst = this.instance; |
|
6835 |
||
6836 |
// Do undo |
|
6837 |
if (this.undoIndex > 0) { |
|
6838 |
this.undoIndex--; |
|
6839 |
||
6840 |
tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content); |
|
6841 |
inst.repaint(); |
|
6842 |
||
6843 |
if (inst.settings.custom_undo_redo_restore_selection) |
|
6844 |
inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); |
|
6845 |
} |
|
6846 |
}, |
|
6847 |
||
6848 |
redo : function() { |
|
6849 |
var inst = this.instance; |
|
6850 |
||
6851 |
tinyMCE.execCommand("mceEndTyping"); |
|
6852 |
||
6853 |
if (this.undoIndex < (this.undoLevels.length-1)) { |
|
6854 |
this.undoIndex++; |
|
6855 |
||
6856 |
tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content); |
|
6857 |
inst.repaint(); |
|
6858 |
||
6859 |
if (inst.settings.custom_undo_redo_restore_selection) |
|
6860 |
inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); |
|
6861 |
} |
|
6862 |
||
6863 |
tinyMCE.triggerNodeChange(); |
|
6864 |
} |
|
6865 |
||
6866 |
}; |
|
6867 |
||
6868 |
/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */ |
|
6869 |
||
6870 |
var TinyMCE_ForceParagraphs = { |
|
6871 |
_insertPara : function(inst, e) { |
|
6872 |
var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0); |
|
6873 |
var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock; |
|
6874 |
var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null; |
|
6875 |
var paraBefore, paraAfter, startChop, endChop, contents; |
|
6876 |
||
6877 |
function isEmpty(para) { |
|
6878 |
function isEmptyHTML(html) { |
|
6879 |
return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == ""; |
|
6880 |
} |
|
6881 |
||
6882 |
// Check for images |
|
6883 |
if (para.getElementsByTagName("img").length > 0) |
|
6884 |
return false; |
|
6885 |
||
6886 |
// Check for tables |
|
6887 |
if (para.getElementsByTagName("table").length > 0) |
|
6888 |
return false; |
|
6889 |
||
6890 |
// Check for HRs |
|
6891 |
if (para.getElementsByTagName("hr").length > 0) |
|
6892 |
return false; |
|
6893 |
||
6894 |
// Check all textnodes |
|
6895 |
var nodes = tinyMCE.getNodeTree(para, new Array(), 3); |
|
6896 |
for (var i=0; i<nodes.length; i++) { |
|
6897 |
if (!isEmptyHTML(nodes[i].nodeValue)) |
|
6898 |
return false; |
|
6899 |
} |
|
6900 |
||
6901 |
// No images, no tables, no hrs, no text content then it's empty |
|
6902 |
return true; |
|
6903 |
} |
|
6904 |
||
6905 |
// tinyMCE.debug(body.innerHTML); |
|
6906 |
||
6907 |
// debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString()); |
|
6908 |
||
6909 |
// Setup before range |
|
6910 |
rngBefore = doc.createRange(); |
|
6911 |
rngBefore.setStart(sel.anchorNode, sel.anchorOffset); |
|
6912 |
rngBefore.collapse(true); |
|
6913 |
||
6914 |
// Setup after range |
|
6915 |
rngAfter = doc.createRange(); |
|
6916 |
rngAfter.setStart(sel.focusNode, sel.focusOffset); |
|
6917 |
rngAfter.collapse(true); |
|
6918 |
||
6919 |
// Setup start/end points |
|
6920 |
direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0; |
|
6921 |
startNode = direct ? sel.anchorNode : sel.focusNode; |
|
6922 |
startOffset = direct ? sel.anchorOffset : sel.focusOffset; |
|
6923 |
endNode = direct ? sel.focusNode : sel.anchorNode; |
|
6924 |
endOffset = direct ? sel.focusOffset : sel.anchorOffset; |
|
6925 |
||
6926 |
startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode; |
|
6927 |
endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode; |
|
6928 |
||
6929 |
// Get block elements |
|
6930 |
startBlock = inst.getParentBlockElement(startNode); |
|
6931 |
endBlock = inst.getParentBlockElement(endNode); |
|
6932 |
||
6933 |
// If absolute force paragraph generation within |
|
6934 |
if (startBlock && new RegExp('absolute|relative|static', 'gi').test(startBlock.style.position)) |
|
6935 |
startBlock = null; |
|
6936 |
||
6937 |
if (endBlock && new RegExp('absolute|relative|static', 'gi').test(endBlock.style.position)) |
|
6938 |
endBlock = null; |
|
6939 |
||
6940 |
// Use current block name |
|
6941 |
if (startBlock != null) { |
|
6942 |
blockName = startBlock.nodeName; |
|
6943 |
||
6944 |
// Use P instead |
|
6945 |
if (blockName == "TD" || blockName == "TABLE" || (blockName == "DIV" && new RegExp('left|right', 'gi').test(startBlock.style.cssFloat))) |
|
6946 |
blockName = "P"; |
|
6947 |
} |
|
6948 |
||
6949 |
// Within a list use normal behaviour |
|
6950 |
if (tinyMCE.getParentElement(startBlock, "OL,UL", null, body) != null) |
|
6951 |
return false; |
|
6952 |
||
6953 |
// Within a table create new paragraphs |
|
6954 |
if ((startBlock != null && startBlock.nodeName == "TABLE") || (endBlock != null && endBlock.nodeName == "TABLE")) |
|
6955 |
startBlock = endBlock = null; |
|
6956 |
||
6957 |
// Setup new paragraphs |
|
6958 |
paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName); |
|
6959 |
paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName); |
|
6960 |
||
6961 |
// Is header, then force paragraph under |
|
6962 |
if (/^(H[1-6])$/.test(blockName)) |
|
6963 |
paraAfter = doc.createElement("p"); |
|
6964 |
||
6965 |
// Setup chop nodes |
|
6966 |
startChop = startNode; |
|
6967 |
endChop = endNode; |
|
6968 |
||
6969 |
// Get startChop node |
|
6970 |
node = startChop; |
|
6971 |
do { |
|
6972 |
if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node)) |
|
6973 |
break; |
|
6974 |
||
6975 |
startChop = node; |
|
6976 |
} while ((node = node.previousSibling ? node.previousSibling : node.parentNode)); |
|
6977 |
||
6978 |
// Get endChop node |
|
6979 |
node = endChop; |
|
6980 |
do { |
|
6981 |
if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node)) |
|
6982 |
break; |
|
6983 |
||
6984 |
endChop = node; |
|
6985 |
} while ((node = node.nextSibling ? node.nextSibling : node.parentNode)); |
|
6986 |
||
6987 |
// Fix when only a image is within the TD |
|
6988 |
if (startChop.nodeName == "TD") |
|
6989 |
startChop = startChop.firstChild; |
|
6990 |
||
6991 |
if (endChop.nodeName == "TD") |
|
6992 |
endChop = endChop.lastChild; |
|
6993 |
||
6994 |
// If not in a block element |
|
6995 |
if (startBlock == null) { |
|
6996 |
// Delete selection |
|
6997 |
rng.deleteContents(); |
|
6998 |
||
6999 |
if (!tinyMCE.isSafari) |
|
7000 |
sel.removeAllRanges(); |
|
7001 |
||
7002 |
if (startChop != rootElm && endChop != rootElm) { |
|
7003 |
// Insert paragraph before |
|
7004 |
rngBefore = rng.cloneRange(); |
|
7005 |
||
7006 |
if (startChop == body) |
|
7007 |
rngBefore.setStart(startChop, 0); |
|
7008 |
else |
|
7009 |
rngBefore.setStartBefore(startChop); |
|
7010 |
||
7011 |
paraBefore.appendChild(rngBefore.cloneContents()); |
|
7012 |
||
7013 |
// Insert paragraph after |
|
7014 |
if (endChop.parentNode.nodeName == blockName) |
|
7015 |
endChop = endChop.parentNode; |
|
7016 |
||
7017 |
// If not after image |
|
7018 |
//if (rng.startContainer.nodeName != "BODY" && rng.endContainer.nodeName != "BODY") |
|
7019 |
rng.setEndAfter(endChop); |
|
7020 |
||
7021 |
if (endChop.nodeName != "#text" && endChop.nodeName != "BODY") |
|
7022 |
rngBefore.setEndAfter(endChop); |
|
7023 |
||
7024 |
contents = rng.cloneContents(); |
|
7025 |
if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY")) |
|
7026 |
paraAfter.innerHTML = contents.firstChild.innerHTML; |
|
7027 |
else |
|
7028 |
paraAfter.appendChild(contents); |
|
7029 |
||
7030 |
// Check if it's a empty paragraph |
|
7031 |
if (isEmpty(paraBefore)) |
|
7032 |
paraBefore.innerHTML = " "; |
|
7033 |
||
7034 |
// Check if it's a empty paragraph |
|
7035 |
if (isEmpty(paraAfter)) |
|
7036 |
paraAfter.innerHTML = " "; |
|
7037 |
||
7038 |
// Delete old contents |
|
7039 |
rng.deleteContents(); |
|
7040 |
rngAfter.deleteContents(); |
|
7041 |
rngBefore.deleteContents(); |
|
7042 |
||
7043 |
// Insert new paragraphs |
|
7044 |
if (tinyMCE.isOpera) { |
|
7045 |
paraBefore.normalize(); |
|
7046 |
rngBefore.insertNode(paraBefore); |
|
7047 |
paraAfter.normalize(); |
|
7048 |
rngBefore.insertNode(paraAfter); |
|
7049 |
} else { |
|
7050 |
paraAfter.normalize(); |
|
7051 |
rngBefore.insertNode(paraAfter); |
|
7052 |
paraBefore.normalize(); |
|
7053 |
rngBefore.insertNode(paraBefore); |
|
7054 |
} |
|
7055 |
||
7056 |
//tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML); |
|
7057 |
} else { |
|
7058 |
body.innerHTML = "<" + blockName + "> </" + blockName + "><" + blockName + "> </" + blockName + ">"; |
|
7059 |
paraAfter = body.childNodes[1]; |
|
7060 |
} |
|
7061 |
||
7062 |
inst.selection.moveToBookmark(b); |
|
7063 |
inst.selection.selectNode(paraAfter, true, true); |
|
7064 |
||
7065 |
return true; |
|
7066 |
} |
|
7067 |
||
7068 |
// Place first part within new paragraph |
|
7069 |
if (startChop.nodeName == blockName) |
|
7070 |
rngBefore.setStart(startChop, 0); |
|
7071 |
else |
|
7072 |
rngBefore.setStartBefore(startChop); |
|
7073 |
||
7074 |
rngBefore.setEnd(startNode, startOffset); |
|
7075 |
paraBefore.appendChild(rngBefore.cloneContents()); |
|
7076 |
||
7077 |
// Place secound part within new paragraph |
|
7078 |
rngAfter.setEndAfter(endChop); |
|
7079 |
rngAfter.setStart(endNode, endOffset); |
|
7080 |
contents = rngAfter.cloneContents(); |
|
7081 |
||
7082 |
if (contents.firstChild && contents.firstChild.nodeName == blockName) { |
|
7083 |
/* var nodes = contents.firstChild.childNodes; |
|
7084 |
for (var i=0; i<nodes.length; i++) { |
|
7085 |
//tinyMCE.debug(nodes[i].nodeName); |
|
7086 |
if (nodes[i].nodeName != "BODY") |
|
7087 |
paraAfter.appendChild(nodes[i]); |
|
7088 |
} |
|
7089 |
*/ |
|
7090 |
paraAfter.innerHTML = contents.firstChild.innerHTML; |
|
7091 |
} else |
|
7092 |
paraAfter.appendChild(contents); |
|
7093 |
||
7094 |
// Check if it's a empty paragraph |
|
7095 |
if (isEmpty(paraBefore)) |
|
7096 |
paraBefore.innerHTML = " "; |
|
7097 |
||
7098 |
// Check if it's a empty paragraph |
|
7099 |
if (isEmpty(paraAfter)) |
|
7100 |
paraAfter.innerHTML = " "; |
|
7101 |
||
7102 |
// Create a range around everything |
|
7103 |
rng = doc.createRange(); |
|
7104 |
||
7105 |
if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) { |
|
7106 |
rng.setStartBefore(startChop.parentNode); |
|
7107 |
} else { |
|
7108 |
if (rngBefore.startContainer.nodeName.toUpperCase() == blockName && rngBefore.startOffset == 0) |
|
7109 |
rng.setStartBefore(rngBefore.startContainer); |
|
7110 |
else |
|
7111 |
rng.setStart(rngBefore.startContainer, rngBefore.startOffset); |
|
7112 |
} |
|
7113 |
||
7114 |
if (!endChop.nextSibling && endChop.parentNode.nodeName.toUpperCase() == blockName) |
|
7115 |
rng.setEndAfter(endChop.parentNode); |
|
7116 |
else |
|
7117 |
rng.setEnd(rngAfter.endContainer, rngAfter.endOffset); |
|
7118 |
||
7119 |
// Delete all contents and insert new paragraphs |
|
7120 |
rng.deleteContents(); |
|
7121 |
||
7122 |
if (tinyMCE.isOpera) { |
|
7123 |
rng.insertNode(paraBefore); |
|
7124 |
rng.insertNode(paraAfter); |
|
7125 |
} else { |
|
7126 |
rng.insertNode(paraAfter); |
|
7127 |
rng.insertNode(paraBefore); |
|
7128 |
} |
|
7129 |
||
7130 |
//tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML); |
|
7131 |
||
7132 |
// Normalize |
|
7133 |
paraAfter.normalize(); |
|
7134 |
paraBefore.normalize(); |
|
7135 |
||
7136 |
inst.selection.moveToBookmark(b); |
|
7137 |
inst.selection.selectNode(paraAfter, true, true); |
|
7138 |
||
7139 |
return true; |
|
7140 |
}, |
|
7141 |
||
7142 |
_handleBackSpace : function(inst) { |
|
7143 |
var r = inst.getRng(), sn = r.startContainer, nv, s = false; |
|
7144 |
||
7145 |
// Added body check for bug #1527787 |
|
7146 |
if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR" && sn.parentNode.nodeName != "BODY") { |
|
7147 |
nv = sn.nodeValue; |
|
7148 |
||
7149 |
// Handle if a backspace is pressed after a space character #bug 1466054 removed since fix for #1527787 |
|
7150 |
/*if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ') |
|
7151 |
s = true;*/ |
|
7152 |
||
7153 |
// Only remove BRs if we are at the end of line #bug 1464152 |
|
7154 |
if (nv != null && r.startOffset == nv.length) |
|
7155 |
sn.nextSibling.parentNode.removeChild(sn.nextSibling); |
|
7156 |
} |
|
7157 |
||
7158 |
if (inst.settings.auto_resize) |
|
7159 |
inst.resizeToContent(); |
|
7160 |
||
7161 |
return s; |
|
7162 |
} |
|
7163 |
||
7164 |
}; |
|
7165 |
||
7166 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */ |
|
7167 |
||
7168 |
function TinyMCE_Layer(id, bm) { |
|
7169 |
this.id = id; |
|
7170 |
this.blockerElement = null; |
|
7171 |
this.events = false; |
|
7172 |
this.element = null; |
|
7173 |
this.blockMode = typeof(bm) != 'undefined' ? bm : true; |
|
7174 |
this.doc = document; |
|
7175 |
}; |
|
7176 |
||
7177 |
TinyMCE_Layer.prototype = { |
|
7178 |
moveRelativeTo : function(re, p) { |
|
7179 |
var rep = this.getAbsPosition(re); |
|
7180 |
var w = parseInt(re.offsetWidth); |
|
7181 |
var h = parseInt(re.offsetHeight); |
|
7182 |
var e = this.getElement(); |
|
7183 |
var ew = parseInt(e.offsetWidth); |
|
7184 |
var eh = parseInt(e.offsetHeight); |
|
7185 |
var x, y; |
|
7186 |
||
7187 |
switch (p) { |
|
7188 |
case "tl": |
|
7189 |
x = rep.absLeft; |
|
7190 |
y = rep.absTop; |
|
7191 |
break; |
|
7192 |
||
7193 |
case "tr": |
|
7194 |
x = rep.absLeft + w; |
|
7195 |
y = rep.absTop; |
|
7196 |
break; |
|
7197 |
||
7198 |
case "bl": |
|
7199 |
x = rep.absLeft; |
|
7200 |
y = rep.absTop + h; |
|
7201 |
break; |
|
7202 |
||
7203 |
case "br": |
|
7204 |
x = rep.absLeft + w; |
|
7205 |
y = rep.absTop + h; |
|
7206 |
break; |
|
7207 |
||
7208 |
case "cc": |
|
7209 |
x = rep.absLeft + (w / 2) - (ew / 2); |
|
7210 |
y = rep.absTop + (h / 2) - (eh / 2); |
|
7211 |
break; |
|
7212 |
} |
|
7213 |
||
7214 |
this.moveTo(x, y); |
|
7215 |
}, |
|
7216 |
||
7217 |
moveBy : function(x, y) { |
|
7218 |
var e = this.getElement(); |
|
7219 |
this.moveTo(parseInt(e.style.left) + x, parseInt(e.style.top) + y); |
|
7220 |
}, |
|
7221 |
||
7222 |
moveTo : function(x, y) { |
|
7223 |
var e = this.getElement(); |
|
7224 |
||
7225 |
e.style.left = x + "px"; |
|
7226 |
e.style.top = y + "px"; |
|
7227 |
||
7228 |
this.updateBlocker(); |
|
7229 |
}, |
|
7230 |
||
7231 |
resizeBy : function(w, h) { |
|
7232 |
var e = this.getElement(); |
|
7233 |
this.resizeTo(parseInt(e.style.width) + w, parseInt(e.style.height) + h); |
|
7234 |
}, |
|
7235 |
||
7236 |
resizeTo : function(w, h) { |
|
7237 |
var e = this.getElement(); |
|
7238 |
||
7239 |
if (w != null) |
|
7240 |
e.style.width = w + "px"; |
|
7241 |
||
7242 |
if (h != null) |
|
7243 |
e.style.height = h + "px"; |
|
7244 |
||
7245 |
this.updateBlocker(); |
|
7246 |
}, |
|
7247 |
||
7248 |
show : function() { |
|
7249 |
var el = this.getElement(); |
|
7250 |
||
7251 |
if (el) { |
|
7252 |
el.style.display = 'block'; |
|
7253 |
this.updateBlocker(); |
|
7254 |
} |
|
7255 |
}, |
|
7256 |
||
7257 |
hide : function() { |
|
7258 |
var el = this.getElement(); |
|
7259 |
||
7260 |
if (el) { |
|
7261 |
el.style.display = 'none'; |
|
7262 |
this.updateBlocker(); |
|
7263 |
} |
|
7264 |
}, |
|
7265 |
||
7266 |
isVisible : function() { |
|
7267 |
return this.getElement().style.display == 'block'; |
|
7268 |
}, |
|
7269 |
||
7270 |
getElement : function() { |
|
7271 |
if (!this.element) |
|
7272 |
this.element = this.doc.getElementById(this.id); |
|
7273 |
||
7274 |
return this.element; |
|
7275 |
}, |
|
7276 |
||
7277 |
setBlockMode : function(s) { |
|
7278 |
this.blockMode = s; |
|
7279 |
}, |
|
7280 |
||
7281 |
updateBlocker : function() { |
|
7282 |
var e, b, x, y, w, h; |
|
7283 |
||
7284 |
b = this.getBlocker(); |
|
7285 |
if (b) { |
|
7286 |
if (this.blockMode) { |
|
7287 |
e = this.getElement(); |
|
7288 |
x = this.parseInt(e.style.left); |
|
7289 |
y = this.parseInt(e.style.top); |
|
7290 |
w = this.parseInt(e.offsetWidth); |
|
7291 |
h = this.parseInt(e.offsetHeight); |
|
7292 |
||
7293 |
b.style.left = x + 'px'; |
|
7294 |
b.style.top = y + 'px'; |
|
7295 |
b.style.width = w + 'px'; |
|
7296 |
b.style.height = h + 'px'; |
|
7297 |
b.style.display = e.style.display; |
|
7298 |
} else |
|
7299 |
b.style.display = 'none'; |
|
7300 |
} |
|
7301 |
}, |
|
7302 |
||
7303 |
getBlocker : function() { |
|
7304 |
var d, b; |
|
7305 |
||
7306 |
if (!this.blockerElement && this.blockMode) { |
|
7307 |
d = this.doc; |
|
7308 |
b = d.getElementById(this.id + "_blocker"); |
|
7309 |
||
7310 |
if (!b) { |
|
7311 |
b = d.createElement("iframe"); |
|
7312 |
||
7313 |
b.setAttribute('id', this.id + "_blocker"); |
|
7314 |
b.style.cssText = 'display: none; position: absolute; left: 0; top: 0'; |
|
7315 |
b.src = 'javascript:false;'; |
|
7316 |
b.frameBorder = '0'; |
|
7317 |
b.scrolling = 'no'; |
|
7318 |
||
7319 |
d.body.appendChild(b); |
|
7320 |
} |
|
7321 |
||
7322 |
this.blockerElement = b; |
|
7323 |
} |
|
7324 |
||
7325 |
return this.blockerElement; |
|
7326 |
}, |
|
7327 |
||
7328 |
getAbsPosition : function(n) { |
|
7329 |
var p = {absLeft : 0, absTop : 0}; |
|
7330 |
||
7331 |
while (n) { |
|
7332 |
p.absLeft += n.offsetLeft; |
|
7333 |
p.absTop += n.offsetTop; |
|
7334 |
n = n.offsetParent; |
|
7335 |
} |
|
7336 |
||
7337 |
return p; |
|
7338 |
}, |
|
7339 |
||
7340 |
create : function(n, c, p, h) { |
|
7341 |
var d = this.doc, e = d.createElement(n); |
|
7342 |
||
7343 |
e.setAttribute('id', this.id); |
|
7344 |
||
7345 |
if (c) |
|
7346 |
e.className = c; |
|
7347 |
||
7348 |
if (!p) |
|
7349 |
p = d.body; |
|
7350 |
||
7351 |
if (h) |
|
7352 |
e.innerHTML = h; |
|
7353 |
||
7354 |
p.appendChild(e); |
|
7355 |
||
7356 |
return this.element = e; |
|
7357 |
}, |
|
7358 |
||
7359 |
exists : function() { |
|
7360 |
return this.doc.getElementById(this.id) != null; |
|
7361 |
}, |
|
7362 |
||
7363 |
parseInt : function(s) { |
|
7364 |
if (s == null || s == '') |
|
7365 |
return 0; |
|
7366 |
||
7367 |
return parseInt(s); |
|
7368 |
}, |
|
7369 |
||
7370 |
remove : function() { |
|
7371 |
var e = this.getElement(), b = this.getBlocker(); |
|
7372 |
||
7373 |
if (e) |
|
7374 |
e.parentNode.removeChild(e); |
|
7375 |
||
7376 |
if (b) |
|
7377 |
b.parentNode.removeChild(b); |
|
7378 |
} |
|
7379 |
||
7380 |
}; |
|
7381 |
||
7382 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */ |
|
7383 |
||
7384 |
function TinyMCE_Menu() { |
|
7385 |
var id; |
|
7386 |
||
7387 |
if (typeof(tinyMCE.menuCounter) == "undefined") |
|
7388 |
tinyMCE.menuCounter = 0; |
|
7389 |
||
7390 |
id = "mc_menu_" + tinyMCE.menuCounter++; |
|
7391 |
||
7392 |
TinyMCE_Layer.call(this, id, true); |
|
7393 |
||
7394 |
this.id = id; |
|
7395 |
this.items = new Array(); |
|
7396 |
this.needsUpdate = true; |
|
7397 |
}; |
|
7398 |
||
7399 |
TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, { |
|
7400 |
init : function(s) { |
|
7401 |
var n; |
|
7402 |
||
7403 |
// Default params |
|
7404 |
this.settings = { |
|
7405 |
separator_class : 'mceMenuSeparator', |
|
7406 |
title_class : 'mceMenuTitle', |
|
7407 |
disabled_class : 'mceMenuDisabled', |
|
7408 |
menu_class : 'mceMenu', |
|
7409 |
drop_menu : true |
|
7410 |
}; |
|
7411 |
||
7412 |
for (n in s) |
|
7413 |
this.settings[n] = s[n]; |
|
7414 |
||
7415 |
this.create('div', this.settings.menu_class); |
|
7416 |
}, |
|
7417 |
||
7418 |
clear : function() { |
|
7419 |
this.items = new Array(); |
|
7420 |
}, |
|
7421 |
||
7422 |
addTitle : function(t) { |
|
7423 |
this.add({type : 'title', text : t}); |
|
7424 |
}, |
|
7425 |
||
7426 |
addDisabled : function(t) { |
|
7427 |
this.add({type : 'disabled', text : t}); |
|
7428 |
}, |
|
7429 |
||
7430 |
addSeparator : function() { |
|
7431 |
this.add({type : 'separator'}); |
|
7432 |
}, |
|
7433 |
||
7434 |
addItem : function(t, js) { |
|
7435 |
this.add({text : t, js : js}); |
|
7436 |
}, |
|
7437 |
||
7438 |
add : function(mi) { |
|
7439 |
this.items[this.items.length] = mi; |
|
7440 |
this.needsUpdate = true; |
|
7441 |
}, |
|
7442 |
||
7443 |
update : function() { |
|
7444 |
var e = this.getElement(), h = '', i, t, m = this.items, s = this.settings; |
|
7445 |
||
7446 |
if (this.settings.drop_menu) |
|
7447 |
h += '<span class="mceMenuLine"></span>'; |
|
7448 |
||
7449 |
h += '<table border="0" cellpadding="0" cellspacing="0">'; |
|
7450 |
||
7451 |
for (i=0; i<m.length; i++) { |
|
7452 |
t = tinyMCE.xmlEncode(m[i].text); |
|
7453 |
c = m[i].class_name ? ' class="' + m[i].class_name + '"' : ''; |
|
7454 |
||
7455 |
switch (m[i].type) { |
|
7456 |
case 'separator': |
|
7457 |
h += '<tr class="' + s.separator_class + '"><td>'; |
|
7458 |
break; |
|
7459 |
||
7460 |
case 'title': |
|
7461 |
h += '<tr class="' + s.title_class + '"><td><span' + c +'>' + t + '</span>'; |
|
7462 |
break; |
|
7463 |
||
7464 |
case 'disabled': |
|
7465 |
h += '<tr class="' + s.disabled_class + '"><td><span' + c +'>' + t + '</span>'; |
|
7466 |
break; |
|
7467 |
||
7468 |
default: |
|
7469 |
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>'; |
|
7470 |
} |
|
7471 |
||
7472 |
h += '</td></tr>'; |
|
7473 |
} |
|
7474 |
||
7475 |
h += '</table>'; |
|
7476 |
||
7477 |
e.innerHTML = h; |
|
7478 |
||
7479 |
this.needsUpdate = false; |
|
7480 |
this.updateBlocker(); |
|
7481 |
}, |
|
7482 |
||
7483 |
show : function() { |
|
7484 |
var nl, i; |
|
7485 |
||
7486 |
if (tinyMCE.lastMenu == this) |
|
7487 |
return; |
|
7488 |
||
7489 |
if (this.needsUpdate) |
|
7490 |
this.update(); |
|
7491 |
||
7492 |
if (tinyMCE.lastMenu && tinyMCE.lastMenu != this) |
|
7493 |
tinyMCE.lastMenu.hide(); |
|
7494 |
||
7495 |
TinyMCE_Layer.prototype.show.call(this); |
|
7496 |
||
7497 |
if (!tinyMCE.isOpera) { |
|
7498 |
// Accessibility stuff |
|
7499 |
/* nl = this.getElement().getElementsByTagName("a"); |
|
7500 |
if (nl.length > 0) |
|
7501 |
nl[0].focus();*/ |
|
7502 |
} |
|
7503 |
||
7504 |
tinyMCE.lastMenu = this; |
|
7505 |
} |
|
7506 |
||
7507 |
}); |
|
7508 |
||
7509 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Compatibility.class.js */ |
|
7510 |
||
7511 |
if (!Function.prototype.call) { |
|
7512 |
Function.prototype.call = function() { |
|
7513 |
var a = arguments, s = a[0], i, as = '', r, o; |
|
7514 |
||
7515 |
for (i=1; i<a.length; i++) |
|
7516 |
as += (i > 1 ? ',' : '') + 'a[' + i + ']'; |
|
7517 |
||
7518 |
o = s._fu; |
|
7519 |
s._fu = this; |
|
7520 |
r = eval('s._fu(' + as + ')'); |
|
7521 |
s._fu = o; |
|
7522 |
||
7523 |
return r; |
|
7524 |
}; |
|
7525 |
}; |
|
7526 |
||
7527 |
/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */ |
|
7528 |
||
7529 |
TinyMCE_Engine.prototype.debug = function() { |
|
7530 |
var m = "", a, i, l = tinyMCE.log.length; |
|
7531 |
||
7532 |
for (i=0, a = this.debug.arguments; i<a.length; i++) { |
|
7533 |
m += a[i]; |
|
7534 |
||
7535 |
if (i<a.length-1) |
|
7536 |
m += ', '; |
|
7537 |
} |
|
7538 |
||
7539 |
if (l < 1000) |
|
7540 |
tinyMCE.log[l] = "[debug] " + m; |
|
7541 |
}; |
|
7542 |