/** * $RCSfile$ * $Revision$ * $Date$ * * @author Moxiecode * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. */ function TinyMCE() { this.instances = new Array(); this.stickyClassesLookup = new Array(); this.windowArgs = new Array(); // Browser check this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); this.isMSIE5 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5') != -1); this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1); this.isGecko = navigator.userAgent.indexOf('Gecko') != -1; // TinyMCE editor id instance counter this.idCounter = 0; // Editor functions this.init = TinyMCE_init; this.addMCEControl = TinyMCE_addMCEControl; this.createMCEControl = TinyMCE_createMCEControl; this.triggerSave = TinyMCE_triggerSave; this._convertOnClick = TinyMCE__convertOnClick; this.resetForm = TinyMCE_resetForm; this.execCommand = TinyMCE_execCommand; this.execInstanceCommand = TinyMCE_execInstanceCommand; this._createIFrame = TinyMCE__createIFrame; this.handleEvent = TinyMCE_handleEvent; this.setupContent = TinyMCE_setupContent; this.switchClass = TinyMCE_switchClass; this.restoreAndSwitchClass = TinyMCE_restoreAndSwitchClass; this.switchClassSticky = TinyMCE_switchClassSticky; this.restoreClass = TinyMCE_restoreClass; this.setClassLock = TinyMCE_setClassLock; this.addEvent = TinyMCE_addEvent; this.onLoad = TinyMCE_onLoad; this.removeMCEControl = TinyMCE_removeMCEControl; this._initCleanup = TinyMCE__initCleanup; this._cleanupHTML = TinyMCE__cleanupHTML; this._cleanupAttribute = TinyMCE__cleanupAttribute; this._fixInlineStyles = TinyMCE__fixInlineStyles; this._cleanupElementName = TinyMCE__cleanupElementName; this._verifyClass = TinyMCE__verifyClass; this.cleanupNode = TinyMCE_cleanupNode; this.convertStringToXML = TinyMCE_convertStringToXML; this.insertLink = TinyMCE_insertLink; this.insertImage = TinyMCE_insertImage; this.getElementByAttributeValue = TinyMCE_getElementByAttributeValue; this.getElementsByAttributeValue = TinyMCE_getElementsByAttributeValue; this.getParentBlockElement = TinyMCE_getParentBlockElement; this.getParentElement = TinyMCE_getParentElement; this.getParam = TinyMCE_getParam; this.getLang = TinyMCE_getLang; this.replaceVar = TinyMCE_replaceVar; this.replaceVars = TinyMCE_replaceVars; this.triggerNodeChange = TinyMCE_triggerNodeChange; this.parseURL = TinyMCE_parseURL; this.convertAbsoluteURLToRelativeURL = TinyMCE_convertAbsoluteURLToRelativeURL; this.updateContent = TinyMCE_updateContent; this._customCleanup = TinyMCE__customCleanup; this.getContent = TinyMCE_getContent; this.setContent = TinyMCE_setContent; this.importThemeLanguagePack = TinyMCE_importThemeLanguagePack; this.importPluginLanguagePack = TinyMCE_importPluginLanguagePack; this.applyTemplate = TinyMCE_applyTemplate; this.openWindow = TinyMCE_openWindow; this.handleVisualAid = TinyMCE_handleVisualAid; this.setAttrib = TinyMCE_setAttrib; this.getAttrib = TinyMCE_getAttrib; this._getThemeFunction = TinyMCE__getThemeFunction; this._themeExecCommand = TinyMCE__themeExecCommand; this.getControlHTML = TinyMCE_getControlHTML; this._setHTML = TinyMCE__setHTML; this._getElementById = TinyMCE__getElementById; this.getInstanceById = TinyMCE_getInstanceById; this.getEditorId = TinyMCE_getEditorId; this.queryInstanceCommandValue = TinyMCE_queryInstanceCommandValue; this.queryInstanceCommandState = TinyMCE_queryInstanceCommandState; this.getWindowArg = TinyMCE_getWindowArg; this.setWindowArg = TinyMCE_setWindowArg; this.getCSSClasses = TinyMCE_getCSSClasses; this.regexpReplace = TinyMCE_regexpReplace; this.cleanupEventStr = TinyMCE_cleanupEventStr; this.getAbsPosition = TinyMCE_getAbsPosition; this.openFileBrowser = TinyMCE_openFileBrowser; } function TinyMCE_init(settings) { var theme; this.settings = settings; function defParam(key, def_val) { settings[key] = tinyMCE.getParam(key, def_val); } // Check if valid browser has execcommand support if (typeof(document.execCommand) == 'undefined') return; // Get script base path if (!tinyMCE.baseURL) { var elements = document.getElementsByTagName('script'); for (var i=0; i'); document.write(''); document.write(''); // Add theme plugins var themePlugins = tinyMCE.getParam('plugins', '', true, ','); if (this.settings['plugins'] != '') { for (var i=0; i'); } } function TinyMCE_confirmAdd(e) { if (tinyMCE.isMSIE) var targetElement = event.srcElement; else var targetElement = e.target; var elementId = targetElement.name ? targetElement.name : targetElement.id; if (!targetElement.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])) tinyMCE.addMCEControl(targetElement, elementId, tinyMCE.createMCEControl(tinyMCE.settings)); else targetElement.setAttribute('mce_noask', 'true'); } function TinyMCE_updateContent(form_element_name) { // find MCE instance linked to given form element and copy it's value var formElement = document.getElementById(form_element_name); for (var instanceName in tinyMCE.instances) { var instance = tinyMCE.instances[instanceName]; if (instance.formElement == formElement) { tinyMCE._setHTML(instance.contentWindow.document, instance.formElement.value); if (!tinyMCE.isMSIE) instance.contentWindow.document.body.innerHTML = tinyMCE._cleanupHTML(instance.contentWindow.document, this.settings, instance.contentWindow.document.body, instance.visualAid); } } } function TinyMCE_addMCEControl(replace_element, form_element_name, mce_control) { var editorId = "mce_editor_" + tinyMCE.idCounter++; mce_control.editorId = editorId; this.instances[editorId] = mce_control; mce_control.onAdd(replace_element, form_element_name); } function TinyMCE_createMCEControl(settings) { return new TinyMCEControl(settings); } function TinyMCE_triggerSave(skip_cleanup, skip_callback) { // Cleanup and set all form fields for (var instanceName in tinyMCE.instances) { var instance = tinyMCE.instances[instanceName]; tinyMCE.settings['preformatted'] = false; // Default to false if (typeof(skip_cleanup) == "undefined") skip_cleanup = false; // Default to false if (typeof(skip_callback) == "undefined") skip_callback = false; tinyMCE._setHTML(instance.contentWindow.document, instance.contentWindow.document.body.innerHTML); var htm = skip_cleanup ? instance.contentWindow.document.body.innerHTML : tinyMCE._cleanupHTML(instance.contentWindow.document, this.settings, instance.contentWindow.document.body, this.visualAid, true); //var htm = tinyMCE._cleanupHTML(instance.contentWindow.document, tinyMCE.settings, instance.contentWindow.document.body, false, true); if (tinyMCE.settings["encoding"] == "xml" || tinyMCE.settings["encoding"] == "html") htm = tinyMCE.convertStringToXML(htm); if (!skip_callback && tinyMCE.settings['save_callback'] != "") var content = eval(tinyMCE.settings['save_callback'] + "(instance.formTargetElementId,htm,instance.contentWindow.document.body);"); // Use callback content if available if ((typeof(content) != "undefined") && content != null) htm = content; // Replace some weird entities (Bug: #1056343) htm = tinyMCE.regexpReplace(htm, "(", "(", "gi"); htm = tinyMCE.regexpReplace(htm, ")", ")", "gi"); htm = tinyMCE.regexpReplace(htm, ";", ";", "gi"); htm = tinyMCE.regexpReplace(htm, """, """, "gi"); htm = tinyMCE.regexpReplace(htm, "^", "^", "gi"); instance.formElement.value = htm; } } function TinyMCE__convertOnClick(node) { // Skip on MSIE < 6+ if (tinyMCE.isMSIE5) return; // Convert all onclick to mce_onclick var elms = node.getElementsByTagName("a"); for (var i=0; i", "gi"); content = tinyMCE.regexpReplace(content, "\r", "
", "gi"); content = tinyMCE.regexpReplace(content, "\n", "
", "gi"); } // Call custom cleanup code content = tinyMCE._customCleanup("insert_to_editor", content); if (tinyMCE.isMSIE) { var styleSheet = document.frames[editor_id].document.createStyleSheet(instance.settings['content_css']); // Ugly!!! window.setInterval('try{tinyMCE.getCSSClasses(document.frames["' + editor_id + '"].document, "' + editor_id + '");}catch(e){}', 500); if (tinyMCE.settings["force_br_newlines"]) document.frames[editor_id].document.styleSheets[0].addRule("p", "margin: 0px;"); var patchFunc = function() { var event = document.frames[editor_id].event; event.target = document.frames[editor_id].document; TinyMCE_handleEvent(event); }; var body = document.frames[editor_id].document.body; body.onbeforepaste = patchFunc; body.onbeforecut = patchFunc; body.onpaste = patchFunc; body.editorId = editor_id; } else { var targetDocument = document.getElementById(editor_id).contentWindow.document; // Import editor css var cssImporter = targetDocument.createElement("link"); cssImporter.rel = "stylesheet"; cssImporter.href = instance.settings['content_css']; if (headArr = targetDocument.getElementsByTagName("head")); headArr[0].appendChild(cssImporter); } // Fix for bug #958637 if (!tinyMCE.isMSIE) { if (tinyMCE.settings['force_p_newlines']) { // Remove weridness! content = content.replace(new RegExp('<>', 'g'), ""); } if (tinyMCE.settings['cleanup_on_startup']) { var contentElement = instance.contentWindow.document.createElement("body"); contentElement.innerHTML = content; instance.contentWindow.document.body.innerHTML = tinyMCE._cleanupHTML(instance.contentWindow.document, this.settings, contentElement); } else { var contentElement = instance.contentWindow.document.createElement("body"); var doc = instance.contentWindow.document; // Convert all strong/em to b/i content = tinyMCE.regexpReplace(content, "", "", "gi"); content = tinyMCE.regexpReplace(content, "", "", "gi"); contentElement.innerHTML = content; // Convert img src nodes var elms = contentElement.getElementsByTagName("img"); for (var i=0; i"); rng.collapse(false); rng.select(); tinyMCE.triggerNodeChange(false); return false; } } // Backspace or delete if (e.keyCode == 8 || e.keyCode == 46) { tinyMCE.selectedElement = e.target; tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a"); tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img"); tinyMCE.triggerNodeChange(false); } return false; break; case "keyup": case "keydown": if (e.target.editorId) tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId]; else return; // Handle backspace if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { // Insert P element instead of BR if (tinyMCE.selectedInstance._handleBackSpace()) { // Cancel event e.preventDefault(); return false; } } tinyMCE.selectedElement = null; tinyMCE.selectedNode = null; var elm = tinyMCE.selectedInstance.getFocusElement(); tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); tinyMCE.selectedElement = elm; // Update visualaids on tabs if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) tinyMCE.handleVisualAid(tinyMCE.selectedInstance.contentWindow.document.body, true, tinyMCE.settings['visual']); // Insert space instead of   /* if (e.type == "keydown" && e.keyCode == 32) { if (tinyMCE.selectedInstance._insertSpace()) { // Cancel event e.returnValue = false; e.cancelBubble = true; return false; } }*/ // MSIE custom key handling if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) { // Check if it's a position key press var keys = new Array(13,45,36,35,33,34,37,38,39,40); var posKey = false; for (var i=0; i 18 && e.keyCode != 255)) { tinyMCE.selectedInstance.execCommand("mceAddUndoLevel"); tinyMCE.selectedInstance.typing = true; tinyMCE.triggerNodeChange(false); } if (posKey && e.type == "keyup") tinyMCE.triggerNodeChange(false); var ctrlKeys = new Array(66,73,85,86,88); // B/I/U/V/X var keys = new Array(8,46); // Backspace,Delete for (var i=0; i 0) { for (var i=0; i "; // Is MSIE script element if (tinyMCE.isMSIE && elementName == "script") return "<" + elementName + elementAttribs + ">" + node.text + ""; // Clean up children if (node.hasChildNodes()) { // Force BR if (elementName == "p" && tinyMCE.cleanup_force_br_newlines) output += ""; else output += "<" + elementName + elementAttribs + ">"; for (var i=0; i"; } else { // Allways leave anchor elements open if (elementName == "a") output += "<" + elementName + elementAttribs + ">"; else { // No children output += "<" + elementName + elementAttribs + " />"; } } return output; case 3: // Text // Do not convert script elements if (node.parentNode.nodeName.toLowerCase() == "script") return node.nodeValue; return this.convertStringToXML(node.nodeValue); case 8: // Comment return ""; default: // Unknown return "[UNKNOWN NODETYPE " + node.nodeType + "]"; } } function TinyMCE_convertStringToXML(html_data) { var output = ""; for (var i=0; i', '', 'gi'); var html = this.cleanupNode(element); if (tinyMCE.settings['debug']) alert("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms."); // Remove pesky HR paragraphs html = tinyMCE.regexpReplace(html, '


