/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */ function TinyMCE_Engine() { var ua; this.majorVersion = "2"; this.minorVersion = "1.1.1"; this.releaseDate = "2007-05-14"; this.instances = []; this.switchClassCache = []; this.windowArgs = []; this.loadedFiles = []; this.pendingFiles = []; this.loadingIndex = 0; this.configs = []; this.currentConfig = 0; this.eventHandlers = []; this.log = []; this.undoLevels = []; this.undoIndex = 0; this.typingUndoIndex = -1; this.settings = []; // Browser check 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.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1); this.isGecko = ua.indexOf('Gecko') != -1; // Will also be true on Safari this.isSafari = ua.indexOf('Safari') != -1; this.isOpera = window['opera'] && opera.buildNumber ? true : false; this.isMac = ua.indexOf('Mac') != -1; this.isNS7 = ua.indexOf('Netscape/7') != -1; this.isNS71 = ua.indexOf('Netscape/7.1') != -1; this.dialogCounter = 0; this.plugins = []; this.themes = []; this.menus = []; this.loadedPlugins = []; this.buttonMap = []; this.isLoaded = false; // 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; } this.isIE = this.isMSIE; this.isRealIE = this.isMSIE && !this.isOpera; // TinyMCE editor id instance counter this.idCounter = 0; }; TinyMCE_Engine.prototype = { init : function(settings) { var theme, nl, baseHREF = "", i, cssPath, entities, h, p, src, elements = [], head; // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry. if (this.isMSIE5_0) return; this.settings = settings; // Check if valid browser has execcommand support if (typeof(document.execCommand) == 'undefined') return; // Get script base path if (!tinyMCE.baseURL) { // Search through head head = document.getElementsByTagName('head')[0]; if (head) { for (i=0, nl = head.getElementsByTagName('script'); i'); this._def("font_size_classes", ''); this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true); this._def("event_elements", 'a,img', true); this._def("convert_urls", true); this._def("table_inline_editing", false); this._def("object_resizing", true); this._def("custom_shortcuts", true); this._def("convert_on_click", false); this._def("content_css", ''); this._def("fix_list_elements", true); this._def("fix_table_elements", false); this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml'); this._def("hidden_tab_class", ''); this._def("display_tab_class", ''); this._def("gecko_spellcheck", false); this._def("hide_selects_on_submit", true); this._def("forced_root_block", false); this._def("remove_trailing_nbsp", false); // Force strict loading mode to false on non Gecko browsers if (this.isMSIE && !this.isOpera) this.settings.strict_loading_mode = false; // 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 baseHREF = tinyMCE.settings.document_base_url; h = document.location.href; 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.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment'; this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment'; this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP'; this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i"); this.posKeyCodes = [13,45,36,35,33,34,37,38,39,40]; this.uniqueURL = 'javascript:void(091039730);'; // Make unique URL non real URL this.uniqueTag = ''; this.callbacks = ['onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup', 'removeInstance']; // Theme url this.settings.theme_href = tinyMCE.baseURL + "/themes/" + theme; if (!tinyMCE.isIE || tinyMCE.isOpera) this.settings.force_br_newlines = false; if (tinyMCE.getParam("popups_css", false)) { 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)) { 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 { if (this.settings.editor_css !== '') this.settings.editor_css = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; } // Only do this once if (this.configs.length == 0) { if (typeof(TinyMCECompressed) == "undefined") { tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad); if (tinyMCE.isRealIE) { if (document.body) tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad); else tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad); } tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad); tinyMCE._addUnloadEvents(); } } 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 p = tinyMCE.getParam('plugins', '', true, ','); if (p.length > 0) { for (i=0; i&"]', 'g'); }, _addUnloadEvents : function() { var st = tinyMCE.settings.add_unload_trigger; if (tinyMCE.isIE) { if (st) { tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler); tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler); } } else { if (st) tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); } }, _def : function(key, def_val, t) { var v = tinyMCE.getParam(key, def_val); v = t ? v.replace(/\s+/g, "") : v; this.settings[key] = v; }, hasPlugin : function(n) { return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; }, addPlugin : function(n, p) { var op = this.plugins[n]; // Use the previous plugin object base URL used when loading external plugins p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n; this.plugins[n] = p; this.loadNextScript(); }, setPluginBaseURL : function(n, u) { var op = this.plugins[n]; if (op) op.baseURL = u; else this.plugins[n] = {baseURL : u}; }, loadPlugin : function(n, u) { u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u; u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u; this.plugins[n] = {baseURL : u}; this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js"); }, hasTheme : function(n) { return typeof(this.themes[n]) != "undefined" && this.themes[n] != null; }, addTheme : function(n, t) { this.themes[n] = t; this.loadNextScript(); }, addMenu : function(n, m) { this.menus[n] = m; }, hasMenu : function(n) { return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null; }, loadScript : function(url) { var i; for (i=0; i'); this.loadedFiles[this.loadedFiles.length] = url; }, loadNextScript : function() { var d = document, se; if (!tinyMCE.settings.strict_loading_mode) return; if (this.loadingIndex < this.pendingFiles.length) { se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script'); se.setAttribute('language', 'javascript'); se.setAttribute('type', 'text/javascript'); se.setAttribute('src', this.pendingFiles[this.loadingIndex++]); d.getElementsByTagName("head")[0].appendChild(se); } else this.loadingIndex = -1; // Done with loading }, loadCSS : function(url) { var ar = url.replace(/\s+/, '').split(','); var lflen = 0, csslen = 0, skip = false; var x = 0, i = 0, nl, le; for (x = 0,csslen = ar.length; x 0) { /* Make sure it doesn't exist. */ for (i=0, lflen=this.loadedFiles.length; i'); this.loadedFiles[this.loadedFiles.length] = ar[x]; } } } }, importCSS : function(doc, css) { var css_ary = css.replace(/\s+/, '').split(','); var csslen, elm, headArr, x, css_file; for (x = 0, csslen = css_ary.length; x 0) { // Is relative, make absolute if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/') css_file = this.documentBasePath + "/" + css_file; if (typeof(doc.createStyleSheet) == "undefined") { 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 doc.createStyleSheet(css_file); } } }, confirmAdd : function(e, settings) { var elm = tinyMCE.isIE ? event.srcElement : e.target; var elementId = elm.name ? elm.name : elm.id; tinyMCE.settings = settings; if (tinyMCE.settings.convert_on_click || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang.lang_edit_confirm))) tinyMCE.addMCEControl(elm, elementId); elm.setAttribute('mce_noask', 'true'); }, updateContent : function(form_element_name) { var formElement, n, inst, doc; // Find MCE instance linked to given form element and copy it's value formElement = document.getElementById(form_element_name); for (n in tinyMCE.instances) { inst = tinyMCE.instances[n]; if (!tinyMCE.isInstance(inst)) continue; inst.switchSettings(); if (inst.formElement == formElement) { doc = inst.getDoc(); tinyMCE._setHTML(doc, inst.formElement.value); if (!tinyMCE.isIE) doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); } } }, addMCEControl : function(replace_element, form_element_name, target_document) { var id = "mce_editor_" + tinyMCE.idCounter++; var inst = new TinyMCE_Control(tinyMCE.settings); inst.editorId = id; this.instances[id] = inst; inst._onAdd(replace_element, form_element_name, target_document); }, removeInstance : function(ti) { var t = [], n, i; // Remove from instances for (n in tinyMCE.instances) { i = tinyMCE.instances[n]; if (tinyMCE.isInstance(i) && ti != i) t[n] = i; } tinyMCE.instances = t; // Remove from global undo/redo n = []; t = tinyMCE.undoLevels; for (i=0; i 0) { tinyMCE.nextUndoRedoAction = 'Undo'; inst = this.undoLevels[--this.undoIndex]; inst.select(); if (!tinyMCE.nextUndoRedoInstanceId) inst.execCommand('Undo'); } } else inst.execCommand('Undo'); return true; case "Redo": if (this.getParam('custom_undo_redo_global')) { if (this.undoIndex <= this.undoLevels.length - 1) { tinyMCE.nextUndoRedoAction = 'Redo'; inst = this.undoLevels[this.undoIndex++]; inst.select(); if (!tinyMCE.nextUndoRedoInstanceId) inst.execCommand('Redo'); } } else inst.execCommand('Redo'); return true; case 'mceFocus': inst = tinyMCE.getInstanceById(value); if (inst) inst.getWin().focus(); return; case "mceAddControl": case "mceAddEditor": tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); return; case "mceAddFrameControl": tinyMCE.addMCEControl(tinyMCE._getElementById(value.element, value.document), value.element, value.document); return; case "mceRemoveControl": case "mceRemoveEditor": tinyMCE.removeMCEControl(value); return; case "mceToggleEditor": inst = tinyMCE.getInstanceById(value); if (inst) { pe = document.getElementById(inst.editorId + '_parent'); te = inst.oldTargetElement; if (typeof(inst.enabled) == 'undefined') inst.enabled = true; inst.enabled = !inst.enabled; if (!inst.enabled) { pe.style.display = 'none'; if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') te.value = inst.getHTML(); else te.innerHTML = inst.getHTML(); te.style.display = inst.oldTargetDisplay; tinyMCE.dispatchCallback(inst, 'hide_instance_callback', 'hideInstance', inst); } else { pe.style.display = 'block'; te.style.display = 'none'; if (te.nodeName == 'TEXTAREA' || te.nodeName == 'INPUT') inst.setHTML(te.value); else inst.setHTML(te.innerHTML); inst.useCSS = false; tinyMCE.dispatchCallback(inst, 'show_instance_callback', 'showInstance', inst); } } else tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); return; case "mceResetDesignMode": // Resets the designmode state of the editors in Gecko if (tinyMCE.isGecko) { for (n in tinyMCE.instances) { if (!tinyMCE.isInstance(tinyMCE.instances[n])) continue; try { tinyMCE.instances[n].getDoc().designMode = "off"; tinyMCE.instances[n].getDoc().designMode = "on"; tinyMCE.instances[n].useCSS = false; } catch (e) { // Ignore any errors } } } return; } if (inst) { inst.execCommand(command, user_interface, value); } else if (tinyMCE.settings.focus_alert) alert(tinyMCELang.lang_focus_alert); }, _createIFrame : function(replace_element, doc, win) { var iframe, id = replace_element.getAttribute("id"); var aw, ah; if (typeof(doc) == "undefined") doc = document; if (typeof(win) == "undefined") win = window; iframe = doc.createElement("iframe"); aw = "" + tinyMCE.settings.area_width; ah = "" + tinyMCE.settings.area_height; if (aw.indexOf('%') == -1) { aw = parseInt(aw); aw = (isNaN(aw) || aw < 0) ? 300 : aw; aw = aw + "px"; } if (ah.indexOf('%') == -1) { ah = parseInt(ah); ah = (isNaN(ah) || ah < 0) ? 240 : ah; ah = ah + "px"; } iframe.setAttribute("id", id); iframe.setAttribute("name", id); iframe.setAttribute("class", "mceEditorIframe"); iframe.setAttribute("border", "0"); iframe.setAttribute("frameBorder", "0"); iframe.setAttribute("marginWidth", "0"); iframe.setAttribute("marginHeight", "0"); iframe.setAttribute("leftMargin", "0"); iframe.setAttribute("topMargin", "0"); iframe.setAttribute("width", aw); iframe.setAttribute("height", ah); iframe.setAttribute("allowtransparency", "true"); iframe.className = 'mceEditorIframe'; if (tinyMCE.settings.auto_resize) iframe.setAttribute("scrolling", "no"); // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs if (tinyMCE.isRealIE) iframe.setAttribute("src", this.settings.default_document); iframe.style.width = aw; iframe.style.height = ah; // Ugly hack for Gecko problem in strict mode if (tinyMCE.settings.strict_loading_mode) iframe.style.marginBottom = '-5px'; // MSIE 5.0 issue if (tinyMCE.isRealIE) replace_element.outerHTML = iframe.outerHTML; else replace_element.parentNode.replaceChild(iframe, replace_element); if (tinyMCE.isRealIE) return win.frames[id]; else return iframe; }, setupContent : function(editor_id) { var inst = tinyMCE.instances[editor_id], i, doc = inst.getDoc(), head = doc.getElementsByTagName('head').item(0); var content = inst.startContent, contentElement, body; // HTML values get XML encoded in strict mode if (tinyMCE.settings.strict_loading_mode) { content = content.replace(/</g, '<'); content = content.replace(/>/g, '>'); content = content.replace(/"/g, '"'); content = content.replace(/&/g, '&'); } tinyMCE.selectedInstance = inst; inst.switchSettings(); // Not loaded correctly hit it again, Mozilla bug #997860 if (!tinyMCE.isIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") { // This part will remove the designMode status // Failes first time in Firefox 1.5b2 on Mac try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {} window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000); return; } // Wait for it to load if (!head || !doc.body) { window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10); return; } // Import theme specific content CSS the user specific tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings.theme + "/css/editor_content.css"); tinyMCE.importCSS(inst.getDoc(), inst.settings.content_css); tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst); // Setup keyboard shortcuts if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) { inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo'); inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo'); } // BlockFormat shortcuts keys for (i=1; i<=6; i++) inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, ''); inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '

'); inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '

'); inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '
'); // Add default shortcuts for gecko if (tinyMCE.isGecko) { inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold'); inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic'); inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline'); } // Setup span styles if (tinyMCE.getParam("convert_fonts_to_spans")) inst.getBody().setAttribute('id', 'mceSpanFonts'); if (tinyMCE.settings.nowrap) doc.body.style.whiteSpace = "nowrap"; doc.body.dir = this.settings.directionality; doc.editorId = editor_id; // Add on document element in Mozilla if (!tinyMCE.isIE) doc.documentElement.editorId = editor_id; inst.setBaseHREF(tinyMCE.settings.base_href); // Replace new line characters to BRs if (tinyMCE.settings.convert_newlines_to_brs) { content = tinyMCE.regexpReplace(content, "\r\n", "
", "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.isIE) { // Ugly!!! window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500); if (tinyMCE.settings.force_br_newlines) doc.styleSheets[0].addRule("p", "margin: 0;"); body = inst.getBody(); body.editorId = editor_id; } content = tinyMCE.cleanupHTMLCode(content); // Fix for bug #958637 if (!tinyMCE.isIE) { contentElement = inst.getDoc().createElement("body"); doc = inst.getDoc(); contentElement.innerHTML = content; if (tinyMCE.settings.cleanup_on_startup) tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); else tinyMCE.setInnerHTML(inst.getBody(), content); tinyMCE.convertAllRelativeURLs(inst.getBody()); } else { if (tinyMCE.settings.cleanup_on_startup) { tinyMCE._setHTML(inst.getDoc(), content); // Produces permission denied error in MSIE 5.5 try { tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody())); } catch(e) { // Ignore } } else tinyMCE._setHTML(inst.getDoc(), content); } // Fix for bug #957681 //inst.getDoc().designMode = inst.getDoc().designMode; tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings.visual, inst); tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc()); // Re-add design mode on mozilla if (!tinyMCE.isIE) tinyMCE.addEventHandlers(inst); // Add blur handler if (tinyMCE.isIE) { tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch); tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953 // Workaround for drag drop/copy paste base href bug if (!tinyMCE.isOpera) { tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove); tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch); tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch); } } // Trigger node change, this call locks buttons for tables and so forth inst.select(); tinyMCE.selectedElement = inst.contentWindow.document.body; // 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.undoRedo.add({ content : inst.startContent }); // Cleanup any mess left from storyAwayURLs if (tinyMCE.isGecko) { // Remove mce_src from textnodes and comments tinyMCE.selectNodes(inst.getBody(), function(n) { if (n.nodeType == 3 || n.nodeType == 8) n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), ""); return false; }); } // Remove Gecko spellchecking if (tinyMCE.isGecko) inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck"); // Cleanup any mess left from storyAwayURLs tinyMCE._removeInternal(inst.getBody()); inst.select(); tinyMCE.triggerNodeChange(false, true); }, 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'), ''); if (!s.match(/(mce_src|mce_href)/gi, s)) { 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; }, _removeInternal : function(n) { if (tinyMCE.isGecko) { // Remove mce_src from textnodes and comments tinyMCE.selectNodes(n, function(n) { if (n.nodeType == 3 || n.nodeType == 8) n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), ""); return false; }); } }, removeTinyMCEFormElements : function(form_obj) { var i, elementId; // Skip form element removal if (!tinyMCE.getParam('hide_selects_on_submit')) return; // 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 (i=0; i"); 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; case "keyup": case "keydown": tinyMCE.hideMenus(); tinyMCE.hasMouseMoved = false; if (inst && inst.handleShortcut(e)) return false; inst._fixRootBlocks(); if (inst.settings.remove_trailing_nbsp) inst._fixTrailingNbsp(); if (e.target.editorId) tinyMCE.instances[e.target.editorId].select(); if (tinyMCE.selectedInstance) tinyMCE.selectedInstance.switchSettings(); 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_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { // Cancel event tinyMCE.execCommand("mceAddUndoLevel"); e.preventDefault(); return false; } } tinyMCE.selectedElement = null; tinyMCE.selectedNode = null; 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.isIE && e.type == "keydown" && e.keyCode == 13) tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement(); // Fix empty elements on return/enter if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) { 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 keys = tinyMCE.posKeyCodes; var posKey = false; for (i=0; i'; h += '{$'+lang+'}'; h += ''; } else { // Normal button h += ''; h += '{$'+lang+'}'; h += ''; } return h; }, getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) { var h = '', m, x; mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');'; cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\''; if (typeof(ui) != "undefined" && ui != null) cmd += ',' + ui; if (typeof(val) != "undefined" && val != null) cmd += ",'" + val + "'"; cmd += ');'; // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) { x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20); if (tinyMCE.isRealIE) h += ''; else h += ''; h += ''; h += ''; h += ''; h += ''; } else { if (tinyMCE.isRealIE) h += ''; else h += ''; h += ''; h += ''; h += ''; h += ''; } return h; }, _menuButtonEvent : function(e, o) { if (o.className == 'mceMenuButtonFocus') return; if (e == 'over') o.className = o.className + ' mceMenuHover'; else o.className = o.className.replace(/\s.*$/, ''); }, addButtonMap : function(m) { var i, a = m.replace(/\s+/, '').split(','); for (i=0; i 0); if (tinyMCE.settings.custom_undo_redo) { undoIndex = inst.undoRedo.undoIndex; undoLevels = inst.undoRedo.undoLevels.length; } tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content); } if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) this.selectedInstance.contentWindow.focus(); }, _customCleanup : function(inst, type, content) { var pl, po, i, customCleanup; // Call custom cleanup customCleanup = tinyMCE.settings.cleanup_callback; if (customCleanup != '') content = tinyMCE.resolveDots(tinyMCE.settings.cleanup_callback, window)(type, content, inst); // Trigger theme cleanup po = tinyMCE.themes[tinyMCE.settings.theme]; if (po && po.cleanup) content = po.cleanup(type, content, inst); // Trigger plugin cleanups pl = inst.plugins; for (i=0; i 0) className += " "; className += classNames[i]; } return className; }, handleVisualAid : function(el, deep, state, inst, skip_dispatch) { var i, x, y, tableElement, anchorName, oldW, oldH, bo, cn; if (!el) return; if (!skip_dispatch) tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst); tableElement = null; switch (el.nodeName) { case "TABLE": oldW = el.style.width; oldH = el.style.height; 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 (y=0; y 0) return inst.cssClasses; if (!doc) return; styles = doc.styleSheets; if (styles && styles.length > 0) { for (x=0; x' + tinyMCE.replaceVar(v, "pluginurl", o.baseURL) + ''; return tinyMCE.replaceVar(v, "pluginurl", o.baseURL); } } o = tinyMCE.themes[tinyMCE.settings.theme]; if (o.getControlHTML && (v = o.getControlHTML(c)) !== '') { if (rtl) return '' + v + ''; return v; } return ''; }, evalFunc : function(f, idx, a, o) { o = !o ? window : o; f = typeof(f) == 'function' ? f : o[f]; return f.apply(o, Array.prototype.slice.call(a, idx)); }, dispatchCallback : function(i, p, n) { return this.callFunc(i, p, n, 0, this.dispatchCallback.arguments); }, executeCallback : function(i, p, n) { return this.callFunc(i, p, n, 1, this.executeCallback.arguments); }, execCommandCallback : function(i, p, n) { return this.callFunc(i, p, n, 2, this.execCommandCallback.arguments); }, callFunc : function(ins, p, n, m, a) { var l, i, on, o, s, v; s = m == 2; l = tinyMCE.getParam(p, ''); if (l !== '' && (v = tinyMCE.evalFunc(l, 3, a)) == s && m > 0) return true; if (ins != null) { for (i=0, l = ins.plugins; i 0) return true; } } l = tinyMCE.themes; for (on in l) { o = l[on]; if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0) return true; } return false; }, resolveDots : function(s, o) { var i; if (typeof(s) == 'string') { for (i=0, s=s.split('.'); i': return '>'; } return c; }) : s; }, add : function(c, m) { var n; for (n in m) c.prototype[n] = m[n]; }, extend : function(p, np) { var o = {}, n; o.parent = p; for (n in p) o[n] = p[n]; for (n in np) o[n] = np[n]; return o; }, hideMenus : function() { var e = tinyMCE.lastSelectedMenuBtn; if (tinyMCE.lastMenu) { tinyMCE.lastMenu.hide(); tinyMCE.lastMenu = null; } if (e) { tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass); tinyMCE.lastSelectedMenuBtn = null; } } }; // Global instances var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors var tinyMCE = new TinyMCE_Engine(); var tinyMCELang = {}; /* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */ function TinyMCE_Control(settings) { var t, i, tos, fu, p, x, fn, fu, pn, s = settings; this.undoRedoLevel = true; this.isTinyMCE_Control = true; // Default settings this.enabled = true; this.settings = s; this.settings.theme = tinyMCE.getParam("theme", "default"); this.settings.width = tinyMCE.getParam("width", -1); this.settings.height = tinyMCE.getParam("height", -1); this.selection = new TinyMCE_Selection(this); this.undoRedo = new TinyMCE_UndoRedo(this); this.cleanup = new TinyMCE_Cleanup(); this.shortcuts = []; this.hasMouseMoved = false; this.foreColor = this.backColor = "#999999"; this.data = {}; this.cssClasses = []; this.cleanup.init({ valid_elements : s.valid_elements, extended_valid_elements : s.extended_valid_elements, valid_child_elements : s.valid_child_elements, entities : s.entities, entity_encoding : s.entity_encoding, debug : s.cleanup_debug, indent : s.apply_source_formatting, invalid_elements : s.invalid_elements, verify_html : s.verify_html, fix_content_duplication : s.fix_content_duplication, convert_fonts_to_spans : s.convert_fonts_to_spans }); // Wrap old theme t = this.settings.theme; if (!tinyMCE.hasTheme(t)) { fn = tinyMCE.callbacks; tos = {}; for (i=0; i 0) { for (i=0; i 1 && tinyMCE.currentConfig != this.settings.index) { tinyMCE.settings = this.settings; tinyMCE.currentConfig = this.settings.index; } }, select : function() { var oldInst = tinyMCE.selectedInstance; if (oldInst != this) { if (oldInst) oldInst.execCommand('mceEndTyping'); tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst); tinyMCE.selectedInstance = this; } }, getBody : function() { return this.contentBody ? this.contentBody : this.getDoc().body; }, getDoc : function() { // return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ? return this.contentWindow.document; }, getWin : function() { return this.contentWindow; }, getContainerWin : function() { return this.containerWindow ? this.containerWindow : window; }, getViewPort : function() { return tinyMCE.getViewPort(this.getWin()); }, getParentNode : function(n, f) { return tinyMCE.getParentNode(n, f, this.getBody()); }, getParentElement : function(n, na, f) { return tinyMCE.getParentElement(n, na, f, this.getBody()); }, getParentBlockElement : function(n) { return tinyMCE.getParentBlockElement(n, this.getBody()); }, resizeToContent : function() { var d = this.getDoc(), b = d.body, de = d.documentElement; this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px'; }, addShortcut : function(m, k, d, cmd, ui, va) { var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts; if (!tinyMCE.getParam('custom_shortcuts')) return false; m = m.toLowerCase(); k = ie && !n ? k.toUpperCase() : k; c = n ? null : k.charCodeAt(0); d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d; sc = { alt : m.indexOf('alt') != -1, ctrl : m.indexOf('ctrl') != -1, shift : m.indexOf('shift') != -1, charCode : c, keyCode : n ? k : (ie ? c : null), desc : d, cmd : cmd, ui : ui, val : va }; for (i=0; i 1 && /(^\u00a0|\u00a0$)/.test(v)) { e.firstChild.nodeValue = v.replace(/(^\u00a0|\u00a0$)/, ''); s.selectNode(e.firstChild, true, false, false); // Select and collapse } } }, _setUseCSS : function(b) { var d = this.getDoc(); try {d.execCommand("useCSS", false, !b);} catch (ex) {} try {d.execCommand("styleWithCSS", false, b);} catch (ex) {} if (!tinyMCE.getParam("table_inline_editing")) try {d.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {} if (!tinyMCE.getParam("object_resizing")) try {d.execCommand('enableObjectResizing', false, "false");} catch (ex) {} }, execCommand : function(command, user_interface, value) { var i, x, z, align, img, div, doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement(); // Is not a undo specific command if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) this.undoBookmark = null; // Mozilla issue if (!tinyMCE.isIE && !this.useCSS) { this._setUseCSS(false); this.useCSS = true; } //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value); this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks // Don't dispatch key commands if (!/mceStartTyping|mceEndTyping/.test(command)) { if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value)) return; } // Fix align on images if (focusElm && focusElm.nodeName == "IMG") { align = focusElm.getAttribute('align'); img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm; switch (command) { case "JustifyLeft": if (align == 'left') img.removeAttribute('align'); else img.setAttribute('align', 'left'); // Remove the div div = focusElm.parentNode; if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) div.parentNode.replaceChild(img, div); this.selection.selectNode(img); this.repaint(); tinyMCE.triggerNodeChange(); return; case "JustifyCenter": img.removeAttribute('align'); // Is centered div = tinyMCE.getParentElement(focusElm, "div"); if (div && div.style.textAlign == "center") { // Remove div if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) div.parentNode.replaceChild(img, div); } else { // Add div div = this.getDoc().createElement("div"); div.style.textAlign = 'center'; div.appendChild(img); focusElm.parentNode.replaceChild(div, focusElm); } this.selection.selectNode(img); this.repaint(); tinyMCE.triggerNodeChange(); return; case "JustifyRight": if (align == 'right') img.removeAttribute('align'); else img.setAttribute('align', 'right'); // Remove the div div = focusElm.parentNode; if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode) div.parentNode.replaceChild(img, div); this.selection.selectNode(img); this.repaint(); tinyMCE.triggerNodeChange(); return; } } if (tinyMCE.settings.force_br_newlines) { var alignValue = ""; if (doc.selection.type != "Control") { switch (command) { case "JustifyLeft": alignValue = "left"; break; case "JustifyCenter": alignValue = "center"; break; case "JustifyFull": alignValue = "justify"; break; case "JustifyRight": alignValue = "right"; break; } if (alignValue !== '') { var rng = doc.selection.createRange(); if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null) divElm.setAttribute("align", alignValue); else if (rng.pasteHTML && rng.htmlText.length > 0) rng.pasteHTML('
' + rng.htmlText + "
"); tinyMCE.triggerNodeChange(); return; } } } switch (command) { case "mceRepaint": this.repaint(); return true; case "unlink": // Unlink if caret is inside link if (tinyMCE.isGecko && this.getSel().isCollapsed) { focusElm = tinyMCE.getParentElement(focusElm, 'A'); if (focusElm) this.selection.selectNode(focusElm, false); } this.getDoc().execCommand(command, user_interface, value); tinyMCE.isGecko && this.getSel().collapseToEnd(); tinyMCE.triggerNodeChange(); return true; case "InsertUnorderedList": case "InsertOrderedList": this.getDoc().execCommand(command, user_interface, value); tinyMCE.triggerNodeChange(); break; case "Strikethrough": this.getDoc().execCommand(command, user_interface, value); tinyMCE.triggerNodeChange(); break; case "mceSelectNode": this.selection.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,blockquote,dt,dl,dd,samp"); if (elm) this.execCommand("mceRemoveNode", false, elm); } else { if (!this.cleanup.isValid(value)) return true; if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value)) value = value.replace(/[^a-z]/gi, ''); if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) { var b = this.selection.getBookmark(); this.getDoc().execCommand("FormatBlock", false, '

'); tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value); this.selection.moveToBookmark(b); } else this.getDoc().execCommand("FormatBlock", false, value); } tinyMCE.triggerNodeChange(); break; case "mceRemoveNode": if (!value) value = tinyMCE.getParentElement(this.getFocusElement()); if (tinyMCE.isIE) { 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 (i=0; parentNode; i++) { if (parentNode.nodeName.toLowerCase() == "body") break; if (parentNode.nodeName.toLowerCase() == "#text") { i--; parentNode = parentNode.parentNode; continue; } if (i == value) { this.selection.selectNode(parentNode, false); tinyMCE.triggerNodeChange(); tinyMCE.selectedNode = parentNode; return; } parentNode = parentNode.parentNode; } break; case "mceSetStyleInfo": 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.isIE) { // 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 || (new RegExp('td|tr|tbody|table|img', 'gi').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, [], 1); for (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 (i=nodes.length-1; i>=0; i--) { var elm = nodes[i], 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 (x=0; x 0) { value = tinyMCE.replaceVar(value, "selection", selectedText); tinyMCE.execCommand('mceInsertContent', false, value); } this._addBogusBR(); 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("mceSetStyleInfo", 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.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft; var scrollY = this.getBody().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": // Force empty string if (!value) value = ''; var insertHTMLFailed = false; // Removed since it produced problems in IE // this.getWin().focus(); if (tinyMCE.isGecko || tinyMCE.isOpera) { try { // Is plain text or HTML, &,   etc will be encoded wrong in FF if (value.indexOf('<') == -1 && !value.match(/(&| |<|>)/g)) { 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; } } if (!tinyMCE.isIE) { 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 value = doc.createTextNode(tinyMCE.entityDecode(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); tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); } else { var rng = doc.selection.createRange(), tmpRng = null; var c = value.indexOf('"; } if (hc) { cn = n.childNodes; for (i=0, l=cn.length; i'; return h; }, _serializeAttribute : function(n, r, an) { var av = '', t, os = this.settings.on_save; if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0)) return ''; if (os && this.mceAttribs[an]) av = this._getAttrib(n, this.mceAttribs[an]); if (av.length == 0) av = this._getAttrib(n, an); if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) { av = t; if (av == "mce_empty") return " " + an + '=""'; } if (r.forceAttribs && (t = r.forceAttribs[an])) av = t; if (os && av.length != 0 && /^(src|href|longdesc)$/.test(an)) av = this._urlConverter(this, n, av); if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av)) return ""; if (av.length != 0 && av == "{$uid}") av = "uid_" + (this.idCount++); if (av.length != 0) { if (an.indexOf('on') != 0) av = this.xmlEncode(av, 1); return " " + an + "=" + '"' + av + '"'; } return ""; }, formatHTML : function(h) { var s = this.settings, p = '', i = 0, li = 0, o = '', l; // Replace BR in pre elements to \n h = h.replace(/]*)>(.*?)<\/pre>/gi, function (a, b, c) { c = c.replace(//gi, '\n'); return '' + c + ''; }); h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :) h = '\n' + h; h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting h = h.replace(this.nlBeforeRe, '\n<$1$2>'); h = h.replace(this.nlAfterRe, '<$1$2>\n'); h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n'); h += '\n'; //tinyMCE.debug(h); while ((i = h.indexOf('\n', i + 1)) != -1) { if ((l = h.substring(li + 1, i)).length != 0) { if (this.ouRe.test(l) && p.length >= s.indent_levels) p = p.substring(s.indent_levels); o += p + l + '\n'; if (this.inRe.test(l)) p += this.inStr; } li = i; } //tinyMCE.debug(h); return o; }, xmlEncode : function(s) { var cl = this, re = this.xmlEncodeRe; if (!this.entitiesDone) this._setupEntities(); // Will intialize lookup table switch (this.settings.entity_encoding) { case "raw": return tinyMCE.xmlEncode(s); case "named": return s.replace(re, function (c) { var b = cl.entities[c.charCodeAt(0)]; return b ? '&' + b + ';' : c; }); case "numeric": return s.replace(re, function (c) { return '&#' + c.charCodeAt(0) + ';'; }); } return s; }, split : function(re, s) { var i, l, o = [], c = s.split(re); for (i=0, l=c.length; i' : '>' + h + ''; return o; }, createTag : function(d, tn, a, h) { var o = d.createElement(tn), n; if (a) { for (n in a) { if (typeof(a[n]) != 'function' && a[n] != null) tinyMCE.setAttrib(o, n, a[n]); } } if (h) o.innerHTML = h; return o; }, getElementByAttributeValue : function(n, e, a, v) { return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0]; }, getElementsByAttributeValue : function(n, e, a, v) { var i, nl = n.getElementsByTagName(e), o = []; for (i=0; i]*)>/gi, ''); h = h.replace(/]*)>/gi, ''); h = h.replace(/]*)>/gi, ''); h = h.replace(/]*)>/gi, ''); h = h.replace(/<\/strong>/gi, ''); h = h.replace(/<\/em>/gi, ''); } if (tinyMCE.isRealIE) { // Since MSIE handles invalid HTML better that valid XHTML we // need to make some things invalid.


gets converted to
. h = h.replace(/\s\/>/g, '>'); // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones h = h.replace(/]*)>\u00A0?<\/p>/gi, ' 

'); // Keep empty paragraphs h = h.replace(/]*)>\s* \s*<\/p>/gi, ' 

'); // Keep empty paragraphs h = h.replace(/]*)>\s+<\/p>/gi, ' 

'); // Keep empty paragraphs // Remove first comment e.innerHTML = tinyMCE.uniqueTag + h; e.firstChild.removeNode(true); // Remove weird auto generated empty paragraphs unless it's supposed to be there nl = e.getElementsByTagName("p"); for (i=nl.length-1; i>=0; i--) { n = nl[i]; if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep) n.parentNode.removeChild(n); } } else { h = this.fixGeckoBaseHREFBug(1, e, h); e.innerHTML = h; this.fixGeckoBaseHREFBug(2, e, h); } }, getOuterHTML : function(e) { var d; if (tinyMCE.isIE) return e.outerHTML; d = e.ownerDocument.createElement("body"); d.appendChild(e.cloneNode(true)); return d.innerHTML; }, setOuterHTML : function(e, h, d) { var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t; if (tinyMCE.isIE && e.nodeType == 1) e.outerHTML = h; else { t = d.createElement("body"); t.innerHTML = h; for (i=0, nl=t.childNodes; i-1; i--) { if (ar[i].specified && ar[i].nodeValue) ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); } ar = e.childNodes; for (i=0; i= strTok2.length) { for (i=0; i= strTok2.length || strTok1[i] != strTok2[i]) { breakPoint = i + 1; break; } } } if (strTok1.length < strTok2.length) { for (i=0; i= strTok1.length || strTok1[i] != strTok2[i]) { breakPoint = i + 1; break; } } } if (breakPoint == 1) return targetURL.path; for (i=0; i<(strTok1.length-(breakPoint-1)); i++) outPath += "../"; for (i=breakPoint-1; i=0; i--) { if (baseURLParts[i].length == 0) continue; newBaseURLParts[newBaseURLParts.length] = baseURLParts[i]; } baseURLParts = newBaseURLParts.reverse(); // Merge relURLParts chunks newRelURLParts = []; numBack = 0; for (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 len = baseURLParts.length-numBack; absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/'); 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 this.serializeURL(relURL); }, convertURL : function(url, node, on_save) { var dl = document.location, start, portPart, urlParts, baseUrlParts, tmpUrlParts, curl; var prot = dl.protocol, host = dl.hostname, port = dl.port; // Pass through file protocol if (prot == "file:") return url; // Something is wrong, remove weirdness url = tinyMCE.regexpReplace(url, '(http|https):///', '/'); // Mailto link or anchor (Pass through) if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || /^[ \t\r\n\+]*[#\?]/.test(url)) return url; // Fix relative/Mozilla if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/') return tinyMCE.settings.base_href + url; // Handle relative URLs if (on_save && tinyMCE.getParam('relative_urls')) { curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url); if (curl.charAt(0) == '/') curl = tinyMCE.settings.document_base_prefix + curl; urlParts = tinyMCE.parseURL(curl); tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings.document_base_url); // Force relative if (urlParts.host == tmpUrlParts.host && (urlParts.port == tmpUrlParts.port)) return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings.document_base_url, curl); } // Handle absolute URLs if (!tinyMCE.getParam('relative_urls')) { urlParts = tinyMCE.parseURL(url); baseUrlParts = tinyMCE.parseURL(tinyMCE.settings.base_href); // Force absolute URLs from relative URLs url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, url); // If anchor and path is the same page if (urlParts.anchor && urlParts.path == baseUrlParts.path) return "#" + urlParts.anchor; } // Remove current domain if (tinyMCE.getParam('remove_script_host')) { start = ""; portPart = ""; if (port !== '') portPart = ":" + port; start = prot + "//" + host + portPart + "/"; if (url.indexOf(start) == 0) url = url.substring(start.length-1); } return url; }, convertAllRelativeURLs : function(body) { var i, elms, src, href, mhref, msrc; // Convert all image URL:s to absolute URL elms = body.getElementsByTagName("img"); for (i=0; i bookmark.index) { try { rng.addElement(nl[bookmark.index]); } catch (ex) { // Might be thrown if the node no longer exists } } } else { // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs try { // Incorrect bookmark if (bookmark.start < 0) return true; rng = inst.getSel().createRange(); rng.moveToElementText(inst.getBody()); rng.collapse(true); rng.moveStart('character', bookmark.start); rng.moveEnd('character', bookmark.length); } catch (ex) { return true; } } rng.select(); win.scrollTo(bookmark.scrollX, bookmark.scrollY); return true; } if (tinyMCE.isGecko || tinyMCE.isOpera) { if (!sel) return false; if (bookmark.rng) { sel.removeAllRanges(); sel.addRange(bookmark.rng); } if (bookmark.start != -1 && bookmark.end != -1) { try { sd = this._getTextPos(b, bookmark.start, bookmark.end); rng = doc.createRange(); rng.setStart(sd.startNode, sd.startOffset); rng.setEnd(sd.endNode, sd.endOffset); sel.removeAllRanges(); sel.addRange(rng); if (!tinyMCE.isOpera) win.focus(); } catch (ex) { // Ignore } } /* if (typeof(bookmark.index) != 'undefined') { tinyMCE.selectElements(b, 'IMG', function (n) { if (bookmark.index-- == 0) { // Select image in Gecko here } return false; }); } */ win.scrollTo(bookmark.scrollX, bookmark.scrollY); return true; } return false; }, _getPosText : function(r, sn, en) { var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; while ((n = w.nextNode()) != null) { if (n == sn) d.start = p; if (n == en) { d.end = p; return d; } p += n.nodeValue ? n.nodeValue.length : 0; } return null; }, _getTextPos : function(r, sp, ep) { var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {}; while ((n = w.nextNode()) != null) { p += n.nodeValue ? n.nodeValue.length : 0; if (p >= sp && !d.startNode) { d.startNode = n; d.startOffset = sp - (p - n.nodeValue.length); } if (p >= ep) { d.endNode = n; d.endOffset = ep - (p - n.nodeValue.length); return d; } } return null; }, selectNode : function(node, collapse, select_text_node, to_start) { var inst = this.instance, sel, rng, nodes; if (!node) return; if (typeof(collapse) == "undefined") collapse = true; if (typeof(select_text_node) == "undefined") select_text_node = false; if (typeof(to_start) == "undefined") to_start = true; if (inst.settings.auto_resize) inst.resizeToContent(); if (tinyMCE.isRealIE) { rng = inst.getDoc().body.createTextRange(); try { rng.moveToElementText(node); if (collapse) rng.collapse(to_start); rng.select(); } catch (e) { // Throws illigal agrument in MSIE some times } } else { sel = this.getSel(); if (!sel) return; if (tinyMCE.isSafari) { sel.setBaseAndExtent(node, 0, node, node.innerText.length); if (collapse) { if (to_start) sel.collapseToStart(); else sel.collapseToEnd(); } this.scrollToNode(node); return; } rng = inst.getDoc().createRange(); if (select_text_node) { // Find first textnode in tree nodes = tinyMCE.getNodeTree(node, [], 3); if (nodes.length > 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; }, scrollToNode : function(node) { var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin; // Only scroll if out of visible area if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25)) w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25); // Scroll container window if (inst.settings.auto_resize) { cwin = inst.getContainerWin(); cvp = tinyMCE.getViewPort(cwin); p = this.getAbsPosition(node); if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height) cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25); } }, getAbsPosition : function(n) { var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement); return { absLeft : ipos.absLeft + pos.absLeft, absTop : ipos.absTop + pos.absTop }; }, getSel : function() { var inst = this.instance; if (tinyMCE.isRealIE) return inst.getDoc().selection; return inst.contentWindow.getSelection(); }, getRng : function() { var s = this.getSel(); if (s == null) return null; if (tinyMCE.isRealIE) return s.createRange(); if (tinyMCE.isSafari && !s.getRangeAt) return '' + window.getSelection(); if (s.rangeCount > 0) return s.getRangeAt(0); return null; }, isCollapsed : function() { var r = this.getRng(); if (r.item) return false; return r.boundingWidth == 0 || this.getSel().isCollapsed; }, collapse : function(b) { var r = this.getRng(), s = this.getSel(); if (r.select) { r.collapse(b); r.select(); } else { if (b) s.collapseToStart(); else s.collapseToEnd(); } }, getFocusElement : function() { var inst = this.instance, doc, rng, sel, elm; if (tinyMCE.isRealIE) { doc = inst.getDoc(); rng = doc.selection.createRange(); // if (rng.collapse) // rng.collapse(true); elm = rng.item ? rng.item(0) : rng.parentElement(); } else { if (!tinyMCE.isSafari && inst.isHidden()) return inst.getBody(); sel = this.getSel(); rng = this.getRng(); if (!sel || !rng) return null; elm = rng.commonAncestorContainer; //elm = (sel && sel.anchorNode) ? sel.anchorNode : null; // Handle selection a image or other control like element such as anchors if (!rng.collapsed) { // Is selection small if (rng.startContainer == rng.endContainer) { if (rng.startOffset - rng.endOffset < 2) { if (rng.startContainer.hasChildNodes()) elm = rng.startContainer.childNodes[rng.startOffset]; } } } // Get the element parent of the node elm = tinyMCE.getParentElement(elm); //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") // elm = tinyMCE.selectedElement; } return elm; } }; /* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */ function TinyMCE_UndoRedo(inst) { this.instance = inst; this.undoLevels = []; this.undoIndex = 0; this.typingUndoIndex = -1; this.undoRedo = true; }; TinyMCE_UndoRedo.prototype = { add : function(l) { var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur; if (l) { this.undoLevels[this.undoLevels.length] = l; return true; } if (this.typingUndoIndex != -1) { this.undoIndex = this.typingUndoIndex; if (tinyMCE.typingUndoIndex != -1) tinyMCE.undoIndex = tinyMCE.typingUndoIndex; } newHTML = tinyMCE.trim(inst.getBody().innerHTML); if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) { //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content); // Is dirty again inst.isNotDirty = false; tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst); // Time to compress customUndoLevels = tinyMCE.settings.custom_undo_redo_levels; if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) { for (i=0; i 0) { this.undoIndex--; tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content); inst.repaint(); if (inst.settings.custom_undo_redo_restore_selection) inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); } }, redo : function() { var inst = this.instance; tinyMCE.execCommand("mceEndTyping"); if (this.undoIndex < (this.undoLevels.length-1)) { this.undoIndex++; tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content); inst.repaint(); if (inst.settings.custom_undo_redo_restore_selection) inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); } tinyMCE.triggerNodeChange(); } }; /* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */ var TinyMCE_ForceParagraphs = { _insertPara : function(inst, e) { var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0); var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock; var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null; var paraBefore, paraAfter, startChop, endChop, contents, i; function isEmpty(para) { var nodes; 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 nodes = tinyMCE.getNodeTree(para, [], 3); for (i=0; i <" + blockName + "> "; paraAfter = body.childNodes[1]; } inst.selection.moveToBookmark(b); inst.selection.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); contents = rngAfter.cloneContents(); if (contents.firstChild && contents.firstChild.nodeName == blockName) { /* var nodes = contents.firstChild.childNodes; for (i=0; i= r.startOffset && nv.charAt(r.startOffset - 1) == ' ') s = true;*/ // Only remove BRs if we are at the end of line #bug 1464152 if (nv != null && r.startOffset == nv.length) sn.nextSibling.parentNode.removeChild(sn.nextSibling); } if (inst.settings.auto_resize) inst.resizeToContent(); return s; } }; /* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */ function TinyMCE_Layer(id, bm) { this.id = id; this.blockerElement = null; this.events = false; this.element = null; this.blockMode = typeof(bm) != 'undefined' ? bm : true; this.doc = document; }; TinyMCE_Layer.prototype = { moveRelativeTo : function(re, p) { var rep = this.getAbsPosition(re), e = this.getElement(), x, y; var w = parseInt(re.offsetWidth), h = parseInt(re.offsetHeight); var ew = parseInt(e.offsetWidth), eh = parseInt(e.offsetHeight); switch (p) { case "tl": x = rep.absLeft; y = rep.absTop; break; case "tr": x = rep.absLeft + w; y = rep.absTop; break; case "bl": x = rep.absLeft; y = rep.absTop + h; break; case "br": x = rep.absLeft + w; y = rep.absTop + h; break; case "cc": x = rep.absLeft + (w / 2) - (ew / 2); y = rep.absTop + (h / 2) - (eh / 2); break; } this.moveTo(x, y); }, moveBy : function(x, y) { var e = this.getElement(); this.moveTo(parseInt(e.style.left) + x, parseInt(e.style.top) + y); }, moveTo : function(x, y) { var e = this.getElement(); e.style.left = x + "px"; e.style.top = y + "px"; this.updateBlocker(); }, resizeBy : function(w, h) { var e = this.getElement(); this.resizeTo(parseInt(e.style.width) + w, parseInt(e.style.height) + h); }, resizeTo : function(w, h) { var e = this.getElement(); if (w != null) e.style.width = w + "px"; if (h != null) e.style.height = h + "px"; this.updateBlocker(); }, show : function() { var el = this.getElement(); if (el) { el.style.display = 'block'; this.updateBlocker(); } }, hide : function() { var el = this.getElement(); if (el) { el.style.display = 'none'; this.updateBlocker(); } }, isVisible : function() { return this.getElement().style.display == 'block'; }, getElement : function() { if (!this.element) this.element = this.doc.getElementById(this.id); return this.element; }, setBlockMode : function(s) { this.blockMode = s; }, updateBlocker : function() { var e, b, x, y, w, h; b = this.getBlocker(); if (b) { if (this.blockMode) { e = this.getElement(); x = this.parseInt(e.style.left); y = this.parseInt(e.style.top); w = this.parseInt(e.offsetWidth); h = this.parseInt(e.offsetHeight); b.style.left = x + 'px'; b.style.top = y + 'px'; b.style.width = w + 'px'; b.style.height = h + 'px'; b.style.display = e.style.display; } else b.style.display = 'none'; } }, getBlocker : function() { var d, b; if (!this.blockerElement && this.blockMode) { d = this.doc; b = d.getElementById(this.id + "_blocker"); if (!b) { b = d.createElement("iframe"); b.setAttribute('id', this.id + "_blocker"); b.style.cssText = 'display: none; position: absolute; left: 0; top: 0'; b.src = 'javascript:false;'; b.frameBorder = '0'; b.scrolling = 'no'; d.body.appendChild(b); } this.blockerElement = b; } return this.blockerElement; }, getAbsPosition : function(n) { var p = {absLeft : 0, absTop : 0}; while (n) { p.absLeft += n.offsetLeft; p.absTop += n.offsetTop; n = n.offsetParent; } return p; }, create : function(n, c, p, h) { var d = this.doc, e = d.createElement(n); e.setAttribute('id', this.id); if (c) e.className = c; if (!p) p = d.body; if (h) e.innerHTML = h; p.appendChild(e); return this.element = e; }, exists : function() { return this.doc.getElementById(this.id) != null; }, parseInt : function(s) { if (s == null || s == '') return 0; return parseInt(s); }, remove : function() { var e = this.getElement(), b = this.getBlocker(); if (e) e.parentNode.removeChild(e); if (b) b.parentNode.removeChild(b); } }; /* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */ function TinyMCE_Menu() { var id; if (typeof(tinyMCE.menuCounter) == "undefined") tinyMCE.menuCounter = 0; id = "mc_menu_" + tinyMCE.menuCounter++; TinyMCE_Layer.call(this, id, true); this.id = id; this.items = []; this.needsUpdate = true; }; TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, { init : function(s) { var n; // Default params this.settings = { separator_class : 'mceMenuSeparator', title_class : 'mceMenuTitle', disabled_class : 'mceMenuDisabled', menu_class : 'mceMenu', drop_menu : true }; for (n in s) this.settings[n] = s[n]; this.create('div', this.settings.menu_class); }, clear : function() { this.items = []; }, addTitle : function(t) { this.add({type : 'title', text : t}); }, addDisabled : function(t) { this.add({type : 'disabled', text : t}); }, addSeparator : function() { this.add({type : 'separator'}); }, addItem : function(t, js) { this.add({text : t, js : js}); }, add : function(mi) { this.items[this.items.length] = mi; this.needsUpdate = true; }, update : function() { var e = this.getElement(), h = '', i, t, m = this.items, s = this.settings; if (this.settings.drop_menu) h += ''; h += ''; for (i=0; i'; } h += '
'; break; case 'title': h += '
' + t + ''; break; case 'disabled': h += '
' + t + ''; break; default: h += '
' + t + ''; } h += '
'; e.innerHTML = h; this.needsUpdate = false; this.updateBlocker(); }, show : function() { var nl, i; if (tinyMCE.lastMenu == this) return; if (this.needsUpdate) this.update(); if (tinyMCE.lastMenu && tinyMCE.lastMenu != this) tinyMCE.lastMenu.hide(); TinyMCE_Layer.prototype.show.call(this); if (!tinyMCE.isOpera) { // Accessibility stuff /* nl = this.getElement().getElementsByTagName("a"); if (nl.length > 0) nl[0].focus();*/ } tinyMCE.lastMenu = this; } }); /* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */ tinyMCE.add(TinyMCE_Engine, { debug : function() { var m = "", a, i, l = tinyMCE.log.length; for (i=0, a = this.debug.arguments; i 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); if (but[0] == button_name) return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null)); } // Custom controlls other than buttons switch (button_name) { case "formatselect": var html = ''; return html; case "styleselect": return ''; case "fontselect": var fontHTML = ''; return fontHTML; case "fontsizeselect": return ''; case "|": case "separator": return ''; case "spacer": return ''; case "rowseparator": return '
'; } return ""; }, /** * Theme specific execcommand handling. */ execCommand : function(editor_id, element, command, user_interface, value) { switch (command) { case 'mceHelp': tinyMCE.openWindow({ file : 'about.htm', width : 480, height : 380 }, { tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion, tinymce_releasedate : tinyMCE.releaseDate, inline : "yes" }); return true; case "mceLink": var inst = tinyMCE.getInstanceById(editor_id); var doc = inst.getDoc(); var selectedText = ""; if (tinyMCE.isMSIE) { var rng = doc.selection.createRange(); selectedText = rng.text; } else selectedText = inst.getSel().toString(); if (!tinyMCE.linkElement) { if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0)) return true; } var href = "", target = "", title = "", onclick = "", action = "insert", style_class = ""; if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a") tinyMCE.linkElement = tinyMCE.selectedElement; // Is anchor not a link if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "") tinyMCE.linkElement = null; if (tinyMCE.linkElement) { href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href'); target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target'); title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title'); onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class'); // Try old onclick to if copy/pasted content if (onclick == "") onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick'); onclick = tinyMCE.cleanupEventStr(onclick); href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); // Use mce_href if defined mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href'); if (mceRealHref != "") { href = mceRealHref; if (tinyMCE.getParam('convert_urls')) href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);"); } action = "update"; } var template = new Array(); template['file'] = 'link.htm'; template['width'] = 310; template['height'] = 200; // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0); if (inst.settings['insertlink_callback']) { var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);"); if (returnVal && returnVal['href']) TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']); } else { tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"}); } return true; case "mceImage": var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = ""; var title = "", onmouseover = "", onmouseout = "", action = "insert"; var img = tinyMCE.imgElement; var inst = tinyMCE.getInstanceById(editor_id); if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { img = tinyMCE.selectedElement; tinyMCE.imgElement = img; } if (img) { // Is it a internal MCE visual aid image, then skip this one. if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0) return true; src = tinyMCE.getAttrib(img, 'src'); alt = tinyMCE.getAttrib(img, 'alt'); // Try polling out the title if (alt == "") alt = tinyMCE.getAttrib(img, 'title'); // Fix width/height attributes if the styles is specified if (tinyMCE.isGecko) { var w = img.style.width; if (w != null && w != "") img.setAttribute("width", w); var h = img.style.height; if (h != null && h != "") img.setAttribute("height", h); } border = tinyMCE.getAttrib(img, 'border'); hspace = tinyMCE.getAttrib(img, 'hspace'); vspace = tinyMCE.getAttrib(img, 'vspace'); width = tinyMCE.getAttrib(img, 'width'); height = tinyMCE.getAttrib(img, 'height'); align = tinyMCE.getAttrib(img, 'align'); onmouseover = tinyMCE.getAttrib(img, 'onmouseover'); onmouseout = tinyMCE.getAttrib(img, 'onmouseout'); title = tinyMCE.getAttrib(img, 'title'); // Is realy specified? if (tinyMCE.isMSIE) { width = img.attributes['width'].specified ? width : ""; height = img.attributes['height'].specified ? height : ""; } //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover)); //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout)); src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); // Use mce_src if defined mceRealSrc = tinyMCE.getAttrib(img, 'mce_src'); if (mceRealSrc != "") { src = mceRealSrc; if (tinyMCE.getParam('convert_urls')) src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);"); } //if (onmouseover != "") // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);"); //if (onmouseout != "") // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);"); action = "update"; } var template = new Array(); template['file'] = 'image.htm?src={$src}'; template['width'] = 355; template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0); // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0); template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0); if (inst.settings['insertimage_callback']) { var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);"); if (returnVal && returnVal['src']) TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']); } else tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"}); return true; case "forecolor": var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm; TinyMCE_AdvancedTheme._hideMenus(editor_id); if (!fcp.exists()) { fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); elm = fcp.getElement(); elm._editor_id = editor_id; elm._command = "forecolor"; elm._switchId = editor_id + "_forecolor"; tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); } img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0]; p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); fcp.moveTo(p.absLeft, p.absTop); fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor; fcp.show(); return false; case "forecolorpicker": this._pickColor(editor_id, 'forecolor'); return true; case "forecolorMenu": TinyMCE_AdvancedTheme._hideMenus(editor_id); // Create color layer var ml = new TinyMCE_Layer(editor_id + '_fcMenu'); if (!ml.exists()) ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor')); tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus'); ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl'); ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); if (tinyMCE.isOpera) ml.moveBy(0, -2); ml.show(); return true; case "HiliteColor": var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img; TinyMCE_AdvancedTheme._hideMenus(editor_id); if (!bcp.exists()) { bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar')); elm = bcp.getElement(); elm._editor_id = editor_id; elm._command = "HiliteColor"; elm._switchId = editor_id + "_backcolor"; tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent); tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent); } img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0]; p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar')); bcp.moveTo(p.absLeft, p.absTop); bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor; bcp.show(); return false; case "HiliteColorMenu": TinyMCE_AdvancedTheme._hideMenus(editor_id); // Create color layer var ml = new TinyMCE_Layer(editor_id + '_bcMenu'); if (!ml.exists()) ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor')); tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus'); ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl'); ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1); if (tinyMCE.isOpera) ml.moveBy(0, -2); ml.show(); return true; case "backcolorpicker": this._pickColor(editor_id, 'HiliteColor'); return true; case "mceColorPicker": if (user_interface) { var template = []; if (!value['callback'] && !value['color']) value['color'] = value['document'].getElementById(value['element_id']).value; template['file'] = 'color_picker.htm'; template['width'] = 380; template['height'] = 250; template['close_previous'] = "no"; template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0); if (typeof(value['store_selection']) == "undefined") value['store_selection'] = true; tinyMCE.lastColorPickerValue = value; tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : value['color']}); } else { var savedVal = tinyMCE.lastColorPickerValue, elm; if (savedVal['callback']) { savedVal['callback'](value); return true; } elm = savedVal['document'].getElementById(savedVal['element_id']); elm.value = value; if (elm.onchange != null && elm.onchange != '') eval('elm.onchange();'); } return true; case "mceCodeEditor": var template = new Array(); template['file'] = 'source_editor.htm'; template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720)); template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580)); tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"}); return true; case "mceCharMap": var template = new Array(); template['file'] = 'charmap.htm'; template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0); template['height'] = 250; template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; case "mceInsertAnchor": var template = new Array(); template['file'] = 'anchor.htm'; template['width'] = 320; template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0); template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0); template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; case "mceNewDocument": if (confirm(tinyMCE.getLang('lang_newdocument'))) tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' '); return true; } return false; }, /** * Editor instance template function. */ getEditorTemplate : function(settings, editorId) { function removeFromArray(in_array, remove_array) { var outArray = new Array(), skip; for (var i=0; i 

