X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/ff81ee6e8304a1982a3ec4f5b134764a29d502cf..refs/tags/wordpress-2.7.1:/wp-includes/js/tinymce/tiny_mce.js diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index 3f6c6bf3..55aba6e3 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -1,6081 +1 @@ -/** - * $RCSfile: tiny_mce_src.js,v $ - * $Revision: 1.281 $ - * $Date: 2005/12/02 08:12:07 $ - * - * @author Moxiecode - * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. - */ - -function TinyMCE() { - this.majorVersion = "2"; - this.minorVersion = "0"; - this.releaseDate = "2005-12-01"; - - this.instances = new Array(); - this.stickyClassesLookup = new Array(); - this.windowArgs = new Array(); - this.loadedFiles = new Array(); - this.configs = new Array(); - this.currentConfig = 0; - this.eventHandlers = new Array(); - - // Browser check - var ua = navigator.userAgent; - this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); - this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1); - this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1); - this.isGecko = ua.indexOf('Gecko') != -1; - this.isSafari = ua.indexOf('Safari') != -1; - this.isOpera = ua.indexOf('Opera') != -1; - this.isMac = ua.indexOf('Mac') != -1; - this.isNS7 = ua.indexOf('Netscape/7') != -1; - this.isNS71 = ua.indexOf('Netscape/7.1') != -1; - this.dialogCounter = 0; - - // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those - if (this.isOpera) { - this.isMSIE = true; - this.isGecko = false; - this.isSafari = false; - } - - // TinyMCE editor id instance counter - this.idCounter = 0; -}; - -TinyMCE.prototype.defParam = function(key, def_val) { - this.settings[key] = tinyMCE.getParam(key, def_val); -}; - -TinyMCE.prototype.init = function(settings) { - var theme; - - this.settings = settings; - - // 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'); - this.defParam("font_size_classes", ''); - this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large'); - this.defParam("event_elements", 'a,img'); - this.defParam("convert_urls", true); - this.defParam("table_inline_editing", false); - this.defParam("object_resizing", true); - - // Browser check IE - if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1) - return; - - // Browser check Gecko - if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1) - return; - - // Browser check Safari - if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1) - return; - - // Browser check Opera - if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1) - return; - - // If not super absolute make it so - var baseHREF = tinyMCE.settings['document_base_url']; - var h = document.location.href; - var p = h.indexOf('://'); - if (p > 0 && document.location.protocol != "file:") { - p = h.indexOf('/', p + 3); - h = h.substring(0, p); - - if (baseHREF.indexOf('://') == -1) - baseHREF = h + baseHREF; - - tinyMCE.settings['document_base_url'] = baseHREF; - tinyMCE.settings['document_base_prefix'] = h; - } - - // Trim away query part - if (baseHREF.indexOf('?') != -1) - baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); - - this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; - - theme = this.settings['theme']; - this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i"); - this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); - this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL - this.uniqueTag = ''; - - // Theme url - this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme; - - if (!tinyMCE.isMSIE) - this.settings['force_br_newlines'] = false; - - if (tinyMCE.getParam("content_css", false)) { - var cssPath = tinyMCE.getParam("content_css", ""); - - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['content_css'] = this.documentBasePath + "/" + cssPath; - else - this.settings['content_css'] = cssPath; - } else - this.settings['content_css'] = ''; - - if (tinyMCE.getParam("popups_css", false)) { - var cssPath = tinyMCE.getParam("popups_css", ""); - - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['popups_css'] = this.documentBasePath + "/" + cssPath; - else - this.settings['popups_css'] = cssPath; - } else - this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css"; - - if (tinyMCE.getParam("editor_css", false)) { - var cssPath = tinyMCE.getParam("editor_css", ""); - - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['editor_css'] = this.documentBasePath + "/" + cssPath; - else - this.settings['editor_css'] = cssPath; - } else - this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; - - if (tinyMCE.settings['debug']) { - var msg = "Debug: \n"; - - msg += "baseURL: " + this.baseURL + "\n"; - msg += "documentBasePath: " + this.documentBasePath + "\n"; - msg += "content_css: " + this.settings['content_css'] + "\n"; - msg += "popups_css: " + this.settings['popups_css'] + "\n"; - msg += "editor_css: " + this.settings['editor_css'] + "\n"; - - alert(msg); - } - - // Init HTML cleanup - this._initCleanup(); - - // Only do this once - if (this.configs.length == 0) { - // Is Safari enabled - if (this.isSafari && this.getParam('safari_warning', true)) - alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false"); - - tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad); - - if (tinyMCE.isMSIE) { - if (tinyMCE.settings['add_unload_trigger']) { - tinyMCE.addEvent(window, "unload", TinyMCE.prototype.unloadHandler); - tinyMCE.addEvent(window.document, "beforeunload", TinyMCE.prototype.unloadHandler); - } - } else { - if (tinyMCE.settings['add_unload_trigger']) - tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); - } - } - - this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js'); - this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js'); - this.loadCSS(this.settings['editor_css']); - - // Add plugins - var themePlugins = tinyMCE.getParam('plugins', '', true, ','); - if (this.settings['plugins'] != '') { - for (var i=0; i'); - - this.loadedFiles[this.loadedFiles.length] = url; -}; - -TinyMCE.prototype.loadCSS = function(url) { - for (var i=0; i'); - - this.loadedFiles[this.loadedFiles.length] = url; -}; - -TinyMCE.prototype.importCSS = function(doc, css_file) { - if (css_file == '') - return; - - if (typeof(doc.createStyleSheet) == "undefined") { - var elm = doc.createElement("link"); - - elm.rel = "stylesheet"; - elm.href = css_file; - - if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0) - headArr[0].appendChild(elm); - } else - var styleSheet = doc.createStyleSheet(css_file); -}; - -TinyMCE.prototype.confirmAdd = function(e, settings) { - var elm = tinyMCE.isMSIE ? event.srcElement : e.target; - var elementId = elm.name ? elm.name : elm.id; - - tinyMCE.settings = settings; - - if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])) - tinyMCE.addMCEControl(elm, elementId); - - elm.setAttribute('mce_noask', 'true'); -}; - -TinyMCE.prototype.updateContent = function(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 n in tinyMCE.instances) { - var inst = tinyMCE.instances[n]; - if (!tinyMCE.isInstance(inst)) - continue; - - inst.switchSettings(); - - if (inst.formElement == formElement) { - var doc = inst.getDoc(); - - tinyMCE._setHTML(doc, inst.formElement.value); - - if (!tinyMCE.isMSIE) - doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); - } - } -}; - -TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) { - var id = "mce_editor_" + tinyMCE.idCounter++; - var inst = new TinyMCEControl(tinyMCE.settings); - - inst.editorId = id; - this.instances[id] = inst; - - inst.onAdd(replace_element, form_element_name, target_document); -}; - -TinyMCE.prototype.triggerSave = function(skip_cleanup, skip_callback) { - // Cleanup and set all form fields - for (var n in tinyMCE.instances) { - var inst = tinyMCE.instances[n]; - if (!tinyMCE.isInstance(inst)) - continue; - - inst.switchSettings(); - - 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(inst.getDoc(), inst.getBody().innerHTML); - - // Remove visual aids when cleanup is disabled - if (inst.settings['cleanup'] == false) { - tinyMCE.handleVisualAid(inst.getBody(), true, false, inst); - tinyMCE._setEventsEnabled(inst.getBody(), true); - } - - tinyMCE._customCleanup(inst, "submit_content_dom", inst.contentWindow.document.body); - var htm = skip_cleanup ? inst.getBody().innerHTML : tinyMCE._cleanupHTML(inst, inst.getDoc(), this.settings, inst.getBody(), this.visualAid, true); - htm = tinyMCE._customCleanup(inst, "submit_content", htm); - - 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'] + "(inst.formTargetElementId,htm,inst.getBody());"); - - // 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"); - - if (inst.formElement) - inst.formElement.value = htm; - } -}; - -TinyMCE.prototype._setEventsEnabled = function(node, state) { - var events = new Array('onfocus','onblur','onclick','ondblclick', - 'onmousedown','onmouseup','onmouseover','onmousemove', - 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'); - - var evs = tinyMCE.settings['event_elements'].split(','); - for (var y=0; y", "gi"); - content = tinyMCE.regexpReplace(content, "\r", "
", "gi"); - content = tinyMCE.regexpReplace(content, "\n", "
", "gi"); - } - - // Open closed anchors -// content = content.replace(new RegExp('', 'gi'), ''); - - // Call custom cleanup code - content = tinyMCE.storeAwayURLs(content); - content = tinyMCE._customCleanup(inst, "insert_to_editor", content); - - if (tinyMCE.isMSIE) { - // 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 body = document.frames[editor_id].document.body; - - tinyMCE.addEvent(body, "beforepaste", TinyMCE.prototype.eventPatch); - tinyMCE.addEvent(body, "beforecut", TinyMCE.prototype.eventPatch); - - body.editorId = editor_id; - } - - content = tinyMCE.cleanupHTMLCode(content); - - // Fix for bug #958637 - if (!tinyMCE.isMSIE) { - var contentElement = inst.getDoc().createElement("body"); - var doc = inst.getDoc(); - - contentElement.innerHTML = content; - - // Remove weridness! - if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) - content = content.replace(new RegExp('<>', 'g'), ""); - - if (tinyMCE.settings['cleanup_on_startup']) - tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); - else { - // Convert all strong/em to b/i - content = tinyMCE.regexpReplace(content, "", "", "gi"); - content = tinyMCE.regexpReplace(content, "", "", "gi"); - content = tinyMCE.regexpReplace(content, "", "", "gi"); - tinyMCE.setInnerHTML(inst.getBody(), content); - } - - inst.convertAllRelativeURLs(); - } else { - if (tinyMCE.settings['cleanup_on_startup']) { - tinyMCE._setHTML(inst.getDoc(), content); - - // Produces permission denied error in MSIE 5.5 - eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}'); - } else - tinyMCE._setHTML(inst.getDoc(), content); - } - - // Fix for bug #957681 - //inst.getDoc().designMode = inst.getDoc().designMode; - - // Setup element references - var parentElm = document.getElementById(inst.editorId + '_parent'); - if (parentElm.lastChild.nodeName == "INPUT") - inst.formElement = tinyMCE.isGecko ? parentElm.firstChild : parentElm.lastChild; - else - inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; - - tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst); - tinyMCE.executeCallback('setupcontent_callback', '_setupContent', 0, editor_id, inst.getBody(), inst.getDoc()); - - // Re-add design mode on mozilla - if (!tinyMCE.isMSIE) - TinyMCE.prototype.addEventHandlers(editor_id); - - // Add blur handler - if (tinyMCE.isMSIE) - tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE.prototype.eventPatch); - - // Trigger node change, this call locks buttons for tables and so forth - tinyMCE.selectedInstance = inst; - tinyMCE.selectedElement = inst.contentWindow.document.body; - - if (!inst.isHidden()) - tinyMCE.triggerNodeChange(false, true); - - // Call custom DOM cleanup - tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody()); - tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody()); - tinyMCE._setEventsEnabled(inst.getBody(), false); - tinyMCE.cleanupAnchors(inst.getDoc()); - - if (tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertSpansToFonts(inst.getDoc()); - - inst.startContent = tinyMCE.trim(inst.getBody().innerHTML); - inst.undoLevels[inst.undoLevels.length] = inst.startContent; - - tinyMCE.operaOpacityCounter = -1; -}; - -TinyMCE.prototype.cleanupHTMLCode = function(s) { - s = s.replace(/

/gi, '

 

'); - s = s.replace(/

\s*<\/p>/gi, '

 

'); - - // Open closed tags like to -// tinyMCE.debug("f:" + s); - s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3>'); -// tinyMCE.debug("e:" + s); - - // Remove trailing space to - s = s.replace(new RegExp('\\s+> to - s = s.replace(/<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />'); - - // Weird MSIE bug,