', '
'); html = tinyMCE.regexpReplace(html, '

 


 

', '
'); // Remove some mozilla crap if (!tinyMCE.isMSIE) { html = html.replace(new RegExp('', 'g'), ""); } if (tinyMCE.settings['apply_source_formatting']) { html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n"); html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n\n"); html = html.replace(new RegExp('
', 'g'), "
\n"); } if (tinyMCE.settings['force_br_newlines']) { var re = new RegExp('

 

', 'g'); html = html.replace(re, "
"); } if (tinyMCE.settings['force_p_newlines']) { // Remove weridness! var re = new RegExp('<>', 'g'); html = html.replace(re, ""); } // Emtpy node, return empty if (html == "
" || html == "

 

") html = ""; // Call custom cleanup code html = tinyMCE._customCleanup(on_save ? "get_from_editor" : "insert_to_editor", html); if (tinyMCE.settings["preformatted"]) return "
" + html + "
"; return html; } function TinyMCE_insertLink(href, target, title, onclick) { function setAttrib(element, name, value) { if (value != null && value != "") element.setAttribute(name, value); else element.removeAttribute(name); } this.execCommand("mceAddUndoLevel"); if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") { var doc = this.selectedInstance.contentWindow.document; var linkElement = doc.createElement("a"); href = eval(tinyMCE.settings['urlconvertor_callback'] + "(href, linkElement);"); setAttrib(linkElement, 'href', href); setAttrib(linkElement, 'target', target); setAttrib(linkElement, 'title', title); setAttrib(linkElement, 'mce_onclick', onclick); linkElement.appendChild(this.selectedElement.cloneNode(true)); this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement); return; } if (!this.linkElement && this.selectedInstance) { this.selectedInstance.contentDocument.execCommand("createlink", false, "#mce_temp_url#"); tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", "#mce_temp_url#"); var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", "#mce_temp_url#"); for (var i=0; i= strTok2.length) { for (var i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { breakPoint = i + 1; break; } } } if (strTok1.length < strTok2.length) { for (var i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { breakPoint = i + 1; break; } } } if (breakPoint == 1) return url_to_relative; for (var i=0; i<(strTok1.length-(breakPoint-1)); i++) outputString += "../"; for (var i=breakPoint-1; i 0); if (tinyMCE.settings['custom_undo_redo']) { undoIndex = inst.undoIndex; undoLevels = inst.undoLevels.length; } // Trigger plugin nodechanges var plugins = tinyMCE.getParam('plugins', '', true, ','); for (var i=0; i'); } function TinyMCE_importPluginLanguagePack(theme_name, valid_languages) { var lang = "en"; valid_languages = valid_languages.split(','); for (var i=0; i'); } /** * Adds themeurl, settings and lang to HTML code. */ function TinyMCE_applyTemplate(html, args) { html = tinyMCE.replaceVar(html, "themeurl", tinyMCE.themeURL); if (typeof(args) != "undefined") html = tinyMCE.replaceVars(html, args); html = tinyMCE.replaceVars(html, tinyMCE.settings); html = tinyMCE.replaceVars(html, tinyMCELang); return html; } function TinyMCE_openWindow(template, args) { var html, width, height, x, y, resizable, scrollbars, url; args['mce_template_file'] = template['file']; tinyMCE.windowArgs = args; html = template['html']; if (!(width = template['width'])) width = 320; if (!(height = template['height'])) height = 200; // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! if (tinyMCE.isMSIE) height += 30; x = parseInt(screen.width / 2.0) - (width / 2.0); y = parseInt(screen.height / 2.0) - (height / 2.0); resizable = (args && args['resizable']) ? args['resizable'] : "no"; scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; // Replace all args as variables in URL for (var name in args) url = tinyMCE.replaceVar(url, name, escape(args[name])); if (html) { html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']); html = tinyMCE.applyTemplate(html, args); var win = window.open("", "mcePopup", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); win.document.write(html); win.document.close(); win.resizeTo(width, height); win.focus(); } else { if (tinyMCE.isMSIE && resizable != 'yes') { var features = "resizable:" + resizable + ";scroll:" + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + width + "px;dialogHeight:" + height + "px;"; window.showModalDialog(url, window, features); } else { var win = window.open(url, "mcePopup", "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); eval('try { win.resizeTo(width, height); } catch(e) { }'); win.focus(); } } } function TinyMCE_handleVisualAid(element, deep, state) { var tableElement = null; // Remove visual aid elements /* if (!state && element.getAttribute && element.getAttribute('mceVisualAid') == "true") { element.parentNode.removeChild(element); return; }*/ switch (element.nodeName.toLowerCase()) { case "table": var cssText = element.getAttribute("border") == 0 ? tinyMCE.settings['visual_table_style'] : ""; var attribValue = element.style.pixelWidth == 0 ? element.getAttribute("width") : element.style.pixelWidth; element.setAttribute("width", attribValue); attribValue = element.style.pixelHeight == 0 ? element.getAttribute("height") : element.style.pixelHeight; element.setAttribute("height", attribValue); element.style.cssText = state ? cssText : ""; for (var y=0; y'; return; } break;*/ } if (deep && element.hasChildNodes()) { for (var i=0; i

breaks runtime? if (tinyMCE.isMSIE) { var re = new RegExp('


', 'g'); html_content = html_content.replace(re, "
"); } doc.body.innerHTML = html_content; // *Content duplication bug fix if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) { // Remove P elements in P elements var paras = doc.getElementsByTagName("P"); for (var i=0; i<\/o:p>", "
"); html = tinyMCE.regexpReplace(html, " <\/o:p>", ""); html = tinyMCE.regexpReplace(html, "", ""); html = tinyMCE.regexpReplace(html, "

<\/p>", ""); html = tinyMCE.regexpReplace(html, "

<\/p>\r\n

<\/p>", ""); html = tinyMCE.regexpReplace(html, "

 <\/p>", "
"); html = tinyMCE.regexpReplace(html, "

\s*(

\s*)?", "

"); html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "

"); } // Always set the htmlText output doc.body.innerHTML = html; } } function TinyMCE__getElementById(element_id) { var elm = document.getElementById(element_id); if (!elm) { // Check for element in forms for (var j=0; j 0) { var csses = null; // Just ignore any errors eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(0).rules : doc.styleSheets[0].cssRules;} catch(e) {}"); if (!csses) return null; for (var i=0; i 0) tinyMCE.cssClasses = output; return output; } function TinyMCE_regexpReplace(in_str, reg_exp, replace_str, opts) { if (typeof(opts) == "undefined") opts = 'g'; var re = new RegExp(reg_exp, opts); return in_str.replace(re, replace_str); } function TinyMCE_cleanupEventStr(str) { str = "" + str; str = str.replace('function anonymous()\n{\n', ''); str = str.replace('\n}', ''); return str; } function TinyMCE_getAbsPosition(node) { var x = 0, y = 0; var pos = new Object(); var parentNode = node; while (parentNode) { x += parentNode.offsetLeft; y += parentNode.offsetTop; parentNode = parentNode.offsetParent; } pos.absLeft = x; pos.absTop = y; return pos; } function TinyMCE_openFileBrowser(field_name, url, type) { var cb = tinyMCE.getParam("file_browser_callback"); // Call to external callback if(eval('typeof('+cb+')') == "undefined") alert("Callback function: " + cb + " could not be found."); else eval(cb + "(field_name, url, type);"); } // TinyMCEControl function TinyMCEControl(settings) { // Undo levels this.undoLevels = new Array(); this.undoIndex = 0; // Default settings this.settings = settings; this.settings['theme'] = tinyMCE.getParam("theme", "default"); this.settings['width'] = tinyMCE.getParam("width", -1); this.settings['height'] = tinyMCE.getParam("height", -1); // Functions this.execCommand = TinyMCEControl_execCommand; this.queryCommandValue = TinyMCEControl_queryCommandValue; this.queryCommandState = TinyMCEControl_queryCommandState; this.onAdd = TinyMCEControl_onAdd; this.getFocusElement = TinyMCEControl_getFocusElement; this.autoResetDesignMode = TinyMCEControl_autoResetDesignMode; this._insertPara = TinyMCEControl__insertPara; this._insertSpace = TinyMCEControl__insertSpace; this._handleBackSpace = TinyMCEControl__handleBackSpace; this.selectNode = TinyMCEControl_selectNode; } function TinyMCEControl_selectNode(node, collapse, select_text_node) { if (typeof(collapse) == "undefined") collapse = true; if (typeof(select_text_node) == "undefined") select_text_node = false; if (tinyMCE.isMSIE) { var rng = this.contentWindow.document.body.createTextRange(); rng.moveToElementText(node); if (collapse) rng.collapse(false); rng.select(); } else { var rng = this.contentWindow.document.createRange(); var sel = this.contentWindow.getSelection(); // Select the text node within if (select_text_node && (node.firstChild && node.firstChild.nodeType == 3)) rng.selectNodeContents(node.firstChild); else rng.selectNodeContents(node); if (collapse) rng.collapse(true); sel.removeAllRanges(); sel.addRange(rng); } // Scroll to node position var pos = tinyMCE.getAbsPosition(node); var doc = this.contentWindow.document; var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft; var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop; var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : parseInt(this.targetElement.style.height); // Only scroll if out of visible area if (!tinyMCE.settings['auto_resize'] && !(node.absTop > scrollY && node.absTop < (scrollY - 25 + height))) this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25); // Set selected element tinyMCE.selectedElement = null; if (node.nodeType == 1) tinyMCE.selectedElement = node; } function TinyMCEControl__insertPara() { var doc = this.contentWindow.document; var sel = this.contentWindow.getSelection(); var win = this.contentWindow; // Setup before range var rngBefore = doc.createRange(); rngBefore.setStart(sel.anchorNode, sel.anchorOffset); rngBefore.collapse(true); // Setup after range var rngAfter = doc.createRange(); rngAfter.setStart(sel.focusNode, sel.focusOffset); rngAfter.collapse(true); // Setup start/end points var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0; var startNode = direct ? sel.anchorNode : sel.focusNode; var startOffset = direct ? sel.anchorOffset : sel.focusOffset; var endNode = direct ? sel.focusNode : sel.anchorNode; var endOffset = direct ? sel.focusOffset : sel.anchorOffset; // Get block elements var startBlock = tinyMCE.getParentBlockElement(startNode); var endBlock = tinyMCE.getParentBlockElement(endNode); // Within a list item (use normal behavior) if ((startBlock != null && startBlock.nodeName.toLowerCase() == "li") || (endBlock != null && endBlock.nodeName.toLowerCase() == "li")) return false; // Within a table create new paragraphs if ((startBlock != null && startBlock.nodeName.toLowerCase() == "table") || (endBlock != null && endBlock.nodeName.toLowerCase() == "table")) startBlock = endBlock = null; // Setup new paragraphs var paraBefore = (startBlock != null && startBlock.nodeName.toLowerCase() == "p") ? startBlock.cloneNode(false) : doc.createElement("p"); var paraAfter = (endBlock != null && endBlock.nodeName.toLowerCase() == "p") ? endBlock.cloneNode(false) : doc.createElement("p"); // Setup chop nodes var startChop = startNode; var endChop = endNode; while ((startChop.previousSibling && startChop.previousSibling.nodeName.toLowerCase() != 'p') || (startChop.parentNode && startChop.parentNode != startBlock && startChop.parentNode.nodeType != 9)) startChop = startChop.previousSibling ? startChop.previousSibling : startChop.parentNode; while ((endChop.nextSibling && endChop.nextSibling.nodeName.toLowerCase() != 'p') || (endChop.parentNode && endChop.parentNode != endBlock && endChop.parentNode.nodeType != 9)) endChop = endChop.nextSibling ? endChop.nextSibling : endChop.parentNode; // Fix first node if (startChop.nodeName.toLowerCase() == "html") startChop = sel.focusNode; // Empty document if (sel.focusNode.nodeName.toLowerCase() == "body") { var html = tinyMCE.regexpReplace(doc.body.innerHTML, "[ \t\r\n]", ""); if (html == "" || html == "
") { doc.body.innerHTML = "

 

 

"; this.selectNode(doc.body.childNodes[1], true, true); return true; } } // Place first part within new paragraph rngBefore.setStartBefore(startChop); rngBefore.setEnd(startNode, startOffset); paraBefore.appendChild(rngBefore.cloneContents()); // Place secound part within new paragraph rngAfter.setEndAfter(endChop); rngAfter.setStart(endNode, endOffset); paraAfter.appendChild(rngAfter.cloneContents()); // Check if it's a empty paragraph if (paraBefore.innerHTML == "") paraBefore.innerHTML = " "; // Check if it's a empty paragraph if (paraAfter.innerHTML == "") paraAfter.innerHTML = " "; // Create a range around everything var rng = doc.createRange(); if (!startChop.previousSibling && startChop.parentNode.nodeName.toLowerCase() == 'p') rng.setStartBefore(startChop.parentNode); else { if (rngBefore.startContainer.nodeName.toLowerCase() == 'p' && rngBefore.startOffset == 0) rng.setStartBefore(rngBefore.startContainer); else rng.setStart(rngBefore.startContainer, rngBefore.startOffset); } if (!endChop.nextSibling && endChop.parentNode.nodeName.toLowerCase() == 'p') rng.setEndAfter(endChop.parentNode); else rng.setEnd(rngAfter.endContainer, rngAfter.endOffset); // Delete all contents and insert new paragraphs rng.deleteContents(); rng.insertNode(paraAfter); rng.insertNode(paraBefore); this.selectNode(paraAfter, true, true); return true; } function TinyMCEControl__insertSpace() { return true; } function TinyMCEControl__handleBackSpace() { var sel = this.contentWindow.getSelection(); if (sel == null) return false; var rng = sel.getRangeAt(0); var node = rng.startContainer; while (node != null && (node = node.nextSibling) != null) { if (node.nodeName == 'BR') node.parentNode.removeChild(node); else if (node.nodeType == 1) // Break at other element break; } return false; } function TinyMCEControl_autoResetDesignMode() { // Add fix for tab/style.display none/block problems in Gecko if (!tinyMCE.isMSIE && tinyMCE.settings['auto_reset_designmode']) { var sel = this.contentWindow.getSelection(); // Weird, wheres that cursor selection? if (!sel || !sel.rangeCount || sel.rangeCount == 0) eval('try { this.contentWindow.document.designMode = "On"; } catch(e) {}'); } } function TinyMCEControl_execCommand(command, user_interface, value) { function getAttrib(elm, name) { return elm.getAttribute(name) ? elm.getAttribute(name) : ""; } // Mozilla issue if (!tinyMCE.isMSIE && !this.useCSS) { this.contentWindow.document.execCommand("useCSS", false, true); this.useCSS = true; } //alert("command: " + command + ", user_interface: " + user_interface + ", value: " + value); this.contentDocument = this.contentWindow.document; // <-- Strange!! // Call theme execcommand if (tinyMCE._themeExecCommand(this.editorId, this.contentDocument.body, command, user_interface, value)) return; // Add undo level of operation if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceImage" && command != "mceLink" && command != "mceToggleVisualAid" && (command != "mceInsertTable" && !user_interface)) this.execCommand("mceAddUndoLevel"); // Fix align on images if (this.getFocusElement() && this.getFocusElement().nodeName.toLowerCase() == "img") { var align = this.getFocusElement().getAttribute('align'); switch (command) { case "JustifyLeft": if (align == 'left') this.getFocusElement().removeAttribute('align'); else this.getFocusElement().setAttribute('align', 'left'); tinyMCE.triggerNodeChange(); return; case "JustifyCenter": if (align == 'middle') this.getFocusElement().removeAttribute('align'); else this.getFocusElement().setAttribute('align', 'middle'); tinyMCE.triggerNodeChange(); return; case "JustifyRight": if (align == 'right') this.getFocusElement().removeAttribute('align'); else this.getFocusElement().setAttribute('align', 'right'); tinyMCE.triggerNodeChange(); return; } } if (tinyMCE.settings['force_br_newlines']) { var doc = this.contentWindow.document; var alignValue = ""; if (doc.selection.type != "Control") { switch (command) { case "JustifyLeft": alignValue = "left"; break; case "JustifyCenter": alignValue = "center"; break; case "JustifyFull": alignValue = "justify"; break; case "JustifyRight": alignValue = "right"; break; } if (alignValue != "") { var rng = doc.selection.createRange(); if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) divElm.setAttribute("align", alignValue); else if (rng.pasteHTML && rng.htmlText.length > 0) rng.pasteHTML('
' + rng.htmlText + "
"); tinyMCE.triggerNodeChange(); return; } } } switch (command) { case "mceSelectNode": this.selectNode(value); tinyMCE.triggerNodeChange(); tinyMCE.selectedNode = value; break; case "mceSelectNodeDepth": var parentNode = this.getFocusElement(); for (var i=0; parentNode; i++) { if (parentNode.nodeName.toLowerCase() == "body") break; if (parentNode.nodeName.toLowerCase() == "#text") { i--; parentNode = parentNode.parentNode; continue; } if (i == value) { this.selectNode(parentNode, false); tinyMCE.triggerNodeChange(); tinyMCE.selectedNode = parentNode; return; } parentNode = parentNode.parentNode; } break; case "HiliteColor": if (tinyMCE.isGecko) { this.contentDocument.execCommand("useCSS", false, false); this.contentDocument.execCommand('hilitecolor', false, value); this.contentDocument.execCommand("useCSS", false, true); } else this.contentDocument.execCommand('backcolor', false, value); break; case "Cut": case "Copy": case "Paste": var cmdFailed = false; // Try executing command eval('try {this.contentDocument.execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}'); // Alert error in gecko if command failed if (tinyMCE.isGecko && cmdFailed) { // Confirm more info if (confirm(tinyMCE.getLang('lang_clipboard_msg'))) window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal'); return; } else tinyMCE.triggerNodeChange(); break; case "mceLink": var selectedText = ""; if (tinyMCE.isMSIE) { var doc = this.contentWindow.document; var rng = doc.selection.createRange(); selectedText = rng.text; } else selectedText = this.contentWindow.getSelection().toString(); if (!tinyMCE.linkElement) { if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) return; } var href = "", target = "", title = "", onclick = "", action = "insert"; if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") tinyMCE.linkElement = tinyMCE.selectedElement; // Is anchor not a link if (tinyMCE.linkElement != null && getAttrib(tinyMCE.linkElement, 'href') == "") tinyMCE.linkElement = null; if (tinyMCE.linkElement) { href = getAttrib(tinyMCE.linkElement, 'href'); target = getAttrib(tinyMCE.linkElement, 'target'); title = getAttrib(tinyMCE.linkElement, 'title'); onclick = getAttrib(tinyMCE.linkElement, 'mce_onclick'); // Try old onclick to if copy/pasted content if (onclick == "") onclick = getAttrib(tinyMCE.linkElement, 'onclick'); onclick = tinyMCE.cleanupEventStr(onclick); // Fix for drag-drop/copy paste bug in Mozilla mceRealHref = getAttrib(tinyMCE.linkElement, 'mce_real_href'); if (mceRealHref != "") href = mceRealHref; href = eval(tinyMCE.settings['urlconvertor_callback'] + "(href, tinyMCE.linkElement, true);"); action = "update"; } if (this.settings['insertlink_callback']) { var returnVal = eval(this.settings['insertlink_callback'] + "(href, target, title, onclick, action);"); if (returnVal && returnVal['href']) tinyMCE.insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick']); } else { tinyMCE.openWindow(this.insertLinkTemplate, {href : href, target : target, title : title, onclick : onclick, action : action}); } break; case "mceImage": var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; var title = "", onmouseover = "", onmouseout = "", action = "insert"; if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") tinyMCE.imgElement = tinyMCE.selectedElement; if (tinyMCE.imgElement) { // Is it a internal MCE visual aid image, then skip this one. var imgName = getAttrib(tinyMCE.imgElement, 'name'); if (imgName.substring(0, 4)=='mce_') return; src = getAttrib(tinyMCE.imgElement, 'src'); alt = getAttrib(tinyMCE.imgElement, 'alt'); // Try polling out the title if (alt == "") alt = getAttrib(tinyMCE.imgElement, 'title'); border = getAttrib(tinyMCE.imgElement, 'border'); hspace = getAttrib(tinyMCE.imgElement, 'hspace'); vspace = getAttrib(tinyMCE.imgElement, 'vspace'); width = getAttrib(tinyMCE.imgElement, 'width'); height = getAttrib(tinyMCE.imgElement, 'height'); align = getAttrib(tinyMCE.imgElement, 'align'); onmouseover = getAttrib(tinyMCE.imgElement, 'onmouseover'); onmouseout = getAttrib(tinyMCE.imgElement, 'onmouseout'); title = getAttrib(tinyMCE.imgElement, 'title'); onmouseover = tinyMCE.cleanupEventStr(onmouseover); onmouseout = tinyMCE.cleanupEventStr(onmouseout); // Fix for drag-drop/copy paste bug in Mozilla mceRealSrc = getAttrib(tinyMCE.imgElement, 'mce_real_src'); if (mceRealSrc != "") src = mceRealSrc; src = eval(tinyMCE.settings['urlconvertor_callback'] + "(src, tinyMCE.imgElement, true);"); action = "update"; } if (this.settings['insertimage_callback']) { var returnVal = eval(this.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); if (returnVal && returnVal['src']) tinyMCE.insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); } else tinyMCE.openWindow(this.insertImageTemplate, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action}); break; case "mceCleanupWord": if (tinyMCE.isMSIE) { var html = this.contentDocument.body.createTextRange().htmlText; if (html.indexOf('="mso') != -1) { tinyMCE._setHTML(this.contentDocument, this.contentDocument.body.innerHTML); html = tinyMCE._cleanupHTML(this.contentDocument, this.settings, this.contentDocument.body, this.visualAid); } this.contentDocument.body.innerHTML = html; } break; case "mceCleanup": tinyMCE._setHTML(this.contentDocument, this.contentDocument.body.innerHTML); this.contentDocument.body.innerHTML = tinyMCE._cleanupHTML(this.contentDocument, this.settings, this.contentDocument.body, this.visualAid); tinyMCE.triggerNodeChange(); break; case "mceAnchor": if (!user_interface) { var aElm = tinyMCE.getParentElement(this.getFocusElement(), "a", "name"); if (aElm) { if (value == null || value == "") { if (tinyMCE.isMSIE) { aElm.outerHTML = aElm.innerHTML; } else { var rng = aElm.ownerDocument.createRange(); rng.setStartBefore(aElm); rng.setEndAfter(aElm); rng.deleteContents(); rng.insertNode(rng.createContextualFragment(aElm.innerHTML)); } } else aElm.setAttribute('name', value); } else { this.contentDocument.execCommand("fontname", false, "#mce_temp_font#"); var elementArray = tinyMCE.getElementsByAttributeValue(this.contentDocument.body, "font", "face", "#mce_temp_font#"); for (var x=0; x 0) { value = tinyMCE.replaceVar(value, "selection", selectedText); tinyMCE.execCommand('mceInsertContent',false,value); } tinyMCE.triggerNodeChange(); break; case "mceSetAttribute": if (typeof(value) == 'object') { var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets']; var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); if (targetNode) { targetNode.setAttribute(value['name'], value['value']); tinyMCE.triggerNodeChange(); } } break; case "mceSetCSSClass": var selectedText = false; if (tinyMCE.isMSIE) { var doc = this.contentWindow.document; var rng = doc.selection.createRange(); selectedText = (rng.text && rng.text.length > 0); } else selectedText = (this.contentWindow.getSelection().toString().length > 0); // Use selectedNode instead if defined if (tinyMCE.selectedNode) tinyMCE.selectedElement = tinyMCE.selectedNode; if (selectedText && !tinyMCE.selectedNode) { this.contentDocument.execCommand("removeformat", false, null); this.contentDocument.execCommand("fontname", false, "#mce_temp_font#"); var elementArray = tinyMCE.getElementsByAttributeValue(this.contentDocument.body, "font", "face", "#mce_temp_font#"); /* this.contentDocument.execCommand("createlink", false, "#mce_temp_url#"); var elementArray = tinyMCE.getElementsByAttributeValue(this.contentDocument.body, "a", "href", "#mce_temp_url#"); */ // Change them all for (var x=0; x customUndoLevels) { for (var i=0; i 0) { this.undoIndex--; this.contentWindow.document.body.innerHTML = this.undoLevels[this.undoIndex]; } //window.status = "Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex; tinyMCE.triggerNodeChange(); } else this.contentDocument.execCommand(command, user_interface, value); break; case "Redo": if (tinyMCE.settings['custom_undo_redo']) { if (this.undoIndex < (this.undoLevels.length-1)) { this.undoIndex++; this.contentWindow.document.body.innerHTML = this.undoLevels[this.undoIndex]; //window.status = "Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex; } tinyMCE.triggerNodeChange(); } else this.contentDocument.execCommand(command, user_interface, value); break; case "mceToggleVisualAid": this.visualAid = !this.visualAid; tinyMCE.handleVisualAid(this.contentWindow.document.body, true, this.visualAid); tinyMCE.triggerNodeChange(); break; /* case "removeformat": //this.contentDocument.execCommand('FormatBlock', user_interface, ''); var doc = this.contentWindow.document; var rng = doc.selection.createRange(); var elm = rng.item ? rng.item(0) : rng.parentElement(); html = "" + rng.text + "<" + elm.nodeName + ">"; this.contentDocument.execCommand('FontName', user_interface, '#mce_temp_name#'); var html = this.contentDocument.innerHTML; html.replace('=0; i--) { templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML"; if (eval("typeof(" + templateFunction + ")") != 'undefined') { var html = eval(templateFunction + "('" + control_name + "');"); if (html != "") return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]); } } return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');"); } function TinyMCE__themeExecCommand(editor_id, element, command, user_interface, value) { var themePlugins = tinyMCE.getParam('plugins', '', true, ','); var templateFunction; // Is it defined in any plugins for (var i=themePlugins.length; i>=0; i--) { templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand"; if (eval("typeof(" + templateFunction + ")") != 'undefined') { if (eval(templateFunction + "(editor_id, element, command, user_interface, value);")) return true; } } // Theme funtion templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand"; if (eval("typeof(" + templateFunction + ")") != 'undefined') return eval(templateFunction + "(editor_id, element, command, user_interface, value);"); // Pass to normal return false; } function TinyMCE__getThemeFunction(suffix, skip_plugins) { if (skip_plugins) return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; var themePlugins = tinyMCE.getParam('plugins', '', true, ','); var templateFunction; // Is it defined in any plugins for (var i=themePlugins.length; i>=0; i--) { templateFunction = 'TinyMCE_' + themePlugins[i] + suffix; if (eval("typeof(" + templateFunction + ")") != 'undefined') return templateFunction; } return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; } function TinyMCEControl_queryCommandValue(command) { return this.contentWindow.document.queryCommandValue(command); } function TinyMCEControl_queryCommandState(command) { return this.contentWindow.document.queryCommandState(command); } function TinyMCEControl_onAdd(replace_element, form_element_name) { tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings['theme']; this.settings['themeurl'] = tinyMCE.themeURL; if (!replace_element) { alert("Error: Could not find the target element."); return false; } var templateFunction = tinyMCE._getThemeFunction('_getInsertLinkTemplate'); if (eval("typeof(" + templateFunction + ")") != 'undefined') this.insertLinkTemplate = eval(templateFunction + '(this.settings);'); var templateFunction = tinyMCE._getThemeFunction('_getInsertImageTemplate'); if (eval("typeof(" + templateFunction + ")") != 'undefined') this.insertImageTemplate = eval(templateFunction + '(this.settings);'); var templateFunction = tinyMCE._getThemeFunction('_getEditorTemplate'); if (eval("typeof(" + templateFunction + ")") == 'undefined') { alert("Error: Could not find the template function: " + templateFunction); return false; } var editorTemplate = eval(templateFunction + '(this.settings, this.editorId);'); var deltaWidth = editorTemplate['delta_width'] ? editorTemplate['delta_width'] : 0; var deltaHeight = editorTemplate['delta_height'] ? editorTemplate['delta_height'] : 0; var html = '' + editorTemplate['html']; var templateFunction = tinyMCE._getThemeFunction('_handleNodeChange', true); if (eval("typeof(" + templateFunction + ")") != 'undefined') this.settings['handleNodeChangeCallback'] = templateFunction; html = tinyMCE.replaceVar(html, "editor_id", this.editorId); html = tinyMCE.replaceVar(html, "default_document", tinyMCE.baseURL + "/blank.htm"); this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm"; this.settings['old_width'] = this.settings['width']; this.settings['old_height'] = this.settings['height']; // Set default width, height if (this.settings['width'] == -1) this.settings['width'] = replace_element.offsetWidth; if (this.settings['height'] == -1) this.settings['height'] = replace_element.offsetHeight; this.settings['area_width'] = this.settings['width']; this.settings['area_height'] = this.settings['height']; this.settings['area_width'] += deltaWidth; this.settings['area_height'] += deltaHeight; // Special % handling if (("" + this.settings['width']).indexOf('%') != -1) this.settings['area_width'] = "100%"; if (("" + this.settings['height']).indexOf('%') != -1) this.settings['area_height'] = "100%"; if (("" + replace_element.style.width).indexOf('%') != -1) { this.settings['width'] = replace_element.style.width; this.settings['area_width'] = "100%"; } if (("" + replace_element.style.height).indexOf('%') != -1) { this.settings['height'] = replace_element.style.height; this.settings['area_height'] = "100%"; } html = tinyMCE.applyTemplate(html); this.settings['width'] = this.settings['old_width']; this.settings['height'] = this.settings['old_height']; this.visualAid = this.settings['visual']; this.formTargetElementId = form_element_name; // Get replace_element contents if (replace_element.nodeName.toLowerCase() == "textarea") this.startContent = replace_element.value; else this.startContent = replace_element.innerHTML; // If not text area if (replace_element.nodeName.toLowerCase() != "textarea") { this.oldTargetElement = replace_element.cloneNode(true); // Debug mode if (tinyMCE.settings['debug']) html += ''; else html += ''; html += ''; // Output HTML and set editable if (!tinyMCE.isMSIE) { var rng = replace_element.ownerDocument.createRange(); rng.setStartBefore(replace_element); var fragment = rng.createContextualFragment(html); replace_element.parentNode.replaceChild(fragment, replace_element); } else replace_element.outerHTML = html; } else { html += ''; // Just hide the textarea element this.oldTargetElement = replace_element; if (!tinyMCE.settings['debug']) this.oldTargetElement.style.display = "none"; // Output HTML and set editable if (!tinyMCE.isMSIE) { var rng = replace_element.ownerDocument.createRange(); rng.setStartBefore(replace_element); var fragment = rng.createContextualFragment(html); replace_element.parentNode.insertBefore(fragment, replace_element); } else replace_element.insertAdjacentHTML("beforeBegin", html); } // Setup iframe var dynamicIFrame = false; var tElm = document.getElementById(this.editorId); if (!tinyMCE.isMSIE) { if (tElm && tElm.nodeName.toLowerCase() == "span") { tElm = tinyMCE._createIFrame(tElm); dynamicIFrame = true; } this.targetElement = tElm; this.iframeElement = tElm; this.contentDocument = tElm.contentDocument; this.contentWindow = tElm.contentWindow; //this.contentWindow.document.designMode = "on"; } else { if (tElm && tElm.nodeName.toLowerCase() == "span") tElm = tinyMCE._createIFrame(tElm); else tElm = document.frames[this.editorId]; this.targetElement = tElm; this.iframeElement = document.getElementById(this.editorId); this.contentDocument = tElm.window.document; this.contentWindow = tElm.window; this.contentDocument.designMode = "on"; } // Setup base HTML var doc = this.contentDocument; if (dynamicIFrame) { var html = "" + '' + '' + '' + 'blank_page' + '' + '' + '' + '' + ''; try { this.contentWindow.document.designMode = "on"; doc.open(); doc.write(html); doc.close(); } catch (e) { // Failed Mozilla 1.3 this.contentWindow.document.location.href = tinyMCE.baseURL + "/blank.htm"; } } // This timeout is needed in MSIE 5.5 for some odd reason // it seems that the document.frames isn't initialized yet? if (tinyMCE.isMSIE) window.setTimeout("TinyMCE_addEventHandlers('" + this.editorId + "');", 1); //window.setTimeout("tinyMCE.setupContent('" + this.editorId + "');", (tinyMCE.isMSIE ? 1 : 1000)); tinyMCE.setupContent(this.editorId); return true; } function TinyMCEControl_getFocusElement() { if (tinyMCE.isMSIE) { var doc = this.contentWindow.document; var rng = doc.selection.createRange(); var elm = rng.item ? rng.item(0) : rng.parentElement(); } else { var sel = this.contentWindow.getSelection(); var elm = (sel && sel.anchorNode) ? sel.anchorNode : null; if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") elm = tinyMCE.selectedElement; } return elm; } // Global instances var tinyMCE = new TinyMCE(); var tinyMCELang = new Array();