'; var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout"); // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY! var styleSelectHTML = ''; if (settings['theme_advanced_styles']) { var stylesAr = settings['theme_advanced_styles'].split(';'); for (var i=0; i' + key + ''; } TinyMCE_AdvancedTheme._autoImportCSSClasses = false; } switch(layoutManager) { case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)... var toolbarHTML = ""; var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom"); var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center"); var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation); var defVals = { theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect", theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code", theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap" }; // Add accessibility control toolbarHTML += ' 0) { toolbarHTML += "
"; deltaHeight -= 23; } } // Add accessibility control toolbarHTML += '
'; // Setup template html template['html'] = ''; if (toolbarLocation == "top") template['html'] += ''; if (statusbarLocation == "top") { template['html'] += ''; deltaHeight -= 23; } template['html'] += ''; if (toolbarLocation == "bottom") template['html'] += ''; // External toolbar changes if (toolbarLocation == "external") { var bod = document.body; var elm = document.createElement ("div"); toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML); toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId}); elm.className = "mceToolbarExternal"; elm.id = editorId+"_toolbar"; elm.innerHTML = '
' + toolbarHTML + '
' + statusbarHTML + '
' + toolbarHTML + '
'+toolbarHTML+'
'; bod.appendChild (elm); // bod.style.marginTop = elm.offsetHeight + "px"; deltaHeight = 0; tinyMCE.getInstanceById(editorId).toolbarElement = elm; //template['html'] = '
'+toolbarHTML+'
' + template["html"]; } else { tinyMCE.getInstanceById(editorId).toolbarElement = null; } if (statusbarLocation == "bottom") { template['html'] += '' + statusbarHTML + ''; deltaHeight -= 23; } template['html'] += ''; //"SimpleLayout" break; case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom. template['html'] = ''; var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ","); var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container"); var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center"); //Render Containers: for (var i = 0; i < containers.length; i++) { if (containers[i] == "mceEditor") //Exceptions for mceEditor and ... template['html'] += ''; else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath: { var pathClass = "mceStatusbar"; if (i == containers.length-1) { pathClass = "mceStatusbarBottom"; } else if (i == 0) { pathClass = "mceStatusbar"; } else { deltaHeight-=2; } template['html'] += ''; deltaHeight -= 22; } else { // Render normal Container var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ','); var curContainerHTML = ""; var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign); var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS); curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ',')); for (var j=0; j 0) { curContainerHTML += "
"; deltaHeight -= 23; } template['html'] += '
'; } } template['html'] += '
' + statusbarHTML + '
' + curContainerHTML + '
'; //RowLayout break; case "CustomLayout" : //User defined layout callback... var customLayout = tinyMCE.getParam("theme_advanced_custom_layout",""); if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") { template = eval(customLayout + "(template);"); } break; } if (resizing) template['html'] += ''; template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML); // Set to default values if (!template['delta_width']) template['delta_width'] = 0; if (!template['delta_height']) template['delta_height'] = deltaHeight; return template; }, initInstance : function(inst) { if (tinyMCE.getParam("theme_advanced_resizing", false)) { if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width"); var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height"); TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true)); } } inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink'); }, removeInstance : function(inst) { new TinyMCE_Layer(inst.editorId + '_fcMenu').remove(); new TinyMCE_Layer(inst.editorId + '_bcMenu').remove(); }, hideInstance : function(inst) { TinyMCE_AdvancedTheme._hideMenus(inst.editorId); }, _handleMenuEvent : function(e) { var te = tinyMCE.isMSIE ? window.event.srcElement : e.target; tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId)); if (e.type == "click") tinyMCE.execInstanceCommand(te._editor_id, te._command); }, _hideMenus : function(id) { var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu'); if (fcml.exists() && fcml.isVisible()) { tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton'); fcml.hide(); } if (bcml.exists() && bcml.isVisible()) { tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton'); bcml.hide(); } }, /** * Node change handler. */ handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) { var alignNode, breakOut, classNode; function selectByValue(select_elm, value, first_index) { first_index = typeof(first_index) == "undefined" ? false : true; if (select_elm) { for (var i=0; i=0; i--) { var nodeName = path[i].nodeName.toLowerCase(); var nodeData = ""; if (nodeName.indexOf("html:") == 0) nodeName = nodeName.substring(5); if (nodeName == "b") { nodeName = "strong"; } if (nodeName == "i") { nodeName = "em"; } if (nodeName == "span") { var cn = tinyMCE.getAttrib(path[i], "class"); if (cn != "" && cn.indexOf('mceItem') == -1) nodeData += "class: " + cn + " "; var st = tinyMCE.getAttrib(path[i], "style"); if (st != "") { st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st)); nodeData += "style: " + tinyMCE.xmlEncode(st) + " "; } } if (nodeName == "font") { if (tinyMCE.getParam("convert_fonts_to_spans")) nodeName = "span"; var face = tinyMCE.getAttrib(path[i], "face"); if (face != "") nodeData += "font: " + tinyMCE.xmlEncode(face) + " "; var size = tinyMCE.getAttrib(path[i], "size"); if (size != "") nodeData += "size: " + tinyMCE.xmlEncode(size) + " "; var color = tinyMCE.getAttrib(path[i], "color"); if (color != "") nodeData += "color: " + tinyMCE.xmlEncode(color) + " "; } if (tinyMCE.getAttrib(path[i], 'id') != "") { nodeData += "id: " + path[i].getAttribute('id') + " "; } var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); if (className != "" && className.indexOf('mceItem') == -1) nodeData += "class: " + className + " "; if (tinyMCE.getAttrib(path[i], 'src') != "") { var src = tinyMCE.getAttrib(path[i], "mce_src"); if (src == "") src = tinyMCE.getAttrib(path[i], "src"); nodeData += "src: " + tinyMCE.xmlEncode(src) + " "; } if (path[i].nodeName == 'A' && tinyMCE.getAttrib(path[i], 'href') != "") { var href = tinyMCE.getAttrib(path[i], "mce_href"); if (href == "") href = tinyMCE.getAttrib(path[i], "href"); nodeData += "href: " + tinyMCE.xmlEncode(href) + " "; } className = tinyMCE.getAttrib(path[i], "class"); if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) { nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase(); nodeData = path[i].getAttribute('title'); } if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") { nodeName = "a"; nodeName += "#" + tinyMCE.xmlEncode(anchor); nodeData = ""; } if (tinyMCE.getAttrib(path[i], 'name').indexOf("mce_") != 0) { var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false); if (className != "" && className.indexOf('mceItem') == -1) { nodeName += "." + className; } } var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');'; html += '' + nodeName + ''; if (i > 0) { html += " » "; } } pathElm.innerHTML = '' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; } // Reset old states tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal'); if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1) tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected'); // Get link var anchorLink = tinyMCE.getParentElement(node, "a", "href"); if (anchorLink || any_selection) { tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal'); } // Handle visual aid tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal'); if (undo_levels != -1) { tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled'); } // Within li, blockquote if (tinyMCE.getParentElement(node, "li,blockquote")) tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal'); // Has redo levels if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0)) tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal'); // Has undo levels if (undo_index != -1 && (undo_index > 0 && undo_levels > 0)) tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal'); // Select class in select box var selectElm = document.getElementById(editor_id + "_styleSelect"); if (selectElm) { TinyMCE_AdvancedTheme._setupCSSClasses(editor_id); classNode = node; breakOut = false; var index = 0; do { if (classNode && classNode.className) { for (var i=0; i"); else selectByValue(selectElm, ""); } // Select fontselect var selectElm = document.getElementById(editor_id + "_fontNameSelect"); if (selectElm) { if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) { var face = inst.queryCommandValue('FontName'); face = face == null || face == "" ? "" : face; selectByValue(selectElm, face, face != ""); } else { var elm = tinyMCE.getParentElement(node, "font", "face"); if (elm) { var family = tinyMCE.getAttrib(elm, "face"); if (family == '') family = '' + elm.style.fontFamily; if (!selectByValue(selectElm, family, family != "")) selectByValue(selectElm, ""); } else selectByValue(selectElm, ""); } } // Select fontsize var selectElm = document.getElementById(editor_id + "_fontSizeSelect"); if (selectElm) { if (!tinyMCE.isSafari && !tinyMCE.isOpera) { var size = inst.queryCommandValue('FontSize'); selectByValue(selectElm, size == null || size == "" ? "0" : size); } else { var elm = tinyMCE.getParentElement(node, "font", "size"); if (elm) { var size = tinyMCE.getAttrib(elm, "size"); if (size == '') { var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px'); size = '' + elm.style.fontSize; for (var i=0; i 0) selectElm.setAttribute('cssImported', 'true'); } }, _setCookie : function(name, value, expires, path, domain, secure) { var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + escape(path) : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; }, _getCookie : function(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); }, _resizeTo : function(inst, w, h, set_w) { var editorContainer = document.getElementById(inst.editorId + '_parent'); var tableElm = editorContainer.firstChild; var iframe = inst.iframeElement; if (w == null || w == "null") { set_w = false; w = 0; } if (h == null || h == "null") return; w = parseInt(w); h = parseInt(h); if (tinyMCE.isGecko) { w += 2; h += 2; } var dx = w - tableElm.clientWidth; var dy = h - tableElm.clientHeight; w = w < 1 ? 30 : w; h = h < 1 ? 30 : h; if (set_w) tableElm.style.width = w + "px"; tableElm.style.height = h + "px"; iw = iframe.clientWidth + dx; ih = iframe.clientHeight + dy; iw = iw < 1 ? 30 : iw; ih = ih < 1 ? 30 : ih; if (tinyMCE.isGecko) { iw -= 2; ih -= 2; } if (set_w) iframe.style.width = iw + "px"; iframe.style.height = ih + "px"; // Is it to small, make it bigger again if (set_w) { var tableBodyElm = tableElm.firstChild; var minIframeWidth = tableBodyElm.scrollWidth; if (inst.iframeElement.clientWidth < minIframeWidth) { dx = minIframeWidth - inst.iframeElement.clientWidth; inst.iframeElement.style.width = (iw + dx) + "px"; } } // Remove pesky table controls inst.useCSS = false; }, /** * Handles resizing events. */ _resizeEventHandler : function(e) { var resizer = TinyMCE_AdvancedTheme._resizer; // Do nothing if (!resizer.resizing) return; e = typeof(e) == "undefined" ? window.event : e; var dx = e.screenX - resizer.downX; var dy = e.screenY - resizer.downY; var resizeBox = resizer.resizeBox; var editorId = resizer.editorId; switch (e.type) { case "mousemove": var w, h; w = resizer.width + dx; h = resizer.height + dy; w = w < 1 ? 1 : w; h = h < 1 ? 1 : h; if (resizer.horizontal) resizeBox.style.width = w + "px"; resizeBox.style.height = h + "px"; break; case "mouseup": TinyMCE_AdvancedTheme._setResizing(e, editorId, false); TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal); // Expire in a month if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) { var expires = new Date(); expires.setTime(expires.getTime() + 3600000 * 24 * 30); // Set the cookies TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires); TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires); } break; } }, /** * Starts/stops the editor resizing. */ _setResizing : function(e, editor_id, state) { e = typeof(e) == "undefined" ? window.event : e; var resizer = TinyMCE_AdvancedTheme._resizer; var editorContainer = document.getElementById(editor_id + '_parent'); var editorArea = document.getElementById(editor_id + '_parent').firstChild; var resizeBox = document.getElementById(editor_id + '_resize_box'); var inst = tinyMCE.getInstanceById(editor_id); if (state) { // Place box over editor area var width = editorArea.clientWidth; var height = editorArea.clientHeight; resizeBox.style.width = width + "px"; resizeBox.style.height = height + "px"; resizer.iframeWidth = inst.iframeElement.clientWidth; resizer.iframeHeight = inst.iframeElement.clientHeight; // Hide editor and show resize box editorArea.style.display = "none"; resizeBox.style.display = "block"; // Add event handlers, only once if (!resizer.eventHandlers) { if (tinyMCE.isMSIE) tinyMCE.addEvent(document, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler); else tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler); tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler); resizer.eventHandlers = true; } resizer.resizing = true; resizer.downX = e.screenX; resizer.downY = e.screenY; resizer.width = parseInt(resizeBox.style.width); resizer.height = parseInt(resizeBox.style.height); resizer.editorId = editor_id; resizer.resizeBox = resizeBox; resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true); } else { resizer.resizing = false; resizeBox.style.display = "none"; editorArea.style.display = tinyMCE.isMSIE && !tinyMCE.isOpera ? "block" : "table"; tinyMCE.execCommand('mceResetDesignMode'); } }, _getColorHTML : function(id, n, cm) { var i, h, cl; h = ''; cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(','); h += ''; for (i=0; i'; if ((i+1) % 8 == 0) h += ''; } h += '
'; if (tinyMCE.getParam("theme_advanced_more_colors", true)) h += '' + tinyMCE.getLang('lang_more_colors') + ''; return h; }, _pickColor : function(id, cm) { var inputColor, inst = tinyMCE.selectedInstance; if (cm == 'forecolor' && inst) inputColor = inst.foreColor; if ((cm == 'backcolor' || cm == 'HiliteColor') && inst) inputColor = inst.backColor; tinyMCE.execCommand('mceColorPicker', true, {color : inputColor, callback : function(c) { tinyMCE.execInstanceCommand(id, cm, false, c); }}); }, _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) { tinyMCE.execCommand("mceInsertContent", false, tinyMCE.createTagHTML('img', { src : tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src), // Force absolute mce_src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout })); }, _insertLink : function(href, target, title, onclick, style_class) { tinyMCE.execCommand('mceBeginUndoLevel'); if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") { var doc = tinyMCE.selectedInstance.getDoc(); var linkElement = tinyMCE.getParentElement(tinyMCE.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(tinyMCE.selectedElement.cloneNode(true)); tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement); } return; } if (!tinyMCE.linkElement && tinyMCE.selectedInstance) { if (tinyMCE.isSafari) { tinyMCE.execCommand("mceInsertContent", false, '' + tinyMCE.selectedInstance.selection.getSelectedHTML() + ''); } else tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL); tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); for (var i=0; i -1) { nl[ci].style.zIndex = z[fi]; nl[fi].style.zIndex = z[ci]; } else { if (z[ci] > 0) nl[ci].style.zIndex = z[ci] - 1; } } else { // Move forward // Try find a higher one for (i=0; i z[ci]) { fi = i; break; } } if (fi > -1) { nl[ci].style.zIndex = z[fi]; nl[fi].style.zIndex = z[ci]; } else nl[ci].style.zIndex = z[ci] + 1; } inst.repaint(); }, _getParentLayer : function(n) { return tinyMCE.getParentNode(n, function(n) { return n.nodeType == 1 && new RegExp('absolute|relative|static', 'gi').test(n.style.position); }); }, _insertLayer : function() { var inst = tinyMCE.selectedInstance; var e = tinyMCE.getParentElement(inst.getFocusElement()); var p = tinyMCE.getAbsPosition(e); var d = inst.getDoc(); var ne = d.createElement('div'); var h = inst.selection.getSelectedHTML(); // Move div ne.style.position = 'absolute'; ne.style.left = p.absLeft + 'px'; ne.style.top = (p.absTop > 20 ? p.absTop : 20) + 'px'; ne.style.width = '100px'; ne.style.height = '100px'; ne.className = 'mceVisualAid'; if (!h) h = tinyMCE.getLang('lang_layer_content'); ne.innerHTML = h; // Add it d.body.appendChild(ne); }, _toggleAbsolute : function() { var inst = tinyMCE.selectedInstance; var le = this._getParentLayer(inst.getFocusElement()); if (le == null) le = tinyMCE.getParentElement(inst.getFocusElement(), 'div,p,img'); if (le) { if (le.style.position.toLowerCase() == "absolute") { le.style.position = ""; le.style.left = ""; le.style.top = ""; } else { le.style.position = "absolute"; if (le.style.left == "") le.style.left = 20 + 'px'; if (le.style.top == "") le.style.top = 20 + 'px'; if (le.style.width == "") le.style.width = le.width ? (le.width + 'px') : '100px'; if (le.style.height == "") le.style.height = le.height ? (le.height + 'px') : '100px'; tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst); } inst.repaint(); tinyMCE.triggerNodeChange(); } } }; tinyMCE.addPlugin("layer", TinyMCE_LayerPlugin); // UK lang variables tinyMCE.addToLang('layer',{ insertlayer_desc : 'Insert new layer', forward_desc : 'Move forward', backward_desc : 'Move backward', absolute_desc : 'Toggle absolute positioning', content : 'New layer...' }); /** * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('table'); var TinyMCE_TablePlugin = { getInfo : function() { return { longname : 'Tables', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/table', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, initInstance : function(inst) { if (tinyMCE.isGecko) { var doc = inst.getDoc(); tinyMCE.addEvent(doc, "mouseup", TinyMCE_TablePlugin._mouseDownHandler); } inst.tableRowClipboard = null; }, /** * Returns the HTML contents of the table control. */ getControlHTML : function(control_name) { var controls = new Array( ['table', 'table.gif', 'lang_table_desc', 'mceInsertTable', true], ['delete_table', 'table_delete.gif', 'lang_table_del', 'mceTableDelete'], ['delete_col', 'table_delete_col.gif', 'lang_table_delete_col_desc', 'mceTableDeleteCol'], ['delete_row', 'table_delete_row.gif', 'lang_table_delete_row_desc', 'mceTableDeleteRow'], ['col_after', 'table_insert_col_after.gif', 'lang_table_col_after_desc', 'mceTableInsertColAfter'], ['col_before', 'table_insert_col_before.gif', 'lang_table_col_before_desc', 'mceTableInsertColBefore'], ['row_after', 'table_insert_row_after.gif', 'lang_table_row_after_desc', 'mceTableInsertRowAfter'], ['row_before', 'table_insert_row_before.gif', 'lang_table_row_before_desc', 'mceTableInsertRowBefore'], ['row_props', 'table_row_props.gif', 'lang_table_row_desc', 'mceTableRowProps', true], ['cell_props', 'table_cell_props.gif', 'lang_table_cell_desc', 'mceTableCellProps', true], ['split_cells', 'table_split_cells.gif', 'lang_table_split_cells_desc', 'mceTableSplitCells', true], ['merge_cells', 'table_merge_cells.gif', 'lang_table_merge_cells_desc', 'mceTableMergeCells', true]); // Render table control for (var i=0; i 4 ? but[4] : false) + (but.length > 5 ? ', \'' + but[5] + '\'' : '') + ');return false;'; if (but[0] == control_name) return tinyMCE.getButtonHTML(control_name, but[2], '{$pluginurl}/images/'+ but[1], but[3], (but.length > 4 ? but[4] : false)); } // Special tablecontrols if (control_name == "tablecontrols") { var html = ""; html += tinyMCE.getControlHTML("table"); html += tinyMCE.getControlHTML("separator"); html += tinyMCE.getControlHTML("row_props"); html += tinyMCE.getControlHTML("cell_props"); html += tinyMCE.getControlHTML("separator"); html += tinyMCE.getControlHTML("row_before"); html += tinyMCE.getControlHTML("row_after"); html += tinyMCE.getControlHTML("delete_row"); html += tinyMCE.getControlHTML("separator"); html += tinyMCE.getControlHTML("col_before"); html += tinyMCE.getControlHTML("col_after"); html += tinyMCE.getControlHTML("delete_col"); html += tinyMCE.getControlHTML("separator"); html += tinyMCE.getControlHTML("split_cells"); html += tinyMCE.getControlHTML("merge_cells"); return html; } return ""; }, /** * Executes the table commands. */ execCommand : function(editor_id, element, command, user_interface, value) { // Is table command switch (command) { case "mceInsertTable": case "mceTableRowProps": case "mceTableCellProps": case "mceTableSplitCells": case "mceTableMergeCells": case "mceTableInsertRowBefore": case "mceTableInsertRowAfter": case "mceTableDeleteRow": case "mceTableInsertColBefore": case "mceTableInsertColAfter": case "mceTableDeleteCol": case "mceTableCutRow": case "mceTableCopyRow": case "mceTablePasteRowBefore": case "mceTablePasteRowAfter": case "mceTableDelete": var inst = tinyMCE.getInstanceById(editor_id); inst.execCommand('mceBeginUndoLevel'); TinyMCE_TablePlugin._doExecCommand(editor_id, element, command, user_interface, value); inst.execCommand('mceEndUndoLevel'); return true; } // Pass to next handler in chain return false; }, handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { var colspan = "1", rowspan = "1", tdElm; var inst = tinyMCE.getInstanceById(editor_id); // Reset table controls tinyMCE.switchClass(editor_id + '_table', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_delete_table', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_row_props', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_cell_props', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_row_before', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_row_after', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_delete_row', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_col_before', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_col_after', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_delete_col', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_split_cells', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_merge_cells', 'mceButtonDisabled'); // Within a td element if (tdElm = tinyMCE.getParentElement(node, "td,th")) { tinyMCE.switchClass(editor_id + '_cell_props', 'mceButtonSelected'); tinyMCE.switchClass(editor_id + '_delete_table', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_row_before', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_row_after', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_delete_row', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_col_before', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_col_after', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_delete_col', 'mceButtonNormal'); colspan = tinyMCE.getAttrib(tdElm, "colspan"); rowspan = tinyMCE.getAttrib(tdElm, "rowspan"); colspan = colspan == "" ? "1" : colspan; rowspan = rowspan == "" ? "1" : rowspan; if (colspan != "1" || rowspan != "1") tinyMCE.switchClass(editor_id + '_split_cells', 'mceButtonNormal'); } // Within a tr element if (tinyMCE.getParentElement(node, "tr")) tinyMCE.switchClass(editor_id + '_row_props', 'mceButtonSelected'); // Within table if (tinyMCE.getParentElement(node, "table")) { tinyMCE.switchClass(editor_id + '_table', 'mceButtonSelected'); tinyMCE.switchClass(editor_id + '_merge_cells', 'mceButtonNormal'); } }, // Private plugin internal methods _mouseDownHandler : function(e) { var elm = tinyMCE.isMSIE ? event.srcElement : e.target; var focusElm = tinyMCE.selectedInstance.getFocusElement(); // If press on special Mozilla create TD/TR thingie if (elm.nodeName == "BODY" && (focusElm.nodeName == "TD" || focusElm.nodeName == "TH" || (focusElm.parentNode && focusElm.parentNode.nodeName == "TD") ||(focusElm.parentNode && focusElm.parentNode.nodeName == "TH") )) { window.setTimeout(function() { var tableElm = tinyMCE.getParentElement(focusElm, "table"); tinyMCE.handleVisualAid(tableElm, true, tinyMCE.settings['visual'], tinyMCE.selectedInstance); }, 10); } }, /** * Executes the table commands. */ _doExecCommand : function(editor_id, element, command, user_interface, value) { var inst = tinyMCE.getInstanceById(editor_id); var focusElm = inst.getFocusElement(); var trElm = tinyMCE.getParentElement(focusElm, "tr"); var tdElm = tinyMCE.getParentElement(focusElm, "td,th"); var tableElm = tinyMCE.getParentElement(focusElm, "table"); var doc = inst.contentWindow.document; var tableBorder = tableElm ? tableElm.getAttribute("border") : ""; // Get first TD if no TD found if (trElm && tdElm == null) tdElm = trElm.cells[0]; // ------- Inner functions --------- function inArray(ar, v) { for (var i=0; i 0 && inArray(ar[i], v)) return true; // Found value if (ar[i] == v) return true; } return false; } function makeTD() { var newTD = doc.createElement("td"); newTD.innerHTML = " "; } function getColRowSpan(td) { var colspan = tinyMCE.getAttrib(td, "colspan"); var rowspan = tinyMCE.getAttrib(td, "rowspan"); colspan = colspan == "" ? 1 : parseInt(colspan); rowspan = rowspan == "" ? 1 : parseInt(rowspan); return {colspan : colspan, rowspan : rowspan}; } function getCellPos(grid, td) { var x, y; for (y=0; y 1) { // Remove due to colspan for (var i=x; i 1) td.rowSpan = sd.rowspan + 1; lastElm = td; } deleteMarked(tableElm); } } function prevElm(node, name) { while ((node = node.previousSibling) != null) { if (node.nodeName == name) return node; } return null; } function nextElm(node, names) { var namesAr = names.split(','); while ((node = node.nextSibling) != null) { for (var i=0; i 1) { do { var nexttd = nextElm(td, "TD,TH"); if (td._delete) td.parentNode.removeChild(td); } while ((td = nexttd) != null); } } while ((tr = next) != null); } function addRows(td_elm, tr_elm, rowspan) { // Add rows td_elm.rowSpan = 1; var trNext = nextElm(tr_elm, "TR"); for (var i=1; i 1) { var newTD = cells[x].cloneNode(true); var sd = getColRowSpan(cells[x]); newTD.rowSpan = sd.rowspan - 1; var nextTD = nextTR.cells[x]; if (nextTD == null) nextTR.appendChild(newTD); else nextTR.insertBefore(newTD, nextTD); } } // Delete cells var lastTDElm = null; for (var x=0; tdElm = getCell(grid, cpos.rowindex, x); x++) { if (tdElm != lastTDElm) { var sd = getColRowSpan(tdElm); if (sd.rowspan > 1) { tdElm.rowSpan = sd.rowspan - 1; } else { trElm = tdElm.parentNode; if (trElm.parentNode) trElm._delete = true; } lastTDElm = tdElm; } } deleteMarked(tableElm); cpos.rowindex--; if (cpos.rowindex < 0) cpos.rowindex = 0; // Recalculate grid and select grid = getTableGrid(tableElm); inst.selection.selectNode(getCell(grid, cpos.rowindex, 0), tinyMCE.isGecko, true); // Only collape on gecko break; case "mceTableInsertColBefore": if (!trElm || !tdElm) return true; var grid = getTableGrid(tableElm); var cpos = getCellPos(grid, tdElm); var lastTDElm = null; for (var y=0; tdElm = getCell(grid, y, cpos.cellindex); y++) { if (tdElm != lastTDElm) { var sd = getColRowSpan(tdElm); if (sd['colspan'] == 1) { var newTD = doc.createElement(tdElm.nodeName); newTD.innerHTML = " "; newTD.rowSpan = tdElm.rowSpan; tdElm.parentNode.insertBefore(newTD, tdElm); } else tdElm.colSpan++; lastTDElm = tdElm; } } grid = getTableGrid(tableElm); inst.selection.selectNode(getCell(grid, cpos.rowindex, cpos.cellindex + 1), tinyMCE.isGecko, true); // Only collape on gecko break; case "mceTableInsertColAfter": if (!trElm || !tdElm) return true; var grid = getTableGrid(tableElm); var cpos = getCellPos(grid, tdElm); var lastTDElm = null; for (var y=0; tdElm = getCell(grid, y, cpos.cellindex); y++) { if (tdElm != lastTDElm) { var sd = getColRowSpan(tdElm); if (sd['colspan'] == 1) { var newTD = doc.createElement(tdElm.nodeName); newTD.innerHTML = " "; newTD.rowSpan = tdElm.rowSpan; var nextTD = nextElm(tdElm, "TD,TH"); if (nextTD == null) tdElm.parentNode.appendChild(newTD); else nextTD.parentNode.insertBefore(newTD, nextTD); } else tdElm.colSpan++; lastTDElm = tdElm; } } grid = getTableGrid(tableElm); inst.selection.selectNode(getCell(grid, cpos.rowindex, cpos.cellindex), tinyMCE.isGecko, true); // Only collape on gecko break; case "mceTableDeleteCol": if (!trElm || !tdElm) return true; var grid = getTableGrid(tableElm); var cpos = getCellPos(grid, tdElm); var lastTDElm = null; // Only one col, remove whole table if (grid.length > 1 && grid[0].length <= 1) { tableElm = tinyMCE.getParentElement(tableElm, "table"); // Look for table instead of tbody tableElm.parentNode.removeChild(tableElm); return true; } // Delete cells for (var y=0; tdElm = getCell(grid, y, cpos.cellindex); y++) { if (tdElm != lastTDElm) { var sd = getColRowSpan(tdElm); if (sd['colspan'] > 1) tdElm.colSpan = sd['colspan'] - 1; else { if (tdElm.parentNode) tdElm.parentNode.removeChild(tdElm); } lastTDElm = tdElm; } } cpos.cellindex--; if (cpos.cellindex < 0) cpos.cellindex = 0; // Recalculate grid and select grid = getTableGrid(tableElm); inst.selection.selectNode(getCell(grid, cpos.rowindex, 0), tinyMCE.isGecko, true); // Only collape on gecko break; case "mceTableSplitCells": if (!trElm || !tdElm) return true; var spandata = getColRowSpan(tdElm); var colspan = spandata["colspan"]; var rowspan = spandata["rowspan"]; // Needs splitting if (colspan > 1 || rowspan > 1) { // Generate cols tdElm.colSpan = 1; for (var i=1; i 1) addRows(newTD, trElm, rowspan); } addRows(tdElm, trElm, rowspan); } // Apply visual aids tableElm = tinyMCE.getParentElement(inst.getFocusElement(), "table"); break; case "mceTableMergeCells": var rows = new Array(); var sel = inst.getSel(); var grid = getTableGrid(tableElm); if (tinyMCE.isMSIE || sel.rangeCount == 1) { if (user_interface) { // Setup template var template = new Array(); var sp = getColRowSpan(tdElm); template['file'] = '../../plugins/table/merge_cells.htm'; template['width'] = 250; template['height'] = 105 + (tinyMCE.isNS7 ? 25 : 0); // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_table_merge_cells_delta_width', 0); template['height'] += tinyMCE.getLang('lang_table_merge_cells_delta_height', 0); // Open window tinyMCE.openWindow(template, {editor_id : inst.editorId, inline : "yes", action : "update", numcols : sp.colspan, numrows : sp.rowspan}); return true; } else { var numRows = parseInt(value['numrows']); var numCols = parseInt(value['numcols']); var cpos = getCellPos(grid, tdElm); if (("" + numRows) == "NaN") numRows = 1; if (("" + numCols) == "NaN") numCols = 1; // Get rows and cells var tRows = tableElm.rows; for (var y=cpos.rowindex; y 0) rows[rows.length] = rowCells; } //return true; } } else { var cells = new Array(); var sel = inst.getSel(); var lastTR = null; var curRow = null; var x1 = -1, y1 = -1, x2, y2; // Only one cell selected, whats the point? if (sel.rangeCount < 2) return true; // Get all selected cells for (var i=0; i 0) rows[rows.length] = rowCells; } // Find selected cells in grid and box var curRow = new Array(); var lastTR = null; for (var y=0; y colSpan) colSpan = rowColSpan; lastRowSpan = -1; } // Validate vertical and get total rowspan var lastColSpan = -1; for (var x=0; x rowSpan) rowSpan = colRowSpan; lastColSpan = -1; } // Setup td tdElm = rows[0][0]; tdElm.rowSpan = rowSpan; tdElm.colSpan = colSpan; // Merge cells for (var y=0; y 0)) tdElm.innerHTML += html; // Not current cell if (rows[y][x] != tdElm && !rows[y][x]._deleted) { var cpos = getCellPos(grid, rows[y][x]); var tr = rows[y][x].parentNode; tr.removeChild(rows[y][x]); rows[y][x]._deleted = true; // Empty TR, remove it if (!tr.hasChildNodes()) { tr.parentNode.removeChild(tr); var lastCell = null; for (var x=0; cellElm = getCell(grid, cpos.rowindex, x); x++) { if (cellElm != lastCell && cellElm.rowSpan > 1) cellElm.rowSpan--; lastCell = cellElm; } if (tdElm.rowSpan > 1) tdElm.rowSpan--; } } } } break; } tableElm = tinyMCE.getParentElement(inst.getFocusElement(), "table"); tinyMCE.handleVisualAid(tableElm, true, tinyMCE.settings['visual'], tinyMCE.selectedInstance); tinyMCE.triggerNodeChange(); inst.repaint(); } return true; } // Pass to next handler in chain return false; } }; tinyMCE.addPlugin("table", TinyMCE_TablePlugin); // UK lang variables tinyMCE.addToLang('table',{ general_tab : 'General', advanced_tab : 'Advanced', general_props : 'General properties', advanced_props : 'Advanced properties', desc : 'Inserts a new table', row_before_desc : 'Insert row before', row_after_desc : 'Insert row after', delete_row_desc : 'Delete row', col_before_desc : 'Insert column before', col_after_desc : 'Insert column after', delete_col_desc : 'Remove column', rowtype : 'Row in table part', title : 'Insert/Modify table', width : 'Width', height : 'Height', cols : 'Columns', rows : 'Rows', cellspacing : 'Cellspacing', cellpadding : 'Cellpadding', border : 'Border', align : 'Alignment', align_default : 'Default', align_left : 'Left', align_right : 'Right', align_middle : 'Center', row_title : 'Table row properties', cell_title : 'Table cell properties', cell_type : 'Cell type', row_desc : 'Table row properties', cell_desc : 'Table cell properties', valign : 'Vertical alignment', align_top : 'Top', align_bottom : 'Bottom', props_desc : 'Table properties', bordercolor : 'Border color', bgcolor : 'Background color', merge_cells_title : 'Merge table cells', split_cells_desc : 'Split merged table cells', merge_cells_desc : 'Merge table cells', cut_row_desc : 'Cut table row', copy_row_desc : 'Copy table row', paste_row_before_desc : 'Paste table row before', paste_row_after_desc : 'Paste table row after', id : 'Id', style: 'Style', langdir : 'Language direction', langcode : 'Language code', mime : 'Target MIME type', ltr : 'Left to right', rtl : 'Right to left', bgimage : 'Background image', summary : 'Summary', td : "Data", th : "Header", cell_cell : 'Update current cell', cell_row : 'Update all cells in row', cell_all : 'Update all cells in table', row_row : 'Update current row', row_odd : 'Update odd rows in table', row_even : 'Update even rows in table', row_all : 'Update all rows in table', thead : 'Table Head', tbody : 'Table Body', tfoot : 'Table Foot', del : 'Delete table', scope : 'Scope', row : 'Row', col : 'Col', rowgroup : 'Row Group', colgroup : 'Col Group', col_limit : 'You\'ve exceeded the maximum number of columns of {$cols}.', row_limit : 'You\'ve exceeded the maximum number of rows of {$rows}.', cell_limit : 'You\'ve exceeded the maximum number of cells of {$cells}.', missing_scope: 'Are you sure you want to continue without specifying a scope for this table header cell. Without it, it may be difficult for some users with disabilities to understand the content or data displayed of the table.', caption : 'Table caption' }); /** * $Id: editor_plugin_src.js 251 2007-04-10 20:16:15Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('save'); var TinyMCE_SavePlugin = { getInfo : function() { return { longname : 'Save', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/save', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, initInstance : function(inst) { inst.addShortcut('ctrl', 's', 'lang_save_desc', 'mceSave'); }, /** * Returns the HTML contents of the save control. */ getControlHTML : function(cn) { switch (cn) { case "save": return tinyMCE.getButtonHTML(cn, 'lang_save_desc', '{$pluginurl}/images/save.gif', 'mceSave'); case "cancel": return tinyMCE.getButtonHTML(cn, 'lang_cancel_desc', '{$pluginurl}/images/cancel.gif', 'mceCancel'); } return ""; }, /** * Executes the save command. */ execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mceSave": return this._save(editor_id, element, command, user_interface, value); case "mceCancel": return this._cancel(editor_id, element, command, user_interface, value); } // Pass to next handler in chain return false; }, _save : function(editor_id, element, command, user_interface, value) { var inst, formObj, os, i, elementId; if (tinyMCE.getParam("fullscreen_is_enabled")) return true; inst = tinyMCE.selectedInstance; formObj = inst.formElement.form; if (tinyMCE.getParam("save_enablewhendirty") && !inst.isDirty()) return true; if (formObj) { tinyMCE.triggerSave(); // Use callback instead if ((os = tinyMCE.getParam("save_onsavecallback"))) { if (eval(os + '(inst);')) { inst.startContent = tinyMCE.trim(inst.getBody().innerHTML); /*inst.undoLevels = new Array(); inst.undoIndex = 0; inst.typingUndoIndex = -1; inst.undoRedo = true; inst.undoLevels[inst.undoLevels.length] = inst.startContent;*/ tinyMCE.triggerNodeChange(false, true); } return true; } // Disable all UI form elements that TinyMCE created for (i=0; i'); } else { tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", size : size, width : width, noshade : noshade, mceDo : 'insert'}); } } return true; } // Pass to next handler in chain return false; }, handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { if (node == null) return; do { if (node.nodeName == "HR") { tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonSelected'); return true; } } while ((node = node.parentNode)); tinyMCE.switchClass(editor_id + '_advhr', 'mceButtonNormal'); return true; } }; tinyMCE.addPlugin("advhr", TinyMCE_AdvancedHRPlugin); // UK lang variables tinyMCE.addToLang('',{ insert_advhr_desc : 'Horizontale rule', insert_advhr_width : 'Width', insert_advhr_size : 'Height', insert_advhr_noshade : 'No shadow' }); /** * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('advimage'); var TinyMCE_AdvancedImagePlugin = { getInfo : function() { return { longname : 'Advanced image', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/advimage', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, getControlHTML : function(cn) { switch (cn) { case "image": return tinyMCE.getButtonHTML(cn, 'lang_image_desc', '{$themeurl}/images/image.gif', 'mceAdvImage'); } return ""; }, execCommand : function(editor_id, element, command, user_interface, value) { switch (command) { case "mceAdvImage": var template = new Array(); template['file'] = '../../plugins/advimage/image.htm'; template['width'] = 480; template['height'] = 380; // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_advimage_delta_width', 0); template['height'] += tinyMCE.getLang('lang_advimage_delta_height', 0); var inst = tinyMCE.getInstanceById(editor_id); var elm = inst.getFocusElement(); if (elm != null && tinyMCE.getAttrib(elm, 'class').indexOf('mceItem') != -1) return true; tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; } return false; }, cleanup : function(type, content) { switch (type) { case "insert_to_editor_dom": var imgs = content.getElementsByTagName("img"), src, i; for (i=0; i 0); if (anySelection || (focusElm != null && focusElm.nodeName == "A")) { tinyMCE.openWindow({ file : '../../plugins/advlink/link.htm', width : 480 + tinyMCE.getLang('lang_advlink_delta_width', 0), height : 400 + tinyMCE.getLang('lang_advlink_delta_height', 0) }, { editor_id : editor_id, inline : "yes" }); } return true; } return false; }, handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { if (node == null) return; do { if (node.nodeName == "A" && tinyMCE.getAttrib(node, 'href') != "") { tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonSelected'); return true; } } while ((node = node.parentNode)); if (any_selection) { tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonNormal'); return true; } tinyMCE.switchClass(editor_id + '_advlink', 'mceButtonDisabled'); return true; } }; tinyMCE.addPlugin("advlink", TinyMCE_AdvancedLinkPlugin); // UK lang variables tinyMCE.addToLang('advlink',{ general_tab : 'General', popup_tab : 'Popup', events_tab : 'Events', advanced_tab : 'Advanced', general_props : 'General properties', popup_props : 'Popup properties', event_props : 'Events', advanced_props : 'Advanced properties', popup_opts : 'Options', anchor_names : 'Anchors', target_same : 'Open in this window / frame', target_parent : 'Open in parent window / frame', target_top : 'Open in top frame (replaces all frames)', target_blank : 'Open in new window', popup : 'Javascript popup', popup_url : 'Popup URL', popup_name : 'Window name', popup_return : 'Insert \'return false\'', popup_scrollbars : 'Show scrollbars', popup_statusbar : 'Show status bar', popup_toolbar : 'Show toolbars', popup_menubar : 'Show menu bar', popup_location : 'Show location bar', popup_resizable : 'Make window resizable', popup_dependent : 'Dependent (Mozilla/Firefox only)', popup_size : 'Size', popup_position : 'Position (X/Y)', id : 'Id', style: 'Style', classes : 'Classes', target_name : 'Target name', langdir : 'Language direction', target_langcode : 'Target language', langcode : 'Language code', encoding : 'Target character encoding', mime : 'Target MIME type', rel : 'Relationship page to target', rev : 'Relationship target to page', tabindex : 'Tabindex', accesskey : 'Accesskey', ltr : 'Left to right', rtl : 'Right to left' });/** * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('emotions'); // Plucin static class var TinyMCE_EmotionsPlugin = { getInfo : function() { return { longname : 'Emotions', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/emotions', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, /** * Returns the HTML contents of the emotions control. */ getControlHTML : function(cn) { switch (cn) { case "emotions": return tinyMCE.getButtonHTML(cn, 'lang_emotions_desc', '{$pluginurl}/images/emotions.gif', 'mceEmotion'); } return ""; }, /** * Executes the mceEmotion command. */ execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mceEmotion": var template = new Array(); template['file'] = '../../plugins/emotions/emotions.htm'; // Relative to theme template['width'] = 250; template['height'] = 160; // Language specific width and height addons template['width'] += tinyMCE.getLang('lang_emotions_delta_width', 0); template['height'] += tinyMCE.getLang('lang_emotions_delta_height', 0); tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); return true; } // Pass to next handler in chain return false; } }; // Register plugin tinyMCE.addPlugin('emotions', TinyMCE_EmotionsPlugin); // UK lang variables tinyMCE.addToLang('emotions',{ title : 'Insert emotion', desc : 'Emotions', cool : 'Cool', cry : 'Cry', embarassed : 'Embarassed', foot_in_mouth : 'Foot in mouth', frown : 'Frown', innocent : 'Innocent', kiss : 'Kiss', laughing : 'Laughing', money_mouth : 'Money mouth', sealed : 'Sealed', smile : 'Smile', surprised : 'Surprised', tongue_out : 'Tongue out', undecided : 'Undecided', wink : 'Wink', yell : 'Yell' }); /** * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('iespell'); var TinyMCE_IESpellPlugin = { getInfo : function() { return { longname : 'IESpell (MSIE Only)', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/iespell', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, /** * Returns the HTML contents of the iespell control. */ getControlHTML : function(cn) { // Is it the iespell control and is the brower MSIE. if (cn == "iespell" && (tinyMCE.isMSIE && !tinyMCE.isOpera)) return tinyMCE.getButtonHTML(cn, 'lang_iespell_desc', '{$pluginurl}/images/iespell.gif', 'mceIESpell'); return ""; }, /** * Executes the mceIESpell command. */ execCommand : function(editor_id, element, command, user_interface, value) { // Handle ieSpellCommand if (command == "mceIESpell") { try { var ieSpell = new ActiveXObject("ieSpell.ieSpellExtension"); ieSpell.CheckDocumentNode(tinyMCE.getInstanceById(editor_id).contentDocument.documentElement); } catch (e) { if (e.number == -2146827859) { if (confirm(tinyMCE.getLang("lang_iespell_download", "", true))) window.open('http://www.iespell.com/download.php', 'ieSpellDownload', ''); } else alert("Error Loading ieSpell: Exception " + e.number); } return true; } // Pass to next handler in chain return false; } }; tinyMCE.addPlugin("iespell", TinyMCE_IESpellPlugin); // UK lang variables tinyMCE.addToLang('',{ iespell_desc : 'Run spell checking', iespell_download : "ieSpell not detected. Click OK to go to download page." }); /** * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('insertdatetime'); var TinyMCE_InsertDateTimePlugin = { getInfo : function() { return { longname : 'Insert date/time', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/insertdatetime', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, /** * Returns the HTML contents of the insertdate, inserttime controls. */ getControlHTML : function(cn) { switch (cn) { case "insertdate": return tinyMCE.getButtonHTML(cn, 'lang_insertdate_desc', '{$pluginurl}/images/insertdate.gif', 'mceInsertDate'); case "inserttime": return tinyMCE.getButtonHTML(cn, 'lang_inserttime_desc', '{$pluginurl}/images/inserttime.gif', 'mceInsertTime'); } return ""; }, /** * Executes the mceInsertDate command. */ execCommand : function(editor_id, element, command, user_interface, value) { /* Adds zeros infront of value */ function addZeros(value, len) { value = "" + value; if (value.length < len) { for (var i=0; i<(len-value.length); i++) value = "0" + value; } return value; } function getDateTime(d, fmt) { fmt = fmt.replace("%D", "%m/%d/%y"); fmt = fmt.replace("%r", "%I:%M:%S %p"); fmt = fmt.replace("%Y", "" + d.getFullYear()); fmt = fmt.replace("%y", "" + d.getYear()); fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2)); fmt = fmt.replace("%d", addZeros(d.getDate(), 2)); fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2)); fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2)); fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2)); fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1)); fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM")); fmt = fmt.replace("%B", "" + tinyMCE.getLang("lang_inserttime_months_long")[d.getMonth()]); fmt = fmt.replace("%b", "" + tinyMCE.getLang("lang_inserttime_months_short")[d.getMonth()]); fmt = fmt.replace("%A", "" + tinyMCE.getLang("lang_inserttime_day_long")[d.getDay()]); fmt = fmt.replace("%a", "" + tinyMCE.getLang("lang_inserttime_day_short")[d.getDay()]); fmt = fmt.replace("%%", "%"); return fmt; } // Handle commands switch (command) { case "mceInsertDate": tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_dateFormat", tinyMCE.getLang('lang_insertdate_def_fmt')))); return true; case "mceInsertTime": tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, getDateTime(new Date(), tinyMCE.getParam("plugin_insertdate_timeFormat", tinyMCE.getLang('lang_inserttime_def_fmt')))); return true; } // Pass to next handler in chain return false; } }; tinyMCE.addPlugin("insertdatetime", TinyMCE_InsertDateTimePlugin); // UK lang variables tinyMCE.addToLang('',{ insertdate_def_fmt : '%Y-%m-%d', inserttime_def_fmt : '%H:%M:%S', insertdate_desc : 'Insert date', inserttime_desc : 'Insert time', inserttime_months_long : new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"), inserttime_months_short : new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), inserttime_day_long : new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"), inserttime_day_short : new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") }); /** * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ * * @author Moxiecode * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('preview'); var TinyMCE_PreviewPlugin = { getInfo : function() { return { longname : 'Preview', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/preview', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, /** * Returns the HTML contents of the preview control. */ getControlHTML : function(cn) { switch (cn) { case "preview": return tinyMCE.getButtonHTML(cn, 'lang_preview_desc', '{$pluginurl}/images/preview.gif', 'mcePreview'); } return ""; }, /** * Executes the mcePreview command. */ execCommand : function(editor_id, element, command, user_interface, value) { // Handle commands switch (command) { case "mcePreview": var previewPage = tinyMCE.getParam("plugin_preview_pageurl", null); var previewWidth = tinyMCE.getParam("plugin_preview_width", "550"); var previewHeight = tinyMCE.getParam("plugin_preview_height", "600"); // Use a custom preview page if (previewPage) { var template = new Array(); template['file'] = previewPage; template['width'] = previewWidth; template['height'] = previewHeight; tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "yes", inline : "yes", content : tinyMCE.getContent(), content_css : tinyMCE.getParam("content_css")}); } else { var win = window.open("", "mcePreview", "menubar=no,toolbar=no,scrollbars=yes,resizable=yes,left=20,top=20,width=" + previewWidth + ",height=" + previewHeight); var html = "", i; var c = tinyMCE.getContent(); var pos = c.indexOf('', pos); pos2 = c.lastIndexOf(''); c = c.substring(pos + 1, pos2); } html += tinyMCE.getParam('doctype'); html += ''; html += ''; html += '' + tinyMCE.getLang('lang_preview_desc') + ''; html += ''; html += ''; for (i=0; i'; html += ''; html += ''; html += ''; html += c; html += ''; html += ''; win.document.write(html); win.document.close(); } return true; } return false; }, _setDoc : function(d) { TinyMCE_PreviewPlugin._doc = d; d._embeds = new Array(); }, _setWin : function(d) { TinyMCE_PreviewPlugin._win = d; }, _onLoad : function() { var nl, i, el = new Array(), d = TinyMCE_PreviewPlugin._doc, sv, ne; nl = d.getElementsByTagName("script"); for (i=0; i'; h += ']*>\s*write(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)\(\{([^\)]*)\}\);\s*<\/script>/gi, ''); content = content.replace(/]*)>/gi, '
'); content = content.replace(/]*)>/gi, '
'); content = content.replace(/<\/(object|embed)([^>]*)>/gi, '
'); content = content.replace(/]*)>/gi, '
'); content = content.replace(new RegExp('\\/ class="mceItemParam"><\\/div>', 'gi'), 'class="mceItemParam">
'); break; case "insert_to_editor_dom": d = inst.getDoc(); nl = content.getElementsByTagName("img"); for (i=0; i', startPos); attribs = TinyMCE_MediaPlugin._parseAttributes(content.substring(startPos + 4, endPos)); // Is not flash, skip it if (!/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(attribs['class'])) continue; endPos += 2; // Parse attributes at = attribs['title']; if (at) { at = at.replace(/&(#39|apos);/g, "'"); at = at.replace(/&#quot;/g, '"'); try { pl = eval('x={' + at + '};'); } catch (ex) { pl = {}; } } // Use object/embed if (!tinyMCE.getParam('media_use_script', false)) { switch (attribs['class']) { case 'mceItemFlash': ci = 'd27cdb6e-ae6d-11cf-96b8-444553540000'; cb = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; mt = 'application/x-shockwave-flash'; break; case 'mceItemShockWave': ci = '166B1BCA-3F9C-11CF-8075-444553540000'; cb = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0'; mt = 'application/x-director'; break; case 'mceItemWindowsMedia': ci = tinyMCE.getParam('media_wmp6_compatible') ? '05589FA1-C356-11CE-BF01-00AA0055595A' : '6BF52A52-394A-11D3-B153-00C04F79FAA6'; cb = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'; mt = 'application/x-mplayer2'; break; case 'mceItemQuickTime': ci = '02BF25D5-8C17-4B23-BC80-D3488ABDDC6B'; cb = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0'; mt = 'video/quicktime'; break; case 'mceItemRealMedia': ci = 'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'; cb = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0'; mt = 'audio/x-pn-realaudio-plugin'; break; } // Force absolute URL if (!tinyMCE.getParam("relative_urls")) pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src); embedHTML = TinyMCE_MediaPlugin._getEmbed(ci, cb, mt, pl, attribs); } else { // Use script version switch (attribs['class']) { case 'mceItemFlash': s = 'writeFlash'; break; case 'mceItemShockWave': s = 'writeShockWave'; break; case 'mceItemWindowsMedia': s = 'writeWindowsMedia'; break; case 'mceItemQuickTime': s = 'writeQuickTime'; break; case 'mceItemRealMedia': s = 'writeRealMedia'; break; } if (attribs.width) at = at.replace(/width:[^0-9]?[0-9]+%?[^0-9]?/g, "width:'" + attribs.width + "'"); if (attribs.height) at = at.replace(/height:[^0-9]?[0-9]+%?[^0-9]?/g, "height:'" + attribs.height + "'"); // Force absolute URL if (!tinyMCE.getParam("relative_urls")) { pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src); at = at.replace(new RegExp("src:'[^']*'", "g"), "src:'" + pl.src + "'"); } embedHTML = ''; } // Insert embed/object chunk chunkBefore = content.substring(0, startPos); chunkAfter = content.substring(endPos); content = chunkBefore + embedHTML + chunkAfter; } break; } return content; }, handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { if (node == null) return; do { if (node.nodeName == "IMG" && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(node, 'class'))) { tinyMCE.switchClass(editor_id + '_media', 'mceButtonSelected'); return true; } } while ((node = node.parentNode)); tinyMCE.switchClass(editor_id + '_media', 'mceButtonNormal'); return true; }, _createImgFromEmbed : function(n, d, cl) { var ne, at, i, ti = '', an; ne = d.createElement('img'); ne.src = tinyMCE.getParam("theme_href") + '/images/spacer.gif'; ne.width = tinyMCE.getAttrib(n, 'width'); ne.height = tinyMCE.getAttrib(n, 'height'); ne.className = cl; at = n.attributes; for (i=0; i 0 ? ti.substring(0, ti.length - 1) : ti; ne.title = ti; n.parentNode.replaceChild(ne, n); }, _createImg : function(cl, d, n) { var i, nl, ti = "", an, av, al = new Array(); ne = d.createElement('img'); ne.src = tinyMCE.getParam("theme_href") + '/images/spacer.gif'; ne.width = tinyMCE.getAttrib(n, 'width'); ne.height = tinyMCE.getAttrib(n, 'height'); ne.className = cl; al.id = tinyMCE.getAttrib(n, 'id'); al.name = tinyMCE.getAttrib(n, 'name'); al.width = tinyMCE.getAttrib(n, 'width'); al.height = tinyMCE.getAttrib(n, 'height'); al.bgcolor = tinyMCE.getAttrib(n, 'bgcolor'); al.align = tinyMCE.getAttrib(n, 'align'); al.class_name = tinyMCE.getAttrib(n, 'mce_class'); nl = n.getElementsByTagName('div'); for (i=0; i 0 ? ti.substring(0, ti.length - 1) : ti; ne.title = ti; return ne; }, _getEmbed : function(cls, cb, mt, p, at) { var h = '', n; p.width = at.width ? at.width : p.width; p.height = at.height ? at.height : p.height; h += ''; // Add extra url parameter if it's an absolute URL on WMP if (n == 'src' && p[n].indexOf('://') != -1 && mt == 'application/x-mplayer2') h += ''; } } h += ' 0) tinyMCE.execCommand('delete'); if (html && html.length > 0) tinyMCE.execCommand('mcePasteWord', false, html); tinyMCE.cancelEvent(e); return false; } return true; }, _insertText : function(content, bLinebreaks) { if (content && content.length > 0) { if (bLinebreaks) { // Special paragraph treatment if (tinyMCE.getParam("paste_create_paragraphs", true)) { var rl = tinyMCE.getParam("paste_replace_list", '\u2122,TM,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(','); for (var i=0; i

