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