breaks runtime? - if (tinyMCE.isMSIE) - s = s.replace(/


<\/p>/gi, "
"); - - // Convert relative anchors to absolute URLs ex: #something to file.htm#something - s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#"); - - return s; -}; - -TinyMCE.prototype.storeAwayURLs = function(s) { - // Remove all mce_src, mce_href and replace them with new ones - s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); - s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); - s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"'); - s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"'); - - return s; -}; - -TinyMCE.prototype.cancelEvent = function(e) { - if (tinyMCE.isMSIE) { - e.returnValue = false; - e.cancelBubble = true; - } else - e.preventDefault(); -}; - -TinyMCE.prototype.removeTinyMCEFormElements = function(form_obj) { - // Check if form is valid - if (typeof(form_obj) == "undefined" || form_obj == null) - return; - - // If not a form, find the form - if (form_obj.nodeName != "FORM") { - if (form_obj.form) - form_obj = form_obj.form; - else - form_obj = tinyMCE.getParentElement(form_obj, "form"); - } - - // Still nothing - if (form_obj == null) - return; - - // Disable all UI form elements that TinyMCE created - for (var i=0; i'); - } - } - - // Return key pressed - if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) { - if (e.target.editorId) - tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId]; - - if (tinyMCE.selectedInstance) { - var sel = tinyMCE.selectedInstance.getDoc().selection; - var rng = sel.createRange(); - - if (tinyMCE.getParentElement(rng.parentElement(), "li") != null) - return false; - - // Cancel event - e.returnValue = false; - e.cancelBubble = true; - - // Insert BR element - rng.pasteHTML("
"); - rng.collapse(false); - rng.select(); - - tinyMCE.execCommand("mceAddUndoLevel"); - 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; - - if (tinyMCE.selectedInstance) - tinyMCE.selectedInstance.switchSettings(); - - var inst = tinyMCE.selectedInstance; - - // 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(e.type)) { - // Cancel event - tinyMCE.execCommand("mceAddUndoLevel"); - 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.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance); - - // Fix empty elements on return/enter, check where enter occured - if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13) - tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement(); - - // Fix empty elements on return/enter - if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) { - var elm = tinyMCE.enterKeyElement; - if (elm) { - var re = new RegExp('^HR|IMG|BR$','g'); // Skip these - var dre = new RegExp('^H[1-6]$','g'); // Add double on these - - if (!elm.hasChildNodes() && !re.test(elm.nodeName)) { - if (dre.test(elm.nodeName)) - elm.innerHTML = "  "; - else - elm.innerHTML = " "; - } - } - } - - // Check if it's a position key - var keys = tinyMCE.posKeyCodes; - var posKey = false; - for (var i=0; i -1) - suffix = '?rnd=' + this.operaOpacityCounter++; - - element.src = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/images/opacity.png" + suffix; - element.style.backgroundImage = "url('" + element.mceOldSrc + "')"; - } else { - if (element.mceOldSrc) { - element.src = element.mceOldSrc; - element.parentNode.style.backgroundImage = ""; - element.mceOldSrc = null; - } - } - } - } -}; - -TinyMCE.prototype.restoreClass = function(element) { - if (element != null && element.oldClassName && !element.classLock) { - element.className = element.oldClassName; - element.oldClassName = null; - } -}; - -TinyMCE.prototype.setClassLock = function(element, lock_state) { - if (element != null) - element.classLock = lock_state; -}; - -TinyMCE.prototype.addEvent = function(obj, name, handler) { - if (tinyMCE.isMSIE) { - obj.attachEvent("on" + name, handler); - } else - obj.addEventListener(name, handler, false); -}; - -TinyMCE.prototype.submitPatch = function() { - tinyMCE.removeTinyMCEFormElements(this); - tinyMCE.triggerSave(); - this.mceOldSubmit(); - tinyMCE.isNotDirty = true; -}; - -TinyMCE.prototype.onLoad = function() { - for (var c=0; c 0) - return; - - if (val.indexOf('%') == -1) - val += 'px'; - break; - - case "vspace": - case "hspace": - elm.style.marginTop = val + "px"; - elm.style.marginBottom = val + "px"; - elm.removeAttribute(attrib); - return; - - case "align": - if (elm.nodeName == "IMG") { - if (tinyMCE.isMSIE) - elm.style.styleFloat = val; - else - elm.style.cssFloat = val; - } else - elm.style.textAlign = val; - - elm.removeAttribute(attrib); - return; - } - - if (val != '') { - eval('elm.style.' + style + ' = val;'); - elm.removeAttribute(attrib); - } - } - } else { - if (style == '') - return; - - var val = eval('elm.style.' + style) == '' ? tinyMCE.getAttrib(elm, attrib) : eval('elm.style.' + style); - val = val == null ? '' : '' + val; - - switch (attrib) { - // Always move background to style - case "background": - if (val.indexOf('url') == -1 && val != '') - val = "url('" + val + "');"; - - if (val != '') { - elm.style.backgroundImage = val; - elm.removeAttribute(attrib); - } - return; - - case "border": - case "width": - case "height": - val = val.replace('px', ''); - break; - - case "align": - if (tinyMCE.getAttrib(elm, 'align') == '') { - if (elm.nodeName == "IMG") { - if (tinyMCE.isMSIE && elm.style.styleFloat != '') { - val = elm.style.styleFloat; - style = 'styleFloat'; - } else if (tinyMCE.isGecko && elm.style.cssFloat != '') { - val = elm.style.cssFloat; - style = 'cssFloat'; - } - } - } - break; - } - - if (val != '') { - elm.removeAttribute(attrib); - elm.setAttribute(attrib, val); - eval('elm.style.' + style + ' = "";'); - } - } -}; - -TinyMCE.prototype._cleanupAttribute = function(valid_attributes, element_name, attribute_node, element_node) { - var attribName = attribute_node.nodeName.toLowerCase(); - var attribValue = attribute_node.nodeValue; - var attribMustBeValue = null; - var verified = false; - - // Mozilla attibute, remove them - if (attribName.indexOf('moz_') != -1) - return null; - - if (!tinyMCE.cleanup_on_save && (attribName == "mce_href" || attribName == "mce_src")) - return {name : attribName, value : attribValue}; - - // Verify attrib - if (tinyMCE.cleanup_verify_html && !verified) { - for (var i=1; i 1) - val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')"; - } - - // Force HEX colors - if (tinyMCE.getParam("force_hex_style_colors")) - val = tinyMCE.convertRGBToHex(val, true); - - if (val != "url('')") - str += key.toLowerCase() + ": " + val + "; "; - } - } - - if (new RegExp('; $').test(str)) - str = str.substring(0, str.length - 2); - - return str; -}; - -TinyMCE.prototype.convertRGBToHex = function(s, k) { - if (s.toLowerCase().indexOf('rgb') != -1) { - var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi"); - var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(','); - if (rgb.length == 5) { - r = parseInt(rgb[1]).toString(16); - g = parseInt(rgb[2]).toString(16); - b = parseInt(rgb[3]).toString(16); - - r = r.length == 1 ? '0' + r : r; - g = g.length == 1 ? '0' + g : g; - b = b.length == 1 ? '0' + b : b; - - s = "#" + r + g + b; - - if (k) - s = rgb[0] + s + rgb[4]; - } - } - - return s; -}; - -TinyMCE.prototype.convertHexToRGB = function(s) { - if (s.indexOf('#') != -1) { - s = s.replace(new RegExp('[^0-9A-F]', 'gi'), ''); - return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")"; - } - - return s; -}; - -TinyMCE.prototype._verifyClass = function(node) { - // Sometimes the class gets set to null, weird Gecko bug? - if (tinyMCE.isGecko) { - var className = node.getAttribute('class'); - if (!className) - return false; - } - - // Trim CSS class - if (tinyMCE.isMSIE) - var className = node.getAttribute('className'); - - if (tinyMCE.cleanup_verify_css_classes && tinyMCE.cleanup_on_save) { - var csses = tinyMCE.getCSSClasses(); - nonDefinedCSS = true; - for (var c=0; c' + output; - } - } - - // Remove deprecated attributes - var re = new RegExp("^(TABLE|TD|TR)$"); - if (re.test(node.nodeName)) { - // Move attrib to style - if ((node.nodeName != "TABLE" || tinyMCE.cleanup_inline_styles) && (width = tinyMCE.getAttrib(node, "width")) != '') { - node.style.width = width.indexOf('%') != -1 ? width : width.replace(/[^0-9]/gi, '') + "px"; - node.removeAttribute("width"); - } - - // Is table and not inline - if ((node.nodeName == "TABLE" && !tinyMCE.cleanup_inline_styles) && node.style.width != '') { - tinyMCE.setAttrib(node, "width", node.style.width.replace('px','')); - node.style.width = ''; - } - - // Move attrib to style - if ((height = tinyMCE.getAttrib(node, "height")) != '') { - height = "" + height; // Force string - node.style.height = height.indexOf('%') != -1 ? height : height.replace(/[^0-9]/gi, '') + "px"; - node.removeAttribute("height"); - } - } - - // Handle inline/outline styles - if (tinyMCE.cleanup_inline_styles) { - var re = new RegExp("^(TABLE|TD|TR|IMG|HR)$"); - if (re.test(node.nodeName) && tinyMCE.getAttrib(node, "class").indexOf('mceItem') == -1) { - tinyMCE._moveStyle(node, 'width', 'width'); - tinyMCE._moveStyle(node, 'height', 'height'); - tinyMCE._moveStyle(node, 'borderWidth', 'border'); - tinyMCE._moveStyle(node, '', 'vspace'); - tinyMCE._moveStyle(node, '', 'hspace'); - tinyMCE._moveStyle(node, 'textAlign', 'align'); - tinyMCE._moveStyle(node, 'backgroundColor', 'bgColor'); - tinyMCE._moveStyle(node, 'borderColor', 'borderColor'); - tinyMCE._moveStyle(node, 'backgroundImage', 'background'); - - // Refresh element in old MSIE - if (tinyMCE.isMSIE5) - node.outerHTML = node.outerHTML; - } else if (tinyMCE.isBlockElement(node)) - tinyMCE._moveStyle(node, 'textAlign', 'align'); - - if (node.nodeName == "FONT") - tinyMCE._moveStyle(node, 'color', 'color'); - } - - // Set attrib data - if (elementValidAttribs) { - for (var a=1; a" + node.innerHTML + ""; - - // Remove empty tables - if (elementName == "table" && !node.hasChildNodes()) - return ""; - - // Handle element attributes - if (node.attributes.length > 0) { - var lastAttrib = ""; - - for (var i=0; i" + this.convertStringToXML(String.fromCharCode(160)) + ""; - - // Is MSIE script element - if (tinyMCE.isMSIE && elementName == "script") - return "<" + elementName + elementAttribs + ">" + node.text + ""; - - // Clean up children - if (node.hasChildNodes()) { - // If not empty span - if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) { - // Force BR - if (elementName == "p" && tinyMCE.cleanup_force_br_newlines) - output += ""; - else - output += "<" + elementName + elementAttribs + ">"; - } - - for (var i=0; i"; - } - } else { - if (!nonEmptyTag) { - if (openTag) - output += "<" + elementName + elementAttribs + ">"; - else - output += "<" + elementName + elementAttribs + " />"; - } - } - - return output; - - case 3: // Text - // Do not convert script elements - if (node.parentNode.nodeName == "SCRIPT" || node.parentNode.nodeName == "NOSCRIPT" || node.parentNode.nodeName == "STYLE") - return node.nodeValue; - - return this.convertStringToXML(node.nodeValue); - - case 8: // Comment - return ""; - - default: // Unknown - return "[UNKNOWN NODETYPE " + node.nodeType + "]"; - } -}; - -TinyMCE.prototype.convertStringToXML = function(html_data) { - var output = ""; - - for (var i=0; i 127) - output += '&#' + chr + ";"; - else - output += String.fromCharCode(chr); - - continue; - } - - // Raw entities - if (tinyMCE.settings['entity_encoding'] == "raw") { - output += String.fromCharCode(chr); - continue; - } - - // Named entities - if (typeof(tinyMCE.settings['cleanup_entities']["c" + chr]) != 'undefined' && tinyMCE.settings['cleanup_entities']["c" + chr] != '') - output += '&' + tinyMCE.settings['cleanup_entities']["c" + chr] + ';'; - else - output += '' + String.fromCharCode(chr); - } - - return output; -}; - -TinyMCE.prototype._getCleanupElementName = function(chunk) { - var pos; - - if (chunk.charAt(0) == '+') - chunk = chunk.substring(1); - - if (chunk.charAt(0) == '-') - chunk = chunk.substring(1); - - if ((pos = chunk.indexOf('/')) != -1) - chunk = chunk.substring(0, pos); - - if ((pos = chunk.indexOf('[')) != -1) - chunk = chunk.substring(0, pos); - - return chunk; -}; - -TinyMCE.prototype._initCleanup = function() { - // Parse valid elements and attributes - var validElements = tinyMCE.settings["valid_elements"]; - validElements = validElements.split(','); - - // Handle extended valid elements - var extendedValidElements = tinyMCE.settings["extended_valid_elements"]; - extendedValidElements = extendedValidElements.split(','); - for (var i=0; i/gi, '>'); - - return html; - } - - if (on_save && tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertFontsToSpans(doc); - - // Call custom cleanup code - tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body); - - // Move bgcolor to style - var n = doc.getElementsByTagName("font"); - for (var i=0; i[ \n\r]*[ \n\r]*

', '
', 'gi')); - tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '', '', 'gi')); - } - - var html = this.cleanupNode(element); - - if (tinyMCE.settings['debug']) - tinyMCE.debug("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms."); - - // Remove pesky HR paragraphs and other crap - html = tinyMCE.regexpReplace(html, '


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

 


 

', '
'); - html = tinyMCE.regexpReplace(html, '\\s*
\\s*', ' '); - html = tinyMCE.regexpReplace(html, '

\\s*
\\s*

', '

 

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

\\s* \\s*
\\s* \\s*

', '

 

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

\\s* \\s*
\\s*

', '

 

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

\\s*
\\s* \\s*

', '

 

'); - - // Remove empty anchors - html = html.replace(new RegExp('(.*?)', 'gi'), '$1'); - - // Remove some mozilla crap - if (!tinyMCE.isMSIE) - html = html.replace(new RegExp('', 'g'), ""); - - if (tinyMCE.settings['remove_linebreaks']) - html = html.replace(new RegExp('\r|\n', 'g'), ' '); - - if (tinyMCE.getParam('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.isGecko && tinyMCE.settings['remove_lt_gt']) { - // Remove weridness! - var re = new RegExp('<>', 'g'); - html = html.replace(re, ""); - } - - // Call custom cleanup code - html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html); - - // Emtpy node, return empty - var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase(); - if (chk == "
" || chk == "
" || chk == "

 

" || chk == "

 

" || chk == "

") - html = ""; - - if (tinyMCE.settings["preformatted"]) - return "
" + html + "
"; - - return html; -}; - -TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) { - tinyMCE.execCommand('mceBeginUndoLevel'); - - if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") { - var doc = this.selectedInstance.getDoc(); - var linkElement = tinyMCE.getParentElement(this.selectedElement, "a"); - var newLink = false; - - if (!linkElement) { - linkElement = doc.createElement("a"); - newLink = true; - } - - var mhref = href; - var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);"); - mhref = tinyMCE.getParam('convert_urls') ? href : mhref; - - tinyMCE.setAttrib(linkElement, 'href', thref); - tinyMCE.setAttrib(linkElement, 'mce_href', mhref); - tinyMCE.setAttrib(linkElement, 'target', target); - tinyMCE.setAttrib(linkElement, 'title', title); - tinyMCE.setAttrib(linkElement, 'onclick', onclick); - tinyMCE.setAttrib(linkElement, 'class', style_class); - - if (newLink) { - linkElement.appendChild(this.selectedElement.cloneNode(true)); - this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement); - } - - return; - } - - if (!this.linkElement && this.selectedInstance) { - if (tinyMCE.isSafari) { - tinyMCE.execCommand("mceInsertContent", false, '' + this.selectedInstance.getSelectedHTML() + ''); - } else - this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL); - - tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - for (var i=0; i'; - - tinyMCE.execCommand("mceInsertContent", false, html); - } else { - if (!this.imgElement && this.selectedInstance) { - if (tinyMCE.isSafari) - tinyMCE.execCommand("mceInsertContent", false, ''); - else - this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL); - - tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL); - } - } - - if (this.imgElement) { - var needsRepaint = false; - var msrc = src; - - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);"); - - if (tinyMCE.getParam('convert_urls')) - msrc = src; - - if (onmouseover && onmouseover != "") - onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';"; - - if (onmouseout && onmouseout != "") - onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';"; - - // Use alt as title if it's undefined - if (typeof(title) == "undefined") - title = alt; - - if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align")) - needsRepaint = true; - - tinyMCE.setAttrib(this.imgElement, 'src', src); - tinyMCE.setAttrib(this.imgElement, 'mce_src', msrc); - tinyMCE.setAttrib(this.imgElement, 'alt', alt); - tinyMCE.setAttrib(this.imgElement, 'title', title); - tinyMCE.setAttrib(this.imgElement, 'align', align); - tinyMCE.setAttrib(this.imgElement, 'border', border, true); - tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true); - tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true); - tinyMCE.setAttrib(this.imgElement, 'width', width, true); - tinyMCE.setAttrib(this.imgElement, 'height', height, true); - tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover); - tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout); - - // Fix for bug #989846 - Image resize bug - if (width && width != "") - this.imgElement.style.pixelWidth = width; - - if (height && height != "") - this.imgElement.style.pixelHeight = height; - - if (needsRepaint) - tinyMCE.selectedInstance.repaint(); - } - - tinyMCE.execCommand('mceEndUndoLevel'); -}; - -TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) { - var elements = this.getElementsByAttributeValue(node, element_name, attrib, value); - if (elements.length == 0) - return null; - - return elements[0]; -}; - -TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) { - var elements = new Array(); - - if (node && node.nodeName.toLowerCase() == element_name) { - if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1) - elements[elements.length] = node; - } - - if (node && node.hasChildNodes()) { - for (var x=0, n=node.childNodes.length; x= 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 targetURL.path; - - for (var i=0; i<(strTok1.length-(breakPoint-1)); i++) - outPath += "../"; - - for (var i=breakPoint-1; i=0; i--) { - if (baseURLParts[i].length == 0) - continue; - - newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; - } - baseURLParts = newBaseURLParts.reverse(); - - // Merge relURLParts chunks - var newRelURLParts = new Array(); - var numBack = 0; - for (var i=relURLParts.length-1; i>=0; i--) { - if (relURLParts[i].length == 0 || relURLParts[i] == ".") - continue; - - if (relURLParts[i] == '..') { - numBack++; - continue; - } - - if (numBack > 0) { - numBack--; - continue; - } - - newRelURLParts[newRelURLParts.length] = relURLParts[i]; - } - - relURLParts = newRelURLParts.reverse(); - - // Remove end from absolute path - var len = baseURLParts.length-numBack; - var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); - var start = "", end = ""; - - // Build output URL - relURL.protocol = baseURL.protocol; - relURL.host = baseURL.host; - relURL.port = baseURL.port; - - // Re-add trailing slash if it's removed - if (relURL.path.charAt(relURL.path.length-1) == "/") - absPath += "/"; - - relURL.path = absPath; - - return TinyMCE.prototype.serializeURL(relURL); -}; - -TinyMCE.prototype.getParam = function(name, default_value, strip_whitespace, split_chr) { - var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; - - // Fix bool values - if (value == "true" || value == "false") - return (value == "true"); - - if (strip_whitespace) - value = tinyMCE.regexpReplace(value, "[ \t\r\n]", ""); - - if (typeof(split_chr) != "undefined" && split_chr != null) { - value = value.split(split_chr); - var outArray = new Array(); - - for (var i=0; i 0); - - if (tinyMCE.settings['custom_undo_redo']) { - undoIndex = inst.undoIndex; - undoLevels = inst.undoLevels.length; - } - - tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content); - } - } - - if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) - this.selectedInstance.contentWindow.focus(); -}; - -TinyMCE.prototype._customCleanup = function(inst, type, content) { - // Call custom cleanup - var customCleanup = tinyMCE.settings['cleanup_callback']; - if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") - content = eval(customCleanup + "(type, content, inst);"); - - // Trigger plugin cleanups - var plugins = tinyMCE.getParam('plugins', '', true, ','); - for (var i=0; i 0) - className += " "; - - className += classNames[i]; - } - - return className; -}; - -TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) { - if (!el) - return; - - var tableElement = null; - - switch (el.nodeName) { - case "TABLE": - var oldW = el.style.width; - var oldH = el.style.height; - var bo = tinyMCE.getAttrib(el, "border"); - - bo = bo == "" || bo == "0" ? true : false; - - tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); - - el.style.width = oldW; - el.style.height = oldH; - - for (var y=0; y 0) { - tinyMCE.setAttrib(s[i], 'size', fSize); - s[i].style.fontSize = ''; - } - - var fFace = s[i].style.fontFamily; - if (fFace != null && fFace != "") { - tinyMCE.setAttrib(s[i], 'face', fFace); - s[i].style.fontFamily = ''; - } - - var fColor = s[i].style.color; - if (fColor != null && fColor != "") { - tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); - s[i].style.color = ''; - } - } -}; - -TinyMCE.prototype.convertFontsToSpans = function(doc) { - var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); - - var h = doc.body.innerHTML; - h = h.replace(/ 0 && fSize < 8) { - if (fsClasses != null) - tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); - else - s[i].style.fontSize = sizes[fSize-1]; - } - - s[i].removeAttribute('size'); - } - - if (fFace != "") { - s[i].style.fontFamily = fFace; - s[i].removeAttribute('face'); - } - - if (fColor != "") { - s[i].style.color = fColor; - s[i].removeAttribute('color'); - } - } -}; - -/* -TinyMCE.prototype.applyClassesToFonts = function(doc, size) { - var f = doc.getElementsByTagName("font"); - for (var i=0; i=0; x--) - tinyMCE.insertAfter(cn[x], an[i]); - } - } -}; - -TinyMCE.prototype._setHTML = function(doc, html_content) { - // Force closed anchors open - //html_content = html_content.replace(new RegExp('', 'gi'), ''); - - html_content = tinyMCE.cleanupHTMLCode(html_content); - - // Try innerHTML if it fails use pasteHTML in MSIE - try { - tinyMCE.setInnerHTML(doc.body, html_content); - } catch (e) { - if (this.isMSIE) - doc.body.createTextRange().pasteHTML(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 - tinyMCE.setInnerHTML(doc.body, html); - } - - tinyMCE.cleanupAnchors(doc); - - if (tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertSpansToFonts(doc); -}; - -TinyMCE.prototype.getImageSrc = function(str) { - var pos = -1; - - if (!str) - return ""; - - if ((pos = str.indexOf('this.src=')) != -1) { - var src = str.substring(pos + 10); - - src = src.substring(0, src.indexOf('\'')); - - return src; - } - - return ""; -}; - -TinyMCE.prototype._getElementById = function(element_id) { - var elm = document.getElementById(element_id); - if (!elm) { - // Check for element in forms - for (var j=0; j 0) { - for (var x=0; x 0) - tinyMCE.cssClasses = output; - - return output; -}; - -TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) { - if (in_str == null) - return in_str; - - if (typeof(opts) == "undefined") - opts = 'g'; - - var re = new RegExp(reg_exp, opts); - return in_str.replace(re, replace_str); -}; - -TinyMCE.prototype.trim = function(str) { - return str.replace(/^\s*|\s*$/g, ""); -}; - -TinyMCE.prototype.cleanupEventStr = function(str) { - str = "" + str; - str = str.replace('function anonymous()\n{\n', ''); - str = str.replace('\n}', ''); - str = str.replace(/^return true;/gi, ''); // Remove event blocker - - return str; -}; - -TinyMCE.prototype.getAbsPosition = function(node) { - var pos = new Object(); - - pos.absLeft = pos.absTop = 0; - - var parentNode = node; - while (parentNode) { - pos.absLeft += parentNode.offsetLeft; - pos.absTop += parentNode.offsetTop; - - parentNode = parentNode.offsetParent; - } - - return pos; -}; - -TinyMCE.prototype.getControlHTML = function(control_name) { - 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] + "_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 + "');"); -}; - -TinyMCE.prototype._themeExecCommand = function(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; -}; - -TinyMCE.prototype._getThemeFunction = function(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; -}; - - -TinyMCE.prototype.isFunc = function(func_name) { - if (func_name == null || func_name == "") - return false; - - return eval("typeof(" + func_name + ")") != "undefined"; -}; - -TinyMCE.prototype.exec = function(func_name, args) { - var str = func_name + '('; - - // Add all arguments - for (var i=3; i 1 && tinyMCE.currentConfig != this.settings['index']) { - tinyMCE.settings = this.settings; - tinyMCE.currentConfig = this.settings['index']; - } -}; - -TinyMCEControl.prototype.convertAllRelativeURLs = function() { - var body = this.getBody(); - - // Convert all image URL:s to absolute URL - var elms = body.getElementsByTagName("img"); - for (var i=0; i 0) - rng.selectNodeContents(nodes[0]); - else - rng.selectNodeContents(node); - } else - rng.selectNode(node); - - if (collapse) { - // Special treatment of textnode collapse - if (!to_start && node.nodeType == 3) { - rng.setStart(node, node.nodeValue.length); - rng.setEnd(node, node.nodeValue.length); - } else - rng.collapse(to_start); - } - - sel.removeAllRanges(); - sel.addRange(rng); - } - - this.scrollToNode(node); - - // Set selected element - tinyMCE.selectedElement = null; - if (node.nodeType == 1) - tinyMCE.selectedElement = node; -}; - -TinyMCEControl.prototype.scrollToNode = function(node) { - // Scroll to node position - var pos = tinyMCE.getAbsPosition(node); - var doc = this.getDoc(); - 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 : this.targetElement.clientHeight; - - // Only scroll if out of visible area - if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height))) - this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25); -}; - -TinyMCEControl.prototype.getBody = function() { - return this.getDoc().body; -}; - -TinyMCEControl.prototype.getDoc = function() { - return this.contentWindow.document; -}; - -TinyMCEControl.prototype.getWin = function() { - return this.contentWindow; -}; - -TinyMCEControl.prototype.getSel = function() { - if (tinyMCE.isMSIE && !tinyMCE.isOpera) - return this.getDoc().selection; - - var sel = this.contentWindow.getSelection(); - - // Fake getRangeAt - if (tinyMCE.isSafari && !sel.getRangeAt) { - var newSel = new Object(); - var doc = this.getDoc(); - - function getRangeAt(idx) { - var rng = new Object(); - - rng.startContainer = this.focusNode; - rng.endContainer = this.anchorNode; - rng.commonAncestorContainer = this.focusNode; - rng.createContextualFragment = function (html) { - // Seems to be a tag - if (html.charAt(0) == '<') { - var elm = doc.createElement("div"); - - elm.innerHTML = html; - - return elm.firstChild; - } - - return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!"); - }; - - rng.deleteContents = function () { - doc.execCommand("Delete", false, ""); - }; - - return rng; - } - - // Patch selection - - newSel.focusNode = sel.baseNode; - newSel.focusOffset = sel.baseOffset; - newSel.anchorNode = sel.extentNode; - newSel.anchorOffset = sel.extentOffset; - newSel.getRangeAt = getRangeAt; - newSel.text = "" + sel; - newSel.realSelection = sel; - - newSel.toString = function () {return this.text;}; - - return newSel; - } - - return sel; -}; - -TinyMCEControl.prototype.getRng = function() { - var sel = this.getSel(); - if (sel == null) - return null; - - if (tinyMCE.isMSIE && !tinyMCE.isOpera) - return sel.createRange(); - - if (tinyMCE.isSafari) { - var rng = this.getDoc().createRange(); - var sel = this.getSel().realSelection; - - rng.setStart(sel.baseNode, sel.baseOffset); - rng.setEnd(sel.extentNode, sel.extentOffset); - - return rng; - } - - return this.getSel().getRangeAt(0); -}; - -TinyMCEControl.prototype._insertPara = function(e) { - function isEmpty(para) { - function isEmptyHTML(html) { - return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == ""; - } - - // Check for images - if (para.getElementsByTagName("img").length > 0) - return false; - - // Check for tables - if (para.getElementsByTagName("table").length > 0) - return false; - - // Check for HRs - if (para.getElementsByTagName("hr").length > 0) - return false; - - // Check all textnodes - var nodes = tinyMCE.getNodeTree(para, new Array(), 3); - for (var i=0; i <" + blockName + "> "; - paraAfter = body.childNodes[1]; - } - - this.selectNode(paraAfter, true, true); - - return true; - } - - // Place first part within new paragraph - if (startChop.nodeName == blockName) - rngBefore.setStart(startChop, 0); - else - rngBefore.setStartBefore(startChop); - - rngBefore.setEnd(startNode, startOffset); - paraBefore.appendChild(rngBefore.cloneContents()); - - // Place secound part within new paragraph - rngAfter.setEndAfter(endChop); - rngAfter.setStart(endNode, endOffset); - var contents = rngAfter.cloneContents(); - - if (contents.firstChild && contents.firstChild.nodeName == blockName) { -/* var nodes = contents.firstChild.childNodes; - for (var i=0; i 0) - rng.pasteHTML('
' + rng.htmlText + "
"); - - tinyMCE.triggerNodeChange(); - return; - } - } - } - - switch (command) { - case "mceRepaint": - this.repaint(); - return true; - - case "mceStoreSelection": - this.selectionBookmark = this.getBookmark(); - return true; - - case "mceRestoreSelection": - this.moveToBookmark(this.selectionBookmark); - return true; - - case "InsertUnorderedList": - case "InsertOrderedList": - var tag = (command == "InsertUnorderedList") ? "ul" : "ol"; - - if (tinyMCE.isSafari) - this.execCommand("mceInsertContent", false, "<" + tag + ">
  •  
  • <" + tag + ">"); - else - this.getDoc().execCommand(command, user_interface, value); - - tinyMCE.triggerNodeChange(); - break; - - case "Strikethrough": - if (tinyMCE.isSafari) - this.execCommand("mceInsertContent", false, "" + this.getSelectedHTML() + ""); - else - this.getDoc().execCommand(command, user_interface, value); - - tinyMCE.triggerNodeChange(); - break; - - case "mceSelectNode": - this.selectNode(value); - tinyMCE.triggerNodeChange(); - tinyMCE.selectedNode = value; - break; - - case "FormatBlock": - if (value == null || value == "") { - var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address"); - - if (elm) - this.execCommand("mceRemoveNode", false, elm); - } else - this.getDoc().execCommand("FormatBlock", false, value); - - tinyMCE.triggerNodeChange(); - - break; - - case "mceRemoveNode": - if (!value) - value = tinyMCE.getParentElement(this.getFocusElement()); - - if (tinyMCE.isMSIE) { - value.outerHTML = value.innerHTML; - } else { - var rng = value.ownerDocument.createRange(); - rng.setStartBefore(value); - rng.setEndAfter(value); - rng.deleteContents(); - rng.insertNode(rng.createContextualFragment(value.innerHTML)); - } - - tinyMCE.triggerNodeChange(); - - 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 "SetStyleInfo": - var rng = this.getRng(); - var sel = this.getSel(); - var scmd = value['command']; - var sname = value['name']; - var svalue = value['value'] == null ? '' : value['value']; - //var svalue = value['value'] == null ? '' : value['value']; - var wrapper = value['wrapper'] ? value['wrapper'] : "span"; - var parentElm = null; - var invalidRe = new RegExp("^BODY|HTML$", "g"); - var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null; - - // Whole element selected check - if (tinyMCE.isMSIE) { - // Control range - if (rng.item) - parentElm = rng.item(0); - else { - var pelm = rng.parentElement(); - var prng = doc.selection.createRange(); - prng.moveToElementText(pelm); - - if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) { - if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName)) - parentElm = pelm; - } - } - } else { - var felm = this.getFocusElement(); - if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode)) - parentElm = felm; - } - - // Whole element selected - if (parentElm && !invalidRe.test(parentElm.nodeName)) { - if (scmd == "setstyle") - tinyMCE.setStyleAttrib(parentElm, sname, svalue); - - if (scmd == "setattrib") - tinyMCE.setAttrib(parentElm, sname, svalue); - - if (scmd == "removeformat") { - parentElm.style.cssText = ''; - tinyMCE.setAttrib(parentElm, 'class', ''); - } - - // Remove style/attribs from all children - var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1); - for (var z=0; z=0; i--) { - var elm = nodes[i]; - var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; - - elm.removeAttribute("mce_new"); - - // Is only child a element - if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) { - //tinyMCE.debug("merge1" + isNew); - this._mergeElements(scmd, elm, elm.childNodes[0], isNew); - continue; - } - - // Is I the only child - if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) { - //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName); - if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName)) - this._mergeElements(scmd, elm.parentNode, elm, false); - } - } - - // Remove empty wrappers - var nodes = doc.getElementsByTagName(wrapper); - for (var i=nodes.length-1; i>=0; i--) { - var elm = nodes[i]; - var isEmpty = true; - - // Check if it has any attribs - var tmp = doc.createElement("body"); - tmp.appendChild(elm.cloneNode(false)); - - // Is empty span, remove it - tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); - //tinyMCE.debug(tmp.innerHTML); - if (new RegExp('', 'gi').test(tmp.innerHTML)) { - 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": - this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value}); - break; - - case "mceInsertRawHTML": - var key = 'tiny_mce_marker'; - - this.execCommand('mceBeginUndoLevel'); - - // Insert marker key - this.execCommand('mceInsertContent', false, key); - - // Store away scroll pos - var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft; - var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop; - - // Find marker and replace with RAW HTML - var html = this.getBody().innerHTML; - if ((pos = html.indexOf(key)) != -1) - tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length)); - - // Restore scoll pos - this.contentWindow.scrollTo(scrollX, scrollY); - - this.execCommand('mceEndUndoLevel'); - - break; - - case "mceInsertContent": - var insertHTMLFailed = false; - this.getWin().focus(); -/* WP - if (tinyMCE.isGecko || tinyMCE.isOpera) { - try { - // Is plain text or HTML - if (value.indexOf('<') == -1) { - var r = this.getRng(); - var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value)); - var s = this.getSel(); - var r2 = r.cloneRange(); - - // Insert text at cursor position - s.removeAllRanges(); - r.deleteContents(); - r.insertNode(n); - - // Move the cursor to the end of text - r2.selectNode(n); - r2.collapse(false); - s.removeAllRanges(); - s.addRange(r2); - } else { - value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value); - this.getDoc().execCommand('inserthtml', false, value); - tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); - } - } catch (ex) { - insertHTMLFailed = true; - } - - if (!insertHTMLFailed) { - tinyMCE.triggerNodeChange(); - return; - } - } -*/ - // Ugly hack in Opera due to non working "inserthtml" - if (tinyMCE.isOpera && insertHTMLFailed) { - this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL); - var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL); - ar[0].outerHTML = value; - return; - } - - if (!tinyMCE.isMSIE) { - var isHTML = value.indexOf('<') != -1; - var sel = this.getSel(); - var rng = this.getRng(); - - if (isHTML) { - if (tinyMCE.isSafari) { - var tmpRng = this.getDoc().createRange(); - - tmpRng.setStart(this.getBody(), 0); - tmpRng.setEnd(this.getBody(), 0); - - value = tmpRng.createContextualFragment(value); - } else - value = rng.createContextualFragment(value); - } else { - // Setup text node - var el = document.createElement("div"); - el.innerHTML = value; - value = el.firstChild.nodeValue; - value = doc.createTextNode(value); - } - - // Insert plain text in Safari - if (tinyMCE.isSafari && !isHTML) { - this.execCommand('InsertText', false, value.nodeValue); - tinyMCE.triggerNodeChange(); - return true; - } else if (tinyMCE.isSafari && isHTML) { - rng.deleteContents(); - rng.insertNode(value); - tinyMCE.triggerNodeChange(); - return true; - } - - rng.deleteContents(); - - // If target node is text do special treatment, (Mozilla 1.3 fix) - if (rng.startContainer.nodeType == 3) { - var node = rng.startContainer.splitText(rng.startOffset); - node.parentNode.insertBefore(value, node); - } else - rng.insertNode(value); - - if (!isHTML) { - // Removes weird selection trails - sel.selectAllChildren(doc.body); - sel.removeAllRanges(); - - // Move cursor to end of content - var rng = doc.createRange(); - - rng.selectNode(value); - rng.collapse(false); - - sel.addRange(rng); - } else - rng.collapse(false); - } else { - var rng = doc.selection.createRange(); - var c = value.indexOf(')/g,'\n');s=s.replace(/^[\r\n]*|[\r\n]*$/g,'');s=s.replace(/^\s*(\/\/\s*|\]\]>|-->|\]\]-->)\s*$/g,'');return s;};h=h.replace(/]+|)>([\s\S]*?)<\/script>/g,function(v,a,b){b=trim(b);if(!a)a=' type="text/javascript"';if(b)b='';return''+b+'';});h=h.replace(/]+|)>([\s\S]*?)<\/style>/g,function(v,a,b){b=trim(b);return''+b+'';});}h=h.replace(//g,'');h=h.replace(/<([\w:]+) [^>]*(src|href|style|shape|coords)[^>]*>/gi,function(a,n){function handle(m,b,c){var u=c;if(a.indexOf('mce_'+b)!=-1)return m;if(b=='style'){if(t._isRes(c))return m;if(s.hex_colors){u=u.replace(/rgb\([^\)]+\)/g,function(v){return t.toHex(v);});}if(s.url_converter){u=u.replace(/url\([\'\"]?([^\)\'\"]+)\)/g,function(x,c){return'url('+t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),b,n))+')';});}}else if(b!='coords'&&b!='shape'){if(s.url_converter)u=t.encode(s.url_converter.call(s.url_converter_scope||t,t.decode(c),b,n));}return' '+b+'="'+c+'" mce_'+b+'="'+u+'"';};a=a.replace(/ (src|href|style|coords|shape)=[\"]([^\"]+)[\"]/gi,handle);a=a.replace(/ (src|href|style|coords|shape)=[\']([^\']+)[\']/gi,handle);return a.replace(/ (src|href|style|coords|shape)=([^\s\"\'>]+)/gi,handle);});}return h;},getOuterHTML:function(e){var d;e=this.get(e);if(!e)return null;if(isIE)return e.outerHTML;d=(e.ownerDocument||this.doc).createElement("body");d.appendChild(e.cloneNode(true));return d.innerHTML;},setOuterHTML:function(e,h,d){var t=this;return this.run(e,function(e){var n,tp;e=t.get(e);d=d||e.ownerDocument||t.doc;if(isIE&&e.nodeType==1)e.outerHTML=h;else{tp=d.createElement("body");tp.innerHTML=h;n=tp.lastChild;while(n){t.insertAfter(n.cloneNode(true),e);n=n.previousSibling;}t.remove(e);}});},decode:function(s){var e,n,v;if(/&[^;]+;/.test(s)){e=this.doc.createElement("div");e.innerHTML=s;n=e.firstChild;v='';if(n){do{v+=n.nodeValue;}while(n.nextSibling);}return v||s;}return s;},encode:function(s){return s?(''+s).replace(/[<>&\"]/g,function(c,b){switch(c){case'&':return'&';case'"':return'"';case'<':return'<';case'>':return'>';}return c;}):s;},insertAfter:function(n,r){var t=this;r=t.get(r);return this.run(n,function(n){var p,ns;p=r.parentNode;ns=r.nextSibling;if(ns)p.insertBefore(n,ns);else p.appendChild(n);return n;});},isBlock:function(n){if(n.nodeType&&n.nodeType!==1)return false;n=n.nodeName||n;return/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n);},replace:function(n,o,k){if(is(o,'array'))n=n.cloneNode(true);return this.run(o,function(o){if(k){each(o.childNodes,function(c){n.appendChild(c.cloneNode(true));});}return o.parentNode.replaceChild(n,o);});},toHex:function(s){var c=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(s);function hex(s){s=parseInt(s).toString(16);return s.length>1?s:'0'+s;};if(c){s='#'+hex(c[1])+hex(c[2])+hex(c[3]);return s;}return s;},getClasses:function(){var t=this,cl=[],i,lo={},f=t.settings.class_filter,ov;if(t.classes)return t.classes;function addClasses(s){each(s.imports,function(r){addClasses(r);});each(s.cssRules||s.rules,function(r){switch(r.type||1){case 1:if(r.selectorText){each(r.selectorText.split(','),function(v){v=v.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(v)||!/\.[\w\-]+$/.test(v))return;ov=v;v=v.replace(/.*\.([a-z0-9_\-]+).*/i,'$1');if(f&&!(v=f(v,ov)))return;if(!lo[v]){cl.push({'class':v});lo[v]=1;}});}break;case 3:addClasses(r.styleSheet);break;}});};try{each(t.doc.styleSheets,addClasses);}catch(ex){}if(cl.length>0)t.classes=cl;return cl;},run:function(e,f,s){var t=this,o;if(t.doc&&typeof(e)==='string')e=t.get(e);if(!e)return false;s=s||this;if(!e.nodeType&&(e.length||e.length===0)){o=[];each(e,function(e,i){if(e){if(typeof(e)=='string')e=t.doc.getElementById(e);o.push(f.call(s,e,i));}});return o;}return f.call(s,e);},getAttribs:function(n){var o;n=this.get(n);if(!n)return[];if(isIE){o=[];if(n.nodeName=='OBJECT')return n.attributes;n.cloneNode(false).outerHTML.replace(/([a-z0-9\:\-_]+)=/gi,function(a,b){o.push({specified:1,nodeName:b});});return o;}return n.attributes;},destroy:function(s){var t=this;t.win=t.doc=t.root=null;if(!s)tinymce.removeUnload(t.destroy);},_isRes:function(c){return/^(top|left|bottom|right|width|height)/i.test(c)||/;\s*(top|left|bottom|right|width|height)/i.test(c);}});tinymce.DOM=new tinymce.dom.DOMUtils(document,{process_html:0});})();(function(){var each=tinymce.each,DOM=tinymce.DOM,isIE=tinymce.isIE,isWebKit=tinymce.isWebKit,Event;tinymce.create('static tinymce.dom.Event',{inits:[],events:[],add:function(o,n,f,s){var cb,t=this,el=t.events,r;if(o&&o instanceof Array){r=[];each(o,function(o){o=DOM.get(o);r.push(t.add(o,n,f,s));});return r;}o=DOM.get(o);if(!o)return;cb=function(e){e=e||window.event;if(e&&!e.target&&isIE)e.target=e.srcElement;if(!s)return f(e);return f.call(s,e);};if(n=='unload'){tinymce.unloads.unshift({func:cb});return cb;}if(n=='init'){if(t.domLoaded)cb();else t.inits.push(cb);return cb;}el.push({obj:o,name:n,func:f,cfunc:cb,scope:s});t._add(o,n,cb);return f;},remove:function(o,n,f){var t=this,a=t.events,s=false,r;if(o&&o instanceof Array){r=[];each(o,function(o){o=DOM.get(o);r.push(t.remove(o,n,f));});return r;}o=DOM.get(o);each(a,function(e,i){if(e.obj==o&&e.name==n&&(!f||(e.func==f||e.cfunc==f))){a.splice(i,1);t._remove(o,n,e.cfunc);s=true;return false;}});return s;},clear:function(o){var t=this,a=t.events,i,e;if(o){o=DOM.get(o);for(i=a.length-1;i>=0;i--){e=a[i];if(e.obj===o){t._remove(e.obj,e.name,e.cfunc);e.obj=e.cfunc=null;a.splice(i,1);}}}},cancel:function(e){if(!e)return false;this.stop(e);return this.prevent(e);},stop:function(e){if(e.stopPropagation)e.stopPropagation();else e.cancelBubble=true;return false;},prevent:function(e){if(e.preventDefault)e.preventDefault();else e.returnValue=false;return false;},_unload:function(){var t=Event;each(t.events,function(e,i){t._remove(e.obj,e.name,e.cfunc);e.obj=e.cfunc=null;});t.events=[];t=null;},_add:function(o,n,f){if(o.attachEvent)o.attachEvent('on'+n,f);else if(o.addEventListener)o.addEventListener(n,f,false);else o['on'+n]=f;},_remove:function(o,n,f){if(o){try{if(o.detachEvent)o.detachEvent('on'+n,f);else if(o.removeEventListener)o.removeEventListener(n,f,false);else o['on'+n]=null;}catch(ex){}}},_pageInit:function(){var e=Event;if(e.domLoaded)return;e._remove(window,'DOMContentLoaded',e._pageInit);e.domLoaded=true;each(e.inits,function(c){c();});e.inits=[];},_wait:function(){var t;if(window.tinyMCE_GZ&&tinyMCE_GZ.loaded){Event.domLoaded=1;return;}if(isIE&&document.location.protocol!='https:'){document.write('';bi=s.body_id||'tinymce';if(bi.indexOf('=')!=-1){bi=t.getParam('body_id','','hash');bi=bi[t.id]||bi;}bc=s.body_class||'';if(bc.indexOf('=')!=-1){bc=t.getParam('body_class','','hash');bc=bc[t.id]||'';}t.iframeHTML+='';if(tinymce.relaxedDomain){if(isIE||(tinymce.isOpera&&parseFloat(opera.version())>=9.5))u='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+t.id+'");document.write(ed.iframeHTML);document.close();ed.setupIframe();})()';else if(tinymce.isOpera)u='javascript:(function(){document.open();document.domain="'+document.domain+'";document.close();ed.setupIframe();})()';}n=DOM.add(o.iframeContainer,'iframe',{id:t.id+"_ifr",src:u||'javascript:""',frameBorder:'0',style:{width:'100%',height:h}});t.contentAreaContainer=o.iframeContainer;DOM.get(o.editorContainer).style.display=t.orgDisplay;DOM.get(t.id).style.display='none';if(tinymce.isOldWebKit){Event.add(n,'load',t.setupIframe,t);n.src=tinymce.baseURL+'/plugins/safari/blank.htm';}else{if(!isIE||!tinymce.relaxedDomain)t.setupIframe();e=n=o=null;}},setupIframe:function(){var t=this,s=t.settings,e=DOM.get(t.id),d=t.getDoc(),h,b;if(!isIE||!tinymce.relaxedDomain){d.open();d.write(t.iframeHTML);d.close();}if(!isIE){try{if(!s.readonly)d.designMode='On';}catch(ex){}}if(isIE){b=t.getBody();DOM.hide(b);if(!s.readonly)b.contentEditable=true;DOM.show(b);}t.dom=new tinymce.DOM.DOMUtils(t.getDoc(),{keep_values:true,url_converter:t.convertURL,url_converter_scope:t,hex_colors:s.force_hex_style_colors,class_filter:s.class_filter,update_styles:1,fix_ie_paragraphs:1});t.serializer=new tinymce.dom.Serializer({entity_encoding:s.entity_encoding,entities:s.entities,valid_elements:s.verify_html===false?'*[*]':s.valid_elements,extended_valid_elements:s.extended_valid_elements,valid_child_elements:s.valid_child_elements,invalid_elements:s.invalid_elements,fix_table_elements:s.fix_table_elements,fix_list_elements:s.fix_list_elements,fix_content_duplication:s.fix_content_duplication,convert_fonts_to_spans:s.convert_fonts_to_spans,font_size_classes:s.font_size_classes,font_size_style_values:s.font_size_style_values,apply_source_formatting:s.apply_source_formatting,remove_linebreaks:s.remove_linebreaks,element_format:s.element_format,dom:t.dom});t.selection=new tinymce.dom.Selection(t.dom,t.getWin(),t.serializer);t.forceBlocks=new tinymce.ForceBlocks(t,{forced_root_block:s.forced_root_block});t.editorCommands=new tinymce.EditorCommands(t);t.serializer.onPreProcess.add(function(se,o){return t.onPreProcess.dispatch(t,o,se);});t.serializer.onPostProcess.add(function(se,o){return t.onPostProcess.dispatch(t,o,se);});t.onPreInit.dispatch(t);if(!s.gecko_spellcheck)t.getBody().spellcheck=0;if(!s.readonly)t._addEvents();t.controlManager.onPostRender.dispatch(t,t.controlManager);t.onPostRender.dispatch(t);if(s.directionality)t.getBody().dir=s.directionality;if(s.nowrap)t.getBody().style.whiteSpace="nowrap";if(s.auto_resize)t.onNodeChange.add(t.resizeToContent,t);if(s.custom_elements){function handleCustom(ed,o){each(explode(s.custom_elements),function(v){var n;if(v.indexOf('~')===0){v=v.substring(1);n='span';}else n='div';o.content=o.content.replace(new RegExp('<('+v+')([^>]*)>','g'),'<'+n+' mce_name="$1"$2>');o.content=o.content.replace(new RegExp('','g'),'');});};t.onBeforeSetContent.add(handleCustom);t.onPostProcess.add(function(ed,o){if(o.set)handleCustom(ed,o)});}if(s.handle_node_change_callback){t.onNodeChange.add(function(ed,cm,n){t.execCallback('handle_node_change_callback',t.id,n,-1,-1,true,t.selection.isCollapsed());});}if(s.save_callback){t.onSaveContent.add(function(ed,o){var h=t.execCallback('save_callback',t.id,o.content,t.getBody());if(h)o.content=h;});}if(s.onchange_callback){t.onChange.add(function(ed,l){t.execCallback('onchange_callback',t,l);});}if(s.convert_newlines_to_brs){t.onBeforeSetContent.add(function(ed,o){if(o.initial)o.content=o.content.replace(/\r?\n/g,'
    ');});}if(s.fix_nesting&&isIE){t.onBeforeSetContent.add(function(ed,o){o.content=t._fixNesting(o.content);});}if(s.preformatted){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^\s*/,'');o.content=o.content.replace(/<\/pre>\s*$/,'');if(o.set)o.content='
    '+o.content+'
    ';});}if(s.verify_css_classes){t.serializer.attribValueFilter=function(n,v){var s,cl;if(n=='class'){if(!t.classesRE){cl=t.dom.getClasses();if(cl.length>0){s='';each(cl,function(o){s+=(s?'|':'')+o['class'];});t.classesRE=new RegExp('('+s+')','gi');}}return!t.classesRE||/(\bmceItem\w+\b|\bmceTemp\w+\b)/g.test(v)||t.classesRE.test(v)?v:'';}return v;};}if(s.convert_fonts_to_spans)t._convertFonts();if(s.inline_styles)t._convertInlineElements();if(s.cleanup_callback){t.onBeforeSetContent.add(function(ed,o){o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);});t.onPreProcess.add(function(ed,o){if(o.set)t.execCallback('cleanup_callback','insert_to_editor_dom',o.node,o);if(o.get)t.execCallback('cleanup_callback','get_from_editor_dom',o.node,o);});t.onPostProcess.add(function(ed,o){if(o.set)o.content=t.execCallback('cleanup_callback','insert_to_editor',o.content,o);if(o.get)o.content=t.execCallback('cleanup_callback','get_from_editor',o.content,o);});}if(s.save_callback){t.onGetContent.add(function(ed,o){if(o.save)o.content=t.execCallback('save_callback',t.id,o.content,t.getBody());});}if(s.handle_event_callback){t.onEvent.add(function(ed,e,o){if(t.execCallback('handle_event_callback',e,ed,o)===false)Event.cancel(e);});}t.onSetContent.add(function(){t.addVisual(t.getBody());});if(s.padd_empty_editor){t.onPostProcess.add(function(ed,o){o.content=o.content.replace(/^(]*>( | |\s|\u00a0|)<\/p>[\r\n]*|
    [\r\n]*)$/,'');});}if(isGecko&&!s.readonly){try{d.designMode='Off';d.designMode='On';}catch(ex){}}setTimeout(function(){if(t.removed)return;t.load({initial:true,format:(s.cleanup_on_startup?'html':'raw')});t.startContent=t.getContent({format:'raw'});t.undoManager.add({initial:true});t.initialized=true;t.onInit.dispatch(t);t.execCallback('setupcontent_callback',t.id,t.getBody(),t.getDoc());t.execCallback('init_instance_callback',t);t.focus(true);t.nodeChanged({initial:1});if(s.content_css){tinymce.each(explode(s.content_css),function(u){t.dom.loadCSS(t.documentBaseURI.toAbsolute(u));});}if(s.auto_focus){setTimeout(function(){var ed=EditorManager.get(s.auto_focus);ed.selection.select(ed.getBody(),1);ed.selection.collapse(1);ed.getWin().focus();},100);}},1);e=null;},focus:function(sf){var oed,t=this,ce=t.settings.content_editable;if(!sf){if(!ce&&(!isIE||t.selection.getNode().ownerDocument!=t.getDoc()))t.getWin().focus();}if(EditorManager.activeEditor!=t){if((oed=EditorManager.activeEditor)!=null)oed.onDeactivate.dispatch(oed,t);t.onActivate.dispatch(t,oed);}EditorManager._setActive(t);},execCallback:function(n){var t=this,f=t.settings[n],s;if(!f)return;if(t.callbackLookup&&(s=t.callbackLookup[n])){f=s.func;s=s.scope;}if(is(f,'string')){s=f.replace(/\.\w+$/,'');s=s?tinymce.resolve(s):0;f=tinymce.resolve(f);t.callbackLookup=t.callbackLookup||{};t.callbackLookup[n]={func:f,scope:s};}return f.apply(s||t,Array.prototype.slice.call(arguments,1));},translate:function(s){var c=this.settings.language||'en',i18n=EditorManager.i18n;if(!s)return'';return i18n[c+'.'+s]||s.replace(/{\#([^}]+)\}/g,function(a,b){return i18n[c+'.'+b]||'{#'+b+'}';});},getLang:function(n,dv){return EditorManager.i18n[(this.settings.language||'en')+'.'+n]||(is(dv)?dv:'{#'+n+'}');},getParam:function(n,dv,ty){var tr=tinymce.trim,v=is(this.settings[n])?this.settings[n]:dv,o;if(ty==='hash'){o={};if(is(v,'string')){each(v.indexOf('=')>0?v.split(/[;,](?![^=;,]*(?:[;,]|$))/):v.split(','),function(v){v=v.split('=');if(v.length>1)o[tr(v[0])]=tr(v[1]);else o[tr(v[0])]=tr(v);});}else o=v;return o;}return v;},nodeChanged:function(o){var t=this,s=t.selection,n=s.getNode()||t.getBody();if(t.initialized){t.onNodeChange.dispatch(t,o?o.controlManager||t.controlManager:t.controlManager,isIE&&n.ownerDocument!=t.getDoc()?t.getBody():n,s.isCollapsed(),o);}},addButton:function(n,s){var t=this;t.buttons=t.buttons||{};t.buttons[n]=s;},addCommand:function(n,f,s){this.execCommands[n]={func:f,scope:s||this};},addQueryStateHandler:function(n,f,s){this.queryStateCommands[n]={func:f,scope:s||this};},addQueryValueHandler:function(n,f,s){this.queryValueCommands[n]={func:f,scope:s||this};},addShortcut:function(pa,desc,cmd_func,sc){var t=this,c;if(!t.settings.custom_shortcuts)return false;t.shortcuts=t.shortcuts||{};if(is(cmd_func,'string')){c=cmd_func;cmd_func=function(){t.execCommand(c,false,null);};}if(is(cmd_func,'object')){c=cmd_func;cmd_func=function(){t.execCommand(c[0],c[1],c[2]);};}each(explode(pa),function(pa){var o={func:cmd_func,scope:sc||this,desc:desc,alt:false,ctrl:false,shift:false};each(explode(pa,'+'),function(v){switch(v){case'alt':case'ctrl':case'shift':o[v]=true;break;default:o.charCode=v.charCodeAt(0);o.keyCode=v.toUpperCase().charCodeAt(0);}});t.shortcuts[(o.ctrl?'ctrl':'')+','+(o.alt?'alt':'')+','+(o.shift?'shift':'')+','+o.keyCode]=o;});return true;},execCommand:function(cmd,ui,val,a){var t=this,s=0,o,st;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(cmd)&&(!a||!a.skip_focus))t.focus();o={};t.onBeforeExecCommand.dispatch(t,cmd,ui,val,o);if(o.terminate)return false;if(t.execCallback('execcommand_callback',t.id,t.selection.getNode(),cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(o=t.execCommands[cmd]){st=o.func.call(o.scope,ui,val);if(st!==true){t.onExecCommand.dispatch(t,cmd,ui,val,a);return st;}}each(t.plugins,function(p){if(p.execCommand&&p.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);s=1;return false;}});if(s)return true;if(t.theme.execCommand&&t.theme.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}if(t.editorCommands.execCommand(cmd,ui,val)){t.onExecCommand.dispatch(t,cmd,ui,val,a);return true;}t.getDoc().execCommand(cmd,ui,val);t.onExecCommand.dispatch(t,cmd,ui,val,a);},queryCommandState:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryStateCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandState(c);if(o!==-1)return o;try{return this.getDoc().queryCommandState(c);}catch(ex){}},queryCommandValue:function(c){var t=this,o,s;if(t._isHidden())return;if(o=t.queryValueCommands[c]){s=o.func.call(o.scope);if(s!==true)return s;}o=t.editorCommands.queryCommandValue(c);if(is(o))return o;try{return this.getDoc().queryCommandValue(c);}catch(ex){}},show:function(){var t=this;DOM.show(t.getContainer());DOM.hide(t.id);t.load();},hide:function(){var t=this,d=t.getDoc();if(isIE&&d)d.execCommand('SelectAll');t.save();DOM.hide(t.getContainer());DOM.setStyle(t.id,'display',t.orgDisplay);},isHidden:function(){return!DOM.isHidden(this.id);},setProgressState:function(b,ti,o){this.onSetProgressState.dispatch(this,b,ti,o);return b;},resizeToContent:function(){var t=this;DOM.setStyle(t.id+"_ifr",'height',t.getBody().scrollHeight);},load:function(o){var t=this,e=t.getElement(),h;if(e){o=o||{};o.load=true;h=t.setContent(is(e.value)?e.value:e.innerHTML,o);o.element=e;if(!o.no_events)t.onLoadContent.dispatch(t,o);o.element=e=null;return h;}},save:function(o){var t=this,e=t.getElement(),h,f;if(!e||!t.initialized)return;o=o||{};o.save=true;if(!o.no_events){t.undoManager.typing=0;t.undoManager.add();}o.element=e;h=o.content=t.getContent(o);if(!o.no_events)t.onSaveContent.dispatch(t,o);h=o.content;if(!/TEXTAREA|INPUT/i.test(e.nodeName)){e.innerHTML=h;if(f=DOM.getParent(t.id,'form')){each(f.elements,function(e){if(e.name==t.id){e.value=h;return false;}});}}else e.value=h;o.element=e=null;return h;},setContent:function(h,o){var t=this;o=o||{};o.format=o.format||'html';o.set=true;o.content=h;if(!o.no_events)t.onBeforeSetContent.dispatch(t,o);if(!tinymce.isIE&&(h.length===0||/^\s+$/.test(h))){o.content=t.dom.setHTML(t.getBody(),'
    ');o.format='raw';}o.content=t.dom.setHTML(t.getBody(),tinymce.trim(o.content));if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;o.content=t.dom.setHTML(t.getBody(),t.serializer.serialize(t.getBody(),o));}if(!o.no_events)t.onSetContent.dispatch(t,o);return o.content;},getContent:function(o){var t=this,h;o=o||{};o.format=o.format||'html';o.get=true;if(!o.no_events)t.onBeforeGetContent.dispatch(t,o);if(o.format!='raw'&&t.settings.cleanup){o.getInner=true;h=t.serializer.serialize(t.getBody(),o);}else h=t.getBody().innerHTML;h=h.replace(/^\s*|\s*$/g,'');o.content=h;if(!o.no_events)t.onGetContent.dispatch(t,o);return o.content;},isDirty:function(){var t=this;return tinymce.trim(t.startContent)!=tinymce.trim(t.getContent({format:'raw',no_events:1}))&&!t.isNotDirty;},getContainer:function(){var t=this;if(!t.container)t.container=DOM.get(t.editorContainer||t.id+'_parent');return t.container;},getContentAreaContainer:function(){return this.contentAreaContainer;},getElement:function(){return DOM.get(this.settings.content_element||this.id);},getWin:function(){var t=this,e;if(!t.contentWindow){e=DOM.get(t.id+"_ifr");if(e)t.contentWindow=e.contentWindow;}return t.contentWindow;},getDoc:function(){var t=this,w;if(!t.contentDocument){w=t.getWin();if(w)t.contentDocument=w.document;}return t.contentDocument;},getBody:function(){return this.bodyElement||this.getDoc().body;},convertURL:function(u,n,e){var t=this,s=t.settings;if(s.urlconverter_callback)return t.execCallback('urlconverter_callback',u,e,true,n);if(!s.convert_urls||(e&&e.nodeName=='LINK')||u.indexOf('file:')===0)return u;if(s.relative_urls)return t.documentBaseURI.toRelative(u);u=t.documentBaseURI.toAbsolute(u,s.remove_script_host);return u;},addVisual:function(e){var t=this,s=t.settings;e=e||t.getBody();if(!is(t.hasVisual))t.hasVisual=s.visual;each(t.dom.select('table,a',e),function(e){var v;switch(e.nodeName){case'TABLE':v=t.dom.getAttrib(e,'border');if(!v||v=='0'){if(t.hasVisual)t.dom.addClass(e,s.visual_table_class);else t.dom.removeClass(e,s.visual_table_class);}return;case'A':v=t.dom.getAttrib(e,'name');if(v){if(t.hasVisual)t.dom.addClass(e,'mceItemAnchor');else t.dom.removeClass(e,'mceItemAnchor');}return;}});t.onVisualAid.dispatch(t,e,t.hasVisual);},remove:function(){var t=this,e=t.getContainer();t.removed=1;t.hide();t.execCallback('remove_instance_callback',t);t.onRemove.dispatch(t);t.onExecCommand.listeners=[];EditorManager.remove(t);DOM.remove(e);},destroy:function(s){var t=this;if(t.destroyed)return;if(!s){tinymce.removeUnload(t.destroy);tinyMCE.onBeforeUnload.remove(t._beforeUnload);if(t.theme.destroy)t.theme.destroy();t.controlManager.destroy();t.selection.destroy();t.dom.destroy();if(!t.settings.content_editable){Event.clear(t.getWin());Event.clear(t.getDoc());}Event.clear(t.getBody());Event.clear(t.formElement);}if(t.formElement){t.formElement.submit=t.formElement._mceOldSubmit;t.formElement._mceOldSubmit=null;}t.contentAreaContainer=t.formElement=t.container=t.settings.content_element=t.bodyElement=t.contentDocument=t.contentWindow=null;if(t.selection)t.selection=t.selection.win=t.selection.dom=t.selection.dom.doc=null;t.destroyed=1;},_addEvents:function(){var t=this,i,s=t.settings,lo={mouseup:'onMouseUp',mousedown:'onMouseDown',click:'onClick',keyup:'onKeyUp',keydown:'onKeyDown',keypress:'onKeyPress',submit:'onSubmit',reset:'onReset',contextmenu:'onContextMenu',dblclick:'onDblClick',paste:'onPaste'};function eventHandler(e,o){var ty=e.type;if(t.removed)return;if(t.onEvent.dispatch(t,e,o)!==false){t[lo[e.fakeType||e.type]].dispatch(t,e,o);}};each(lo,function(v,k){switch(k){case'contextmenu':if(tinymce.isOpera){Event.add(t.getBody(),'mousedown',function(e){if(e.ctrlKey){e.fakeType='contextmenu';eventHandler(e);}});}else Event.add(t.getBody(),k,eventHandler);break;case'paste':Event.add(t.getBody(),k,function(e){var tx,h,el,r;if(e.clipboardData)tx=e.clipboardData.getData('text/plain');else if(tinymce.isIE)tx=t.getWin().clipboardData.getData('Text');eventHandler(e,{text:tx,html:h});});break;case'submit':case'reset':Event.add(t.getElement().form||DOM.getParent(t.id,'form'),k,eventHandler);break;default:Event.add(s.content_editable?t.getBody():t.getDoc(),k,eventHandler);}});Event.add(s.content_editable?t.getBody():(isGecko?t.getDoc():t.getWin()),'focus',function(e){t.focus(true);});if(tinymce.isGecko){Event.add(t.getDoc(),'DOMNodeInserted',function(e){var v;e=e.target;if(e.nodeType===1&&e.nodeName==='IMG'&&(v=e.getAttribute('mce_src')))e.src=t.documentBaseURI.toAbsolute(v);});}if(isGecko){function setOpts(){var t=this,d=t.getDoc(),s=t.settings;if(isGecko&&!s.readonly){if(t._isHidden()){try{if(!s.content_editable)d.designMode='On';}catch(ex){}}try{d.execCommand("styleWithCSS",0,false);}catch(ex){if(!t._isHidden())try{d.execCommand("useCSS",0,true);}catch(ex){}}if(!s.table_inline_editing)try{d.execCommand('enableInlineTableEditing',false,false);}catch(ex){}if(!s.object_resizing)try{d.execCommand('enableObjectResizing',false,false);}catch(ex){}}};t.onBeforeExecCommand.add(setOpts);t.onMouseDown.add(setOpts);}t.onMouseUp.add(t.nodeChanged);t.onClick.add(t.nodeChanged);t.onKeyUp.add(function(ed,e){var c=e.keyCode;if((c>=33&&c<=36)||(c>=37&&c<=40)||c==13||c==45||c==46||c==8||(tinymce.isMac&&(c==91||c==93))||e.ctrlKey)t.nodeChanged();});t.onReset.add(function(){t.setContent(t.startContent,{format:'raw'});});if(t.getParam('tab_focus')){function tabCancel(ed,e){if(e.keyCode===9)return Event.cancel(e);};function tabHandler(ed,e){var x,i,f,el,v;function find(d){f=DOM.getParent(ed.id,'form');el=f.elements;if(f){each(el,function(e,i){if(e.id==ed.id){x=i;return false;}});if(d>0){for(i=x+1;i=0;i--){if(el[i].type!='hidden')return el[i];}}}return null;};if(e.keyCode===9){v=explode(ed.getParam('tab_focus'));if(v.length==1){v[1]=v[0];v[0]=':prev';}if(e.shiftKey){if(v[0]==':prev')el=find(-1);else el=DOM.get(v[0]);}else{if(v[1]==':next')el=find(1);else el=DOM.get(v[1]);}if(el){if(ed=EditorManager.get(el.id||el.name))ed.focus();else window.setTimeout(function(){window.focus();el.focus();},10);return Event.cancel(e);}}};t.onKeyUp.add(tabCancel);if(isGecko){t.onKeyPress.add(tabHandler);t.onKeyDown.add(tabCancel);}else t.onKeyDown.add(tabHandler);}if(s.custom_shortcuts){if(s.custom_undo_redo_keyboard_shortcuts){t.addShortcut('ctrl+z',t.getLang('undo_desc'),'Undo');t.addShortcut('ctrl+y',t.getLang('redo_desc'),'Redo');}if(isGecko){t.addShortcut('ctrl+b',t.getLang('bold_desc'),'Bold');t.addShortcut('ctrl+i',t.getLang('italic_desc'),'Italic');t.addShortcut('ctrl+u',t.getLang('underline_desc'),'Underline');}for(i=1;i<=6;i++)t.addShortcut('ctrl+'+i,'',['FormatBlock',false,'']);t.addShortcut('ctrl+7','',['FormatBlock',false,'

    ']);t.addShortcut('ctrl+8','',['FormatBlock',false,'

    ']);t.addShortcut('ctrl+9','',['FormatBlock',false,'
    ']);function find(e){var v=null;if(!e.altKey&&!e.ctrlKey&&!e.metaKey)return v;each(t.shortcuts,function(o){if(tinymce.isMac&&o.ctrl!=e.metaKey)return;else if(!tinymce.isMac&&o.ctrl!=e.ctrlKey)return;if(o.alt!=e.altKey)return;if(o.shift!=e.shiftKey)return;if(e.keyCode==o.keyCode||(e.charCode&&e.charCode==o.charCode)){v=o;return false;}});return v;};t.onKeyUp.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyPress.add(function(ed,e){var o=find(e);if(o)return Event.cancel(e);});t.onKeyDown.add(function(ed,e){var o=find(e);if(o){o.func.call(o.scope);return Event.cancel(e);}});}if(tinymce.isIE){Event.add(t.getDoc(),'controlselect',function(e){var re=t.resizeInfo,cb;e=e.target;if(e.nodeName!=='IMG')return;if(re)Event.remove(re.node,re.ev,re.cb);if(!t.dom.hasClass(e,'mceItemNoResize')){ev='resizeend';cb=Event.add(e,ev,function(e){var v;e=e.target;if(v=t.dom.getStyle(e,'width')){t.dom.setAttrib(e,'width',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'width','');}if(v=t.dom.getStyle(e,'height')){t.dom.setAttrib(e,'height',v.replace(/[^0-9%]+/g,''));t.dom.setStyle(e,'height','');}});}else{ev='resizestart';cb=Event.add(e,'resizestart',Event.cancel,Event);}re=t.resizeInfo={node:e,ev:ev,cb:cb};});t.onKeyDown.add(function(ed,e){switch(e.keyCode){case 8:if(t.selection.getRng().item){t.selection.getRng().item(0).removeNode();return Event.cancel(e);}}});}if(tinymce.isOpera){t.onClick.add(function(ed,e){Event.prevent(e);});}if(s.custom_undo_redo){function addUndo(){t.undoManager.typing=0;t.undoManager.add();};if(tinymce.isIE){Event.add(t.getWin(),'blur',function(e){var n;if(t.selection){n=t.selection.getNode();if(!t.removed&&n.ownerDocument&&n.ownerDocument!=t.getDoc())addUndo();}});}else{Event.add(t.getDoc(),'blur',function(){if(t.selection&&!t.removed)addUndo();});}t.onMouseDown.add(addUndo);t.onKeyUp.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45||e.ctrlKey){t.undoManager.typing=0;t.undoManager.add();}});t.onKeyDown.add(function(ed,e){if((e.keyCode>=33&&e.keyCode<=36)||(e.keyCode>=37&&e.keyCode<=40)||e.keyCode==13||e.keyCode==45){if(t.undoManager.typing){t.undoManager.add();t.undoManager.typing=0;}return;}if(!t.undoManager.typing){t.undoManager.add();t.undoManager.typing=1;}});}},_convertInlineElements:function(){var t=this,s=t.settings,dom=t.dom,v,e,na,st,sp;function convert(ed,o){if(!s.inline_styles)return;if(o.get){each(t.dom.select('table,u,strike',o.node),function(n){switch(n.nodeName){case'TABLE':if(v=dom.getAttrib(n,'height')){dom.setStyle(n,'height',v);dom.setAttrib(n,'height','');}break;case'U':case'STRIKE':n.style.textDecoration=n.nodeName=='U'?'underline':'line-through';dom.setAttrib(n,'mce_style','');dom.setAttrib(n,'mce_name','span');break;}});}else if(o.set){each(t.dom.select('table,span',o.node).reverse(),function(n){if(n.nodeName=='TABLE'){if(v=dom.getStyle(n,'height'))dom.setAttrib(n,'height',v.replace(/[^0-9%]+/g,''));}else{if(n.style.textDecoration=='underline')na='u';else if(n.style.textDecoration=='line-through')na='strike';else na='';if(na){n.style.textDecoration='';dom.setAttrib(n,'mce_style','');e=dom.create(na,{style:dom.getAttrib(n,'style')});dom.replace(e,n,1);}}});}};t.onPreProcess.add(convert);if(!s.cleanup_on_startup){t.onSetContent.add(function(ed,o){if(o.initial)convert(t,{node:t.getBody(),set:1});});}},_convertFonts:function(){var t=this,s=t.settings,dom=t.dom,fz,fzn,sl,cl;if(!s.inline_styles)return;fz=[8,10,12,14,18,24,36];fzn=['xx-small','x-small','small','medium','large','x-large','xx-large'];if(sl=s.font_size_style_values)sl=explode(sl);if(cl=s.font_size_classes)cl=explode(cl);function process(no){var n,sp,nl,x;if(!s.inline_styles)return;nl=t.dom.select('font',no);for(x=nl.length-1;x>=0;x--){n=nl[x];sp=dom.create('span',{style:dom.getAttrib(n,'style'),'class':dom.getAttrib(n,'class')});dom.setStyles(sp,{fontFamily:dom.getAttrib(n,'face'),color:dom.getAttrib(n,'color'),backgroundColor:n.style.backgroundColor});if(n.size){if(sl)dom.setStyle(sp,'fontSize',sl[parseInt(n.size)-1]);else dom.setAttrib(sp,'class',cl[parseInt(n.size)-1]);}dom.setAttrib(sp,'mce_style','');dom.replace(sp,n,1);}};t.onPreProcess.add(function(ed,o){if(o.get)process(o.node);});t.onSetContent.add(function(ed,o){if(o.initial)process(o.node);});},_isHidden:function(){var s;if(!isGecko)return 0;s=this.selection.getSel();return(!s||!s.rangeCount||s.rangeCount==0);},_fixNesting:function(s){var d=[],i;s=s.replace(/<(\/)?([^\s>]+)[^>]*?>/g,function(a,b,c){var e;if(b==='/'){if(!d.length)return'';if(c!==d[d.length-1].tag){for(i=d.length-1;i>=0;i--){if(d[i].tag===c){d[i].close=1;break;}}return'';}else{d.pop();if(d.length&&d[d.length-1].close){a=a+'';d.pop();}}}else{if(/^(br|hr|input|meta|img|link|param)$/i.test(c))return a;if(/\/>$/.test(a))return a;d.push({tag:c});}return a;});for(i=d.length-1;i>=0;i--)s+='';return s;}});})();(function(){var each=tinymce.each,isIE=tinymce.isIE,isGecko=tinymce.isGecko,isOpera=tinymce.isOpera,isWebKit=tinymce.isWebKit;function isBlock(n){return/^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP)$/.test(n.nodeName);};tinymce.create('tinymce.EditorCommands',{EditorCommands:function(ed){this.editor=ed;},execCommand:function(cmd,ui,val){var t=this,ed=t.editor,f;switch(cmd){case'Cut':case'Copy':case'Paste':try{ed.getDoc().execCommand(cmd,ui,val);}catch(ex){if(isGecko){ed.windowManager.confirm(ed.getLang('clipboard_msg'),function(s){if(s)window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');});}else ed.windowManager.alert(ed.getLang('clipboard_no_support'));}return true;case'mceResetDesignMode':case'mceBeginUndoLevel':return true;case'unlink':t.UnLink();return true;case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':t.mceJustify(cmd,cmd.substring(7).toLowerCase());return true;case'mceEndUndoLevel':case'mceAddUndoLevel':ed.undoManager.add();return true;default:f=this[cmd];if(f){f.call(this,ui,val);return true;}}return false;},Indent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){d.setStyle(e,'paddingLeft',(parseInt(e.style.paddingLeft||0)+iv)+iu);});return;}ed.getDoc().execCommand('Indent',false,null);if(isIE){d.getParent(s.getNode(),function(n){if(n.nodeName=='BLOCKQUOTE'){n.dir=n.style.cssText='';}});}},Outdent:function(){var ed=this.editor,d=ed.dom,s=ed.selection,e,v,iv,iu;iv=ed.settings.indentation;iu=/[a-z%]+$/i.exec(iv);iv=parseInt(iv);if(ed.settings.inline_styles&&(!this.queryStateInsertUnorderedList()&&!this.queryStateInsertOrderedList())){each(this._getSelectedBlocks(),function(e){v=Math.max(0,parseInt(e.style.paddingLeft||0)-iv);d.setStyle(e,'paddingLeft',v?v+iu:'');});return;}ed.getDoc().execCommand('Outdent',false,null);},mceSetAttribute:function(u,v){var ed=this.editor,d=ed.dom,e;if(e=d.getParent(ed.selection.getNode(),d.isBlock))d.setAttrib(e,v.name,v.value);},mceSetContent:function(u,v){this.editor.setContent(v);},mceToggleVisualAid:function(){var ed=this.editor;ed.hasVisual=!ed.hasVisual;ed.addVisual();},mceReplaceContent:function(u,v){var s=this.editor.selection;s.setContent(v.replace(/\{\$selection\}/g,s.getContent({format:'text'})));},mceInsertLink:function(u,v){var ed=this.editor,s=ed.selection,e=ed.dom.getParent(s.getNode(),'A');if(tinymce.is(v,'string'))v={href:v};function set(e){each(v,function(v,k){ed.dom.setAttrib(e,k,v);});};if(!e){ed.execCommand('CreateLink',false,'javascript:mctmp(0);');each(ed.dom.select('a'),function(e){if(e.href=='javascript:mctmp(0);')set(e);});}else{if(v.href)set(e);else ed.dom.remove(e,1);}},UnLink:function(){var ed=this.editor,s=ed.selection;if(s.isCollapsed())s.select(s.getNode());ed.getDoc().execCommand('unlink',false,null);s.collapse(0);},FontName:function(u,v){var t=this,ed=t.editor,s=ed.selection,e;if(!v){if(s.isCollapsed())s.select(s.getNode());t.RemoveFormat();}else{if(ed.settings.convert_fonts_to_spans)t._applyInlineStyle('span',{style:{fontFamily:v}});else ed.getDoc().execCommand('FontName',false,v);}},FontSize:function(u,v){var ed=this.editor,s=ed.settings,fc,fs;if(s.convert_fonts_to_spans&&v>=1&&v<=7){fs=tinymce.explode(s.font_size_style_values);fc=tinymce.explode(s.font_size_classes);if(fc)v=fc[v-1]||v;else v=fs[v-1]||v;}if(v>=1&&v<=7)ed.getDoc().execCommand('FontSize',false,v);else this._applyInlineStyle('span',{style:{fontSize:v}});},queryCommandValue:function(c){var f=this['queryValue'+c];if(f)return f.call(this,c);return false;},queryCommandState:function(cmd){var f;switch(cmd){case'JustifyLeft':case'JustifyCenter':case'JustifyRight':case'JustifyFull':return this.queryStateJustify(cmd,cmd.substring(7).toLowerCase());default:if(f=this['queryState'+cmd])return f.call(this,cmd);}return-1;},_queryState:function(c){try{return this.editor.getDoc().queryCommandState(c);}catch(ex){}},_queryVal:function(c){try{return this.editor.getDoc().queryCommandValue(c);}catch(ex){}},queryValueFontSize:function(){var ed=this.editor,v=0,p;if(p=ed.dom.getParent(ed.selection.getNode(),'SPAN'))v=p.style.fontSize;if(!v&&(isOpera||isWebKit)){if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.size;return v;}return v||this._queryVal('FontSize');},queryValueFontName:function(){var ed=this.editor,v=0,p;if(p=ed.dom.getParent(ed.selection.getNode(),'FONT'))v=p.face;if(p=ed.dom.getParent(ed.selection.getNode(),'SPAN'))v=p.style.fontFamily.replace(/, /g,',').replace(/[\'\"]/g,'').toLowerCase();if(!v)v=this._queryVal('FontName');return v;},mceJustify:function(c,v){var ed=this.editor,se=ed.selection,n=se.getNode(),nn=n.nodeName,bl,nb,dom=ed.dom,rm;if(ed.settings.inline_styles&&this.queryStateJustify(c,v))rm=1;bl=dom.getParent(n,ed.dom.isBlock);if(nn=='IMG'){if(v=='full')return;if(rm){if(v=='center')dom.setStyle(bl||n.parentNode,'textAlign','');dom.setStyle(n,'float','');this.mceRepaint();return;}if(v=='center'){if(bl&&/^(TD|TH)$/.test(bl.nodeName))bl=0;if(!bl||bl.childNodes.length>1){nb=dom.create('p');nb.appendChild(n.cloneNode(false));if(bl)dom.insertAfter(nb,bl);else dom.insertAfter(nb,n);dom.remove(n);n=nb.firstChild;bl=nb;}dom.setStyle(bl,'textAlign',v);dom.setStyle(n,'float','');}else{dom.setStyle(n,'float',v);dom.setStyle(bl||n.parentNode,'textAlign','');}this.mceRepaint();return;}if(ed.settings.inline_styles&&ed.settings.forced_root_block){if(rm)v='';each(this._getSelectedBlocks(dom.getParent(se.getStart(),dom.isBlock),dom.getParent(se.getEnd(),dom.isBlock)),function(e){dom.setAttrib(e,'align','');dom.setStyle(e,'textAlign',v=='full'?'justify':v);});return;}else if(!rm)ed.getDoc().execCommand(c,false,null);if(ed.settings.inline_styles){if(rm){dom.getParent(ed.selection.getNode(),function(n){if(n.style&&n.style.textAlign)dom.setStyle(n,'textAlign','');});return;}each(dom.select('*'),function(n){var v=n.align;if(v){if(v=='full')v='justify';dom.setStyle(n,'textAlign',v);dom.setAttrib(n,'align','');}});}},mceSetCSSClass:function(u,v){this.mceSetStyleInfo(0,{command:'setattrib',name:'class',value:v});},getSelectedElement:function(){var t=this,ed=t.editor,dom=ed.dom,se=ed.selection,r=se.getRng(),r1,r2,sc,ec,so,eo,e,sp,ep,re;if(se.isCollapsed()||r.item)return se.getNode();re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if(isIE){r1=r.duplicate();r1.collapse(true);sc=r1.parentElement();r2=r.duplicate();r2.collapse(false);ec=r2.parentElement();if(sc!=ec){r1.move('character',1);sc=r1.parentElement();}if(sc==ec){r1=r.duplicate();r1.moveToElementText(sc);if(r1.compareEndPoints('StartToStart',r)==0&&r1.compareEndPoints('EndToEnd',r)==0)return re&&re.test(sc.nodeName)?null:sc;}}else{function getParent(n){return dom.getParent(n,function(n){return n.nodeType==1;});};sc=r.startContainer;ec=r.endContainer;so=r.startOffset;eo=r.endOffset;if(!r.collapsed){if(sc==ec){if(so-eo<2){if(sc.hasChildNodes()){sp=sc.childNodes[so];return re&&re.test(sp.nodeName)?null:sp;}}}}if(sc.nodeType!=3||ec.nodeType!=3)return null;if(so==0){sp=getParent(sc);if(sp&&sp.firstChild!=sc)sp=null;}if(so==sc.nodeValue.length){e=sc.nextSibling;if(e&&e.nodeType==1)sp=sc.nextSibling;}if(eo==0){e=ec.previousSibling;if(e&&e.nodeType==1)ep=e;}if(eo==ec.nodeValue.length){ep=getParent(ec);if(ep&&ep.lastChild!=ec)ep=null;}if(sp==ep)return re&&sp&&re.test(sp.nodeName)?null:sp;}return null;},InsertHorizontalRule:function(){if(isGecko||isIE)this.editor.selection.setContent('
    ');else this.editor.getDoc().execCommand('InsertHorizontalRule',false,'');},RemoveFormat:function(){var t=this,ed=t.editor,s=ed.selection,b;if(isWebKit)s.setContent(s.getContent({format:'raw'}).replace(/(<(span|b|i|strong|em|strike) [^>]+>|<(span|b|i|strong|em|strike)>|<\/(span|b|i|strong|em|strike)>|)/g,''),{format:'raw'});else ed.getDoc().execCommand('RemoveFormat',false,null);t.mceSetStyleInfo(0,{command:'removeformat'});ed.addVisual();},mceSetStyleInfo:function(u,v){var t=this,ed=t.editor,d=ed.getDoc(),dom=ed.dom,e,b,s=ed.selection,nn=v.wrapper||'span',b=s.getBookmark(),re;function set(n,e){if(n.nodeType==1){switch(v.command){case'setattrib':return dom.setAttrib(n,v.name,v.value);case'setstyle':return dom.setStyle(n,v.name,v.value);case'removeformat':return dom.setAttrib(n,'class','');}}};re=ed.settings.merge_styles_invalid_parents;if(tinymce.is(re,'string'))re=new RegExp(re,'i');if((e=t.getSelectedElement())&&!ed.settings.force_span_wrappers)set(e,1);else{d.execCommand('FontName',false,'__');each(isWebKit?dom.select('span'):dom.select('font'),function(n){var sp,e;if(dom.getAttrib(n,'face')=='__'||n.style.fontFamily==='__'){sp=dom.create(nn,{mce_new:'1'});set(sp);each(n.childNodes,function(n){sp.appendChild(n.cloneNode(true));});dom.replace(sp,n);}});}each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!dom.getAttrib(n,'mce_new')){p=dom.getParent(n,function(n){return n.nodeType==1&&dom.getAttrib(n,'mce_new');});if(p)dom.remove(n,1);}});each(dom.select(nn).reverse(),function(n){var p=n.parentNode;if(!p||!dom.getAttrib(n,'mce_new'))return;if(ed.settings.force_span_wrappers&&p.nodeName!='SPAN')return;if(p.nodeName==nn.toUpperCase()&&p.childNodes.length==1)return dom.remove(p,1);if(n.nodeType==1&&(!re||!re.test(p.nodeName))&&p.childNodes.length==1){set(p);dom.setAttrib(n,'class','');}});each(dom.select(nn).reverse(),function(n){if(dom.getAttrib(n,'mce_new')||(dom.getAttribs(n).length<=1&&n.className==='')){if(!dom.getAttrib(n,'class')&&!dom.getAttrib(n,'style'))return dom.remove(n,1);dom.setAttrib(n,'mce_new','');}});s.moveToBookmark(b);},queryStateJustify:function(c,v){var ed=this.editor,n=ed.selection.getNode(),dom=ed.dom;if(n&&n.nodeName=='IMG'){if(dom.getStyle(n,'float')==v)return 1;return n.parentNode.style.textAlign==v;}n=dom.getParent(ed.selection.getStart(),function(n){return n.nodeType==1&&n.style.textAlign;});if(v=='full')v='justify';if(ed.settings.inline_styles)return(n&&n.style.textAlign==v);return this._queryState(c);},ForeColor:function(ui,v){var ed=this.editor;if(ed.settings.convert_fonts_to_spans){this._applyInlineStyle('span',{style:{color:v}});return;}else ed.getDoc().execCommand('ForeColor',false,v);},HiliteColor:function(ui,val){var t=this,ed=t.editor,d=ed.getDoc();if(ed.settings.convert_fonts_to_spans){this._applyInlineStyle('span',{style:{backgroundColor:val}});return;}function set(s){if(!isGecko)return;try{d.execCommand("styleWithCSS",0,s);}catch(ex){d.execCommand("useCSS",0,!s);}};if(isGecko||isOpera){set(true);d.execCommand('hilitecolor',false,val);set(false);}else d.execCommand('BackColor',false,val);},Undo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.undo();ed.nodeChanged();}else ed.getDoc().execCommand('Undo',false,null);},Redo:function(){var ed=this.editor;if(ed.settings.custom_undo_redo){ed.undoManager.redo();ed.nodeChanged();}else ed.getDoc().execCommand('Redo',false,null);},FormatBlock:function(ui,val){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,bl,nb,b;function isBlock(n){return/^(P|DIV|H[1-6]|ADDRESS|BLOCKQUOTE|PRE)$/.test(n.nodeName);};bl=dom.getParent(s.getNode(),function(n){return isBlock(n);});if(bl){if((isIE&&isBlock(bl.parentNode))||bl.nodeName=='DIV'){nb=ed.dom.create(val);each(dom.getAttribs(bl),function(v){dom.setAttrib(nb,v.nodeName,dom.getAttrib(bl,v.nodeName));});b=s.getBookmark();dom.replace(nb,bl,1);s.moveToBookmark(b);ed.nodeChanged();return;}}val=ed.settings.forced_root_block?(val||'

    '):val;if(val.indexOf('<')==-1)val='<'+val+'>';if(tinymce.isGecko)val=val.replace(/<(div|blockquote|code|dt|dd|dl|samp)>/gi,'$1');ed.getDoc().execCommand('FormatBlock',false,val);},mceCleanup:function(){var ed=this.editor,s=ed.selection,b=s.getBookmark();ed.setContent(ed.getContent());s.moveToBookmark(b);},mceRemoveNode:function(ui,val){var ed=this.editor,s=ed.selection,b,n=val||s.getNode();if(n==ed.getBody())return;b=s.getBookmark();ed.dom.remove(n,1);s.moveToBookmark(b);ed.nodeChanged();},mceSelectNodeDepth:function(ui,val){var ed=this.editor,s=ed.selection,c=0;ed.dom.getParent(s.getNode(),function(n){if(n.nodeType==1&&c++==val){s.select(n);ed.nodeChanged();return false;}},ed.getBody());},mceSelectNode:function(u,v){this.editor.selection.select(v);},mceInsertContent:function(ui,val){this.editor.selection.setContent(val);},mceInsertRawHTML:function(ui,val){var ed=this.editor;ed.selection.setContent('tiny_mce_marker');ed.setContent(ed.getContent().replace(/tiny_mce_marker/g,val));},mceRepaint:function(){var s,b,e=this.editor;if(tinymce.isGecko){try{s=e.selection;b=s.getBookmark(true);if(s.getSel())s.getSel().selectAllChildren(e.getBody());s.collapse(true);s.moveToBookmark(b);}catch(ex){}}},queryStateUnderline:function(){var ed=this.editor,n=ed.selection.getNode();if(n&&n.nodeName=='A')return false;return this._queryState('Underline');},queryStateOutdent:function(){var ed=this.editor,n;if(ed.settings.inline_styles){if((n=ed.dom.getParent(ed.selection.getStart(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;if((n=ed.dom.getParent(ed.selection.getEnd(),ed.dom.isBlock))&&parseInt(n.style.paddingLeft)>0)return true;}return this.queryStateInsertUnorderedList()||this.queryStateInsertOrderedList()||(!ed.settings.inline_styles&&!!ed.dom.getParent(ed.selection.getNode(),'BLOCKQUOTE'));},queryStateInsertUnorderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'UL');},queryStateInsertOrderedList:function(){return this.editor.dom.getParent(this.editor.selection.getNode(),'OL');},queryStatemceBlockQuote:function(){return!!this.editor.dom.getParent(this.editor.selection.getStart(),function(n){return n.nodeName==='BLOCKQUOTE';});},mceBlockQuote:function(){var t=this,ed=t.editor,s=ed.selection,dom=ed.dom,sb,eb,n,bm,bq,r,bq2,i,nl;function getBQ(e){return dom.getParent(e,function(n){return n.nodeName==='BLOCKQUOTE';});};sb=dom.getParent(s.getStart(),isBlock);eb=dom.getParent(s.getEnd(),isBlock);if(bq=getBQ(sb)){if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();if(getBQ(eb)){bq2=bq.cloneNode(false);while(n=eb.nextSibling)bq2.appendChild(n.parentNode.removeChild(n));}if(bq2)dom.insertAfter(bq2,bq);nl=t._getSelectedBlocks(sb,eb);for(i=nl.length-1;i>=0;i--){dom.insertAfter(nl[i],bq);}if(/^\s*$/.test(bq.innerHTML))dom.remove(bq,1);if(bq2&&/^\s*$/.test(bq2.innerHTML))dom.remove(bq2,1);if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(0);if(dom.getParent(s.getStart(),isBlock)!=sb){r=s.getRng();r.move('character',-1);r.select();}}}else t.editor.selection.moveToBookmark(bm);return;}if(isIE&&!sb&&!eb){t.editor.getDoc().execCommand('Indent');n=getBQ(s.getNode());n.style.margin=n.dir='';return;}if(!sb||!eb)return;if(sb!=eb||sb.childNodes.length>1||(sb.childNodes.length==1&&sb.firstChild.nodeName!='BR'))bm=s.getBookmark();each(t._getSelectedBlocks(getBQ(s.getStart()),getBQ(s.getEnd())),function(e){if(e.nodeName=='BLOCKQUOTE'&&!bq){bq=e;return;}if(!bq){bq=dom.create('blockquote');e.parentNode.insertBefore(bq,e);}if(e.nodeName=='BLOCKQUOTE'&&bq){n=e.firstChild;while(n){bq.appendChild(n.cloneNode(true));n=n.nextSibling;}dom.remove(e);return;}bq.appendChild(dom.remove(e));});if(!bm){if(!isIE){r=ed.getDoc().createRange();r.setStart(sb,0);r.setEnd(sb,0);s.setRng(r);}else{s.select(sb);s.collapse(1);}}else s.moveToBookmark(bm);},_applyInlineStyle:function(na,at,op){var t=this,ed=t.editor,dom=ed.dom,bm,lo={},kh;na=na.toUpperCase();if(op&&op.check_classes&&at['class'])op.check_classes.push(at['class']);function replaceFonts(){var bm;each(dom.select(tinymce.isWebKit&&!tinymce.isAir?'span':'font'),function(n){if(n.style.fontFamily=='mceinline'||n.face=='mceinline'){if(!bm)bm=ed.selection.getBookmark();at._mce_new='1';dom.replace(dom.create(na,at),n,1);}});each(dom.select(na),function(n){if(n.getAttribute('_mce_new')){function removeStyle(n){if(n.nodeType==1){each(at.style,function(v,k){dom.setStyle(n,k,'');});if(at['class']&&n.className&&op){each(op.check_classes,function(c){if(dom.hasClass(n,c))dom.removeClass(n,c);});}}};each(dom.select(na,n),removeStyle);if(n.parentNode&&n.parentNode.nodeType==1&&n.parentNode.childNodes.length==1)removeStyle(n.parentNode);dom.getParent(n.parentNode,function(pn){if(pn.nodeType==1){if(at.style){each(at.style,function(v,k){var sv;if(!lo[k]&&(sv=dom.getStyle(pn,k))){if(sv===v)dom.setStyle(n,k,'');lo[k]=1;}});}if(at['class']&&pn.className&&op){each(op.check_classes,function(c){if(dom.hasClass(pn,c))dom.removeClass(n,c);});}}return false;});n.removeAttribute('_mce_new');}});each(dom.select(na).reverse(),function(n){var c=0;each(dom.getAttribs(n),function(an){if(an.nodeName.substring(0,1)!='_'&&dom.getAttrib(n,an.nodeName)!=''){c++;}});if(c==0)dom.remove(n,1);});ed.selection.moveToBookmark(bm);return!!bm;};ed.focus();ed.getDoc().execCommand('FontName',false,'mceinline');replaceFonts();if(kh=t._applyInlineStyle.keyhandler){ed.onKeyUp.remove(kh);ed.onKeyPress.remove(kh);ed.onKeyDown.remove(kh);ed.onSetContent.remove(t._applyInlineStyle.chandler);}if(ed.selection.isCollapsed()){t._pendingStyles=tinymce.extend(t._pendingStyles||{},at.style);t._applyInlineStyle.chandler=ed.onSetContent.add(function(){delete t._pendingStyles;});t._applyInlineStyle.keyhandler=kh=function(e){if(t._pendingStyles){at.style=t._pendingStyles;delete t._pendingStyles;}if(replaceFonts()){ed.onKeyDown.remove(t._applyInlineStyle.keyhandler);ed.onKeyPress.remove(t._applyInlineStyle.keyhandler);}if(e.type=='keyup')ed.onKeyUp.remove(t._applyInlineStyle.keyhandler);};ed.onKeyDown.add(kh);ed.onKeyPress.add(kh);ed.onKeyUp.add(kh);}else t._pendingStyles=0;},_getSelectedBlocks:function(st,en){var ed=this.editor,dom=ed.dom,s=ed.selection,sb,eb,n,bl=[];sb=dom.getParent(st||s.getStart(),isBlock);eb=dom.getParent(en||s.getEnd(),isBlock);if(sb)bl.push(sb);if(sb&&eb&&sb!=eb){n=sb;while((n=n.nextSibling)&&n!=eb){if(isBlock(n))bl.push(n);}}if(eb&&sb!=eb)bl.push(eb);return bl;}});})();tinymce.create('tinymce.UndoManager',{index:0,data:null,typing:0,UndoManager:function(ed){var t=this,Dispatcher=tinymce.util.Dispatcher;t.editor=ed;t.data=[];t.onAdd=new Dispatcher(this);t.onUndo=new Dispatcher(this);t.onRedo=new Dispatcher(this);},add:function(l){var t=this,i,ed=t.editor,b,s=ed.settings,la;l=l||{};l.content=l.content||ed.getContent({format:'raw',no_events:1});l.content=l.content.replace(/^\s*|\s*$/g,'');la=t.data[t.index>0&&(t.index==0||t.index==t.data.length)?t.index-1:t.index];if(!l.initial&&la&&l.content==la.content)return null;if(s.custom_undo_redo_levels){if(t.data.length>s.custom_undo_redo_levels){for(i=0;i0){if(t.index==t.data.length&&t.index>1){i=t.index;t.typing=0;if(!t.add())t.index=i;--t.index;}l=t.data[--t.index];ed.setContent(l.content,{format:'raw'});ed.selection.moveToBookmark(l.bookmark);t.onUndo.dispatch(t,l);}return l;},redo:function(){var t=this,ed=t.editor,l=null;if(t.index','gi');t.rePadd=new RegExp(']+)><\\\/p>|]+)\\\/>|]+)>\\s+<\\\/p>|

    <\\\/p>||

    \\s+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR1=new RegExp(']+)>[\\s\\u00a0]+<\\\/p>|

    [\\s\\u00a0]+<\\\/p>'.replace(/p/g,elm),'gi');t.reNbsp2BR2=new RegExp(']+)>( | )<\\\/p>|

    ( | )<\\\/p>'.replace(/p/g,elm),'gi');t.reBR2Nbsp=new RegExp(']+)>\\s*
    \\s*<\\\/p>|

    \\s*
    \\s*<\\\/p>'.replace(/p/g,elm),'gi');t.reTrailBr=new RegExp('\\s*
    \\s*<\\\/p>'.replace(/p/g,elm),'gi');function padd(ed,o){if(isOpera)o.content=o.content.replace(t.reOpera,'');o.content=o.content.replace(t.rePadd,'<'+elm+'$1$2$3$4$5$6>\u00a0');if(!isIE&&!isOpera&&o.set){o.content=o.content.replace(t.reNbsp2BR1,'<'+elm+'$1$2>
    ');o.content=o.content.replace(t.reNbsp2BR2,'<'+elm+'$1$2>
    ');}else{o.content=o.content.replace(t.reBR2Nbsp,'<'+elm+'$1$2>\u00a0');o.content=o.content.replace(t.reTrailBr,'');}};ed.onBeforeSetContent.add(padd);ed.onPostProcess.add(padd);if(s.forced_root_block){ed.onInit.add(t.forceRoots,t);ed.onSetContent.add(t.forceRoots,t);ed.onBeforeGetContent.add(t.forceRoots,t);}},setup:function(){var t=this,ed=t.editor,s=ed.settings;if(s.forced_root_block){ed.onKeyUp.add(t.forceRoots,t);ed.onPreProcess.add(t.forceRoots,t);}if(s.force_br_newlines){if(isIE){ed.onKeyPress.add(function(ed,e){var n,s=ed.selection;if(e.keyCode==13&&s.getNode().nodeName!='LI'){s.setContent('
    ',{format:'raw'});n=ed.dom.get('__');n.removeAttribute('id');s.select(n);s.collapse();return Event.cancel(e);}});}return;}if(!isIE&&s.force_p_newlines){ed.onKeyPress.add(function(ed,e){if(e.keyCode==13&&!e.shiftKey){if(!t.insertPara(e))Event.cancel(e);}});if(isGecko){ed.onKeyDown.add(function(ed,e){if((e.keyCode==8||e.keyCode==46)&&!e.shiftKey)t.backspaceDelete(e,e.keyCode==8);});}}function ren(rn,na){var ne=ed.dom.create(na);each(rn.attributes,function(a){if(a.specified&&a.nodeValue)ne.setAttribute(a.nodeName.toLowerCase(),a.nodeValue);});each(rn.childNodes,function(n){ne.appendChild(n.cloneNode(true));});rn.parentNode.replaceChild(ne,rn);return ne;};if(isIE&&s.element!='P'){ed.onKeyPress.add(function(ed,e){t.lastElm=ed.selection.getNode().nodeName;});ed.onKeyUp.add(function(ed,e){var bl,sel=ed.selection,n=sel.getNode(),b=ed.getBody();if(b.childNodes.length===1&&n.nodeName=='P'){n=ren(n,s.element);sel.select(n);sel.collapse();ed.nodeChanged();}else if(e.keyCode==13&&!e.shiftKey&&t.lastElm!='P'){bl=ed.dom.getParent(n,'P');if(bl){ren(bl,s.element);ed.nodeChanged();}}});}},find:function(n,t,s){var ed=this.editor,w=ed.getDoc().createTreeWalker(n,4,null,false),c=-1;while(n=w.nextNode()){c++;if(t==0&&n==s)return c;if(t==1&&c==s)return n;}return-1;},forceRoots:function(ed,e){var t=this,ed=t.editor,b=ed.getBody(),d=ed.getDoc(),se=ed.selection,s=se.getSel(),r=se.getRng(),si=-2,ei,so,eo,tr,c=-0xFFFFFF;var nx,bl,bp,sp,le,nl=b.childNodes,i,n,eid;for(i=nl.length-1;i>=0;i--){nx=nl[i];if(nx.nodeType==3||(!t.dom.isBlock(nx)&&nx.nodeType!=8)){if(!bl){if(nx.nodeType!=3||/[^\s]/g.test(nx.nodeValue)){if(si==-2&&r){if(!isIE){if(r.startContainer.nodeType==1&&(n=r.startContainer.childNodes[r.startOffset])&&n.nodeType==1){eid=n.getAttribute("id");n.setAttribute("id","__mce");}else{if(ed.dom.getParent(r.startContainer,function(e){return e===b;})){so=r.startOffset;eo=r.endOffset;si=t.find(b,0,r.startContainer);ei=t.find(b,0,r.endContainer);}}}else{tr=d.body.createTextRange();tr.moveToElementText(b);tr.collapse(1);bp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(1);sp=tr.move('character',c)*-1;tr=r.duplicate();tr.collapse(0);le=(tr.move('character',c)*-1)-sp;si=sp-bp;ei=le;}}bl=ed.dom.create(ed.settings.forced_root_block);bl.appendChild(nx.cloneNode(1));nx.parentNode.replaceChild(bl,nx);}}else{if(bl.hasChildNodes())bl.insertBefore(nx,bl.firstChild);else bl.appendChild(nx);}}else bl=null;}if(si!=-2){if(!isIE){bl=b.getElementsByTagName(ed.settings.element)[0];r=d.createRange();if(si!=-1)r.setStart(t.find(b,1,si),so);else r.setStart(bl,0);if(ei!=-1)r.setEnd(t.find(b,1,ei),eo);else r.setEnd(bl,0);if(s){s.removeAllRanges();s.addRange(r);}}else{try{r=s.createRange();r.moveToElementText(b);r.collapse(1);r.moveStart('character',si);r.moveEnd('character',ei);r.select();}catch(ex){}}}else if(!isIE&&(n=ed.dom.get('__mce'))){if(eid)n.setAttribute('id',eid);else n.removeAttribute('id');r=d.createRange();r.setStartBefore(n);r.setEndBefore(n);se.setRng(r);}},getParentBlock:function(n){var d=this.dom;return d.getParent(n,d.isBlock);},insertPara:function(e){var t=this,ed=t.editor,dom=ed.dom,d=ed.getDoc(),se=ed.settings,s=ed.selection.getSel(),r=s.getRangeAt(0),b=d.body;var rb,ra,dir,sn,so,en,eo,sb,eb,bn,bef,aft,sc,ec,n,vp=dom.getViewPort(ed.getWin()),y,ch,car;function isEmpty(n){n=n.innerHTML;n=n.replace(/<(img|hr|table)/gi,'-');n=n.replace(/<[^>]+>/g,'');return n.replace(/[ \t\r\n]+/g,'')=='';};rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(true);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(true);dir=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;sn=dir?s.anchorNode:s.focusNode;so=dir?s.anchorOffset:s.focusOffset;en=dir?s.focusNode:s.anchorNode;eo=dir?s.focusOffset:s.anchorOffset;if(sn===en&&/^(TD|TH)$/.test(sn.nodeName)){dom.remove(sn.firstChild);ed.dom.add(sn,se.element,null,'
    ');aft=ed.dom.add(sn,se.element,null,'
    ');r=d.createRange();r.selectNodeContents(aft);r.collapse(1);ed.selection.setRng(r);return false;}if(sn==b&&en==b&&b.firstChild&&ed.dom.isBlock(b.firstChild)){sn=en=sn.firstChild;so=eo=0;rb=d.createRange();rb.setStart(sn,0);ra=d.createRange();ra.setStart(en,0);}sn=sn.nodeName=="HTML"?d.body:sn;sn=sn.nodeName=="BODY"?sn.firstChild:sn;en=en.nodeName=="HTML"?d.body:en;en=en.nodeName=="BODY"?en.firstChild:en;sb=t.getParentBlock(sn);eb=t.getParentBlock(en);bn=sb?sb.nodeName:se.element;if(t.dom.getParent(sb,function(n){return/OL|UL|PRE/.test(n.nodeName);}))return true;if(sb&&(sb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(sb.style.position))){bn=se.element;sb=null;}if(eb&&(eb.nodeName=='CAPTION'||/absolute|relative|static/gi.test(eb.style.position))){bn=se.element;eb=null;}if(/(TD|TABLE|TH|CAPTION)/.test(bn)||(sb&&bn=="DIV"&&/left|right/gi.test(sb.style.cssFloat))){bn=se.element;sb=eb=null;}bef=(sb&&sb.nodeName==bn)?sb.cloneNode(0):ed.dom.create(bn);aft=(eb&&eb.nodeName==bn)?eb.cloneNode(0):ed.dom.create(bn);aft.removeAttribute('id');if(/^(H[1-6])$/.test(bn)&&sn.nodeValue&&so==sn.nodeValue.length)aft=ed.dom.create(se.element);n=sc=sn;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;sc=n;}while((n=n.previousSibling?n.previousSibling:n.parentNode));n=ec=en;do{if(n==b||n.nodeType==9||t.dom.isBlock(n)||/(TD|TABLE|TH|CAPTION)/.test(n.nodeName))break;ec=n;}while((n=n.nextSibling?n.nextSibling:n.parentNode));if(sc.nodeName==bn)rb.setStart(sc,0);else rb.setStartBefore(sc);rb.setEnd(sn,so);bef.appendChild(rb.cloneContents()||d.createTextNode(''));try{ra.setEndAfter(ec);}catch(ex){}ra.setStart(en,eo);aft.appendChild(ra.cloneContents()||d.createTextNode(''));r=d.createRange();if(!sc.previousSibling&&sc.parentNode.nodeName==bn){r.setStartBefore(sc.parentNode);}else{if(rb.startContainer.nodeName==bn&&rb.startOffset==0)r.setStartBefore(rb.startContainer);else r.setStart(rb.startContainer,rb.startOffset);}if(!ec.nextSibling&&ec.parentNode.nodeName==bn)r.setEndAfter(ec.parentNode);else r.setEnd(ra.endContainer,ra.endOffset);r.deleteContents();if(isOpera)ed.getWin().scrollTo(0,vp.y);if(bef.firstChild&&bef.firstChild.nodeName==bn)bef.innerHTML=bef.firstChild.innerHTML;if(aft.firstChild&&aft.firstChild.nodeName==bn)aft.innerHTML=aft.firstChild.innerHTML;if(isEmpty(bef))bef.innerHTML='
    ';function appendStyles(e,en){var nl=[],nn,n,i;e.innerHTML='';if(se.keep_styles){n=en;do{if(/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(n.nodeName)){nn=n.cloneNode(false);dom.setAttrib(nn,'id','');nl.push(nn);}}while(n=n.parentNode);}if(nl.length>0){for(i=nl.length-1,nn=e;i>=0;i--)nn=nn.appendChild(nl[i]);nl[0].innerHTML=isOpera?' ':'
    ';return nl[0];}else e.innerHTML=isOpera?' ':'
    ';};if(isEmpty(aft))car=appendStyles(aft,en);if(isOpera&&parseFloat(opera.version())<9.5){r.insertNode(bef);r.insertNode(aft);}else{r.insertNode(aft);r.insertNode(bef);}aft.normalize();bef.normalize();function first(n){return d.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,false).nextNode()||n;};r=d.createRange();r.selectNodeContents(isGecko?first(car||aft):car||aft);r.collapse(1);s.removeAllRanges();s.addRange(r);y=ed.dom.getPos(aft).y;ch=aft.clientHeight;if(yvp.y+vp.h){ed.getWin().scrollTo(0,y