", "gi"); content = tinyMCE.regexpReplace(content, "\r\r", "

", "gi"); content = tinyMCE.regexpReplace(content, "\n\n", "

", "gi"); // Has paragraphs if ((pos = content.indexOf('

')) != -1) { tinyMCE.execCommand("Delete"); var node = tinyMCE.selectedInstance.getFocusElement(); // Get list of elements to break var breakElms = new Array(); do { if (node.nodeType == 1) { // Don't break tables and break at body if (node.nodeName == "TD" || node.nodeName == "BODY") break; breakElms[breakElms.length] = node; } } while(node = node.parentNode); var before = "", after = "

"; before += content.substring(0, pos); for (var i=0; i"; after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">"; } before += "

"; content = before + content.substring(pos+7) + after; } } if (tinyMCE.getParam("paste_create_linebreaks", true)) { content = tinyMCE.regexpReplace(content, "\r\n", "
", "gi"); content = tinyMCE.regexpReplace(content, "\r", "
", "gi"); content = tinyMCE.regexpReplace(content, "\n", "
", "gi"); } } tinyMCE.execCommand("mceInsertRawHTML", false, content); } }, _insertWordContent : function(content) { if (content && content.length > 0) { // Cleanup Word content var bull = String.fromCharCode(8226); var middot = String.fromCharCode(183); var cb; if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "") content = eval(cb + "('before', content)"); var rl = tinyMCE.getParam("paste_replace_list", '\u2122,TM,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(','); for (var i=0; i(.*?)<\/p>', 'gi'), '

$1

'); } content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--"); content = content.replace(new RegExp(bull + "(.*?)
", "gi"), "

" + middot + "$1

"); content = content.replace(new RegExp('', 'gi'), "" + bull); // Covert to bull list content = content.replace(/<\/o:p>/gi, ""); content = content.replace(new RegExp('
]*>/gi, ""); if (tinyMCE.getParam("paste_remove_styles", true)) content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3"); content = content.replace(/<\/?font[^>]*>/gi, ""); // Strips class attributes. switch (tinyMCE.getParam("paste_strip_class_attributes", "all")) { case "all": content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3"); break; case "mso": content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3"); break; } content = content.replace(new RegExp('href="?' + TinyMCE_PastePlugin._reEscape("" + document.location) + '', 'gi'), 'href="' + tinyMCE.settings['document_base_url']); content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3"); content = content.replace(/<\\?\?xml[^>]*>/gi, ""); content = content.replace(/<\/?\w+:[^>]*>/gi, ""); content = content.replace(/-- page break --\s*

 <\/p>/gi, ""); // Remove pagebreaks content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks // content = content.replace(/\/? */gi, "");   // content = content.replace(/

 <\/p>/gi, ''); if (!tinyMCE.settings['force_p_newlines']) { content = content.replace('', '' ,'gi'); content = content.replace('

', '

' ,'gi'); } if (!tinyMCE.isMSIE && !tinyMCE.settings['force_p_newlines']) { content = content.replace(/<\/?p[^>]*>/gi, ""); } content = content.replace(/<\/?div[^>]*>/gi, ""); // Convert all middlot lists to UL lists if (tinyMCE.getParam("paste_convert_middot_lists", true)) { var div = document.createElement("div"); div.innerHTML = content; // Convert all middot paragraphs to li elements var className = tinyMCE.getParam("paste_unindented_list_class", "unIndentedList"); while (TinyMCE_PastePlugin._convertMiddots(div, "--list--")) ; // bull while (TinyMCE_PastePlugin._convertMiddots(div, middot, className)) ; // Middot while (TinyMCE_PastePlugin._convertMiddots(div, bull)) ; // bull content = div.innerHTML; } // Replace all headers with strong and fix some other issues if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) { content = content.replace(/ <\/h[1-6]>/gi, '

  

'); content = content.replace(//gi, '

'); content = content.replace(/<\/h[1-6]>/gi, '

'); content = content.replace(/ <\/b>/gi, '  '); content = content.replace(/^( )*/gi, ''); } content = content.replace(/--list--/gi, ""); // Remove --list-- if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "") content = eval(cb + "('after', content)"); // Insert cleaned content tinyMCE.execCommand("mceInsertContent", false, content); if (tinyMCE.getParam('paste_force_cleanup_wordpaste', true)) window.setTimeout('tinyMCE.execCommand("mceCleanup");', 1); // Do normal cleanup detached from this thread } }, _reEscape : function(s) { var l = "?.\\*[](){}+^$:"; var o = ""; for (var i=0; i$1
'); nv = nv.replace(/\u00a0/g, '\u00b7'); tinyMCE.setOuterHTML(nl[i], nv, d); } } else { nl = tinyMCE.selectNodes(b, function(n) {return n.nodeType == 1 && n.nodeName == 'SPAN' && n.className == 'mceItemHiddenVisualChar';}); for (i=0; i·
' : ' '; tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, h); return true; } return false; }, handleEvent : function(e) { var inst, h; if (!tinyMCE.isOpera && e.type == 'keydown' && e.keyCode == 9 && tinyMCE.getParam('nonbreaking_force_tab', false)) { inst = tinyMCE.selectedInstance; h = (inst.visualChars && inst.visualChars.state) ? '···' : '   '; tinyMCE.execInstanceCommand(inst.editorId, 'mceInsertContent', false, h); tinyMCE.cancelEvent(e); return false; } return true; } }; tinyMCE.addPlugin("nonbreaking", TinyMCE_NonBreakingPlugin); // UK lang variables tinyMCE.addToLang('nonbreaking',{ desc : 'Insert non-breaking space character' }); /** * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $ * * @author Moxiecode - based on work by Andrew Tetlaw * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. */ /* Import plugin specific language pack */ tinyMCE.importPluginLanguagePack('xhtmlxtras'); var TinyMCE_XHTMLXtrasPlugin = { getInfo : function() { return { longname : 'XHTML Xtras Plugin', author : 'Moxiecode Systems AB', authorurl : 'http://tinymce.moxiecode.com', infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion }; }, initInstance : function(inst) { tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/xhtmlxtras/css/xhtmlxtras.css"); }, getControlHTML : function(cn) { switch (cn) { case "cite": return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_cite_desc', '{$pluginurl}/images/cite.gif', 'mceCite', true); case "acronym": return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_acronym_desc', '{$pluginurl}/images/acronym.gif', 'mceAcronym', true); case "abbr": return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_abbr_desc', '{$pluginurl}/images/abbr.gif', 'mceAbbr', true); case "del": return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_del_desc', '{$pluginurl}/images/del.gif', 'mceDel', true); case "ins": return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_ins_desc', '{$pluginurl}/images/ins.gif', 'mceIns', true); case "attribs": return tinyMCE.getButtonHTML(cn, 'lang_xhtmlxtras_attribs_desc', '{$pluginurl}/images/attribs.gif', 'mceAttributes', true); } return ""; }, execCommand : function(editor_id, element, command, user_interface, value) { var template, inst, elm; switch (command) { case "mceCite": if (!this._anySel(editor_id)) return true; template = new Array(); template['file'] = '../../plugins/xhtmlxtras/cite.htm'; template['width'] = 350; template['height'] = 250; tinyMCE.openWindow(template, {editor_id : editor_id}); return true; case "mceAcronym": if (!this._anySel(editor_id)) return true; template = new Array(); template['file'] = '../../plugins/xhtmlxtras/acronym.htm'; template['width'] = 350; template['height'] = 250; tinyMCE.openWindow(template, {editor_id : editor_id}); return true; case "mceAbbr": if (!this._anySel(editor_id)) return true; template = new Array(); template['file'] = '../../plugins/xhtmlxtras/abbr.htm'; template['width'] = 350; template['height'] = 250; tinyMCE.openWindow(template, {editor_id : editor_id}); return true; case "mceIns": if (!this._anySel(editor_id)) return true; template = new Array(); template['file'] = '../../plugins/xhtmlxtras/ins.htm'; template['width'] = 350; template['height'] = 310; tinyMCE.openWindow(template, {editor_id : editor_id}); return true; case "mceDel": if (!this._anySel(editor_id)) return true; template = new Array(); template['file'] = '../../plugins/xhtmlxtras/del.htm'; template['width'] = 350; template['height'] = 310; tinyMCE.openWindow(template, {editor_id : editor_id}); return true; case "mceAttributes": inst = tinyMCE.getInstanceById(editor_id); elm = inst.getFocusElement(); if (elm && elm.nodeName !== 'BODY' && elm.className.indexOf('mceItem') == -1) { tinyMCE.openWindow({ file : '../../plugins/xhtmlxtras/attributes.htm', width : 380, height : 370 }, {editor_id : editor_id}); } return true; } return false; }, cleanup : function(type, content, inst) { if (type == 'insert_to_editor' && tinyMCE.isIE && !tinyMCE.isOpera) { content = content.replace(/]+)>/gi, ''); content = content.replace(/<\/abbr>/gi, ''); } return content; }, handleNodeChange : function(editor_id, node, undo_index,undo_levels, visual_aid, any_selection) { var elm = tinyMCE.getParentElement(node); if (node == null) return; tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonDisabled'); if (!any_selection) { // Disable the buttons tinyMCE.switchClass(editor_id + '_cite', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_del', 'mceButtonDisabled'); tinyMCE.switchClass(editor_id + '_ins', 'mceButtonDisabled'); } else { // A selection means the buttons should be active. tinyMCE.switchClass(editor_id + '_cite', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_del', 'mceButtonNormal'); tinyMCE.switchClass(editor_id + '_ins', 'mceButtonNormal'); } if (elm && elm.nodeName != 'BODY' && elm.className.indexOf('mceItem') == -1) tinyMCE.switchClass(editor_id + '_attribs', 'mceButtonNormal'); switch (node.nodeName) { case "CITE": tinyMCE.switchClass(editor_id + '_cite', 'mceButtonSelected'); return true; case "ACRONYM": tinyMCE.switchClass(editor_id + '_acronym', 'mceButtonSelected'); return true; case "abbr": // IE case "HTML:ABBR": // FF case "ABBR": tinyMCE.switchClass(editor_id + '_abbr', 'mceButtonSelected'); return true; case "DEL": tinyMCE.switchClass(editor_id + '_del', 'mceButtonSelected'); return true; case "INS": tinyMCE.switchClass(editor_id + '_ins', 'mceButtonSelected'); return true; } return true; }, _anySel : function(editor_id) { var inst = tinyMCE.getInstanceById(editor_id), t = inst.selection.getSelectedText(), pe; pe = tinyMCE.getParentElement(inst.getFocusElement(), 'CITE,ACRONYM,ABBR,HTML:ABBR,DEL,INS'); return pe || inst.getFocusElement().nodeName == "IMG" || (t && t.length > 0); } }; tinyMCE.addPlugin("xhtmlxtras", TinyMCE_XHTMLXtrasPlugin); // UK lang variables tinyMCE.addToLang('xhtmlxtras',{ cite_desc : 'Citation', abbr_desc : 'Abbreviation', acronym_desc : 'Acronym', del_desc : 'Deletion', ins_desc : 'Insertion', attribute_label_title : 'Title', attribute_label_id : 'ID', attribute_label_class : 'Class', attribute_label_style : 'Style', attribute_label_cite : 'Cite', attribute_label_datetime : 'Date/Time', attribute_label_langdir : 'Text Direction', attribute_option_ltr : 'Left to right', attribute_option_rtl : 'Right to left', attribute_label_langcode : 'Language', attribute_label_tabindex : 'TabIndex', attribute_label_accesskey : 'AccessKey', attribute_label_cite : 'Cite', attribute_events_tab : 'Events', attribute_attrib_tab : 'Attributes', general_tab : 'General', attrib_tab : 'Attributes', events_tab : 'Events', fieldset_general_tab : 'General Settings', fieldset_attrib_tab : 'Element Attributes', fieldset_events_tab : 'Element Events', title_ins_element : 'Insertion Element', title_del_element : 'Deletion Element', title_acronym_element : 'Acronym Element', title_abbr_element : 'Abbreviation Element', title_cite_element : 'Citation Element', remove : 'Remove', not_set : '--not set--', insert_date : 'Insert current date/time', option_ltr : 'Left to right', option_rtl : 'Right to left', attribs_desc : 'Insert/Edit Attributes', attribs_title : 'Insert/Edit Attributes' }); tinyMCE_GZ.end();