diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php index ddc8915b97..7721e3e0ec 100644 --- a/wp-admin/admin-header.php +++ b/wp-admin/admin-header.php @@ -57,9 +57,7 @@ var manager = new dbxManager('linkmeta'); - - - + diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index 504a8565c6..32b41e1f82 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -143,55 +143,7 @@ endforeach;
- 100)) { - $rows = 12; - } -?> - - -
-
- - + post_content); ?> diff --git a/wp-admin/edit-form-comment.php b/wp-admin/edit-form-comment.php index ac920823c3..d8b9259ece 100644 --- a/wp-admin/edit-form-comment.php +++ b/wp-admin/edit-form-comment.php @@ -37,56 +37,9 @@ addLoadEvent(focusit);
- - - 100)) { - $rows = 10; - } -?> -
+ comment_content, 'content', 'newcomment_author_url'); ?>
- -

diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php index cbc00dc488..8b07bae519 100644 --- a/wp-admin/edit-page-form.php +++ b/wp-admin/edit-page-form.php @@ -130,56 +130,9 @@ endforeach;
- 100)) { - $rows = 10; - } -?> - - -
+ post_content); ?>
- -

diff --git a/wp-includes/functions-post.php b/wp-includes/functions-post.php index 800c6b6074..cbf4150573 100644 --- a/wp-includes/functions-post.php +++ b/wp-includes/functions-post.php @@ -1028,4 +1028,82 @@ function do_all_pings() { //Do Update Services/Generic Pings generic_ping(); } + +/** + * Places two script links in : one to get tinyMCE (big), one to configure and start it (small) + */ +function tinymce_include() { + $src1 = get_settings('siteurl') . '/wp-includes/js/tinymce/tiny_mce_gzip.php'; + $src2 = get_settings('siteurl') . '/wp-includes/js/tinymce/tiny_mce_config.php'; + + echo "\n"; + echo "\n"; +} + +/** + * Places a textarea according to the current user's preferences, filled with $content. + * Also places a script block that enables tabbing between Title and Content. + * + * @param string Editor contents + * @param string (optional) Previous form field's ID (for tabbing support) + */ +function the_editor($content, $id = 'content', $prev_id = 'title') { + $rows = get_settings('default_post_edit_rows'); + if (($rows < 3) || ($rows > 100)) + $rows = 12; + + $rows = "rows='$rows'"; + + the_quicktags(); + + if ( user_can_richedit() ) + add_filter('the_editor_content', 'wp_richedit_pre'); + + $the_editor = apply_filters('the_editor', "

\n"); + $the_editor_content = apply_filters('the_editor_content', $content); + + printf($the_editor, $the_editor_content); + + ?> + + diff --git a/wp-includes/js/tinymce/langs/en.js b/wp-includes/js/tinymce/langs/en.js index f6ffe12716..c093eafa04 100644 --- a/wp-includes/js/tinymce/langs/en.js +++ b/wp-includes/js/tinymce/langs/en.js @@ -1,47 +1,41 @@ // UK lang variables -if (navigator.userAgent.indexOf('Mac OS') != -1) { -// Mac OS browsers use Ctrl to hit accesskeys - var metaKey = 'Ctrl'; -} -else { - var metaKey = 'Alt'; -} - -tinyMCELang['lang_bold_desc'] = 'Bold (' + metaKey + '+b)'; -tinyMCELang['lang_italic_desc'] = 'Italic (' + metaKey + '+i)'; -tinyMCELang['lang_underline_desc'] = 'Underline'; -tinyMCELang['lang_striketrough_desc'] = 'Striketrough (' + metaKey + '-d)'; -tinyMCELang['lang_justifyleft_desc'] = 'Align left (' + metaKey + '-f)'; -tinyMCELang['lang_justifycenter_desc'] = 'Align center (' + metaKey + '-c)'; -tinyMCELang['lang_justifyright_desc'] = 'Align right (' + metaKey + '-r)'; -tinyMCELang['lang_justifyfull_desc'] = 'Align full'; -tinyMCELang['lang_bullist_desc'] = 'Unordered list (' + metaKey + '-l)'; -tinyMCELang['lang_numlist_desc'] = 'Ordered list (' + metaKey + '-o)'; -tinyMCELang['lang_outdent_desc'] = 'Outdent (' + metaKey + '-w)'; -tinyMCELang['lang_indent_desc'] = 'Indent/Blockquote (' + metaKey + '-q)'; -tinyMCELang['lang_undo_desc'] = 'Undo (' + metaKey + '-u)'; -tinyMCELang['lang_redo_desc'] = 'Redo (' + metaKey + '-y)'; -tinyMCELang['lang_link_desc'] = 'Insert/edit link (' + metaKey + '-a)'; -tinyMCELang['lang_unlink_desc'] = 'Unlink (' + metaKey + '-s)'; -tinyMCELang['lang_image_desc'] = 'Insert/edit image (' + metaKey + '-m)'; -tinyMCELang['lang_cleanup_desc'] = 'Cleanup messy code'; -tinyMCELang['lang_focus_alert'] = 'A editor instance must be focused before using this command.'; -tinyMCELang['lang_edit_confirm'] = 'Do you want to use the WYSIWYG mode for this textarea?'; -tinyMCELang['lang_insert_link_title'] = 'Insert/edit link'; -tinyMCELang['lang_insert'] = 'Insert'; -tinyMCELang['lang_update'] = 'Update'; -tinyMCELang['lang_cancel'] = 'Cancel'; -tinyMCELang['lang_insert_link_url'] = 'Link URL'; -tinyMCELang['lang_insert_link_target'] = 'Target'; -tinyMCELang['lang_insert_link_target_same'] = 'Open link in the same window'; -tinyMCELang['lang_insert_link_target_blank'] = 'Open link in a new window'; -tinyMCELang['lang_insert_image_title'] = 'Insert/edit image'; -tinyMCELang['lang_insert_image_src'] = 'Image URL'; -tinyMCELang['lang_insert_image_alt'] = 'Image description'; -tinyMCELang['lang_help_desc'] = 'Help'; -tinyMCELang['lang_bold_img'] = "bold.gif"; -tinyMCELang['lang_italic_img'] = "italic.gif"; -tinyMCELang['lang_underline_img'] = "underline.gif"; -tinyMCELang['lang_clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?'; -tinyMCELang['lang_popup_blocked'] = 'Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.'; +tinyMCE.addToLang('',{ +bold_desc : 'Bold (Ctrl+B)', +italic_desc : 'Italic (Ctrl+I)', +underline_desc : 'Underline (Ctrl+U)', +striketrough_desc : 'Strikethrough', +justifyleft_desc : 'Align left', +justifycenter_desc : 'Align center', +justifyright_desc : 'Align right', +justifyfull_desc : 'Align full', +bullist_desc : 'Unordered list', +numlist_desc : 'Ordered list', +outdent_desc : 'Outdent', +indent_desc : 'Indent', +undo_desc : 'Undo (Ctrl+Z)', +redo_desc : 'Redo (Ctrl+Y)', +link_desc : 'Insert/edit link', +unlink_desc : 'Unlink', +image_desc : 'Insert/edit image', +cleanup_desc : 'Cleanup messy code', +focus_alert : 'A editor instance must be focused before using this command.', +edit_confirm : 'Do you want to use the WYSIWYG mode for this textarea?', +insert_link_title : 'Insert/edit link', +insert : 'Insert', +update : 'Update', +cancel : 'Cancel', +insert_link_url : 'Link URL', +insert_link_target : 'Target', +insert_link_target_same : 'Open link in the same window', +insert_link_target_blank : 'Open link in a new window', +insert_image_title : 'Insert/edit image', +insert_image_src : 'Image URL', +insert_image_alt : 'Image description', +help_desc : 'Help', +bold_img : "bold.gif", +italic_img : "italic.gif", +underline_img : "underline.gif", +clipboard_msg : 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?', +popup_blocked : 'Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.' +}); diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js index 28d7ae7607..4b88d2ecf9 100644 --- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js @@ -1,2 +1,48 @@ +/** + * $RCSfile: editor_plugin_src.js,v $ + * $Revision: 1.11 $ + * $Date: 2006/03/22 12:21:21 $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + */ + /* Import plugin specific language pack */ - tinyMCE.importPluginLanguagePack('autosave','en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl');function TinyMCE_autosave_getInfo(){return{longname:'Auto save',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};};function TinyMCE_autosave_beforeUnloadHandler(){var msg=tinyMCE.getLang("lang_autosave_unload_msg");var anyDirty=false;for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(!tinyMCE.isInstance(inst))continue;if(inst.isDirty())return msg;}return;}window.onbeforeunload=TinyMCE_autosave_beforeUnloadHandler; \ No newline at end of file +tinyMCE.importPluginLanguagePack('autosave', 'en,tr,sv,cs,he,nb,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl,pt_br'); + +var TinyMCE_AutoSavePlugin = { + getInfo : function() { + return { + longname : 'Auto save', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; + }, + + // Private plugin internal methods + + _beforeUnloadHandler : function() { + var n, inst, anyDirty = false, msg = tinyMCE.getLang("lang_autosave_unload_msg"); + + if (tinyMCE.getParam("fullscreen_is_enabled")) + return; + + for (n in tinyMCE.instances) { + inst = tinyMCE.instances[n]; + + if (!tinyMCE.isInstance(inst)) + continue; + + if (inst.isDirty()) + return msg; + } + + return; + } +}; + +window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler; + +tinyMCE.addPlugin("autosave", TinyMCE_AutoSavePlugin); diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css b/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css index e69de29bb2..43be823cdf 100644 --- a/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css +++ b/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css @@ -0,0 +1,69 @@ +/* Window classes */ + +.mceWindow { + position: absolute; + left: 0; + top: 0; + border: 1px solid black; + background-color: #D4D0C8; +} + +.mceWindowHead { + background-color: #334F8D; + width: 100%; + height: 18px; + cursor: move; + overflow: hidden; +} + +.mceWindowBody { + clear: both; + background-color: white; +} + +.mceWindowStatusbar { + background-color: #D4D0C8; + height: 12px; + border-top: 1px solid black; +} + +.mceWindowTitle { + float: left; + font-family: "MS Sans Serif"; + font-size: 9pt; + font-weight: bold; + line-height: 18px; + color: white; + margin-left: 2px; + overflow: hidden; +} + +.mceWindowHeadTools { + margin-right: 2px; +} + +.mceWindowClose, .mceWindowMinimize, .mceWindowMaximize { + display: block; + float: right; + overflow: hidden; + margin-top: 2px; +} + +.mceWindowClose { + margin-left: 2px; +} + +.mceWindowMinimize { +} + +.mceWindowMaximize { +} + +.mceWindowResize { + display: block; + float: right; + overflow: hidden; + cursor: se-resize; + width: 12px; + height: 12px; +} diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js index e69de29bb2..5fb11f5342 100644 --- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js @@ -0,0 +1,662 @@ +/** + * $RCSfile: editor_plugin_src.js,v $ + * $Revision: 1.8 $ + * $Date: 2006/02/06 20:02:38 $ + * + * Moxiecode DHTML Windows script. + * + * @author Moxiecode + * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + */ + +// Patch openWindow, closeWindow TinyMCE functions + +var TinyMCE_InlinePopupsPlugin = { + getInfo : function() { + return { + longname : 'Inline Popups', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; + } +}; + +tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin); + +// Patch openWindow, closeWindow TinyMCE functions + +TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow; + +TinyMCE_Engine.prototype.openWindow = function(template, args) { + // Does the caller support inline + if (args['inline'] != "yes" || tinyMCE.isOpera || tinyMCE.getParam("plugins").indexOf('inlinepopups') == -1) { + mcWindows.selectedWindow = null; + args['mce_inside_iframe'] = false; + this.orgOpenWindow(template, args); + return; + } + + var url, resizable, scrollbars; + + args['mce_inside_iframe'] = true; + tinyMCE.windowArgs = args; + + if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1) + url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; + else + url = template['file']; + + if (!(width = parseInt(template['width']))) + width = 320; + + if (!(height = parseInt(template['height']))) + height = 200; + + resizable = (args && args['resizable']) ? args['resizable'] : "no"; + scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; + + height += 18; + + // Replace all args as variables in URL + for (var name in args) { + if (typeof(args[name]) == 'function') + continue; + + url = tinyMCE.replaceVar(url, name, escape(args[name])); + } + + var elm = document.getElementById(this.selectedInstance.editorId + '_parent'); + var pos = tinyMCE.getAbsPosition(elm); + + // Center div in editor area + pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2)); + pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2)); + + mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop); +}; + +TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow; + +TinyMCE_Engine.prototype.closeWindow = function(win) { + if (mcWindows.selectedWindow != null) + mcWindows.selectedWindow.close(); + else + this.orgCloseWindow(win); +}; + +TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) { + for (var n in mcWindows.windows) { + var win = mcWindows.windows[n]; + if (typeof(win) == 'function') + continue; + + if (win_ref.name == win.id + "_iframe") + window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title; + } +}; + +// * * * * * TinyMCE_Windows classes below + +// Windows handler +function TinyMCE_Windows() { + this.settings = new Array(); + this.windows = new Array(); + this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); + this.isGecko = navigator.userAgent.indexOf('Gecko') != -1; + this.isSafari = navigator.userAgent.indexOf('Safari') != -1; + this.isMac = navigator.userAgent.indexOf('Mac') != -1; + this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1); + this.action = "none"; + this.selectedWindow = null; + this.lastSelectedWindow = null; + this.zindex = 100; + this.mouseDownScreenX = 0; + this.mouseDownScreenY = 0; + this.mouseDownLayerX = 0; + this.mouseDownLayerY = 0; + this.mouseDownWidth = 0; + this.mouseDownHeight = 0; + this.idCounter = 0; +}; + +TinyMCE_Windows.prototype.init = function(settings) { + this.settings = settings; + + if (this.isMSIE) + this.addEvent(document, "mousemove", mcWindows.eventDispatcher); + else + this.addEvent(window, "mousemove", mcWindows.eventDispatcher); + + this.addEvent(document, "mouseup", mcWindows.eventDispatcher); + + this.doc = document; +}; + +TinyMCE_Windows.prototype.getParam = function(name, default_value) { + var value = null; + + value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name]; + + // Fix bool values + if (value == "true" || value == "false") + return (value == "true"); + + return value; +}; + +TinyMCE_Windows.prototype.eventDispatcher = function(e) { + e = typeof(e) == "undefined" ? window.event : e; + + if (mcWindows.selectedWindow == null) + return; + + // Switch focus + if (mcWindows.isGecko && e.type == "mousedown") { + var elm = e.currentTarget; + + for (var n in mcWindows.windows) { + var win = mcWindows.windows[n]; + + if (win.headElement == elm || win.resizeElement == elm) { + win.focus(); + break; + } + } + } + + switch (e.type) { + case "mousemove": + mcWindows.selectedWindow.onMouseMove(e); + break; + + case "mouseup": + mcWindows.selectedWindow.onMouseUp(e); + break; + + case "mousedown": + mcWindows.selectedWindow.onMouseDown(e); + break; + + case "focus": + mcWindows.selectedWindow.onFocus(e); + break; + } +}; + +TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) { + if (this.isMSIE) + obj.attachEvent("on" + name, handler); + else + obj.addEventListener(name, handler, true); +}; + +TinyMCE_Windows.prototype.cancelEvent = function(e) { + if (this.isMSIE) { + e.returnValue = false; + e.cancelBubble = true; + } else + e.preventDefault(); +}; + +TinyMCE_Windows.prototype.parseFeatures = function(opts) { + // Cleanup the options + opts = opts.toLowerCase(); + opts = opts.replace(/;/g, ","); + opts = opts.replace(/[^0-9a-z=,]/g, ""); + + var optionChunks = opts.split(','); + var options = new Array(); + + options['left'] = "10"; + options['top'] = "10"; + options['width'] = "300"; + options['height'] = "300"; + options['resizable'] = "yes"; + options['minimizable'] = "yes"; + options['maximizable'] = "yes"; + options['close'] = "yes"; + options['movable'] = "yes"; + options['statusbar'] = "yes"; + options['scrollbars'] = "auto"; + options['modal'] = "no"; + + if (opts == "") + return options; + + for (var i=0; i'; + html += ''; + html += ''; + + html += '
'; + html += '
'; + html += '
'; +// html += ' '; +// html += ' '; + html += '
'; + html += '
'; + html += '
'; + + if (features['statusbar'] == "yes") { + html += '
'; + + if (features['resizable'] == "yes") { + if (this.isGecko) + html += '
'; + else + html += '
'; + } + + html += '
'; + } + + html += '
'; + + html += ''; + html += ''; + + // Create iframe + this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html); +}; + +// Blocks the document events by placing a image over the whole document +TinyMCE_Windows.prototype.setDocumentLock = function(state) { + if (state) { + var elm = document.getElementById('mcWindowEventBlocker'); + if (elm == null) { + elm = document.createElement("div"); + + elm.id = "mcWindowEventBlocker"; + elm.style.position = "absolute"; + elm.style.left = "0"; + elm.style.top = "0"; + + document.body.appendChild(elm); + } + + elm.style.display = "none"; + + var imgPath = this.getParam("images_path"); + var width = document.body.clientWidth; + var height = document.body.clientHeight; + + elm.style.width = width; + elm.style.height = height; + elm.innerHTML = ''; + + elm.style.zIndex = mcWindows.zindex-1; + elm.style.display = "block"; + } else { + var elm = document.getElementById('mcWindowEventBlocker'); + + if (mcWindows.windows.length == 0) + elm.parentNode.removeChild(elm); + else + elm.style.zIndex = mcWindows.zindex-1; + } +}; + +// Gets called when wrapper iframe is initialized +TinyMCE_Windows.prototype.onLoad = function(name) { + var win = mcWindows.windows[name]; + var id = "mcWindow_" + name; + var wrapperIframe = window.frames[id + "_iframe"].frames[0]; + var wrapperDoc = window.frames[id + "_iframe"].document; + var doc = window.frames[id + "_iframe"].document; + var winDiv = document.getElementById("mcWindow_" + name + "_div"); + var realIframe = window.frames[id + "_iframe"].frames[0]; + + // Set window data + win.id = "mcWindow_" + name; + win.winElement = winDiv; + win.bodyElement = doc.getElementById(id + '_body'); + win.iframeElement = doc.getElementById(id + '_iframe'); + win.headElement = doc.getElementById(id + '_head'); + win.titleElement = doc.getElementById(id + '_title'); + win.resizeElement = doc.getElementById(id + '_resize'); + win.containerElement = doc.getElementById(id + '_container'); + win.left = win.features['left']; + win.top = win.features['top']; + win.frame = window.frames[id + '_iframe'].frames[0]; + win.wrapperFrame = window.frames[id + '_iframe']; + win.wrapperIFrameElement = document.getElementById(id + "_iframe"); + + // Add event handlers + mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher); + + if (win.resizeElement != null) + mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher); + + if (mcWindows.isMSIE) { + mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher); + mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher); + } else { + mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher); + mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher); + mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher); + } + + for (var i=0; i'; + + html += '
'; + html += '
'; + html += '
'; +// html += ' '; +// html += ' '; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + + html += ''; + html += ''; + + // Create iframe + this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html); +}; + +// Gets called when wrapper iframe is initialized +MCWindows.prototype.onLoad = function(name) { + var win = mcWindows.windows[name]; + var id = "mcWindow_" + name; + var wrapperIframe = window.frames[id + "_iframe"].frames[0]; + var wrapperDoc = window.frames[id + "_iframe"].document; + var doc = window.frames[id + "_iframe"].document; + var winDiv = document.getElementById("mcWindow_" + name + "_div"); + var realIframe = window.frames[id + "_iframe"].frames[0]; + + // Set window data + win.id = "mcWindow_" + name + "_iframe"; + win.winElement = winDiv; + win.bodyElement = doc.getElementById(id + '_body'); + win.iframeElement = doc.getElementById(id + '_iframe'); + win.headElement = doc.getElementById(id + '_head'); + win.titleElement = doc.getElementById(id + '_title'); + win.resizeElement = doc.getElementById(id + '_resize'); + win.containerElement = doc.getElementById(id + '_container'); + win.left = win.features['left']; + win.top = win.features['top']; + win.frame = window.frames[id + '_iframe'].frames[0]; + win.wrapperFrame = window.frames[id + '_iframe']; + win.wrapperIFrameElement = document.getElementById(id + "_iframe"); + + // Add event handlers + mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher); + mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher); + + if (mcWindows.isMSIE) { + mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher); + mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher); + } else { + mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher); + mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher); + mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher); + } + + for (var i=0; i + + blank_page + + + + + + + + + diff --git a/wp-includes/js/tinymce/plugins/paste/css/blank.css b/wp-includes/js/tinymce/plugins/paste/css/blank.css new file mode 100644 index 0000000000..eca411a422 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/css/blank.css @@ -0,0 +1,13 @@ +body { + background-color: #FFFFFF; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; +} diff --git a/wp-includes/js/tinymce/plugins/paste/css/pasteword.css b/wp-includes/js/tinymce/plugins/paste/css/pasteword.css new file mode 100644 index 0000000000..b3be6270bb --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/css/pasteword.css @@ -0,0 +1,3 @@ +.sourceIframe { + border: 1px solid #808080; +} diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js new file mode 100644 index 0000000000..916e29fdc2 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js @@ -0,0 +1,388 @@ +/** + * $RCSfile: editor_plugin_src.js,v $ + * $Revision: 1.36 $ + * $Date: 2006/03/20 12:03:44 $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + */ + +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('paste', 'en,tr,sv,cs,zh_cn,fr_ca,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl,nl,fr,pt_br'); + +var TinyMCE_PastePlugin = { + getInfo : function() { + return { + longname : 'Paste text/word', + author : 'Moxiecode Systems', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; + }, + + initInstance : function(inst) { + if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false)) + tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent); + }, + + getControlHTML : function(cn) { + switch (cn) { + case "pastetext": + return tinyMCE.getButtonHTML(cn, 'lang_paste_text_desc', '{$pluginurl}/images/pastetext.gif', 'mcePasteText', true); + + case "pasteword": + return tinyMCE.getButtonHTML(cn, 'lang_paste_word_desc', '{$pluginurl}/images/pasteword.gif', 'mcePasteWord', true); + + case "selectall": + return tinyMCE.getButtonHTML(cn, 'lang_selectall_desc', '{$pluginurl}/images/selectall.gif', 'mceSelectAll', true); + } + + return ''; + }, + + execCommand : function(editor_id, element, command, user_interface, value) { + switch (command) { + case "mcePasteText": + if (user_interface) { + if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) + TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true); + else { + var template = new Array(); + template['file'] = '../../plugins/paste/pastetext.htm'; // Relative to theme + template['width'] = 450; + template['height'] = 400; + var plain_text = ""; + tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); + } + } else + TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']); + + return true; + + case "mcePasteWord": + if (user_interface) { + if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) { + var html = TinyMCE_PastePlugin._clipboardHTML(); + + if (html && html.length > 0) + TinyMCE_PastePlugin._insertWordContent(html); + } else { + var template = new Array(); + template['file'] = '../../plugins/paste/pasteword.htm'; // Relative to theme + template['width'] = 450; + template['height'] = 400; + var plain_text = ""; + tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); + } + } else + TinyMCE_PastePlugin._insertWordContent(value); + + return true; + + case "mceSelectAll": + tinyMCE.execInstanceCommand(editor_id, 'selectall'); + return true; + + } + + // Pass to next handler in chain + return false; + }, + + // Private plugin internal methods + + _handlePasteEvent : function(e) { + switch (e.type) { + case "paste": + var html = TinyMCE_PastePlugin._clipboardHTML(); + var r, inst = tinyMCE.selectedInstance; + + // Removes italic, strong etc, the if was needed due to bug #1437114 + if (inst && (r = inst.getRng()) && r.text.length > 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); + 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 + + {$lang_paste_text_desc} + + + + + + +
+
{$lang_paste_text_desc}
+ +
+ +
+ +
+ +
{$lang_paste_text_title}
+ + + +
+
+ +
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/paste/pasteword.htm b/wp-includes/js/tinymce/plugins/paste/pasteword.htm new file mode 100644 index 0000000000..7acc7f78f6 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/paste/pasteword.htm @@ -0,0 +1,29 @@ + + + + {$lang_paste_word_desc} + + + + + + +
+
{$lang_paste_word_desc}
+ +
{$lang_paste_word_title}
+ +
+ +
+
+ +
+ +
+ +
+
+
+ + diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php new file mode 100755 index 0000000000..cae27f09a7 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php @@ -0,0 +1,339 @@ +cookies array ready for the next request + // Note: This currently ignores the cookie path (and time) completely. Time is not important, + // but path could possibly lead to security problems. + var $persist_referers = true; // For each request, sends path of last request as referer + var $debug = false; + var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found + var $max_redirects = 5; + var $headers_only = false; // If true, stops receiving once headers have been read. + // Basic authorization variables + var $username; + var $password; + // Response vars + var $status; + var $headers = array(); + var $content = ''; + var $errormsg; + // Tracker variables + var $redirect_count = 0; + var $cookie_host = ''; + function HttpClient($host, $port=80) { + $this->host = $host; + $this->port = $port; + } + function get($path, $data = false) { + $this->path = $path; + $this->method = 'GET'; + if ($data) { + $this->path .= '?'.$this->buildQueryString($data); + } + return $this->doRequest(); + } + function post($path, $data) { + $this->path = $path; + $this->method = 'POST'; + $this->postdata = $this->buildQueryString($data); + return $this->doRequest(); + } + function buildQueryString($data) { + $querystring = ''; + if (is_array($data)) { + // Change data in to postable data + foreach ($data as $key => $val) { + if (is_array($val)) { + foreach ($val as $val2) { + $querystring .= urlencode($key).'='.urlencode($val2).'&'; + } + } else { + $querystring .= urlencode($key).'='.urlencode($val).'&'; + } + } + $querystring = substr($querystring, 0, -1); // Eliminate unnecessary & + } else { + $querystring = $data; + } + return $querystring; + } + function doRequest() { + // Performs the actual HTTP request, returning true or false depending on outcome + if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) { + // Set error message + switch($errno) { + case -3: + $this->errormsg = 'Socket creation failed (-3)'; + case -4: + $this->errormsg = 'DNS lookup failure (-4)'; + case -5: + $this->errormsg = 'Connection refused or timed out (-5)'; + default: + $this->errormsg = 'Connection failed ('.$errno.')'; + $this->errormsg .= ' '.$errstr; + $this->debug($this->errormsg); + } + return false; + } + socket_set_timeout($fp, $this->timeout); + $request = $this->buildRequest(); + $this->debug('Request', $request); + fwrite($fp, $request); + // Reset all the variables that should not persist between requests + $this->headers = array(); + $this->content = ''; + $this->errormsg = ''; + // Set a couple of flags + $inHeaders = true; + $atStart = true; + // Now start reading back the response + while (!feof($fp)) { + $line = fgets($fp, 4096); + if ($atStart) { + // Deal with first line of returned data + $atStart = false; + if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { + $this->errormsg = "Status code line invalid: ".htmlentities($line); + $this->debug($this->errormsg); + return false; + } + $http_version = $m[1]; // not used + $this->status = $m[2]; + $status_string = $m[3]; // not used + $this->debug(trim($line)); + continue; + } + if ($inHeaders) { + if (trim($line) == '') { + $inHeaders = false; + $this->debug('Received Headers', $this->headers); + if ($this->headers_only) { + break; // Skip the rest of the input + } + continue; + } + if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { + // Skip to the next header + continue; + } + $key = strtolower(trim($m[1])); + $val = trim($m[2]); + // Deal with the possibility of multiple headers of same name + if (isset($this->headers[$key])) { + if (is_array($this->headers[$key])) { + $this->headers[$key][] = $val; + } else { + $this->headers[$key] = array($this->headers[$key], $val); + } + } else { + $this->headers[$key] = $val; + } + continue; + } + // We're not in the headers, so append the line to the contents + $this->content .= $line; + } + fclose($fp); + // If data is compressed, uncompress it + if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') { + $this->debug('Content is gzip encoded, unzipping it'); + $this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php + $this->content = gzinflate($this->content); + } + // If $persist_cookies, deal with any cookies + if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) { + $cookies = $this->headers['set-cookie']; + if (!is_array($cookies)) { + $cookies = array($cookies); + } + foreach ($cookies as $cookie) { + if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) { + $this->cookies[$m[1]] = $m[2]; + } + } + // Record domain of cookies for security reasons + $this->cookie_host = $this->host; + } + // If $persist_referers, set the referer ready for the next request + if ($this->persist_referers) { + $this->debug('Persisting referer: '.$this->getRequestURL()); + $this->referer = $this->getRequestURL(); + } + // Finally, if handle_redirects and a redirect is sent, do that + if ($this->handle_redirects) { + if (++$this->redirect_count >= $this->max_redirects) { + $this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')'; + $this->debug($this->errormsg); + $this->redirect_count = 0; + return false; + } + $location = isset($this->headers['location']) ? $this->headers['location'] : ''; + $uri = isset($this->headers['uri']) ? $this->headers['uri'] : ''; + if ($location || $uri) { + $url = parse_url($location.$uri); + // This will FAIL if redirect is to a different site + return $this->get($url['path']); + } + } + return true; + } + function buildRequest() { + $headers = array(); + $headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding + $headers[] = "Host: {$this->host}"; + $headers[] = "User-Agent: {$this->user_agent}"; + $headers[] = "Accept: {$this->accept}"; + if ($this->use_gzip) { + $headers[] = "Accept-encoding: {$this->accept_encoding}"; + } + $headers[] = "Accept-language: {$this->accept_language}"; + if ($this->referer) { + $headers[] = "Referer: {$this->referer}"; + } + // Cookies + if ($this->cookies) { + $cookie = 'Cookie: '; + foreach ($this->cookies as $key => $value) { + $cookie .= "$key=$value; "; + } + $headers[] = $cookie; + } + // Basic authentication + if ($this->username && $this->password) { + $headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password); + } + // If this is a POST, set the content type and length + if ($this->postdata) { + $headers[] = 'Content-Type: application/x-www-form-urlencoded'; + $headers[] = 'Content-Length: '.strlen($this->postdata); + } + $request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata; + return $request; + } + function getStatus() { + return $this->status; + } + function getContent() { + return $this->content; + } + function getHeaders() { + return $this->headers; + } + function getHeader($header) { + $header = strtolower($header); + if (isset($this->headers[$header])) { + return $this->headers[$header]; + } else { + return false; + } + } + function getError() { + return $this->errormsg; + } + function getCookies() { + return $this->cookies; + } + function getRequestURL() { + $url = 'http://'.$this->host; + if ($this->port != 80) { + $url .= ':'.$this->port; + } + $url .= $this->path; + return $url; + } + // Setter methods + function setUserAgent($string) { + $this->user_agent = $string; + } + function setAuthorization($username, $password) { + $this->username = $username; + $this->password = $password; + } + function setCookies($array) { + $this->cookies = $array; + } + // Option setting methods + function useGzip($boolean) { + $this->use_gzip = $boolean; + } + function setPersistCookies($boolean) { + $this->persist_cookies = $boolean; + } + function setPersistReferers($boolean) { + $this->persist_referers = $boolean; + } + function setHandleRedirects($boolean) { + $this->handle_redirects = $boolean; + } + function setMaxRedirects($num) { + $this->max_redirects = $num; + } + function setHeadersOnly($boolean) { + $this->headers_only = $boolean; + } + function setDebug($boolean) { + $this->debug = $boolean; + } + // "Quick" static methods + function quickGet($url) { + $bits = parse_url($url); + $host = $bits['host']; + $port = isset($bits['port']) ? $bits['port'] : 80; + $path = isset($bits['path']) ? $bits['path'] : '/'; + if (isset($bits['query'])) { + $path .= '?'.$bits['query']; + } + $client = new HttpClient($host, $port); + if (!$client->get($path)) { + return false; + } else { + return $client->getContent(); + } + } + function quickPost($url, $data) { + $bits = parse_url($url); + $host = $bits['host']; + $port = isset($bits['port']) ? $bits['port'] : 80; + $path = isset($bits['path']) ? $bits['path'] : '/'; + $client = new HttpClient($host, $port); + if (!$client->post($path, $data)) { + return false; + } else { + return $client->getContent(); + } + } + function debug($msg, $object = false) { + if ($this->debug) { + print '
HttpClient Debug: '.$msg; + if ($object) { + ob_start(); + print_r($object); + $content = htmlentities(ob_get_contents()); + ob_end_clean(); + print '
'.$content.'
'; + } + print '
'; + } + } +} + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php new file mode 100755 index 0000000000..971da10f91 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php @@ -0,0 +1,73 @@ +lang = $lang; + } + + // Returns array with bad words or false if failed. + function checkWords($word_array) { + $words = array(); + $wordstr = implode(' ', $word_array); + + $matches = $this->_getMatches($wordstr); + + for ($i=0; $i_getMatches($word); + + if (count($matches) > 0) + $sug = explode("\t", $matches[0][4]); + + return $sug; + } + + function _getMatches($word_list) { + $xml = ""; + + // Setup HTTP Client + $client = new HttpClient('www.google.com'); + $client->setUserAgent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR'); + $client->setHandleRedirects(false); + $client->setDebug(false); + + // Setup XML request + $xml .= ''; + $xml .= ''; + $xml .= '' . htmlentities($word_list) . ''; + + // Execute HTTP Post to Google + if (!$client->post('/tbproxy/spell?lang=' . $this->lang, $xml)) { + $this->errorMsg[] = 'An error occurred: ' . $client->getError(); + return array(); + } + + // Grab and parse content + $xml = $client->getContent(); + preg_match_all('/([^<]*)<\/c>/', $xml, $matches, PREG_SET_ORDER); + + return $matches; + } +} + +// Setup classname, should be the same as the name of the spellchecker class +$spellCheckerConfig['class'] = "TinyGoogleSpell"; + +?> diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php new file mode 100755 index 0000000000..21fb19448e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php @@ -0,0 +1,64 @@ +lang = $lang; + $this->mode = $mode; + $this->plink = false; + $this->errorMsg = array(); + + if (!function_exists("pspell_new")) { + $this->errorMsg[] = "PSpell not found."; + return; + } + + $this->plink = pspell_new($this->lang, $this->spelling, $this->jargon, $this->encoding, $this->mode); + } + + // Returns array with bad words or false if failed. + function checkWords($wordArray) { + if (!$this->plink) { + $this->errorMsg[] = "No PSpell link found for checkWords."; + return array(); + } + + $wordError = array(); + foreach($wordArray as $word) { + if(!pspell_check($this->plink, trim($word))) + $wordError[] = $word; + } + + return $wordError; + } + + // Returns array with suggestions or false if failed. + function getSuggestion($word) { + if (!$this->plink) { + $this->errorMsg[] = "No PSpell link found for getSuggestion."; + return array(); + } + + return pspell_suggest($this->plink, $word); + } +} + +// Setup classname, should be the same as the name of the spellchecker class +$spellCheckerConfig['class'] = "TinyPspell"; + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php new file mode 100755 index 0000000000..cd75ce951e --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php @@ -0,0 +1,100 @@ +lang = $lang; + $this->mode = $mode; + $this->error = false; + $this->errorMsg = array(); + + $this->tmpfile = tempnam($config['tinypspellshell.tmp'], "tinyspell"); + $this->cmd = "cat ". $this->tmpfile ." | " . $config['tinypspellshell.aspell'] . " -a --lang=". $this->lang; + } + + // Returns array with bad words or false if failed. + function checkWords($wordArray) { + if ($fh = fopen($this->tmpfile, "w")) { + fwrite($fh, "!\n"); + foreach($wordArray as $key => $value) + fwrite($fh, "^" . $value . "\n"); + + fclose($fh); + } else { + $this->errorMsg[] = "PSpell not found."; + return array(); + } + + $data = shell_exec($this->cmd); + $returnData = array(); + $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); + + foreach($dataArr as $dstr) { + $matches = array(); + + // Skip this line. + if (strpos($dstr, "@") === 0) + continue; + + preg_match("/\& (.*) .* .*: .*/i", $dstr, $matches); + + if (!empty($matches[1])) + $returnData[] = $matches[1]; + } + + return $returnData; + } + + // Returns array with suggestions or false if failed. + function getSuggestion($word) { + if ($fh = fopen($this->tmpfile, "w")) { + fwrite($fh, "!\n"); + fwrite($fh, "^$word\n"); + fclose($fh); + } else + die("Error opening tmp file."); + + $data = shell_exec($this->cmd); + $returnData = array(); + $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY); + + foreach($dataArr as $dstr) { + $matches = array(); + + // Skip this line. + if (strpos($dstr, "@") === 0) + continue; + + preg_match("/\& .* .* .*: (.*)/i", $dstr, $matches); + + if (!empty($matches[1])) { + // For some reason, the exec version seems to add commas? + $returnData[] = str_replace(",", "", $matches[1]); + } + } + return $returnData; + } +} + +// Setup classname, should be the same as the name of the spellchecker class +$spellCheckerConfig['class'] = "TinyPspellShell"; + +?> \ No newline at end of file diff --git a/wp-includes/js/tinymce/plugins/spellchecker/config.php b/wp-includes/js/tinymce/plugins/spellchecker/config.php new file mode 100755 index 0000000000..a528565a33 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/config.php @@ -0,0 +1,29 @@ + diff --git a/wp-includes/js/tinymce/plugins/spellchecker/css/content.css b/wp-includes/js/tinymce/plugins/spellchecker/css/content.css new file mode 100755 index 0000000000..fb82733cd5 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/css/content.css @@ -0,0 +1,5 @@ +.mceItemHiddenSpellWord { + background: url('../images/wline.gif') repeat-x bottom left; + bo2rder-bottom: 1px dashed red; + cursor: default; +} diff --git a/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css b/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css new file mode 100755 index 0000000000..aa4a8ea3b0 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css @@ -0,0 +1,34 @@ +.mceMsgBox { + border: 1px solid gray; + padding: 8px; +} + +.mceMsgBox span { + vertical-align: top; + color: #555555; +} + +/* Misc */ + +.mceBlockBox { + display: none; + position: absolute; + left: 0; + top: 0; + z-index: 100; + filter:progid:DXImageTransform.Microsoft.Alpha(style=0, opacity=60); + -moz-opacity:0.6; + opacity: 0.6; + background-color: white; +} + +.mceMsgBox { + display: none; + z-index: 101; + position: absolute; + left: 0; + top: 0; + font-family: Arial, Verdana, Tahoma, Helvetica; + font-weight: bold; + font-size: 11px; +} diff --git a/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js b/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js new file mode 100755 index 0000000000..ab3fc6bda5 --- /dev/null +++ b/wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js @@ -0,0 +1,573 @@ +/** + * $RCSfile: editor_plugin_src.js,v $ + * $Revision: 1.4 $ + * $Date: 2006/03/24 17:24:50 $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + */ + +tinyMCE.importPluginLanguagePack('spellchecker', 'en,sv,nn,nb'); + +// Plucin static class +var TinyMCE_SpellCheckerPlugin = { + _contextMenu : new TinyMCE_Menu(), + _menu : new TinyMCE_Menu(), + _counter : 0, + + getInfo : function() { + return { + longname : 'Spellchecker', + author : 'Moxiecode Systems AB', + authorurl : 'http://tinymce.moxiecode.com', + infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_spellchecker.html', + version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion + }; + }, + + handleEvent : function(e) { + var elm = tinyMCE.isMSIE ? e.srcElement : e.target; + var inst = tinyMCE.selectedInstance, args = ''; + var self = TinyMCE_SpellCheckerPlugin; + var cm = self._contextMenu; + var p, p2, x, y, sx, sy, h, elm; + + // Handle click on word + if ((e.type == "click" || e.type == "contextmenu") && elm) { + do { + if (tinyMCE.getAttrib(elm, 'class') == "mceItemHiddenSpellWord") { + inst.spellCheckerElm = elm; + + // Setup arguments + args += 'id=' + inst.editorId + "|" + (++self._counter); + args += '&cmd=suggest&check=' + escape(elm.innerHTML); + args += '&lang=' + escape(inst.spellCheckerLang); + + elm = inst.spellCheckerElm; + p = tinyMCE.getAbsPosition(inst.iframeElement); + p2 = tinyMCE.getAbsPosition(elm); + h = parseInt(elm.offsetHeight); + sx = inst.getBody().scrollLeft; + sy = inst.getBody().scrollTop; + x = p.absLeft + p2.absLeft - sx; + y = p.absTop + p2.absTop - sy + h; + + cm.clear(); + cm.addTitle(tinyMCE.getLang('lang_spellchecker_wait', '', true)); + cm.show(); + cm.moveTo(x, y); + + inst.selection.selectNode(elm, false, false); + + self._sendAjax(self.baseURL + "/tinyspell.php", self._ajaxResponse, 'post', args); + + tinyMCE.cancelEvent(e); + return false; + } + } while ((elm = elm.parentNode)); + } + + return true; + }, + + initInstance : function(inst) { + var self = TinyMCE_SpellCheckerPlugin, m = self._menu, cm = self._contextMenu, e; + + tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/spellchecker/css/content.css"); + + if (!tinyMCE.hasMenu('spellcheckercontextmenu')) { + tinyMCE.importCSS(document, tinyMCE.baseURL + "/plugins/spellchecker/css/spellchecker.css"); + + cm.init({drop_menu : false}); + tinyMCE.addMenu('spellcheckercontextmenu', cm); + } + + if (!tinyMCE.hasMenu('spellcheckermenu')) { + m.init({}); + tinyMCE.addMenu('spellcheckermenu', m); + } + + inst.spellCheckerLang = 'en'; + self._buildSettingsMenu(inst, null); + + e = self._getBlockBoxLayer(inst).create('div', 'mceBlockBox', document.getElementById(inst.editorId + '_parent')); + self._getMsgBoxLayer(inst).create('div', 'mceMsgBox', document.getElementById(inst.editorId + '_parent')); + }, + + _getMsgBoxLayer : function(inst) { + if (!inst.spellCheckerMsgBoxL) + inst.spellCheckerMsgBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerMsgBox', false); + + return inst.spellCheckerMsgBoxL; + }, + + _getBlockBoxLayer : function(inst) { + if (!inst.spellCheckerBoxL) + inst.spellCheckerBoxL = new TinyMCE_Layer(inst.editorId + '_spellcheckerBlockBox', false); + + return inst.spellCheckerBoxL; + }, + + _buildSettingsMenu : function(inst, lang) { + var i, ar = tinyMCE.getParam('spellchecker_languages', '+English=en').split(','), p; + var self = TinyMCE_SpellCheckerPlugin, m = self._menu, c; + + m.clear(); + m.addTitle(tinyMCE.getLang('lang_spellchecker_langs', '', true)); + + for (i=0; i'; + h += ''; + h += ''; + h += ''; + } else { + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + 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.*$/, ''); + }, + + _toggleMenu : function(editor_id, id) { + var self = TinyMCE_SpellCheckerPlugin; + var e = document.getElementById(editor_id + '_spellchecker'); + var inst = tinyMCE.getInstanceById(editor_id); + + if (self._menu.isVisible()) { + tinyMCE.hideMenus(); + return; + } + + tinyMCE.lastMenuBtnClass = e.className.replace(/\s.*$/, ''); + tinyMCE.switchClass(editor_id + '_spellchecker', 'mceMenuButtonFocus'); + + self._menu.moveRelativeTo(e, 'bl'); + self._menu.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? 0 : 1, -1); + + if (tinyMCE.isOpera) + self._menu.moveBy(0, -2); + + self._onMenuEvent(inst, self._menu, 'show'); + + self._menu.show(); + + tinyMCE.lastSelectedMenuBtn = editor_id + '_spellchecker'; + }, + + _onMenuEvent : function(inst, m, n) { + TinyMCE_SpellCheckerPlugin._buildSettingsMenu(inst, inst.spellCheckerLang); + }, + + execCommand : function(editor_id, element, command, user_interface, value) { + var inst = tinyMCE.getInstanceById(editor_id), self = TinyMCE_SpellCheckerPlugin, args = '', co, bb, mb, nl, i, e; + + // Handle commands + switch (command) { + case "mceSpellCheck": + if (!inst.spellcheckerOn) { + inst.spellCheckerBookmark = inst.selection.getBookmark(); + + // Setup arguments + args += 'id=' + inst.editorId + "|" + (++self._counter); + args += '&cmd=spell&check=' + escape(self._getWordList(inst.getBody())).replace(/%20/g, '+'); + args += '&lang=' + escape(inst.spellCheckerLang); + + co = document.getElementById(inst.editorId + '_parent').firstChild; + bb = self._getBlockBoxLayer(inst); + bb.moveRelativeTo(co, 'tl'); + bb.resizeTo(co.offsetWidth, co.offsetHeight); + bb.show(); + + // Setup message box + mb = self._getMsgBoxLayer(inst); + e = mb.getElement(); + e.innerHTML = '' + tinyMCE.getLang('lang_spellchecker_swait', '', true) + ''; + mb.show(); + mb.moveRelativeTo(co, 'cc'); + + if (tinyMCE.isMSIE && !tinyMCE.isOpera) { + nl = co.getElementsByTagName('select'); + for (i=0; i?@[\]^_{|}§©«®±¶·¸»¼½¾¿×÷¤\u201d\u201c'); + + for (i=0; i=0; i--) { + c = tinyMCE.getAttrib(nl[i], 'class'); + + if ((c == 'mceItemHiddenSpellWord' || c == 'mceItemHidden') && (word == null || nl[i].innerHTML == word)) + self._removeWord(nl[i]); + } + + if (b) + inst.selection.moveToBookmark(b); + }, + + _checkDone : function(inst) { + var i, w = 0, nl = inst.getDoc().getElementsByTagName("span") + var self = TinyMCE_SpellCheckerPlugin; + + for (i=nl.length-1; i>=0; i--) { + c = tinyMCE.getAttrib(nl[i], 'class'); + + if (c == 'mceItemHiddenSpellWord') + w++; + } + + if (w == 0) { + self._removeWords(inst.getDoc()); + inst.spellcheckerOn = false; + tinyMCE.switchClass(inst.editorId + '_spellchecker', 'mceMenuButton'); + } + }, + + _removeWord : function(e) { + tinyMCE.setOuterHTML(e, e.innerHTML); + }, + + _markWords : function(doc, n, wl) { + var i, nv, nn, nl = tinyMCE.getNodeTree(n, new Array(), 3); + var r1, r2, r3, r4, r5, w = ''; + var re = TinyMCE_SpellCheckerPlugin._getWordSeparators(); + + for (i=0; i$1$2'); + nv = nv.replace(r3, '$1$2'); + + nn = doc.createElement('span'); + nn.className = "mceItemHidden"; + nn.innerHTML = nv; + + // Remove old text node + nl[i].parentNode.replaceChild(nn, nl[i]); + } + } + }, + + _buildMenu : function(sg, max) { + var i, self = TinyMCE_SpellCheckerPlugin, cm = self._contextMenu; + + cm.clear(); + + if (sg != null) { + cm.addTitle(tinyMCE.getLang('lang_spellchecker_sug', '', true)); + + for (i=0; i'; + die; + } + + // Basic config + $defaultLanguage = $spellCheckerConfig['default.language']; + $defaultMode = $spellCheckerConfig['default.mode']; + + // Normaly not required to configure + $defaultSpelling = $spellCheckerConfig['default.spelling']; + $defaultJargon = $spellCheckerConfig['default.jargon']; + $defaultEncoding = $spellCheckerConfig['default.encoding']; + $outputType = "xml"; // Do not change + + // Get input parameters. + + $check = $_POST['check']; + $cmd = sanitize($_POST['cmd']); + $lang = sanitize($_POST['lang'], "strict"); + $mode = sanitize($_POST['mode'], "strict"); + $spelling = sanitize($_POST['spelling'], "strict"); + $jargon = sanitize($_POST['jargon'], "strict"); + $encoding = sanitize($_POST['encoding'], "strict"); + $sg = sanitize($_POST['sg'], "bool"); + $words = array(); + + $validRequest = true; + + if (empty($check)) + $validRequest = false; + + if (empty($lang)) + $lang = $defaultLanguage; + + if (empty($mode)) + $mode = $defaultMode; + + if (empty($spelling)) + $spelling = $defaultSpelling; + + if (empty($jargon)) + $jargon = $defaultJargon; + + if (empty($encoding)) + $encoding = $defaultEncoding; + + function sanitize($str, $type="strict") { + switch ($type) { + case "strict": + $str = preg_replace("/[^a-zA-Z0-9_\-]/i", "", $str); + break; + case "loose": + $str = preg_replace("//i", "<", $str); + break; + case "bool": + if ($str == "true" || $str == true) + $str = true; + else + $str = false; + break; + } + + return $str; + } + + $result = array(); + $tinyspell = new $spellCheckerConfig['class']($spellCheckerConfig, $lang, $mode, $spelling, $jargon, $encoding); + + if (count($tinyspell->errorMsg) == 0) { + switch($cmd) { + case "spell": + // Space for non-exec version and \n for the exec version. + $words = preg_split("/ |\n/", $check, -1, PREG_SPLIT_NO_EMPTY); + $result = $tinyspell->checkWords($words); + break; + case "suggest": + $result = $tinyspell->getSuggestion($check); + break; + default: + // Just use this for now. + $tinyspell->errorMsg[] = "No command."; + $outputType = $outputType . "error"; + break; + } + } else + $outputType = $outputType . "error"; + + if (!$result) + $result = array(); + + // Output data + switch($outputType) { + case "xml": + header('Content-type: text/xml; charset=utf-8'); + echo ''; + echo "\n"; + if (count($result) == 0) + echo ''; + else + echo ''. utf8_encode(implode(" ", $result)) .''; + + break; + case "xmlerror"; + header('Content-type: text/xml; charset=utf-8'); + echo ''; + echo "\n"; + echo 'errorMsg) .'" />'; + break; + case "html": + var_dump($result); + break; + case "htmlerror": + echo "Error"; + break; + } +?> diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js index 697ba7216b..e5067c0fef 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js +++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js @@ -1,285 +1,400 @@ -/* Import plugin specific language pack */ -tinyMCE.importPluginLanguagePack('wordpress', ''); - -function TinyMCE_wordpress_initInstance(inst) { - if (!tinyMCE.settings['wordpress_skip_plugin_css']) - tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css"); -} - -function TinyMCE_wordpress_getControlHTML(control_name) { - switch (control_name) { - case "wordpress": - var titleMore = tinyMCE.getLang('lang_wordpress_more_button'); - var titlePage = tinyMCE.getLang('lang_wordpress_page_button'); - var titleHelp = tinyMCE.getLang('lang_wordpress_help_button'); - var buttons = ''; - // Add this to the buttons var to put the Page button into the toolbar. - // ''; - return buttons; - } - - return ''; -} - -function TinyMCE_wordpress_parseAttributes(attribute_string) { - var attributeName = ""; - var attributeValue = ""; - var withInName; - var withInValue; - var attributes = new Array(); - var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); - var titleText = tinyMCE.getLang('lang_wordpress_more'); - var titleTextPage = tinyMCE.getLang('lang_wordpress_page'); - - if (attribute_string == null || attribute_string.length < 2) - return null; - - withInName = withInValue = false; - - for (var i=0; i'; - tinyMCE.execCommand("mceInsertContent",true,html); - tinyMCE.selectedInstance.repaint(); - return true; - case "mcewordpresspage": - var flag = ""; - var template = new Array(); - var altPage = tinyMCE.getLang('lang_wordpress_more_alt'); - - // Is selection a image - if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { - flag = getAttrib(focusElm, 'name'); - - if (flag != 'mce_plugin_wordpress_page') // Not a wordpress - return true; - - action = "update"; - } - - html = '' - + ''; - tinyMCE.execCommand("mceInsertContent",true,html); - tinyMCE.selectedInstance.repaint(); - return true; - } - - // Pass to next handler in chain - return false; -} - -function TinyMCE_wordpress_cleanup(type, content) { - switch (type) { - - case "insert_to_editor": - var startPos = 0; - var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); - var altPage = tinyMCE.getLang('lang_wordpress_page_alt'); - - // Parse all tags and replace them with images - while ((startPos = content.indexOf('', startPos)) != -1) { - // Insert image - var contentAfter = content.substring(startPos + 11); - content = content.substring(0, startPos); - content += ''; - content += contentAfter; - - startPos++; - } - var startPos = 0; - - // Parse all tags and replace them with images - while ((startPos = content.indexOf('', startPos)) != -1) { - // Insert image - var contentAfter = content.substring(startPos + 15); - content = content.substring(0, startPos); - content += ''; - content += contentAfter; - - startPos++; - } - - // It's supposed to be WYSIWYG, right? - content = content.replace(new RegExp('&', 'g'), '&'); - - break; - - case "get_from_editor": - // Parse all img tags and replace them with - var startPos = -1; - while ((startPos = content.indexOf('', startPos); - var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos)); - - if (attribs['class'] == "mce_plugin_wordpress_more") { - endPos += 2; - - var embedHTML = ''; - - // Insert embed/object chunk - chunkBefore = content.substring(0, startPos); - chunkAfter = content.substring(endPos); - content = chunkBefore + embedHTML + chunkAfter; - } - if (attribs['class'] == "mce_plugin_wordpress_page") { - endPos += 2; - - var embedHTML = ''; - - // Insert embed/object chunk - chunkBefore = content.substring(0, startPos); - chunkAfter = content.substring(endPos); - content = chunkBefore + embedHTML + chunkAfter; - } - } - - // If it says & in the WYSIWYG editor, it should say & in the html. - content = content.replace(new RegExp('&', 'g'), '&'); - content = content.replace(new RegExp('&nbsp;', 'g'), ' '); - - // Remove anonymous, empty paragraphs. - content = content.replace(new RegExp('

(\\s| )*

', 'mg'), ''); - - // Handle table badness. - content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>'); - content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>'); - content = content.replace(new RegExp('.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '<$2>'); - content = content.replace(new RegExp('.*?<(tr|/table)>', 'mg'), '<$1>'); - content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(
)*)*', 'g'), '<$1>'); - - // Pretty it up for the source editor. - var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p'; - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>'); - content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>'); - content = content.replace(new RegExp('\\s*
\\s*', 'mg'), '
\n'); - content = content.replace(new RegExp('^\\s*', ''), ''); - content = content.replace(new RegExp('\\s*$', ''), ''); - - break; - } - - // Pass through to next handler in chain - return content; -} - -function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { - function getAttrib(elm, name) { - return elm.getAttribute(name) ? elm.getAttribute(name) : ""; - } - - tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal'); - tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal'); - - if (node == null) - return; - - do { - if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0) - tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected'); - if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0) - tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected'); - } while ((node = node.parentNode)); - - return true; -} - -function wp_save_callback(el, content, body) { - // We have a TON of cleanup to do. - - // Mark

if it has any attributes. - content = content.replace(new RegExp('(]+>.*?)

', 'mg'), '$1'); - - // Decode the ampersands of time. - content = content.replace(new RegExp('&', 'g'), '&'); - - // Get it ready for wpautop. - content = content.replace(new RegExp('[\\s]*

[\\s]*', 'mgi'), ''); - content = content.replace(new RegExp('[\\s]*

[\\s]*', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n'); - content = content.replace(new RegExp('\\s*
\\s*', 'gi'), '\n'); - - // Fix some block element newline issues - var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; - content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); - content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); - content = content.replace(new RegExp('
  • ', 'g'), '\t
  • '); - - // Unmark special paragraph closing tags - content = content.replace(new RegExp('', 'g'), '

    \n'); - content = content.replace(new RegExp('\\s*(]+>.*

    )', 'mg'), '\n$1'); - - // Trim any whitespace - content = content.replace(new RegExp('^\\s*', ''), ''); - content = content.replace(new RegExp('\\s*$', ''), ''); - - // Hope. - return content; - -} +/* Import plugin specific language pack */ +tinyMCE.importPluginLanguagePack('wordpress', 'en'); + +var TinyMCE_wordpressPlugin = { + getInfo : function() { + return { + longname : 'WordPress Plugin', + author : 'WordPress', + authorurl : 'http://wordpress.org', + infourl : 'http://wordpress.org', + version : '1' + }; + }, + + getControlHTML : function(control_name) { + switch (control_name) { + case "wp_more": + return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_more_button', '{$pluginurl}/images/more.gif', 'wpMore'); + case "wp_page": + return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_page_button', '{$pluginurl}/images/page.gif', 'wpPage'); + case "wp_help": + var buttons = tinyMCE.getButtonHTML(control_name, 'lang_help_button_title', '{$pluginurl}/images/help.gif', 'wpHelp'); + var hiddenControls = '
    ' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    '; + return buttons+hiddenControls; + case "wp_adv": + return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_adv_button', '{$pluginurl}/images/toolbars.gif', 'wpAdv'); + case "wp_adv_start": + return ''; + } + return ''; + }, + + execCommand : function(editor_id, element, command, user_interface, value) { + var inst = tinyMCE.getInstanceById(editor_id); + var focusElm = inst.getFocusElement(); + var doc = inst.getDoc(); + + function getAttrib(elm, name) { + return elm.getAttribute(name) ? elm.getAttribute(name) : ""; + } + + // Handle commands + switch (command) { + case "wpMore": + var flag = ""; + var template = new Array(); + var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); + + // Is selection a image + if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { + flag = getAttrib(focusElm, 'class'); + + if (flag != 'mce_plugin_wordpress_more') // Not a wordpress + return true; + + action = "update"; + } + + html = '' + + ''; + tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html); + tinyMCE.selectedInstance.repaint(); + return true; + + case "wpPage": + var flag = ""; + var template = new Array(); + var altPage = tinyMCE.getLang('lang_wordpress_more_alt'); + + // Is selection a image + if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { + flag = getAttrib(focusElm, 'name'); + + if (flag != 'mce_plugin_wordpress_page') // Not a wordpress + return true; + + action = "update"; + } + + html = '' + + ''; + tinyMCE.execCommand("mceInsertContent",true,html); + tinyMCE.selectedInstance.repaint(); + return true; + + case "wpHelp": + var template = new Array(); + + template['file'] = tinyMCE.baseURL + '/wp-mce-help.php'; + template['width'] = 480; + template['height'] = 380; + + args = { + resizable : 'yes', + scrollbars : 'yes' + }; + + tinyMCE.openWindow(template, args); + return true; + case "wpAdv": + var adv = document.getElementById('wpadvbar'); + if ( adv.style.display == 'none' ) { + adv.style.display = 'block'; + tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonSelected'); + } else { + adv.style.display = 'none'; + tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonNormal'); + } + return true; + } + + // Pass to next handler in chain + return false; + }, + + cleanup : function(type, content) { + switch (type) { + + case "insert_to_editor": + var startPos = 0; + var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); + var altPage = tinyMCE.getLang('lang_wordpress_page_alt'); + + // Parse all tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 11); + content = content.substring(0, startPos); + content += ''; + content += contentAfter; + + startPos++; + } + var startPos = 0; + + // Parse all tags and replace them with images + while ((startPos = content.indexOf('', startPos)) != -1) { + // Insert image + var contentAfter = content.substring(startPos + 15); + content = content.substring(0, startPos); + content += ''; + content += contentAfter; + + startPos++; + } + + // Look for \n in
    , replace with 
    + var startPos = -1; + while ((startPos = content.indexOf('', startPos+1); + var innerPos = content.indexOf('>', startPos+1); + var chunkBefore = content.substring(0, innerPos); + var chunkAfter = content.substring(endPos); + + var innards = content.substring(innerPos, endPos); + innards = innards.replace(/\n/g, '
    '); + content = chunkBefore + innards + chunkAfter; + } + + break; + + case "get_from_editor": + // Parse all img tags and replace them with + var startPos = -1; + while ((startPos = content.indexOf('', startPos); + var attribs = this._parseAttributes(content.substring(startPos + 4, endPos)); + + if (attribs['class'] == "mce_plugin_wordpress_more" || attribs['name'] == "mce_plugin_wordpress_more") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + if (attribs['class'] == "mce_plugin_wordpress_page" || attribs['name'] == "mce_plugin_wordpress_page") { + endPos += 2; + + var embedHTML = ''; + + // Insert embed/object chunk + chunkBefore = content.substring(0, startPos); + chunkAfter = content.substring(endPos); + content = chunkBefore + embedHTML + chunkAfter; + } + } + + // Remove normal line breaks + content = content.replace(/\n|\r/g, ' '); + + // Look for
    in
    , replace with \n
    +				var startPos = -1;
    +				while ((startPos = content.indexOf('', startPos+1);
    +					var innerPos = content.indexOf('>', startPos+1);
    +					var chunkBefore = content.substring(0, innerPos);
    +					var chunkAfter = content.substring(endPos);
    +					
    +					var innards = content.substring(innerPos, endPos);
    +					innards = innards.replace(new RegExp('', 'g'), '\n');
    +					innards = innards.replace(new RegExp('\\s$', ''), '');
    +					content = chunkBefore + innards + chunkAfter;
    +				}
    +
    +				// Remove anonymous, empty paragraphs.
    +				content = content.replace(new RegExp('

    (\\s| )*

    ', 'mg'), ''); + + // Handle table badness. + content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>'); + content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>'); + content = content.replace(new RegExp('.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '<$2>'); + content = content.replace(new RegExp('.*?<(tr|/table)>', 'mg'), '<$1>'); + content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(
    )*)*', 'g'), '<$1>'); + + // Pretty it up for the source editor. + var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p'; + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>'); + content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>'); + content = content.replace(new RegExp('\\s*
    \\s*', 'mg'), '
    \n'); + content = content.replace(new RegExp('^\\s*', ''), ''); + content = content.replace(new RegExp('\\s*$', ''), ''); + + break; + } + + // Pass through to next handler in chain + return content; + }, + + handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { + + tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonNormal'); + tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonNormal'); + + if (node == null) + return; + + do { + if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0) + tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonSelected'); + if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0) + tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonSelected'); + } while ((node = node.parentNode)); + + return true; + }, + + saveCallback : function(el, content, body) { + // We have a TON of cleanup to do. + + // Mark

    if it has any attributes. + content = content.replace(new RegExp('(]+>.*?)

    ', 'mg'), '$1'); + + // Decode the ampersands of time. + // content = content.replace(new RegExp('&', 'g'), '&'); + + // Get it ready for wpautop. + content = content.replace(new RegExp('[\\s]*

    [\\s]*', 'mgi'), ''); + content = content.replace(new RegExp('[\\s]*

    [\\s]*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n'); + content = content.replace(new RegExp('\\s*
    \\s*', 'gi'), '\n'); + + // Fix some block element newline issues + var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre'; + content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); + content = content.replace(new RegExp('\\s*\\s*', 'mg'), '\n'); + content = content.replace(new RegExp('
  • ', 'g'), '\t
  • '); + + // Unmark special paragraph closing tags + content = content.replace(new RegExp('', 'g'), '

    \n'); + content = content.replace(new RegExp('\\s*(]+>.*

    )', 'mg'), '\n$1'); + + // Trim any whitespace + content = content.replace(new RegExp('^\\s*', ''), ''); + content = content.replace(new RegExp('\\s*$', ''), ''); + + // Hope. + return content; + + }, + + _parseAttributes : function(attribute_string) { + var attributeName = ""; + var attributeValue = ""; + var withInName; + var withInValue; + var attributes = new Array(); + var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g'); + var titleText = tinyMCE.getLang('lang_wordpress_more'); + var titleTextPage = tinyMCE.getLang('lang_wordpress_page'); + + if (attribute_string == null || attribute_string.length < 2) + return null; + + withInName = withInValue = false; + + for (var i=0; i]*\\s)?)(src|href)\\s*=', 'gi'), '<$1 x$4='); + else + h = tinyMCE.orgFixGeckoBaseHREFBug(m, e, h); + + return h; +}; + +tinyMCE.orgStoreAwayURLs = tinyMCE.storeAwayURLs; +tinyMCE.storeAwayURLs = function(s) { + // Remove all mce_src, mce_href and replace them with new ones + s = s.replace(new RegExp('mce_(href|src)\\s*=\\s*\"[^ >\"]*\"', 'gi'), ''); + s = s.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=\\s*"([^"]*)"', 'gi'), '<$1 $4="$5" mce_$4="$5"'); + + return s; +}; diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/help.gif b/wp-includes/js/tinymce/plugins/wordpress/images/help.gif index 933d853a6f..51a1ee4207 100644 Binary files a/wp-includes/js/tinymce/plugins/wordpress/images/help.gif and b/wp-includes/js/tinymce/plugins/wordpress/images/help.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif b/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif new file mode 100755 index 0000000000..dcb70665f8 Binary files /dev/null and b/wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif differ diff --git a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js index c9daa5b80b..f38e89d1db 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/langs/en.js +++ b/wp-includes/js/tinymce/plugins/wordpress/langs/en.js @@ -9,8 +9,25 @@ else { } tinyMCE.addToLang('',{ -wordpress_more_button : 'Split post with More tag (' + metaKey + '-t)', +wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)', wordpress_page_button : 'Split post with Page tag', +wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+b)', wordpress_more_alt : 'More...', -wordpress_page_alt : '...page...' +wordpress_page_alt : '...page...', +help_button_title : 'Help (' + metaKey + '+h)', +bold_desc : 'Bold (Ctrl+B)', +italic_desc : 'Italic (Ctrl+I)', +underline_desc : 'Underline (Ctrl+U)', +link_desc : 'Insert/edit link (' + metaKey + '+a)', +unlink_desc : 'Unlink (' + metaKey + '+s)', +image_desc : 'Insert/edit image (' + metaKey + '+m)', +striketrough_desc : 'Strikethrough (' + metaKey + '+k)', +justifyleft_desc : 'Align left (' + metaKey + '+f)', +justifycenter_desc : 'Align center (' + metaKey + '+c)', +justifyright_desc : 'Align right (' + metaKey + '+r)', +justifyfull_desc : 'Align full (' + metaKey + '+j)', +bullist_desc : 'Unordered list (' + metaKey + '+l)', +numlist_desc : 'Ordered list (' + metaKey + '+o)', +outdent_desc : 'Outdent (' + metaKey + '+w)', +indent_desc : 'Indent List/Blockquote (' + metaKey + '+q)' }); diff --git a/wp-includes/js/tinymce/plugins/wordpress/popups.css b/wp-includes/js/tinymce/plugins/wordpress/popups.css new file mode 100644 index 0000000000..2d9766533b --- /dev/null +++ b/wp-includes/js/tinymce/plugins/wordpress/popups.css @@ -0,0 +1,354 @@ +/* This file contains the CSS data for all popups in TinyMCE */ + +body { + background-color: #F0F0EE; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; + margin: 8px; +} + +td { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 11px; +} + +input { + background: #FFFFFF; + border: 1px solid #cccccc; +} + +td, input, select, textarea { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + +input, select, textarea { + border: 1px solid #808080; +} + +.input_noborder { + border: 0; +} + +#insert, .updateButton { + font-weight: bold; + width: 90px; + height: 21px; + border: 0; + background-image: url('../images/insert_button_bg.gif'); + cursor: pointer; +} + +#cancel { + font-weight: bold; + width: 90px; + height: 21px; + border: 0; + background-image: url('../images/cancel_button_bg.gif'); + cursor: pointer; +} + +/* Mozilla only style */ +html>body #insert, html>body #cancel { + padding-bottom: 2px; +} + +.title { + display: block; + padding-top: 5px; + padding-bottom: 5px; + padding-left: 15px; + font-size: 15px; +} + + +table.charmap { + border-style: solid; + border-width: 1px; + border-color: #AAAAAA; +} + +td.charmap, td.charmapOver { + color: #000000; + border-color: #AAAAAA; + border-style: solid; + border-width: 1px; + text-align: center; + font-size: 12px; +} + +td.charmapOver { + background-color: #CCCCCC; + cursor: default; +} + +a.charmap { + color: #000000; + text-decoration: none +} + +.wordWrapCode { + vertical-align: middle; + border: 1px none #000000; + background-color: transparent; +} + +input.radio { + border: 1px none #000000; + background-color: transparent; + vertical-align: middle; +} + +input.checkbox { + border: 1px none #000000; + background-color: transparent; + vertical-align: middle; +} + +.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceButtonDisabled, .mceButtonSelected { + margin-left: 1px; +} + +.mceButtonNormal { + border-top: 1px solid; + border-left: 1px solid; + border-bottom: 1px solid; + border-right: 1px solid; + border-color: #F0F0EE; + cursor: default; +} + +.mceButtonOver { + border: 1px solid #0A246A; + cursor: default; + background-color: #B6BDD2; +} + +.mceButtonDown { + cursor: default; + border: 1px solid #0A246A; + background-color: #8592B5; +} + +.mceButtonDisabled { + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); + -moz-opacity:0.3; + opacity: 0.3; + border-top: 1px solid; + border-left: 1px solid; + border-bottom: 1px solid; + border-right: 1px solid; + border-color: #F0F0EE; + cursor: default; +} + +.mceActionPanel { + margin-top: 5px; +} + +/* Tabs classes */ + +.tabs { + float: left; + width: 100%; + line-height: normal; + background-image: url("../images/xp/tabs_bg.gif"); +} + +.tabs ul { + margin: 0; + padding: 0 0 0; + list-style: none; +} + +.tabs li { + float: left; + background: url("../images/xp/tab_bg.gif") no-repeat left top; + margin: 0; + margin-left: 0; + margin-right: 2px; + padding: 0 0 0 10px; + line-height: 18px; +} + +.tabs li.current { + background: url("../images/xp/tab_sel_bg.gif") no-repeat left top; + margin-right: 2px; +} + +.tabs span { + float: left; + display: block; + background: url("../images/xp/tab_end.gif") no-repeat right top; + padding: 0px 10px 0 0; +} + +.tabs .current span { + background: url("../images/xp/tab_sel_end.gif") no-repeat right top; +} + +.tabs a { + text-decoration: none; + font-family: Verdana, Arial; + font-size: 10px; +} + +.tabs a:link, .tabs a:visited, .tabs a:hover { + color: black; +} + +.tabs a:hover { +} + +.tabs .current { +} + +.tabs .current a, .tabs .current a:link, .tabs .current a:visited { +} + +.panel_wrapper div.panel { + display: none; +} + +.panel_wrapper div.current { + display: block; + width: 100%; + height: 300px; + overflow: visible; /* Should be auto but that breaks Safari */ +} + +.panel_wrapper { + border: 1px solid #919B9C; + border-top: 0px; + padding: 10px; + padding-top: 5px; + clear: both; + background-color: white; +} + +fieldset { + border: 1px solid #919B9C; + font-family: Verdana, Arial; + font-size: 10px; + padding: 0; + margin: 0; + padding: 4px; +} + +legend { + color: #2B6FB6; + font-weight: bold; +} + +.properties { + width: 100%; +} + +.properties .column1 { +} + +.properties .column2 { + text-align: left; +} + +a:link, a:visited { + color: black; +} + +a:hover { + color: #2B6FB6; +} + +#plugintable thead { + font-weight: bold; + background-color: #DDDDDD; +} + +#plugintable, #about #plugintable td { + border: 1px solid #919B9C; +} + +#plugintable { + width: 99%; + margin-top: 10px; +} + +#pluginscontainer { + height: 290px; + overflow: auto; +} + +/* MSIE Specific styles */ + +* html .panel_wrapper { + width: 100%; +} + +.column { + float: left; +} + +h1, h2, h3, h4 { + color: #2B6FB6; + margin: 0; + padding: 0; + padding-top: 5px; +} + +h3 { + font-size: 14px; +} + +#link .panel_wrapper, #link div.current { + height: 125px; +} + +#image .panel_wrapper, #image div.current { + height: 190px; +} + +/* Disables the advanced tab in the table plugin. */ +/* +#table #advanced_tab { + display: none; +} +*/ + +/* Disables the border input field and label in the table plugin. */ +/* +#table #border, #table #borderlabel { + display: none; +} +*/ + +#insert, #cancel, .submitbutton { + font: 13px Verdana, Arial, Helvetica, sans-serif; + height: auto; + width: auto; + background-color: transparent; + background-image: url(../../../../../wp-admin/images/fade-butt.png); + background-repeat: repeat; + border: 3px double; + border-right-color: rgb(153, 153, 153); + border-bottom-color: rgb(153, 153, 153); + border-left-color: rgb(204, 204, 204); + border-top-color: rgb(204, 204, 204); + color: rgb(51, 51, 51); + padding: 0.25em 0.75em; +} + +#insert:active, #cancel:active, .submitbutton:active { + background: #f4f4f4; + border-left-color: #999; + border-top-color: #999; +} + + diff --git a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css index b51a098482..3698741b7c 100644 --- a/wp-includes/js/tinymce/plugins/wordpress/wordpress.css +++ b/wp-includes/js/tinymce/plugins/wordpress/wordpress.css @@ -19,3 +19,66 @@ background-repeat: no-repeat; background-position: right top; } + +/* This file contains the CSS data for the editable area(iframe) of TinyMCE */ +/* You can extend this CSS by adding your own CSS file with the the content_css option */ + +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 0.9em; + line-height: 1.2em; + padding: .3em; + background-color: #FFFFFF; +} + +td { + font-size: 10px; +} + +pre { + font-family: "Courier New", fixed; + font-size: 11px; + line-height: 13px; +} + +.mceVisualAid { + border: 1px dashed #BBBBBB !important; +} + +.mceItemAnchor { + width: 12px; + line-height: 6px; + overflow: hidden; + padding-left: 12px; + background-image: url('../images/anchor_symbol.gif'); + background-position: bottom; + background-repeat: no-repeat; +} + +/* Important is needed in Gecko browsers inorder to style links */ +/* +a { + color: green !important; +} +*/ + +/* Style selection range colors in Gecko browsers */ +/* +::-moz-selection { + background-color: red; + color: green; +} +*/ + +/* MSIE specific */ + +* html body { + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; +} \ No newline at end of file diff --git a/wp-includes/js/tinymce/themes/advanced/about.htm b/wp-includes/js/tinymce/themes/advanced/about.htm index bbd8d1389a..2a86227fbd 100644 --- a/wp-includes/js/tinymce/themes/advanced/about.htm +++ b/wp-includes/js/tinymce/themes/advanced/about.htm @@ -4,7 +4,7 @@ - +
    @@ -21,7 +21,7 @@

    Version: {$tinymce_version} ({$tinymce_releasedate})

    TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.

    -

    Copyright © 2005, Moxiecode Systems AB, All rights reserved.

    +

    Copyright © 2003-2006, Moxiecode Systems AB, All rights reserved.

    For more information about this software visit the TinyMCE website.

    diff --git a/wp-includes/js/tinymce/themes/advanced/anchor.htm b/wp-includes/js/tinymce/themes/advanced/anchor.htm index 48ba245f49..988bcb68ed 100644 --- a/wp-includes/js/tinymce/themes/advanced/anchor.htm +++ b/wp-includes/js/tinymce/themes/advanced/anchor.htm @@ -3,6 +3,7 @@ {$lang_insert_anchor_title} +
    diff --git a/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-includes/js/tinymce/themes/advanced/charmap.htm index bcebff243e..9dac168b0d 100644 --- a/wp-includes/js/tinymce/themes/advanced/charmap.htm +++ b/wp-includes/js/tinymce/themes/advanced/charmap.htm @@ -4,8 +4,9 @@ + - + diff --git a/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm index e35d711e45..725466ee7e 100644 --- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm +++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm @@ -3,8 +3,9 @@ {$lang_theme_colorpicker_title} + - +
    diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css index 7dbe1feba7..11f75dfad7 100644 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css @@ -1,22 +1,13 @@ /* This file contains the CSS data for the editable area(iframe) of TinyMCE */ /* You can extend this CSS by adding your own CSS file with the the content_css option */ +body, td, pre { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 10px; +} + body { background-color: #FFFFFF; - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 0.9em; - line-height: 1.2em; - padding: .3em; -} - -td { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; -} - -pre { - font-family: Verdana, Arial, Helvetica, sans-serif; - font-size: 10px; } .mceVisualAid { @@ -47,3 +38,16 @@ a { color: green; } */ + +/* MSIE specific */ + +* html body { + scrollbar-3dlight-color: #F0F0EE; + scrollbar-arrow-color: #676662; + scrollbar-base-color: #F0F0EE; + scrollbar-darkshadow-color: #DDDDDD; + scrollbar-face-color: #E0E0DD; + scrollbar-highlight-color: #F0F0EE; + scrollbar-shadow-color: #F0F0EE; + scrollbar-track-color: #F5F5F5; +} diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css index 14f83221a8..3b42925ed0 100644 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css @@ -35,14 +35,14 @@ input, select, textarea { } .input_noborder { - border: 0px solid #808080; + border: 0; } -#insert { +#insert, .updateButton { font-weight: bold; width: 90px; height: 21px; - border: 0px; + border: 0; background-image: url('../images/insert_button_bg.gif'); cursor: pointer; } @@ -51,7 +51,7 @@ input, select, textarea { font-weight: bold; width: 90px; height: 21px; - border: 0px; + border: 0; background-image: url('../images/cancel_button_bg.gif'); cursor: pointer; } @@ -84,7 +84,7 @@ td.charmap, td.charmapOver { td.charmapOver { background-color: #CCCCCC; - cursor: arrow; + cursor: default; } a.charmap { @@ -120,17 +120,17 @@ input.checkbox { border-bottom: 1px solid; border-right: 1px solid; border-color: #F0F0EE; - cursor: arrow; + cursor: default; } .mceButtonOver { border: 1px solid #0A246A; - cursor: arrow; + cursor: default; background-color: #B6BDD2; } .mceButtonDown { - cursor: arrow; + cursor: default; border: 1px solid #0A246A; background-color: #8592B5; } @@ -144,7 +144,7 @@ input.checkbox { border-bottom: 1px solid; border-right: 1px solid; border-color: #F0F0EE; - cursor: arrow; + cursor: default; } .mceActionPanel { @@ -162,7 +162,7 @@ input.checkbox { .tabs ul { margin: 0; - padding: 0px 0px 0; + padding: 0 0 0; list-style: none; } @@ -170,7 +170,7 @@ input.checkbox { float: left; background: url("../images/xp/tab_bg.gif") no-repeat left top; margin: 0; - margin-left: 0px; + margin-left: 0; margin-right: 2px; padding: 0 0 0 10px; line-height: 18px; @@ -185,7 +185,7 @@ input.checkbox { float: left; display: block; background: url("../images/xp/tab_end.gif") no-repeat right top; - padding: 0px 10px 0px 0px; + padding: 0px 10px 0 0; } .tabs .current span { @@ -235,8 +235,8 @@ fieldset { border: 1px solid #919B9C; font-family: Verdana, Arial; font-size: 10px; - padding: 0px; - margin: 0px; + padding: 0; + margin: 0; padding: 4px; } @@ -295,8 +295,8 @@ a:hover { h1, h2, h3, h4 { color: #2B6FB6; - margin: 0px; - padding: 0px; + margin: 0; + padding: 0; padding-top: 5px; } @@ -304,6 +304,14 @@ h3 { font-size: 14px; } +#link .panel_wrapper, #link div.current { + height: 125px; +} + +#image .panel_wrapper, #image div.current { + height: 190px; +} + /* Disables the advanced tab in the table plugin. */ /* #table #advanced_tab { @@ -317,3 +325,30 @@ h3 { display: none; } */ + +/* Below this line is WordPress customizations */ +#insert, #cancel, .submitbutton { + font: 11px Verdana, Arial, Helvetica, sans-serif; + height: auto; + width: auto; + background-color: transparent; + background-image: url(../../../../../../wp-admin/images/fade-butt.png); + background-repeat: repeat; + border: 3px double; + border-right-color: rgb(153, 153, 153); + border-bottom-color: rgb(153, 153, 153); + border-left-color: rgb(204, 204, 204); + border-top-color: rgb(204, 204, 204); + color: rgb(51, 51, 51); + padding: 0.1em 0.5em; +} + +#insert:active, #cancel:active, .submitbutton:active { + background: #f4f4f4; + border-left-color: #999; + border-top-color: #999; +} + +#styleSelectRow { + display: none; +} diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css index f2f5effe47..04fccc72c9 100644 --- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css +++ b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css @@ -1,84 +1,25 @@ /* This file contains the CSS data for the editor UI of TinyMCE instances */ .mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover { - border: 0px; margin: 0px; padding: 0px; background: transparent; -} - -.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceSeparatorLine, .mceButtonDisabled, .mceButtonSelected { - border: 0px; margin: 0px; padding: 0px; background: transparent; - margin-top: 1px; - margin-left: 1px; -} - -.mceButtonNormal { - border-top: 1px solid; - border-left: 1px solid; - border-bottom: 1px solid; - border-right: 1px solid; - border-color: #F0F0EE; - cursor: arrow; -} - -.mceButtonOver { - border: 1px solid #0A246A; - cursor: arrow; - background-color: #B6BDD2; -} - -.mceButtonDown { - cursor: arrow; - border: 1px solid #0A246A; - background-color: #8592B5; -} - -.mceButtonSelected { - border: 1px solid; - border-color: #C0C0BB; - cursor: arrow; -} - -.mceButtonDisabled { - filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); - -moz-opacity:0.3; - opacity: 0.3; - border-top: 1px solid; - border-left: 1px solid; - border-bottom: 1px solid; - border-right: 1px solid; - border-color: #F0F0EE; - cursor: arrow; -} - -.mceSeparator { - border-top: 1px solid buttonhighlight; - border-left: 1px solid buttonhighlight; - border-bottom: 1px solid buttonshadow; - border-right: 1px solid buttonshadow; - margin-right: 2px; - margin-left: 2px; + border: 0; margin: 0; padding: 0; background: transparent; } .mceSeparatorLine { - margin:2px; + border: 0; + padding: 0; margin-left: 4px; - background-color: #F0F0EE; - border-top: 1px solid buttonshadow; - border-left: 1px solid buttonshadow; - border-bottom: 1px solid buttonhighlight; - border-right: 1px solid buttonhighlight; - width: 0px; - height: 15px; + margin-right: 2px; } .mceSelectList { - font-family: "MS Sans Serif"; - font-size: 7pt; + font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; + font-size: 7pt !important; font-weight: normal; margin-top: 3px; - padding: 0px; + padding: 0; display: inline; vertical-align: top; - background-color: #F0F0EE + background-color: #F0F0EE; } .mceLabel, .mceLabelDisabled { @@ -98,15 +39,15 @@ .mceEditor { background: #F0F0EE; border: 1px solid #cccccc; - padding: 0px; - margin: 0px; + padding: 0; + margin: 0; } .mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; - padding: 0px; - margin: 0px; + padding: 0; + margin: 0; } .mceToolbarTop, .mceToolbarBottom { @@ -117,6 +58,7 @@ .mceToolbarTop { border-bottom: 1px solid #cccccc; + padding-bottom: 1px; } .mceToolbarBottom { @@ -176,6 +118,231 @@ height: 10px; display: none; border: 1px dotted gray; - margin: 0px; - padding: 0px; + margin: 0; + padding: 0; +} + +/* Button CSS rules */ + +a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img { + width: 20px; + height: 20px; + cursor: default; + margin-top: 1px; + margin-left: 1px; +} + +a.mceButtonDisabled img { + border: 0 !important; +} + +a.mceButtonNormal img, a.mceButtonSelected img { + border: 1px solid #F0F0EE !important; +} + +a.mceButtonSelected img { + border: 1px solid #6779AA !important; + background-color: #D4D5D8; +} + +a.mceButtonNormal img:hover, a.mceButtonSelected img:hover { + border: 1px solid #0A246A !important; + cursor: default; + background-color: #B6BDD2; +} + +a.mceButtonDisabled img { + -moz-opacity:0.3; + opacity: 0.3; + border: 1px solid #F0F0EE !important; + cursor: default; +} + +a.mceTiledButton img { + background-image: url('../images/buttons.gif'); + background-repeat: no-repeat; +} + +/* MSIE specific rules */ + +* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img { + border: 0 !important; + margin-top: 2px; + margin-bottom: 1px; +} + +* html a.mceButtonDisabled img { + filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); + border: 0 !important; +} + +* html a.mceButtonDisabled { + border: 1px solid #F0F0EE !important; +} + +* html a.mceButtonNormal, * html a.mceButtonSelected { + border: 1px solid #F0F0EE !important; + cursor: default; +} + +* html a.mceButtonSelected { + border: 1px solid #6779AA !important; + background-color: #D4D5D8; +} + +* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover { + border: 1px solid #0A246A !important; + cursor: default; + background-color: #B6BDD2; +} + +* html .mceSelectList { + margin-top: 2px; +} + +/* Menu button CSS rules */ + +span.mceMenuButton img, span.mceMenuButtonSelected img { + border: 1px solid #F0F0EE; + margin-left: 1px; +} + +span.mceMenuButtonSelected img { + border: 1px solid #6779AA; + background-color: #B6BDD2; +} + +span.mceMenuButtonSelected img.mceMenuButton { + border: 1px solid #F0F0EE; + background-color: transparent; +} + +span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton { + border-left: 0; + margin-left: 0; +} + +span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img { + border: 1px solid #0A246A; + background-color: #B6BDD2; +} + +span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton { + border-left: 0; +} + +span.mceMenuButtonFocus img { + border: 1px solid gray; + border-right: 0; + margin-left: 1px; + background-color: #F5F4F2; +} + +span.mceMenuButtonFocus img.mceMenuButton { + border: 1px solid gray; + border-left: 1px solid #F5F4F2; + margin-left: 0; +} + +/* Menu button MSIE specific rules */ + +* html span.mceMenuButton, * html span.mceMenuButtonFocus { + position: relative; + left: 0; + top: 0; +} + +* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img { + position: relative; + top: 1px; +} + +* html span.mceMenuHover img { + border: 1px solid #0A246A; + background-color: #B6BDD2; +} + +* html span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton { + border: 1px solid #0A246A; + background-color: #B6BDD2; + border-left: 0; +} + +/* Menu */ + +.mceMenu { + position: absolute; + left: 0; + top: 0; + display: none; + z-index: 100; + background-color: white; + border: 1px solid gray; + font-weight: normal; +} + +.mceMenu a, .mceMenuTitle, .mceMenuDisabled { + display: block; + width: 100%; + text-decoration: none; + background-color: white; + font-family: Tahoma, Verdana, Arial, Helvetica; + font-size: 11px; + line-height: 20px; + color: black; +} + +.mceMenu a:hover { + background-color: #B6BDD2; + color: black; +} + +.mceMenu span { + padding-left: 10px; + padding-right: 10px; + display: block; + line-height: 20px; +} + +.mceMenuSeparator { + border-bottom: 1px solid gray; + background-color: gray; + height: 1px; +} + +.mceMenuTitle span { + padding-left: 5px; +} + +.mceMenuTitle { + background-color: #DDDDDD; + font-weight: bold; +} + +.mceMenuDisabled { + color: gray; +} + +span.mceMenuSelectedItem { + background-image: url('../images/menu_check.gif'); + background-repeat: no-repeat; + background-position: 5px 8px; + padding-left: 20px; +} + +span.mceMenuCheckItem { + padding-left: 20px; +} + +span.mceMenuLine { + display: block; + position: absolute; + left: 0; + top: -1px; + background-color: #F5F4F2; + width: 30px; + height: 1px; + overflow: hidden; + padding-left: 0; + padding-right: 0; } diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js index 0dd4074f8e..5a3e09c7e7 100644 --- a/wp-includes/js/tinymce/themes/advanced/editor_template.js +++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js @@ -1,13 +1,1409 @@ +/** + * $RCSfile: editor_template_src.js,v $ + * $Revision: 1.93 $ + * $Date: 2006/03/14 17:33:50 $ + * + * @author Moxiecode + * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. + */ + /* Import theme specific language pack */ - tinyMCE.importThemeLanguagePack('advanced');var TinyMCE_advanced_autoImportCSSClasses=true;var TinyMCE_advanced_resizer=new Object();var TinyMCE_advanced_buttons=[['bold','{$lang_bold_img}','{$lang_bold_desc}','Bold'],['italic','{$lang_italic_img}','{$lang_italic_desc}','Italic'],['underline','{$lang_underline_img}','{$lang_underline_desc}','Underline'],['strikethrough','strikethrough.gif','{$lang_striketrough_desc}','Strikethrough'],['justifyleft','left.gif','{$lang_justifyleft_desc}','JustifyLeft'],['justifycenter','center.gif','{$lang_justifycenter_desc}','JustifyCenter'],['justifyright','right.gif','{$lang_justifyright_desc}','JustifyRight'],['justifyfull','full.gif','{$lang_justifyfull_desc}','JustifyFull'],['bullist','bullist.gif','{$lang_bullist_desc}','InsertUnorderedList'],['numlist','numlist.gif','{$lang_numlist_desc}','InsertOrderedList'],['outdent','outdent.gif','{$lang_outdent_desc}','Outdent'],['indent','indent.gif','{$lang_indent_desc}','Indent'],['cut','cut.gif','{$lang_cut_desc}','Cut'],['copy','copy.gif','{$lang_copy_desc}','Copy'],['paste','paste.gif','{$lang_paste_desc}','Paste'],['undo','undo.gif','{$lang_undo_desc}','Undo'],['redo','redo.gif','{$lang_redo_desc}','Redo'],['link','link.gif','{$lang_link_desc}','mceLink',true],['unlink','unlink.gif','{$lang_unlink_desc}','unlink'],['image','image.gif','{$lang_image_desc}','mceImage',true],['cleanup','cleanup.gif','{$lang_cleanup_desc}','mceCleanup'],['help','help.gif','{$lang_help_desc}','mceHelp'],['code','code.gif','{$lang_theme_code_desc}','mceCodeEditor'],['hr','hr.gif','{$lang_theme_hr_desc}','inserthorizontalrule'],['removeformat','removeformat.gif','{$lang_theme_removeformat_desc}','removeformat'],['sub','sub.gif','{$lang_theme_sub_desc}','subscript'],['sup','sup.gif','{$lang_theme_sup_desc}','superscript'],['forecolor','forecolor.gif','{$lang_theme_forecolor_desc}','mceForeColor',true],['backcolor','backcolor.gif','{$lang_theme_backcolor_desc}','mceBackColor',true],['charmap','charmap.gif','{$lang_theme_charmap_desc}','mceCharMap'],['visualaid','visualaid.gif','{$lang_theme_visualaid_desc}','mceToggleVisualAid'],['anchor','anchor.gif','{$lang_theme_anchor_desc}','mceInsertAnchor'],['newdocument','newdocument.gif','{$lang_newdocument_desc}','mceNewDocument']];function TinyMCE_advanced_getControlHTML(button_name){var buttonTileMap=new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif');for(var i=0;i4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '';}}}var cmd='tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+but[3]+'\','+(but.length>4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '';}}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 "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=tinyMCE.getAttrib(elm,"color");if(inputColor=='')inputColor=elm.style.color;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=elm.style.backgroundColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;template['width']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"HiliteColor",input_color:inputColor});return true;case "mceColorPicker":if(user_interface){var template=new Array();var inputColor=value['document'].getElementById(value['element_id']).value;template['file']='color_picker.htm';template['width']=220;template['height']=190;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:inputColor});}else{var savedVal=tinyMCE.lastColorPickerValue;var elm=savedVal['document'].getElementById(savedVal['element_id']);elm.value=value;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",500));template['height']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_height",400));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;}function TinyMCE_advanced_getEditorTemplate(settings,editorId){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i 

    ';var layoutManager=tinyMCE.getParam("theme_advanced_layout_manager","SimpleLayout");var styleSelectHTML='';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i'+key+'';}TinyMCE_advanced_autoImportCSSClasses=false;}switch(layoutManager){case "SimpleLayout":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");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"};/*toolbarHTML+='';*/for(var i=1;i<100;i++){var def=defVals["theme_advanced_buttons"+i];var buttons=tinyMCE.getParam("theme_advanced_buttons"+i,def==null?'':def,true,',');if(buttons.length==0)break;buttons=removeFromArray(buttons,tinyMCE.getParam("theme_advanced_disable","",true,','));buttons=addToArray(buttons,tinyMCE.getParam("theme_advanced_buttons"+i+"_add","",true,','));buttons=addToArray(tinyMCE.getParam("theme_advanced_buttons"+i+"_add_before","",true,','),buttons);for(var b=0;b0){toolbarHTML+="
    ";deltaHeight-=23;}}toolbarHTML+='';template['html']='
    {$lang_theme_charmap_title}
    ';if(toolbarLocation=="top"){template['html']+='';}if(statusbarLocation=="top"){template['html']+='';deltaHeight-=23;}template['html']+='';if(toolbarLocation=="bottom"){template['html']+='';}if(toolbarLocation=="external"){var bod=document.body;var elm=document.createElement("div");toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCE.settings);toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCELang);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,'style_select_options',styleSelectHTML);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,"editor_id",editorId);toolbarHTML=tinyMCE.applyTemplate(toolbarHTML);elm.className="mceToolbarExternal";elm.id=editorId+"_toolbar";elm.innerHTML='
    '+toolbarHTML+'
    '+statusbarHTML+'
    '+toolbarHTML+'
    '+toolbarHTML+'
    ';bod.appendChild(elm);deltaHeight=0;tinyMCE.getInstanceById(editorId).toolbarElement=elm;}else{tinyMCE.getInstanceById(editorId).toolbarElement=null;}if(statusbarLocation=="bottom"){template['html']+=''+statusbarHTML+'';deltaHeight-=23;}template['html']+='';break;case "RowLayout":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");for(var i=0;i';}else if(containers[i]=="mceElementpath"||containers[i]=="mceStatusbar"){var pathClass="mceStatusbar";if(i==containers.length-1){pathClass="mceStatusbarBottom";}else if(i==0){pathClass="mceStatusbar";}else{deltaHeight-=2;}template['html']+='';deltaHeight-=22;}else{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);for(var j=0;j0){curContainerHTML+="
    ";deltaHeight-=23;}template['html']+='
    ';}}template['html']+='
    \ - \ -
    '+statusbarHTML+'
    '+curContainerHTML+'
    ';break;case "BorderLayout":break;case "CustomLayout":var customLayout=tinyMCE.getParam("theme_advanced_custom_layout","");if(customLayout!=""&&eval("typeof("+customLayout+")")!="undefined"){template=eval(customLayout+"(template);");}break;default:alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');break;}template['html']+='
    ';template['html']=tinyMCE.replaceVar(template['html'],'style_select_options',styleSelectHTML);template['delta_width']=0;template['delta_height']=deltaHeight;return template;}function TinyMCE_advanced_setResizing(e,editor_id,state){e=typeof(e)=="undefined"?window.event:e;var resizer=TinyMCE_advanced_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){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;editorArea.style.display="none";resizeBox.style.display="block";if(!resizer.eventHandlers){if(tinyMCE.isMSIE)tinyMCE.addEvent(document,"mousemove",TinyMCE_advanced_resizeEventHandler);else tinyMCE.addEvent(window,"mousemove",TinyMCE_advanced_resizeEventHandler);tinyMCE.addEvent(document,"mouseup",TinyMCE_advanced_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?"block":"table";tinyMCE.execCommand('mceResetDesignMode');}}function TinyMCE_advanced_initInstance(inst){if(tinyMCE.getParam("theme_advanced_resizing",false)){if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var w=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_width");var h=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_height");TinyMCE_advanced_resizeTo(inst,w,h,tinyMCE.getParam("theme_advanced_resize_horizontal",true));}}}function TinyMCE_advanced_setCookie(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;}function TinyMCE_advanced_getCookie(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));}function TinyMCE_advanced_resizeTo(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;if(set_w)tableElm.style.width=w+"px";tableElm.style.height=h+"px";iw=iframe.clientWidth+dx;ih=iframe.clientHeight+dy;if(tinyMCE.isGecko){iw-=2;ih-=2;}if(set_w)iframe.style.width=iw+"px";iframe.style.height=ih+"px";if(set_w){var tableBodyElm=tableElm.firstChild;var minIframeWidth=tableBodyElm.scrollWidth;if(inst.iframeElement.clientWidth=0;i--){var nodeName=path[i].nodeName.toLowerCase();var nodeData="";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: "+st+" ";}}if(nodeName=="font"){if(tinyMCE.getParam("convert_fonts_to_spans"))nodeName="span";var face=tinyMCE.getAttrib(path[i],"face");if(face!="")nodeData+="font: "+face+" ";var size=tinyMCE.getAttrib(path[i],"size");if(size!="")nodeData+="size: "+size+" ";var color=tinyMCE.getAttrib(path[i],"color");if(color!="")nodeData+="color: "+color+" ";}if(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(getAttrib(path[i],'src')!=""){nodeData+="src: "+path[i].getAttribute('src')+" ";}if(getAttrib(path[i],'href')!=""){nodeData+="href: "+path[i].getAttribute('href')+" ";}if(nodeName=="img"&&tinyMCE.getAttrib(path[i],"class").indexOf('mceItemFlash')!=-1){nodeName="flash";nodeData="src: "+path[i].getAttribute('title');}if(nodeName=="a"&&(anchor=tinyMCE.getAttrib(path[i],"name"))!=""){nodeName="a";nodeName+="#"+anchor;nodeData="";}if(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+' ';}tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_link','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_unlink','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_image','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonNormal');if(node.nodeName=="A"&&tinyMCE.getAttrib(node,"class").indexOf('mceItemAnchor')!=-1)tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonSelected');var anchorLink=tinyMCE.getParentElement(node,"a","href");if(anchorLink||any_selection){tinyMCE.switchClassSticky(editor_id+'_link',anchorLink?'mceButtonSelected':'mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_unlink',anchorLink?'mceButtonSelected':'mceButtonNormal',false);}tinyMCE.switchClassSticky(editor_id+'_visualaid',visual_aid?'mceButtonSelected':'mceButtonNormal',false);if(undo_levels!=-1){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonDisabled',true);}if(tinyMCE.getParentElement(node,"li,blockquote")){tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index0)){tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index>0&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonNormal',false);}var selectElm=document.getElementById(editor_id+"_styleSelect");if(selectElm){TinyMCE_advanced_setupCSSClasses(editor_id);classNode=node;breakOut=false;var index=0;do{if(classNode&&classNode.className){for(var i=0;i");}else{selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontNameSelect");if(selectElm){if(!tinyMCE.isSafari&&!(tinyMCE.isMSIE&&!tinyMCE.isOpera)){var face=doc.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,"");}}var selectElm=document.getElementById(editor_id+"_fontSizeSelect");if(selectElm){if(!tinyMCE.isSafari&&!tinyMCE.isOpera){var size=doc.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;i0){selectElm.setAttribute('cssImported','true');}}}; +tinyMCE.importThemeLanguagePack('advanced'); + +var TinyMCE_AdvancedTheme = { + // Private theme fields + _autoImportCSSClasses : true, + _resizer : {}, + _buttons : [ + // Control id, button img, button title, command, user_interface, value + ['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'], + ['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'], + ['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'], + ['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'], + ['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'], + ['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'], + ['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'], + ['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'], + ['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'], + ['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'], + ['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'], + ['indent', 'indent.gif', 'lang_indent_desc', 'Indent'], + ['cut', 'cut.gif', 'lang_cut_desc', 'Cut'], + ['copy', 'copy.gif', 'lang_copy_desc', 'Copy'], + ['paste', 'paste.gif', 'lang_paste_desc', 'Paste'], + ['undo', 'undo.gif', 'lang_undo_desc', 'Undo'], + ['redo', 'redo.gif', 'lang_redo_desc', 'Redo'], + ['link', 'link.gif', 'lang_link_desc', 'mceLink', true], + ['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'], + ['image', 'image.gif', 'lang_image_desc', 'mceImage', true], + ['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'], + ['help', 'help.gif', 'lang_help_desc', 'mceHelp'], + ['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'], + ['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'], + ['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'], + ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'], + ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'], + ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'mceForeColor', true], + ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'mceBackColor', true], + ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'], + ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'], + ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'], + ['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument'] + ], + + _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells', + + /** + * Returns HTML code for the specificed control. + */ + getControlHTML : function(button_name) { + var i, x; + + // Lookup button in button list + for (i=0; i 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 "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 "mceForeColor": + var template = new Array(); + var elm = tinyMCE.selectedInstance.getFocusElement(); + var inputColor = tinyMCE.getAttrib(elm, "color"); + + if (inputColor == '') + inputColor = elm.style.color; + + if (!inputColor) + inputColor = "#000000"; + + template['file'] = 'color_picker.htm'; + template['width'] = 220; + template['height'] = 190; + + tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor}); + return true; + + case "mceBackColor": + var template = new Array(); + var elm = tinyMCE.selectedInstance.getFocusElement(); + var inputColor = elm.style.backgroundColor; + + if (!inputColor) + inputColor = "#000000"; + + template['file'] = 'color_picker.htm'; + template['width'] = 220; + template['height'] = 190; + + template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0); + template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0); + + tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor}); + //mceBackColor + return true; + + case "mceColorPicker": + if (user_interface) { + var template = new Array(); + var inputColor = value['document'].getElementById(value['element_id']).value; + + template['file'] = 'color_picker.htm'; + template['width'] = 220; + template['height'] = 190; + 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 : inputColor}); + } else { + var savedVal = tinyMCE.lastColorPickerValue; + var 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(); + + 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); + + 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); + template['delta_width'] = 0; + 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'); + }, + + /** + * Node change handler. + */ + handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) { + 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 == "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: " + st + " "; + } + } + + if (nodeName == "font") { + if (tinyMCE.getParam("convert_fonts_to_spans")) + nodeName = "span"; + + var face = tinyMCE.getAttrib(path[i], "face"); + if (face != "") + nodeData += "font: " + face + " "; + + var size = tinyMCE.getAttrib(path[i], "size"); + if (size != "") + nodeData += "size: " + size + " "; + + var color = tinyMCE.getAttrib(path[i], "color"); + if (color != "") + nodeData += "color: " + color + " "; + } + + if (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 (getAttrib(path[i], 'src') != "") { + var src = tinyMCE.getAttrib(path[i], "mce_src"); + + if (src == "") + src = tinyMCE.getAttrib(path[i], "src"); + + nodeData += "src: " + src + " "; + } + + if (getAttrib(path[i], 'href') != "") { + var href = tinyMCE.getAttrib(path[i], "mce_href"); + + if (href == "") + href = tinyMCE.getAttrib(path[i], "href"); + + nodeData += "href: " + href + " "; + } + + if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) { + nodeName = "flash"; + nodeData = "src: " + path[i].getAttribute('title'); + } + + if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") { + nodeName = "a"; + nodeName += "#" + anchor; + nodeData = ""; + } + + if (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"; + } + } + }, + + /** + * 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'); + } + }, + + _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) { + tinyMCE.execCommand('mceBeginUndoLevel'); + + if (src == "") + return; + + if (!tinyMCE.imgElement && tinyMCE.isSafari) { + var html = ""; + + html += '' + alt + ''; + + tinyMCE.execCommand("mceInsertContent", false, html); + } else { + if (!tinyMCE.imgElement && tinyMCE.selectedInstance) { + if (tinyMCE.isSafari) + tinyMCE.execCommand("mceInsertContent", false, ''); + else + tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL); + + tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL); + } + } + + if (tinyMCE.imgElement) { + var needsRepaint = false; + var msrc = src; + + src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);"); + + if (tinyMCE.getParam('convert_urls')) + msrc = src; + + if (onmouseover && onmouseover != "") + onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';"; + + if (onmouseout && onmouseout != "") + onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';"; + + // Use alt as title if it's undefined + if (typeof(title) == "undefined") + title = alt; + + if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align")) + needsRepaint = true; + + tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src); + tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc); + tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt); + tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title); + tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align); + tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true); + tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true); + tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true); + tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true); + tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true); + tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover); + tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout); + + // Fix for bug #989846 - Image resize bug + if (width && width != "") + tinyMCE.imgElement.style.pixelWidth = width; + + if (height && height != "") + tinyMCE.imgElement.style.pixelHeight = height; + + if (needsRepaint) + tinyMCE.selectedInstance.repaint(); + } + + tinyMCE.execCommand('mceEndUndoLevel'); + }, + + _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 {$lang_insert_image_title} + - + - - - - - - -
    + + + + +
    +
    +
    - - - - + @@ -49,8 +32,8 @@ if (typeof(tinyMCEImageList) != "undefined" && tinyMCEImageList.length > 0) { var html = ""; - html += ''; - html += ''; + html += ' - - + + - - + - - - - - + + + -
    {$lang_insert_image_title}
    {$lang_insert_image_src}: - +
     
    {$lang_image_list}:
    {$lang_insert_image_alt}:
    {$lang_insert_image_align}:
    -
    + + + + +
    +
    + +
    + +
    + +
    +
    diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif new file mode 100644 index 0000000000..ea341e6089 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/bold_es.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif new file mode 100644 index 0000000000..82085432c6 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif b/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif new file mode 100644 index 0000000000..c3d8fa2311 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/button_menu.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif index 5d5e08b5e6..6196350de8 100644 Binary files a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif and b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/help.gif b/wp-includes/js/tinymce/themes/advanced/images/help.gif new file mode 100644 index 0000000000..51a1ee4207 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/help.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif new file mode 100644 index 0000000000..4572cdb1d0 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/italic_es.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif new file mode 100644 index 0000000000..4f6eeaa2b2 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif b/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif new file mode 100644 index 0000000000..42d609a991 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif new file mode 100644 index 0000000000..c8504f626f Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif new file mode 100644 index 0000000000..e8f7e42769 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif b/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif new file mode 100644 index 0000000000..e4cea97148 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/justifyright.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif b/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif new file mode 100644 index 0000000000..50d6afd505 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/menu_check.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/opacity.png b/wp-includes/js/tinymce/themes/advanced/images/opacity.png new file mode 100644 index 0000000000..b4217cb212 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/opacity.png differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/separator.gif b/wp-includes/js/tinymce/themes/advanced/images/separator.gif new file mode 100644 index 0000000000..4f39b809e9 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/separator.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif new file mode 100644 index 0000000000..551d9148d3 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/underline_es.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif b/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif new file mode 100644 index 0000000000..b715390484 Binary files /dev/null and b/wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif differ diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/about.js b/wp-includes/js/tinymce/themes/advanced/jscripts/about.js index 9cb015d3a7..f60e6f688d 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/about.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/about.js @@ -1,5 +1,8 @@ function init() { + var inst; + tinyMCEPopup.resizeToInnerSize(); + inst = tinyMCE.selectedInstance; // Give FF some time window.setTimeout('insertHelpIFrame();', 10); @@ -20,8 +23,8 @@ function init() { html += ''; html += ''; - for (var i=0; i/g, '&gr;'); + name = name.replace(/>/g, '>'); - html = ''; + // Fix for bug #1447335 + if (tinyMCE.isGecko) + html = ''; + else + html = ''; tinyMCEPopup.execCommand("mceInsertContent", false, html); + + // Fix for bug #1447335 force cursor after the anchor element + if (tinyMCE.isGecko) { + e = inst.getDoc().getElementById('mceNewAnchor'); + + if (e) { + inst.selection.selectNode(e, true, false, false); + e.removeAttribute('id'); + } + } + tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst); } diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js b/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js index 2f758cfa8d..c4ec3261cf 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js @@ -170,7 +170,7 @@ charmap = [ ['ý', 'ý', true, 'y - acute'], ['þ', 'þ', true, 'thorn'], ['ÿ', 'ÿ', true, 'y - diaeresis'], -// ['Α', 'Α', true, 'Alpha'], + ['Α', 'Α', true, 'Alpha'], ['Β', 'Β', true, 'Beta'], ['Γ', 'Γ', true, 'Gamma'], ['Δ', 'Δ', true, 'Delta'], @@ -279,9 +279,9 @@ function renderCharMapHTML() { cols++; html += '' + '' + charmap[i][1] + ''; @@ -299,11 +299,13 @@ function renderCharMapHTML() { } function insertChar(chr) { - tinyMCEPopup.execCommand('mceInsertContent', false, '\&#' + chr + ';'); + tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';'); // Refocus in window if (tinyMCEPopup.isWindow) window.focus(); + + tinyMCEPopup.close(); } function previewChar(codeA, codeB, codeN) { diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js index 1d585aa372..aa80714ad7 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js @@ -99,7 +99,8 @@ function renderColorMap() { + '' + '' + '' - + '' + + '
    ' + + '
    ' + '' + ''; diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/image.js b/wp-includes/js/tinymce/themes/advanced/jscripts/image.js index d97e79b8d5..950c043abc 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/image.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/image.js @@ -8,19 +8,18 @@ if (url != null) { } function insertImage() { - if (window.opener) { - var src = document.forms[0].src.value; - var alt = document.forms[0].alt.value; - var border = '';//document.forms[0].border.value; - var vspace = '';//document.forms[0].vspace.value; - var hspace = '';//document.forms[0].hspace.value; - var width = '';//document.forms[0].width.value; - var height = '';//document.forms[0].height.value; - var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value; + var src = document.forms[0].src.value; + var alt = document.forms[0].alt.value; + var border = document.forms[0].border.value; + var vspace = document.forms[0].vspace.value; + var hspace = document.forms[0].hspace.value; + var width = document.forms[0].width.value; + var height = document.forms[0].height.value; + var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value; - window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align); - top.close(); - } + tinyMCEPopup.restoreSelection(); + tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align); + tinyMCEPopup.close(); } function init() { @@ -37,11 +36,11 @@ function init() { formObj.src.value = tinyMCE.getWindowArg('src'); formObj.alt.value = tinyMCE.getWindowArg('alt'); -// formObj.border.value = tinyMCE.getWindowArg('border'); -// formObj.vspace.value = tinyMCE.getWindowArg('vspace'); -// formObj.hspace.value = tinyMCE.getWindowArg('hspace'); -// formObj.width.value = tinyMCE.getWindowArg('width'); -// formObj.height.value = tinyMCE.getWindowArg('height'); + formObj.border.value = tinyMCE.getWindowArg('border'); + formObj.vspace.value = tinyMCE.getWindowArg('vspace'); + formObj.hspace.value = tinyMCE.getWindowArg('hspace'); + formObj.width.value = tinyMCE.getWindowArg('width'); + formObj.height.value = tinyMCE.getWindowArg('height'); formObj.insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); // Handle file browser @@ -61,17 +60,17 @@ var preloadImg = new Image(); function resetImageData() { var formObj = document.forms[0]; - formObj.width.value = formObj.height.value = ""; + formObj.width.value = formObj.height.value = ""; } function updateImageData() { var formObj = document.forms[0]; -// if (formObj.width.value == "") -// formObj.width.value = preloadImg.width; + if (formObj.width.value == "") + formObj.width.value = preloadImg.width; -// if (formObj.height.value == "") -// formObj.height.value = preloadImg.height; + if (formObj.height.value == "") + formObj.height.value = preloadImg.height; } function getImageData() { diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js index adc1053505..31b38782bd 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/link.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/link.js @@ -10,7 +10,11 @@ if (url != null) { function init() { tinyMCEPopup.resizeToInnerSize(); -// document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link'); + document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link'); + + // Handle file browser + if (isVisible('hrefbrowser')) + document.getElementById('href').style.width = '180px'; var formObj = document.forms[0]; @@ -25,12 +29,15 @@ function init() { document.forms[0].linktitle.value = tinyMCE.getWindowArg('title'); document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); -// addClassesToList('styleSelect', 'theme_advanced_link_styles'); -// selectByValue(formObj, 'styleSelect', tinyMCE.getWindowArg('className'), true); + addClassesToList('styleSelect', 'theme_advanced_link_styles'); + selectByValue(formObj, 'styleSelect', tinyMCE.getWindowArg('className'), true); - // Handle file browser - if (isVisible('hrefbrowser')) - document.getElementById('href').style.width = '180px'; + // Hide css select row if no CSS classes + if (formObj.styleSelect && formObj.styleSelect.options.length <= 1) { + var sr = document.getElementById('styleSelectRow'); + sr.style.display = 'none'; + sr.parentNode.removeChild(sr); + } // Auto select link in list if (typeof(tinyMCELinkList) != "undefined" && tinyMCELinkList.length > 0) { @@ -44,21 +51,20 @@ function init() { } function insertLink() { - if (window.opener) { - var href = document.forms[0].href.value; - var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value; - var title = document.forms[0].linktitle.value; - var style_class = '';//document.forms[0].styleSelect.value; - var dummy; + var href = document.forms[0].href.value; + var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value; + var title = document.forms[0].linktitle.value; + var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : ""; + var dummy; - // Make anchors absolute - if (href.charAt(0) == '#') - href = tinyMCE.settings['document_base_url'] + href; + // Make anchors absolute + if (href.charAt(0) == '#') + href = tinyMCE.settings['document_base_url'] + href; - if (target == '_self') - target = ''; + if (target == '_self') + target = ''; - window.opener.tinyMCE.insertLink(href, target, title, dummy, style_class); - tinyMCEPopup.close(); - } + tinyMCEPopup.restoreSelection(); + tinyMCE.themes['advanced']._insertLink(href, target, title, dummy, style_class); + tinyMCEPopup.close(); } diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js index cb5704f205..c266c8283b 100644 --- a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js +++ b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js @@ -5,13 +5,10 @@ function saveContent() { // Fixes some charcode issues function fixContent(html) { - // WP - return html; - - html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1'); +/* html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1'); html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'\n'); html = tinyMCE.regexpReplace(html, '
    ','
    \n','gi'); - html = tinyMCE.regexpReplace(html, '\n\n','\n','gi'); + html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');*/ return html; } @@ -20,12 +17,20 @@ function onLoadInit() { document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id'))); resizeInputs(); - setWrap('off'); } function setWrap(val) { - // hard soft off - document.forms[0].htmlSource.wrap = val; + var s = document.forms[0].htmlSource; + + s.wrap = val; + + if (tinyMCE.isGecko) { + var v = s.value; + var n = s.cloneNode(false); + n.setAttribute("wrap", val); + s.parentNode.replaceChild(n, s); + n.value = v; + } } function toggleWordWrap(elm) { @@ -51,6 +56,6 @@ function resizeInputs() { } function renderWordWrap() { - if (tinyMCE.isMSIE) + if (tinyMCE.isMSIE || tinyMCE.isGecko) document.write(''); } diff --git a/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js index 14657ba5a3..ca726768ad 100644 --- a/wp-includes/js/tinymce/themes/advanced/langs/en.js +++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js @@ -2,7 +2,7 @@ tinyMCE.addToLang('',{ theme_style_select : '-- Styles --', -theme_code_desc : 'Edit HTML Source (Alt+e)', +theme_code_desc : 'Edit HTML Source', theme_code_title : 'HTML Source Editor', theme_code_wordwrap : 'Word wrap', theme_sub_desc : 'Subscript', diff --git a/wp-includes/js/tinymce/themes/advanced/link.htm b/wp-includes/js/tinymce/themes/advanced/link.htm index 4b866fa04c..98d2f17169 100644 --- a/wp-includes/js/tinymce/themes/advanced/link.htm +++ b/wp-includes/js/tinymce/themes/advanced/link.htm @@ -2,55 +2,39 @@ {$lang_insert_link_title} + - + - -
    - - -
    + + + + +
    +
    + +
    - - - - - + + - - + ', ''); - html = tinyMCE.regexpReplace(html, '

    \\s*
    \\s*

    ', '

     

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

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

    ', '

     

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

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

    ', '

     

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

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

    ', '

     

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

     

    ', 'g'); - html = html.replace(re, "
    "); - } - - if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) { - // Remove weridness! - var re = new RegExp('<>', 'g'); - html = html.replace(re, ""); - } - - // Call custom cleanup code - html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html); - - // Emtpy node, return empty - var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase(); - if (chk == "
    " || chk == "
    " || chk == "

     

    " || chk == "

     

    " || chk == "

    ") - html = ""; - - if (tinyMCE.settings["preformatted"]) - return "
    " + html + "
    "; - - return html; }; -TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) { - tinyMCE.execCommand('mceBeginUndoLevel'); +TinyMCE_Engine.prototype.getContent = function(editor_id) { + var h; - if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") { - var doc = this.selectedInstance.getDoc(); - var linkElement = tinyMCE.getParentElement(this.selectedElement, "a"); - var newLink = false; + if (typeof(editor_id) != "undefined") + tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id); - if (!linkElement) { - linkElement = doc.createElement("a"); - newLink = true; - } + if (tinyMCE.selectedInstance) { + h = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true); - var mhref = href; - var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);"); - mhref = tinyMCE.getParam('convert_urls') ? href : mhref; + // When editing always use fonts internaly + if (tinyMCE.getParam("convert_fonts_to_spans")) + tinyMCE.convertSpansToFonts(this.selectedInstance.getDoc()); - tinyMCE.setAttrib(linkElement, 'href', thref); - tinyMCE.setAttrib(linkElement, 'mce_href', mhref); - tinyMCE.setAttrib(linkElement, 'target', target); - tinyMCE.setAttrib(linkElement, 'title', title); - tinyMCE.setAttrib(linkElement, 'onclick', onclick); - tinyMCE.setAttrib(linkElement, 'class', style_class); - - if (newLink) { - linkElement.appendChild(this.selectedElement.cloneNode(true)); - this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement); - } - - return; - } - - if (!this.linkElement && this.selectedInstance) { - if (tinyMCE.isSafari) { - tinyMCE.execCommand("mceInsertContent", false, '' + this.selectedInstance.getSelectedHTML() + ''); - } else - this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL); - - tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL); - - for (var i=0; i'; - - tinyMCE.execCommand("mceInsertContent", false, html); - } else { - if (!this.imgElement && this.selectedInstance) { - if (tinyMCE.isSafari) - tinyMCE.execCommand("mceInsertContent", false, ''); - else - this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL); - - tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL); - } - } - - if (this.imgElement) { - var needsRepaint = false; - var msrc = src; - - src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);"); - - if (tinyMCE.getParam('convert_urls')) - msrc = src; - - if (onmouseover && onmouseover != "") - onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';"; - - if (onmouseout && onmouseout != "") - onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';"; - - // Use alt as title if it's undefined - if (typeof(title) == "undefined") - title = alt; - - if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align")) - needsRepaint = true; - - tinyMCE.setAttrib(this.imgElement, 'src', src); - tinyMCE.setAttrib(this.imgElement, 'mce_src', msrc); - tinyMCE.setAttrib(this.imgElement, 'alt', alt); - tinyMCE.setAttrib(this.imgElement, 'title', title); - tinyMCE.setAttrib(this.imgElement, 'align', align); - tinyMCE.setAttrib(this.imgElement, 'border', border, true); - tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true); - tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true); - tinyMCE.setAttrib(this.imgElement, 'width', width, true); - tinyMCE.setAttrib(this.imgElement, 'height', height, true); - tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover); - tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout); - - // Fix for bug #989846 - Image resize bug - if (width && width != "") - this.imgElement.style.pixelWidth = width; - - if (height && height != "") - this.imgElement.style.pixelHeight = height; - - if (needsRepaint) - tinyMCE.selectedInstance.repaint(); - } - - tinyMCE.execCommand('mceEndUndoLevel'); -}; - -TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) { - var elements = this.getElementsByAttributeValue(node, element_name, attrib, value); - if (elements.length == 0) - return null; - - return elements[0]; -}; - -TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) { - var elements = new Array(); - - if (node && node.nodeName.toLowerCase() == element_name) { - if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1) - elements[elements.length] = node; - } - - if (node && node.hasChildNodes()) { - for (var x=0, n=node.childNodes.length; x]*>/gi, ''); + h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), ''); + h = h.replace(/


    <\/p>/g, '
    '); + h = h.replace(/

    ( | )<\/p>


    ( | )<\/p>/g, '


    '); + h = h.replace(/
    '); + h = h.replace(/

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

     

    '); + h = h.replace(/

    \s*( | )\s*
    \s*( | )\s*<\/p>/g, '

     

    '); + h = h.replace(/

    \s*( | )\s*
    \s*<\/p>/g, '

     

    '); + h = h.replace(/

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

     

    '); + h = h.replace(/(.*?)<\/a>/g, '$1'); + h = h.replace(/]*)>\s*<\/p>/g, ' 

    '); + + // Clean body + if (/^\s*(
    |

     <\/p>|

     <\/p>|

    <\/p>)\s*$/.test(h)) + h = ''; + + // If preformatted + if (s.preformatted) { + h = h.replace(/^

    /, '');
    +		h = h.replace(/<\/pre>$/, '');
    +		h = '
    ' + h + '
    '; + } + + // Gecko specific processing + if (tinyMCE.isGecko) { + h = h.replace(//g, ''); + h = h.replace(/]*)>\s*
    \s*<\/td>/g, ' '); + } + + if (s.force_br_newlines) + h = h.replace(/

    ( | )<\/p>/g, '
    '); + + // Call custom cleanup code + h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h); + + // Remove internal classes + if (on_save) { + h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), ''); + h = h.replace(new RegExp(' ?class=""', 'g'), ''); + } + + if (s.remove_linebreaks && !c.settings.indent) + h = h.replace(/\n|\r/g, ' '); + + if (d) + t4 = new Date().getTime(); + + if (on_save && c.settings.indent) + h = c.formatHTML(h); + + // If encoding (not recommended option) + if (on_submit && (s.encoding == "xml" || s.encoding == "html")) + h = c.xmlEncode(h); + + if (d) + t5 = new Date().getTime(); + + if (c.settings.debug) + tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + "."); + + return h; +}; + +function TinyMCE_Cleanup() { + this.isMSIE = (navigator.appName == "Microsoft Internet Explorer"); + this.rules = tinyMCE.clearArray(new Array()); + + // Default config + this.settings = { + indent_elements : 'head,table,tbody,thead,tfoot,form,tr,ul,ol,blockquote,object', + newline_before_elements : 'h1,h2,h3,h4,h5,h6,pre,address,div,ul,ol,li,meta,option,area,title,link,base,script,td', + newline_after_elements : 'br,hr,p,pre,address,div,ul,ol,meta,option,area,link,base,script', + newline_before_after_elements : 'html,head,body,table,thead,tbody,tfoot,tr,form,ul,ol,blockquote,p,object,param,hr,div', + indent_char : '\t', + indent_levels : 1, + entity_encoding : 'raw', + valid_elements : '*[*]', + entities : '', + url_converter : '', + invalid_elements : '', + verify_html : false + }; + + this.vElements = tinyMCE.clearArray(new Array()); + this.vElementsRe = ''; + this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON)$/; + this.codeElementsRe = /^(SCRIPT|STYLE)$/; + this.serializationId = 0; + this.mceAttribs = { + href : 'mce_href', + src : 'mce_src', + type : 'mce_type' + }; +} + +TinyMCE_Cleanup.prototype = { + init : function(s) { + var n, a, i, ir, or, st; + + for (n in s) + this.settings[n] = s[n]; + + // Setup code formating + s = this.settings; + + // Setup regexps + this.inRe = this._arrayToRe(s.indent_elements.split(','), '', '^<(', ')[^>]*'); + this.ouRe = this._arrayToRe(s.indent_elements.split(','), '', '^<\\/(', ')[^>]*'); + this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>'); + this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>'); + this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>'); + + if (s.invalid_elements != '') + this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$'); + else + this.iveRe = null; + + // Setup separator + st = ''; + for (i=0; i 1) { + r.vAttribsRe = '^('; + a = this.split(/\|/, p[1]); + + for (i=0; i 0) { + if (av[0].charAt(0) == ':') { + if (!r.forceAttribs) + r.forceAttribs = tinyMCE.clearArray(new Array()); + + r.forceAttribs[t.toLowerCase()] = av[0].substring(1); + } else if (av[0].charAt(0) == '=') { + if (!r.defaultAttribs) + r.defaultAttribs = tinyMCE.clearArray(new Array()); + + dv = av[0].substring(1); + + r.defaultAttribs[t.toLowerCase()] = dv == "" ? "mce_empty" : dv; + } else if (av[0].charAt(0) == '<') { + if (!r.validAttribValues) + r.validAttribValues = tinyMCE.clearArray(new Array()); + + r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), ''); + } + } + + r.vAttribsRe += '' + t.toLowerCase() + (i != a.length - 1 ? '|' : ''); + + a[i] = t.toLowerCase(); + } + + r.vAttribsRe += ')$'; + r.vAttribsRe = this._wildcardToRe(r.vAttribsRe); + r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe); + r.vAttribsRe = new RegExp(r.vAttribsRe); + r.vAttribs = a.reverse(); + + //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC); + } else { + r.vAttribsRe = ''; + r.vAttribs = tinyMCE.clearArray(new Array()); + r.vAttribsReIsWild = false; + } + + or[r.tag] = r; + } + } + + return or; + }, + + serializeNodeAsXML : function(n) { + var s, b; + + if (!this.xmlDoc) { + if (this.isMSIE) { + try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {} + + if (!this.xmlDoc) + try {this.xmlDoc = new ActiveXObject('Microsoft.XmlDom');} catch (e) {} + } else + this.xmlDoc = document.implementation.createDocument('', '', null); + + if (!this.xmlDoc) + alert("Error XML Parser could not be found."); + } + + if (this.xmlDoc.firstChild) + this.xmlDoc.removeChild(this.xmlDoc.firstChild); + + b = this.xmlDoc.createElement("html"); + b = this.xmlDoc.appendChild(b); + + this._convertToXML(n, b); + + if (this.isMSIE) + return this.xmlDoc.xml; + else + return new XMLSerializer().serializeToString(this.xmlDoc); + }, + + _convertToXML : function(n, xn) { + var xd, el, i, l, cn, at, no, hc = false; + + if (this._isDuplicate(n)) + return; + + xd = this.xmlDoc; + + switch (n.nodeType) { + case 1: // Element + hc = n.hasChildNodes(); + + el = xd.createElement(n.nodeName.toLowerCase()); + + at = n.attributes; + for (i=at.length-1; i>-1; i--) { + no = at[i]; + + if (no.specified && no.nodeValue) + el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue); + } + + if (!hc && !this.closeElementsRe.test(n.nodeName)) + el.appendChild(xd.createTextNode("")); + + xn = xn.appendChild(el); + break; + + case 3: // Text + xn.appendChild(xd.createTextNode(n.nodeValue)); + return; + + case 8: // Comment + xn.appendChild(xd.createComment(n.nodeValue)); + return; + } + + if (hc) { + cn = n.childNodes; + + for (i=0, l=cn.length; i + if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && n.nodeName.indexOf('/') != -1) + break; + + if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName))) { + va = true; + + r = this.rules[n.nodeName]; + if (!r) { + at = this.rules; + for (no in at) { + if (at[no] && at[no].validRe.test(n.nodeName)) { + r = at[no]; + break; + } + } + } + + en = r.isWild ? n.nodeName.toLowerCase() : r.oTagName; + f = r.fill; + + if (r.removeEmpty && !hc) + return ""; + + h += '<' + en; + + if (r.vAttribsReIsWild) { + // Serialize wildcard attributes + at = n.attributes; + for (i=at.length-1; i>-1; i--) { + no = at[i]; + if (no.specified && r.vAttribsRe.test(no.nodeName)) + h += this._serializeAttribute(n, r, no.nodeName); + } + } else { + // Serialize specific attributes + for (i=r.vAttribs.length-1; i>-1; i--) + h += this._serializeAttribute(n, r, r.vAttribs[i]); + } + + // Serialize mce_ atts + if (!this.settings.on_save) { + at = this.mceAttribs; + + for (no in at) { + if (at[no]) + h += this._serializeAttribute(n, r, at[no]); + } + } + + // Close these + if (this.closeElementsRe.test(n.nodeName)) + return h + ' />'; + + h += '>'; + + if (this.isMSIE && this.codeElementsRe.test(n.nodeName)) + h += n.innerHTML; + } + break; + + case 3: // Text + if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName)) + return this.isMSIE ? '' : n.nodeValue; + + return this.xmlEncode(n.nodeValue); + + case 8: // Comment + return ""; + } + + 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 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an)) + av = eval(this.settings.url_converter + '(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) + return " " + an + "=" + '"' + this.xmlEncode(av) + '"'; + + return ""; + }, + + formatHTML : function(h) { + var s = this.settings, p = '', i = 0, li = 0, o = '', l; + + 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 i, l, e, o = '', c; + + this._setupEntities(); // Will intialize lookup table + + switch (this.settings.entity_encoding) { + case "raw": + return tinyMCE.xmlEncode(s); + + case "named": + for (i=0, l=s.length; i 127 || c == 60 || c == 62 || c == 38 || c == 39 || c == 34) + o += '&#' + c + ";"; + else + o += String.fromCharCode(c); + } + + return o; + } + + return s; + }, + + split : function(re, s) { + var c = s.split(re); + var i, l, o = new Array(); + + for (i=0, l=c.length; i 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(/]*)> <\/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); + } +}; + +TinyMCE_Engine.prototype.getOuterHTML = function(e) { + if (tinyMCE.isMSIE) + return e.outerHTML; + + var d = e.ownerDocument.createElement("body"); + d.appendChild(e); + return d.innerHTML; +}; + +TinyMCE_Engine.prototype.setOuterHTML = function(e, h) { + if (tinyMCE.isMSIE) { + e.outerHTML = h; + return; + } + + var d = e.ownerDocument.createElement("body"); + d.innerHTML = h; + e.parentNode.replaceChild(d.firstChild, e); +}; + +TinyMCE_Engine.prototype._getElementById = function(id, d) { + var e, i, j, f; + + if (typeof(d) == "undefined") + d = document; + + e = d.getElementById(id); + if (!e) { + f = d.forms; + + for (i=0; i 0); - - if (tinyMCE.settings['custom_undo_redo']) { - undoIndex = inst.undoIndex; - undoLevels = inst.undoLevels.length; - } - - tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content); - } - } - - if (this.selectedInstance && (typeof(focus) == "undefined" || focus)) - this.selectedInstance.contentWindow.focus(); -}; - -TinyMCE.prototype._customCleanup = function(inst, type, content) { - // Call custom cleanup - var customCleanup = tinyMCE.settings['cleanup_callback']; - if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") - content = eval(customCleanup + "(type, content, inst);"); - - // Trigger plugin cleanups - var plugins = tinyMCE.getParam('plugins', '', true, ','); - for (var i=0; i 0) - className += " "; - - className += classNames[i]; - } - - return className; -}; - -TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) { - if (!el) - return; - - var tableElement = null; - - switch (el.nodeName) { - case "TABLE": - var oldW = el.style.width; - var oldH = el.style.height; - var bo = tinyMCE.getAttrib(el, "border"); - - bo = bo == "" || bo == "0" ? true : false; - - tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); - - el.style.width = oldW; - el.style.height = oldH; - - for (var y=0; y 0) { - tinyMCE.setAttrib(s[i], 'size', fSize); - s[i].style.fontSize = ''; - } - - var fFace = s[i].style.fontFamily; - if (fFace != null && fFace != "") { - tinyMCE.setAttrib(s[i], 'face', fFace); - s[i].style.fontFamily = ''; - } - - var fColor = s[i].style.color; - if (fColor != null && fColor != "") { - tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); - s[i].style.color = ''; - } - } -}; - -TinyMCE.prototype.convertFontsToSpans = function(doc) { - var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); - - var h = doc.body.innerHTML; - h = h.replace(/ 0 && fSize < 8) { - if (fsClasses != null) - tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); - else - s[i].style.fontSize = sizes[fSize-1]; - } - - s[i].removeAttribute('size'); - } - - if (fFace != "") { - s[i].style.fontFamily = fFace; - s[i].removeAttribute('face'); - } - - if (fColor != "") { - s[i].style.color = fColor; - s[i].removeAttribute('color'); - } - } -}; - -/* -TinyMCE.prototype.applyClassesToFonts = function(doc, size) { - var f = doc.getElementsByTagName("font"); - for (var i=0; i=0; x--) - tinyMCE.insertAfter(cn[x], an[i]); - } - } -}; - -TinyMCE.prototype._setHTML = function(doc, html_content) { - // Force closed anchors open - //html_content = html_content.replace(new RegExp('', 'gi'), '
    '); - - html_content = tinyMCE.cleanupHTMLCode(html_content); - - // Try innerHTML if it fails use pasteHTML in MSIE - try { - tinyMCE.setInnerHTML(doc.body, html_content); - } catch (e) { - if (this.isMSIE) - doc.body.createTextRange().pasteHTML(html_content); - } - - // Content duplication bug fix - if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) { - // Remove P elements in P elements - var paras = doc.getElementsByTagName("P"); - for (var i=0; i<\/o:p>", "
    "); - html = tinyMCE.regexpReplace(html, " <\/o:p>", ""); - html = tinyMCE.regexpReplace(html, "", ""); - html = tinyMCE.regexpReplace(html, "

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

    <\/p>\r\n

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

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

    \s*(

    \s*)?", "

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

    "); - } - - // Always set the htmlText output - tinyMCE.setInnerHTML(doc.body, html); - } - - tinyMCE.cleanupAnchors(doc); - - if (tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertSpansToFonts(doc); -}; - -TinyMCE.prototype.getImageSrc = function(str) { - var pos = -1; - - if (!str) - return ""; - - if ((pos = str.indexOf('this.src=')) != -1) { - var src = str.substring(pos + 10); - - src = src.substring(0, src.indexOf('\'')); - - return src; - } - - return ""; -}; - -TinyMCE.prototype._getElementById = function(element_id) { - var elm = document.getElementById(element_id); - if (!elm) { - // Check for element in forms - for (var j=0; j 0) { - for (var x=0; x 0) - tinyMCE.cssClasses = output; - - return output; -}; - -TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) { - if (in_str == null) - return in_str; - - if (typeof(opts) == "undefined") - opts = 'g'; - - var re = new RegExp(reg_exp, opts); - return in_str.replace(re, replace_str); -}; - -TinyMCE.prototype.trim = function(str) { - return str.replace(/^\s*|\s*$/g, ""); -}; - -TinyMCE.prototype.cleanupEventStr = function(str) { - str = "" + str; - str = str.replace('function anonymous()\n{\n', ''); - str = str.replace('\n}', ''); - str = str.replace(/^return true;/gi, ''); // Remove event blocker - - return str; -}; - -TinyMCE.prototype.getAbsPosition = function(node) { - var pos = new Object(); - - pos.absLeft = pos.absTop = 0; - - var parentNode = node; - while (parentNode) { - pos.absLeft += parentNode.offsetLeft; - pos.absTop += parentNode.offsetTop; - - parentNode = parentNode.offsetParent; - } - - return pos; -}; - -TinyMCE.prototype.getControlHTML = function(control_name) { - var themePlugins = tinyMCE.getParam('plugins', '', true, ','); - var templateFunction; - - // Is it defined in any plugins - for (var i=themePlugins.length; i>=0; i--) { - templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML"; - if (eval("typeof(" + templateFunction + ")") != 'undefined') { - var html = eval(templateFunction + "('" + control_name + "');"); - if (html != "") - return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]); - } - } - - return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');"); -}; - -TinyMCE.prototype._themeExecCommand = function(editor_id, element, command, user_interface, value) { - var themePlugins = tinyMCE.getParam('plugins', '', true, ','); - var templateFunction; - - // Is it defined in any plugins - for (var i=themePlugins.length; i>=0; i--) { - templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand"; - if (eval("typeof(" + templateFunction + ")") != 'undefined') { - if (eval(templateFunction + "(editor_id, element, command, user_interface, value);")) - return true; - } - } - - // Theme funtion - templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand"; - if (eval("typeof(" + templateFunction + ")") != 'undefined') - return eval(templateFunction + "(editor_id, element, command, user_interface, value);"); - - // Pass to normal - return false; -}; - -TinyMCE.prototype._getThemeFunction = function(suffix, skip_plugins) { - if (skip_plugins) - return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; - - var themePlugins = tinyMCE.getParam('plugins', '', true, ','); - var templateFunction; - - // Is it defined in any plugins - for (var i=themePlugins.length; i>=0; i--) { - templateFunction = 'TinyMCE_' + themePlugins[i] + suffix; - if (eval("typeof(" + templateFunction + ")") != 'undefined') - return templateFunction; - } - - return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix; -}; - - -TinyMCE.prototype.isFunc = function(func_name) { - if (func_name == null || func_name == "") - return false; - - return eval("typeof(" + func_name + ")") != "undefined"; -}; - -TinyMCE.prototype.exec = function(func_name, args) { - var str = func_name + '('; - - // Add all arguments - for (var i=3; i 1 && tinyMCE.currentConfig != this.settings['index']) { - tinyMCE.settings = this.settings; - tinyMCE.currentConfig = this.settings['index']; - } -}; - -TinyMCEControl.prototype.convertAllRelativeURLs = function() { - var body = this.getBody(); - +TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) { // Convert all image URL:s to absolute URL var elms = body.getElementsByTagName("img"); for (var i=0; i bookmark.index) + rng.addElement(nl[bookmark.index]); + } else { + rng = inst.getSel().createRange(); + rng.moveToElementText(inst.getBody()); + rng.collapse(true); + rng.moveStart('character', bookmark.start); + rng.moveEnd('character', bookmark.length); + } + + rng.select(); + + win.scrollTo(bookmark.scrollX, bookmark.scrollY); + return true; + } + + if (tinyMCE.isGecko && bookmark.rng) { + sel.removeAllRanges(); + sel.addRange(bookmark.rng); + win.scrollTo(bookmark.scrollX, bookmark.scrollY); + return true; + } + + if (tinyMCE.isGecko) { + // try { + rng = doc.createRange(); + + nl = doc.getElementsByTagName(bookmark.startTag); + if (nl.length > bookmark.start) + rng.setStart(nl[bookmark.start].childNodes[bookmark.startIndex], bookmark.startOffset); + + nl = doc.getElementsByTagName(bookmark.endTag); + if (nl.length > bookmark.end) + rng.setEnd(nl[bookmark.end].childNodes[bookmark.endIndex], bookmark.endOffset); + + sel.removeAllRanges(); + sel.addRange(rng); + /* } catch { + // Ignore + }*/ + + win.scrollTo(bookmark.scrollX, bookmark.scrollY); + return true; + } + + return false; + }, + + 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 (tinyMCE.isMSIE) { + rng = inst.getBody().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, new Array(), 3); + if (nodes.length > 0) + rng.selectNodeContents(nodes[0]); + else + rng.selectNodeContents(node); + } else + rng.selectNode(node); if (collapse) { - if (to_start) - sel.realSelection.collapseToStart(); - else - sel.realSelection.collapseToEnd(); + // 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); } - this.scrollToNode(node); - - return; + sel.removeAllRanges(); + sel.addRange(rng); } - var rng = this.getDoc().createRange(); + this.scrollToNode(node); - if (select_text_node) { - // Find first textnode in tree - var nodes = tinyMCE.getNodeTree(node, new Array(), 3); - if (nodes.length > 0) - rng.selectNodeContents(nodes[0]); - else - rng.selectNodeContents(node); - } else - rng.selectNode(node); + // Set selected element + tinyMCE.selectedElement = null; + if (node.nodeType == 1) + tinyMCE.selectedElement = 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); - } + scrollToNode : function(node) { + var inst = this.instance; + var pos, doc, scrollX, scrollY, height; - sel.removeAllRanges(); - sel.addRange(rng); - } + // Scroll to node position + pos = tinyMCE.getAbsPosition(node); + doc = inst.getDoc(); + scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft; + scrollY = doc.body.scrollTop + doc.documentElement.scrollTop; + height = tinyMCE.isMSIE ? document.getElementById(inst.editorId).style.pixelHeight : inst.targetElement.clientHeight; - this.scrollToNode(node); + // Only scroll if out of visible area + if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height))) + inst.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25); + }, - // Set selected element - tinyMCE.selectedElement = null; - if (node.nodeType == 1) - tinyMCE.selectedElement = node; -}; + getSel : function() { + var inst = this.instance; -TinyMCEControl.prototype.scrollToNode = function(node) { - // Scroll to node position - var pos = tinyMCE.getAbsPosition(node); - var doc = this.getDoc(); - var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft; - var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop; - var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : this.targetElement.clientHeight; + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + return inst.getDoc().selection; - // Only scroll if out of visible area - if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height))) - this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25); -}; + return inst.contentWindow.getSelection(); + }, -TinyMCEControl.prototype.getBody = function() { - return this.getDoc().body; -}; + getRng : function() { + var inst = this.instance; + var sel = this.getSel(); -TinyMCEControl.prototype.getDoc = function() { - return this.contentWindow.document; -}; + if (sel == null) + return null; -TinyMCEControl.prototype.getWin = function() { - return this.contentWindow; -}; + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + return sel.createRange(); -TinyMCEControl.prototype.getSel = function() { - if (tinyMCE.isMSIE && !tinyMCE.isOpera) - return this.getDoc().selection; + if (tinyMCE.isSafari && !sel.getRangeAt) + return '' + window.getSelection(); - var sel = this.contentWindow.getSelection(); + return sel.getRangeAt(0); + }, - // Fake getRangeAt - if (tinyMCE.isSafari && !sel.getRangeAt) { - var newSel = new Object(); - var doc = this.getDoc(); + getFocusElement : function() { + var inst = this.instance; - function getRangeAt(idx) { - var rng = new Object(); + if (tinyMCE.isMSIE && !tinyMCE.isOpera) { + var doc = inst.getDoc(); + var rng = doc.selection.createRange(); - rng.startContainer = this.focusNode; - rng.endContainer = this.anchorNode; - rng.commonAncestorContainer = this.focusNode; - rng.createContextualFragment = function (html) { - // Seems to be a tag - if (html.charAt(0) == '<') { - var elm = doc.createElement("div"); + // if (rng.collapse) + // rng.collapse(true); - elm.innerHTML = html; - - return elm.firstChild; - } - - return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!"); - }; - - rng.deleteContents = function () { - doc.execCommand("Delete", false, ""); - }; - - return rng; - } - - // Patch selection - - newSel.focusNode = sel.baseNode; - newSel.focusOffset = sel.baseOffset; - newSel.anchorNode = sel.extentNode; - newSel.anchorOffset = sel.extentOffset; - newSel.getRangeAt = getRangeAt; - newSel.text = "" + sel; - newSel.realSelection = sel; - - newSel.toString = function () {return this.text;}; - - return newSel; - } - - return sel; -}; - -TinyMCEControl.prototype.getRng = function() { - var sel = this.getSel(); - if (sel == null) - return null; - - if (tinyMCE.isMSIE && !tinyMCE.isOpera) - return sel.createRange(); - - if (tinyMCE.isSafari) { - var rng = this.getDoc().createRange(); - var sel = this.getSel().realSelection; - - rng.setStart(sel.baseNode, sel.baseOffset); - rng.setEnd(sel.extentNode, sel.extentOffset); - - return rng; - } - - return this.getSel().getRangeAt(0); -}; - -TinyMCEControl.prototype._insertPara = function(e) { - function isEmpty(para) { - function isEmptyHTML(html) { - return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == ""; - } - - // Check for images - if (para.getElementsByTagName("img").length > 0) - return false; - - // Check for tables - if (para.getElementsByTagName("table").length > 0) - return false; - - // Check for HRs - if (para.getElementsByTagName("hr").length > 0) - return false; - - // Check all textnodes - var nodes = tinyMCE.getNodeTree(para, new Array(), 3); - for (var i=0; i <" + blockName + "> "; - paraAfter = body.childNodes[1]; + if (inst.isHidden()) + return inst.getBody(); + + var sel = this.getSel(); + var rng = this.getRng(); + + if (!sel || !rng) + return null; + + var elm = rng.commonAncestorContainer; + //var 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; } - this.selectNode(paraAfter, true, true); - - return true; + return elm; } - - // Place first part within new paragraph - if (startChop.nodeName == blockName) - rngBefore.setStart(startChop, 0); - else - rngBefore.setStartBefore(startChop); - - rngBefore.setEnd(startNode, startOffset); - paraBefore.appendChild(rngBefore.cloneContents()); - - // Place secound part within new paragraph - rngAfter.setEndAfter(endChop); - rngAfter.setStart(endNode, endOffset); - var contents = rngAfter.cloneContents(); - - if (contents.firstChild && contents.firstChild.nodeName == blockName) { -/* var nodes = contents.firstChild.childNodes; - for (var i=0; i customUndoLevels) { + for (var 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); + } + + // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex); + }, + + 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 (this.undoIndex > 0) +// inst.selection.moveToBookmark(this.undoLevels[this.undoIndex-1].bookmark); + if (inst.settings.custom_undo_redo_restore_selection) + inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark); + // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex); + } + + tinyMCE.triggerNodeChange(); + } +}; + +/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */ + +var TinyMCE_ForceParagraphs = { + _insertPara : function(inst, e) { + function isEmpty(para) { + function isEmptyHTML(html) { + return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == ""; + } + + // Check for images + if (para.getElementsByTagName("img").length > 0) + return false; + + // Check for tables + if (para.getElementsByTagName("table").length > 0) + return false; + + // Check for HRs + if (para.getElementsByTagName("hr").length > 0) + return false; + + // Check all textnodes + var nodes = tinyMCE.getNodeTree(para, new Array(), 3); + for (var i=0; i 0) - rng.pasteHTML('
    ' + rng.htmlText + "
    "); - - tinyMCE.triggerNodeChange(); - return; - } - } - } - - switch (command) { - case "mceRepaint": - this.repaint(); - return true; - - case "mceStoreSelection": - this.selectionBookmark = this.getBookmark(); - return true; - - case "mceRestoreSelection": - this.moveToBookmark(this.selectionBookmark); - return true; - - case "InsertUnorderedList": - case "InsertOrderedList": - var tag = (command == "InsertUnorderedList") ? "ul" : "ol"; - - if (tinyMCE.isSafari) - this.execCommand("mceInsertContent", false, "<" + tag + ">
  •  
  • <" + tag + ">"); - else - this.getDoc().execCommand(command, user_interface, value); - - tinyMCE.triggerNodeChange(); - break; - - case "Strikethrough": - if (tinyMCE.isSafari) - this.execCommand("mceInsertContent", false, "" + this.getSelectedHTML() + ""); - else - this.getDoc().execCommand(command, user_interface, value); - - tinyMCE.triggerNodeChange(); - break; - - case "mceSelectNode": - this.selectNode(value); - tinyMCE.triggerNodeChange(); - tinyMCE.selectedNode = value; - break; - - case "FormatBlock": - if (value == null || value == "") { - var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address"); - - if (elm) - this.execCommand("mceRemoveNode", false, elm); - } else - this.getDoc().execCommand("FormatBlock", false, value); - - tinyMCE.triggerNodeChange(); - - break; - - case "mceRemoveNode": - if (!value) - value = tinyMCE.getParentElement(this.getFocusElement()); - - if (tinyMCE.isMSIE) { - value.outerHTML = value.innerHTML; - } else { - var rng = value.ownerDocument.createRange(); - rng.setStartBefore(value); - rng.setEndAfter(value); + // Delete old contents rng.deleteContents(); - rng.insertNode(rng.createContextualFragment(value.innerHTML)); + rngAfter.deleteContents(); + rngBefore.deleteContents(); + + // Insert new paragraphs + paraAfter.normalize(); + rngBefore.insertNode(paraAfter); + paraBefore.normalize(); + rngBefore.insertNode(paraBefore); + + // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML); + } else { + body.innerHTML = "<" + blockName + "> <" + blockName + "> "; + paraAfter = body.childNodes[1]; } - tinyMCE.triggerNodeChange(); + inst.selection.selectNode(paraAfter, true, true); - break; + return true; + } - case "mceSelectNodeDepth": - var parentNode = this.getFocusElement(); - for (var i=0; parentNode; i++) { - if (parentNode.nodeName.toLowerCase() == "body") + // Place first part within new paragraph + if (startChop.nodeName == blockName) + rngBefore.setStart(startChop, 0); + else + rngBefore.setStartBefore(startChop); + + rngBefore.setEnd(startNode, startOffset); + paraBefore.appendChild(rngBefore.cloneContents()); + + // Place secound part within new paragraph + rngAfter.setEndAfter(endChop); + rngAfter.setStart(endNode, endOffset); + var contents = rngAfter.cloneContents(); + + if (contents.firstChild && contents.firstChild.nodeName == blockName) { + /* var nodes = contents.firstChild.childNodes; + for (var i=0; i
    '; + } - 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; + h += '
    {$lang_insert_link_title}
    {$lang_insert_link_url}: - - - - -
     
    + + + + +
     
    {$lang_insert_link_target}: +
    - +
    - +
    diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js index 4e92fdce57..9fbf19f152 100644 --- a/wp-includes/js/tinymce/tiny_mce.js +++ b/wp-includes/js/tinymce/tiny_mce.js @@ -1,19 +1,13 @@ -/** - * $RCSfile: tiny_mce_src.js,v $ - * $Revision: 1.281 $ - * $Date: 2005/12/02 08:12:07 $ - * - * @author Moxiecode - * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved. - */ -function TinyMCE() { +/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */ + +function TinyMCE_Engine() { this.majorVersion = "2"; - this.minorVersion = "0"; - this.releaseDate = "2005-12-01"; + this.minorVersion = "0.5.1"; + this.releaseDate = "2006-03-22"; this.instances = new Array(); - this.stickyClassesLookup = new Array(); + this.switchClassCache = new Array(); this.windowArgs = new Array(); this.loadedFiles = new Array(); this.configs = new Array(); @@ -32,6 +26,12 @@ function TinyMCE() { this.isNS7 = ua.indexOf('Netscape/7') != -1; this.isNS71 = ua.indexOf('Netscape/7.1') != -1; this.dialogCounter = 0; + this.plugins = new Array(); + this.themes = new Array(); + this.menus = new Array(); + this.loadedPlugins = new Array(); + this.buttonMap = new Array(); + this.isLoaded = false; // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those if (this.isOpera) { @@ -44,342 +44,3376 @@ function TinyMCE() { this.idCounter = 0; }; -TinyMCE.prototype.defParam = function(key, def_val) { - this.settings[key] = tinyMCE.getParam(key, def_val); -}; +TinyMCE_Engine.prototype = { + init : function(settings) { + var theme; -TinyMCE.prototype.init = function(settings) { - var theme; + this.settings = settings; - this.settings = settings; + // Check if valid browser has execcommand support + if (typeof(document.execCommand) == 'undefined') + return; - // Check if valid browser has execcommand support - if (typeof(document.execCommand) == 'undefined') - return; + // Get script base path + if (!tinyMCE.baseURL) { + var elements = document.getElementsByTagName('script'); - // Get script base path - if (!tinyMCE.baseURL) { - var elements = document.getElementsByTagName('script'); + for (var i=0; i'); - this.defParam("font_size_classes", ''); - this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large'); - this.defParam("event_elements", 'a,img'); - this.defParam("convert_urls", true); - this.defParam("table_inline_editing", false); - this.defParam("object_resizing", true); + // Set default values on settings + this._def("mode", "none"); + this._def("theme", "advanced"); + this._def("plugins", "", true); + this._def("language", "en"); + this._def("docs_language", this.settings['language']); + this._def("elements", ""); + this._def("textarea_trigger", "mce_editable"); + this._def("editor_selector", ""); + this._def("editor_deselector", "mceNoEditor"); + this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]"); + this._def("extended_valid_elements", ""); + this._def("invalid_elements", ""); + this._def("encoding", ""); + this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL")); + this._def("save_callback", ""); + this._def("debug", false); + this._def("force_br_newlines", false); + this._def("force_p_newlines", true); + this._def("add_form_submit_trigger", true); + this._def("relative_urls", true); + this._def("remove_script_host", true); + this._def("focus_alert", true); + this._def("document_base_url", this.documentURL); + this._def("visual", true); + this._def("visual_table_class", "mceVisualAid"); + this._def("setupcontent_callback", ""); + this._def("fix_content_duplication", true); + this._def("custom_undo_redo", true); + this._def("custom_undo_redo_levels", -1); + this._def("custom_undo_redo_keyboard_shortcuts", true); + this._def("custom_undo_redo_restore_selection", true); + this._def("verify_html", true); + this._def("apply_source_formatting", false); + this._def("directionality", "ltr"); + this._def("cleanup_on_startup", false); + this._def("inline_styles", false); + this._def("convert_newlines_to_brs", false); + this._def("auto_reset_designmode", true); + this._def("entities", "160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true); + this._def("entity_encoding", "named"); + this._def("cleanup_callback", ""); + this._def("add_unload_trigger", true); + this._def("ask", false); + this._def("nowrap", false); + this._def("auto_resize", false); + this._def("auto_focus", false); + this._def("cleanup", true); + this._def("remove_linebreaks", true); + this._def("button_tile_map", false); + this._def("submit_patch", true); + this._def("browsers", "msie,safari,gecko,opera", true); + this._def("dialog_type", "window"); + this._def("accessibility_warnings", true); + this._def("accessibility_focus", true); + this._def("merge_styles_invalid_parents", ""); + this._def("force_hex_style_colors", true); + this._def("trim_span_elements", true); + this._def("convert_fonts_to_spans", false); + this._def("doctype", ''); + 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", false); + this._def("fix_table_elements", false); - // Browser check IE - if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1) - return; + // 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 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 Safari + if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1) + return; - // Browser check Opera - if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1) - return; + // Browser check Opera + if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1) + return; - // If not super absolute make it so - var baseHREF = tinyMCE.settings['document_base_url']; - var h = document.location.href; - var p = h.indexOf('://'); - if (p > 0 && document.location.protocol != "file:") { - p = h.indexOf('/', p + 3); - h = h.substring(0, p); + // If not super absolute make it so + var baseHREF = tinyMCE.settings['document_base_url']; + var h = document.location.href; + var p = h.indexOf('://'); + if (p > 0 && document.location.protocol != "file:") { + p = h.indexOf('/', p + 3); + h = h.substring(0, p); - if (baseHREF.indexOf('://') == -1) - baseHREF = h + baseHREF; + if (baseHREF.indexOf('://') == -1) + baseHREF = h + baseHREF; - tinyMCE.settings['document_base_url'] = baseHREF; - tinyMCE.settings['document_base_prefix'] = h; - } + 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('?')); + // Trim away query part + if (baseHREF.indexOf('?') != -1) + baseHREF = baseHREF.substring(0, baseHREF.indexOf('?')); - this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; + this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/"; - theme = this.settings['theme']; - this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i"); - this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); - this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL - this.uniqueTag = ''; + theme = this.settings['theme']; + this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i"); + this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); + this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL + this.uniqueTag = ''; + this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup'); - // Theme url - this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme; + // Theme url + this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme; - if (!tinyMCE.isMSIE) - this.settings['force_br_newlines'] = false; + if (!tinyMCE.isMSIE) + this.settings['force_br_newlines'] = false; - if (tinyMCE.getParam("content_css", false)) { - var cssPath = tinyMCE.getParam("content_css", ""); + if (tinyMCE.getParam("popups_css", false)) { + var cssPath = tinyMCE.getParam("popups_css", ""); - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['content_css'] = this.documentBasePath + "/" + cssPath; - else - this.settings['content_css'] = cssPath; - } else - this.settings['content_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("popups_css", false)) { - var cssPath = tinyMCE.getParam("popups_css", ""); + if (tinyMCE.getParam("editor_css", false)) { + var cssPath = tinyMCE.getParam("editor_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"; + // Is relative + if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') + this.settings['editor_css'] = this.documentBasePath + "/" + cssPath; + else + this.settings['editor_css'] = cssPath; + } else + this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; - if (tinyMCE.getParam("editor_css", false)) { - var cssPath = tinyMCE.getParam("editor_css", ""); + if (tinyMCE.settings['debug']) { + var msg = "Debug: \n"; - // Is relative - if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/') - this.settings['editor_css'] = this.documentBasePath + "/" + cssPath; - else - this.settings['editor_css'] = cssPath; - } else - this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css"; + msg += "baseURL: " + this.baseURL + "\n"; + msg += "documentBasePath: " + this.documentBasePath + "\n"; + msg += "content_css: " + this.settings['content_css'] + "\n"; + msg += "popups_css: " + this.settings['popups_css'] + "\n"; + msg += "editor_css: " + this.settings['editor_css'] + "\n"; - if (tinyMCE.settings['debug']) { - var msg = "Debug: \n"; + alert(msg); + } - msg += "baseURL: " + this.baseURL + "\n"; - msg += "documentBasePath: " + this.documentBasePath + "\n"; - msg += "content_css: " + this.settings['content_css'] + "\n"; - msg += "popups_css: " + this.settings['popups_css'] + "\n"; - msg += "editor_css: " + this.settings['editor_css'] + "\n"; + // Only do this once + if (this.configs.length == 0) { + // Is Safari enabled + if (this.isSafari && this.getParam('safari_warning', false)) + alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false"); - alert(msg); - } + if (typeof(TinyMCECompressed) == "undefined") { + tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad); - // Init HTML cleanup - this._initCleanup(); + if (tinyMCE.isMSIE && !tinyMCE.isOpera) { + if (document.body) + tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad); + else + tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad); + } - // Only do this once - if (this.configs.length == 0) { - // Is Safari enabled - if (this.isSafari && this.getParam('safari_warning', true)) - alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false"); + tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad); + tinyMCE._addUnloadEvents(); + } + } - tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad); + this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js'); + this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js'); + this.loadCSS(this.settings['editor_css']); + // Add plugins + var p = tinyMCE.getParam('plugins', '', true, ','); + if (p.length > 0) { + for (var i=0; i'); + + this.loadedFiles[this.loadedFiles.length] = url; + }, + + loadCSS : function(url) { + var ar = url.replace(/\s+/, '').split(','); + var lflen = 0, csslen = 0; + var skip = false; + var x = 0, i = 0; + + 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.isMSIE ? 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) { + // Find MCE instance linked to given form element and copy it's value + var formElement = document.getElementById(form_element_name); + for (var n in tinyMCE.instances) { + var inst = tinyMCE.instances[n]; + if (!tinyMCE.isInstance(inst)) + continue; + + inst.switchSettings(); + + if (inst.formElement == formElement) { + var doc = inst.getDoc(); + + tinyMCE._setHTML(doc, inst.formElement.value); + + if (!tinyMCE.isMSIE) + doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); + } + } + }, + + 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); + }, + + removeMCEControl : function(editor_id) { + var inst = tinyMCE.getInstanceById(editor_id); + + if (inst) { + inst.switchSettings(); + + editor_id = inst.editorId; + var html = tinyMCE.getContent(editor_id); + + // Remove editor instance from instances array + var tmpInstances = new Array(); + for (var instanceName in tinyMCE.instances) { + var instance = tinyMCE.instances[instanceName]; + if (!tinyMCE.isInstance(instance)) + continue; + + if (instanceName != editor_id) + tmpInstances[instanceName] = instance; + } + tinyMCE.instances = tmpInstances; + + tinyMCE.selectedElement = null; + tinyMCE.selectedInstance = null; + + // Remove element + var replaceElement = document.getElementById(editor_id + "_parent"); + var oldTargetElement = inst.oldTargetElement; + var targetName = oldTargetElement.nodeName.toLowerCase(); + + if (targetName == "textarea" || targetName == "input") { + // Just show the old text area + replaceElement.parentNode.removeChild(replaceElement); + oldTargetElement.style.display = "inline"; + oldTargetElement.value = html; + } else { + oldTargetElement.innerHTML = html; + oldTargetElement.style.display = 'block'; + + replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement); + replaceElement.parentNode.removeChild(replaceElement); + } + } + }, + + triggerSave : function(skip_cleanup, skip_callback) { + var inst, n; + + // Default to false + if (typeof(skip_cleanup) == "undefined") + skip_cleanup = false; + + // Default to false + if (typeof(skip_callback) == "undefined") + skip_callback = false; + + // Cleanup and set all form fields + for (n in tinyMCE.instances) { + inst = tinyMCE.instances[n]; + + if (!tinyMCE.isInstance(inst)) + continue; + + inst.triggerSave(skip_cleanup, skip_callback); + } + }, + + resetForm : function(form_index) { + var i, inst, n, formObj = document.forms[form_index]; + + for (n in tinyMCE.instances) { + inst = tinyMCE.instances[n]; + + if (!tinyMCE.isInstance(inst)) + continue; + + inst.switchSettings(); + + for (i=0; i'); - - this.loadedFiles[this.loadedFiles.length] = url; -}; - -TinyMCE.prototype.loadCSS = function(url) { - for (var i=0; i'); + case "mceAddControl": + case "mceAddEditor": + tinyMCE.addMCEControl(tinyMCE._getElementById(value), value); + return; - this.loadedFiles[this.loadedFiles.length] = url; -}; + case "mceAddFrameControl": + tinyMCE.addMCEControl(tinyMCE._getElementById(value['element'], value['document']), value['element'], value['document']); + return; -TinyMCE.prototype.importCSS = function(doc, css_file) { - if (css_file == '') - return; + case "mceRemoveControl": + case "mceRemoveEditor": + tinyMCE.removeMCEControl(value); + return; - if (typeof(doc.createStyleSheet) == "undefined") { - var elm = doc.createElement("link"); + case "mceResetDesignMode": + // Resets the designmode state of the editors in Gecko + if (!tinyMCE.isMSIE) { + for (var n in tinyMCE.instances) { + if (!tinyMCE.isInstance(tinyMCE.instances[n])) + continue; - elm.rel = "stylesheet"; - elm.href = css_file; + try { + tinyMCE.instances[n].getDoc().designMode = "on"; + } catch (e) { + // Ignore any errors + } + } + } - if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0) - headArr[0].appendChild(elm); - } else - var styleSheet = doc.createStyleSheet(css_file); -}; + return; + } -TinyMCE.prototype.confirmAdd = function(e, settings) { - var elm = tinyMCE.isMSIE ? event.srcElement : e.target; - var elementId = elm.name ? elm.name : elm.id; + if (this.selectedInstance) { + this.selectedInstance.execCommand(command, user_interface, value); + } else if (tinyMCE.settings['focus_alert']) + alert(tinyMCELang['lang_focus_alert']); + }, - tinyMCE.settings = settings; + _createIFrame : function(replace_element, doc, win) { + var iframe, id = replace_element.getAttribute("id"); + var aw, ah; - if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])) - tinyMCE.addMCEControl(elm, elementId); + if (typeof(doc) == "undefined") + doc = document; - elm.setAttribute('mce_noask', 'true'); -}; + if (typeof(win) == "undefined") + win = window; -TinyMCE.prototype.updateContent = function(form_element_name) { - // Find MCE instance linked to given form element and copy it's value - var formElement = document.getElementById(form_element_name); - for (var n in tinyMCE.instances) { - var inst = tinyMCE.instances[n]; - if (!tinyMCE.isInstance(inst)) - continue; + iframe = doc.createElement("iframe"); + + aw = "" + tinyMCE.settings['area_width']; + ah = "" + tinyMCE.settings['area_height']; + + if (aw.indexOf('%') == -1) { + aw = parseInt(aw); + aw = aw < 0 ? 300 : aw; + aw = aw + "px"; + } + + if (ah.indexOf('%') == -1) { + ah = parseInt(ah); + ah = ah < 0 ? 240 : ah; + ah = ah + "px"; + } + + iframe.setAttribute("id", id); + iframe.setAttribute("className", "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"); + + if (tinyMCE.settings["auto_resize"]) + iframe.setAttribute("scrolling", "no"); + + // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + iframe.setAttribute("src", this.settings['default_document']); + + iframe.style.width = aw; + iframe.style.height = ah; + + // MSIE 5.0 issue + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + replace_element.outerHTML = iframe.outerHTML; + else + replace_element.parentNode.replaceChild(iframe, replace_element); + + if (tinyMCE.isMSIE && !tinyMCE.isOpera) + return win.frames[id]; + else + return iframe; + }, + + setupContent : function(editor_id) { + var inst = tinyMCE.instances[editor_id]; + var doc = inst.getDoc(); + var head = doc.getElementsByTagName('head').item(0); + var content = inst.startContent; inst.switchSettings(); - if (inst.formElement == formElement) { + // Not loaded correctly hit it again, Mozilla bug #997860 + if (!tinyMCE.isMSIE && 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; + } + + if (!head) { + 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'); + } + + // 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.getDoc().body.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.isMSIE) + 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.isMSIE) { + // 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;"); + + var body = inst.getBody(); + body.editorId = editor_id; + } + + content = tinyMCE.cleanupHTMLCode(content); + + // Fix for bug #958637 + if (!tinyMCE.isMSIE) { + var contentElement = inst.getDoc().createElement("body"); var doc = inst.getDoc(); - tinyMCE._setHTML(doc, inst.formElement.value); + contentElement.innerHTML = content; - if (!tinyMCE.isMSIE) - doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid); + // Remove weridness! + if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) + content = content.replace(new RegExp('<>', 'g'), ""); + + if (tinyMCE.settings['cleanup_on_startup']) + tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement)); + else { + // Convert all strong/em to b/i + content = tinyMCE.regexpReplace(content, "", "", "gi"); + content = tinyMCE.regexpReplace(content, "", "", "gi"); + content = tinyMCE.regexpReplace(content, "", "", "gi"); + tinyMCE.setInnerHTML(inst.getBody(), content); + } + + tinyMCE.convertAllRelativeURLs(inst.getBody()); + } else { + if (tinyMCE.settings['cleanup_on_startup']) { + tinyMCE._setHTML(inst.getDoc(), content); + + // Produces permission denied error in MSIE 5.5 + eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}'); + } else + tinyMCE._setHTML(inst.getDoc(), content); + } + + // Fix for bug #957681 + //inst.getDoc().designMode = inst.getDoc().designMode; + + // Setup element references + var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent'); + inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling; + + 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.isMSIE) + tinyMCE.addEventHandlers(inst); + + // Add blur handler + if (tinyMCE.isMSIE) { + 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 + tinyMCE.selectedInstance = inst; + 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 }); + + tinyMCE.selectedInstance = inst; + 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; + }, + + removeTinyMCEFormElements : function(form_obj) { + // Check if form is valid + if (typeof(form_obj) == "undefined" || form_obj == null) + return; + + // If not a form, find the form + if (form_obj.nodeName != "FORM") { + if (form_obj.form) + form_obj = form_obj.form; + else + form_obj = tinyMCE.getParentElement(form_obj, "form"); + } + + // Still nothing + if (form_obj == null) + return; + + // Disable all UI form elements that TinyMCE created + for (var i=0; i"); + rng.collapse(false); + rng.select(); + + tinyMCE.execCommand("mceAddUndoLevel"); + tinyMCE.triggerNodeChange(false); + return false; + } + } + + // Backspace or delete + if (e.keyCode == 8 || e.keyCode == 46) { + tinyMCE.selectedElement = e.target; + tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a"); + tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img"); + tinyMCE.triggerNodeChange(false); + } + + return false; + break; + + case "keyup": + case "keydown": + tinyMCE.hideMenus(); + tinyMCE.hasMouseMoved = false; + + if (inst && inst.handleShortcut(e)) + return false; + + if (e.target.editorId) + tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId]; + else + return; + + if (tinyMCE.selectedInstance) + tinyMCE.selectedInstance.switchSettings(); + + var inst = tinyMCE.selectedInstance; + + // Handle backspace + if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) { + // Insert P element instead of BR + if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) { + // Cancel event + tinyMCE.execCommand("mceAddUndoLevel"); + e.preventDefault(); + return false; + } + } + + tinyMCE.selectedElement = null; + tinyMCE.selectedNode = null; + var elm = tinyMCE.selectedInstance.getFocusElement(); + tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a"); + tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img"); + tinyMCE.selectedElement = elm; + + // Update visualaids on tabs + if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9) + tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance); + + // Fix empty elements on return/enter, check where enter occured + if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13) + tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement(); + + // Fix empty elements on return/enter + if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) { + var elm = tinyMCE.enterKeyElement; + if (elm) { + var re = new RegExp('^HR|IMG|BR$','g'); // Skip these + var dre = new RegExp('^H[1-6]$','g'); // Add double on these + + if (!elm.hasChildNodes() && !re.test(elm.nodeName)) { + if (dre.test(elm.nodeName)) + elm.innerHTML = "  "; + else + elm.innerHTML = " "; + } + } + } + + // Check if it's a position key + var keys = tinyMCE.posKeyCodes; + var posKey = false; + for (var i=0; i'; + h += ''; + h += ''; + } else { + // Normal button + h += ''; + h += ''; + h += ''; + } + + return h; + }, + + 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; + + // Call custom cleanup + var customCleanup = tinyMCE.settings['cleanup_callback']; + if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined") + content = eval(customCleanup + "(type, content, inst);"); + + // Trigger plugin cleanups + pl = inst.plugins; + for (i=0; i 0) { + for (i=ar.length-1; i>=0; i--) { + s = ar[i].substring(2, ar[i].length-1); + + if (s.indexOf('lang_') == 0 && tinyMCELang[s]) + h = tinyMCE.replaceVar(h, s, tinyMCELang[s]); + else if (as && as[s]) + h = tinyMCE.replaceVar(h, s, as[s]); + else if (tinyMCE.settings[s]) + h = tinyMCE.replaceVar(h, s, tinyMCE.settings[s]); + } + } + + h = tinyMCE.replaceVar(h, "themeurl", tinyMCE.themeURL); + + return h; + }, + + replaceVar : function(h, r, v) { + return h.replace(new RegExp('{\\\$' + r + '}', 'g'), v); + }, + + openWindow : function(template, args) { + var html, width, height, x, y, resizable, scrollbars, url; + + args['mce_template_file'] = template['file']; + args['mce_width'] = template['width']; + args['mce_height'] = template['height']; + tinyMCE.windowArgs = args; + + html = template['html']; + if (!(width = parseInt(template['width']))) + width = 320; + + if (!(height = parseInt(template['height']))) + height = 200; + + // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!! + if (tinyMCE.isMSIE) + height += 40; + else + height += 20; + + x = parseInt(screen.width / 2.0) - (width / 2.0); + y = parseInt(screen.height / 2.0) - (height / 2.0); + + resizable = (args && args['resizable']) ? args['resizable'] : "no"; + scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no"; + + if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1) + url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file']; + else + url = template['file']; + + // Replace all args as variables in URL + for (var name in args) { + if (typeof(args[name]) == 'function') + continue; + + url = tinyMCE.replaceVar(url, name, escape(args[name])); + } + + if (html) { + html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']); + html = tinyMCE.applyTemplate(html, args); + + var win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable); + if (win == null) { + alert(tinyMCELang['lang_popup_blocked']); + return; + } + + win.document.write(html); + win.document.close(); + win.resizeTo(width, height); + win.focus(); + } else { + if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") { + height += 10; + + var features = "resizable:" + resizable + + ";scroll:" + + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:" + + width + "px;dialogHeight:" + height + "px;"; + + window.showModalDialog(url, window, features); + } else { + var modal = (resizable == "yes") ? "no" : "yes"; + + if (tinyMCE.isGecko && tinyMCE.isMac) + modal = "no"; + + if (template['close_previous'] != "no") + try {tinyMCE.lastWindow.close();} catch (ex) {} + + var win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable); + if (win == null) { + alert(tinyMCELang['lang_popup_blocked']); + return; + } + + if (template['close_previous'] != "no") + tinyMCE.lastWindow = win; + + eval('try { win.resizeTo(width, height); } catch(e) { }'); + + // Make it bigger if statusbar is forced + if (tinyMCE.isGecko) { + if (win.document.defaultView.statusbar.visible) + win.resizeBy(0, tinyMCE.isMac ? 10 : 24); + } + + win.focus(); + } + } + }, + + closeWindow : function(win) { + win.close(); + }, + + getVisualAidClass : function(class_name, state) { + var aidClass = tinyMCE.settings['visual_table_class']; + + if (typeof(state) == "undefined") + state = tinyMCE.settings['visual']; + + // Split + var classNames = new Array(); + var ar = class_name.split(' '); + for (var i=0; i 0) + className += " "; + + className += classNames[i]; + } + + return className; + }, + + handleVisualAid : function(el, deep, state, inst) { + if (!el) + return; + + var tableElement = null; + + switch (el.nodeName) { + case "TABLE": + var oldW = el.style.width; + var oldH = el.style.height; + var bo = tinyMCE.getAttrib(el, "border"); + + bo = bo == "" || bo == "0" ? true : false; + + tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo)); + + el.style.width = oldW; + el.style.height = oldH; + + for (var y=0; y', 'gi'), ''); + + html_content = tinyMCE.cleanupHTMLCode(html_content); + + // Try innerHTML if it fails use pasteHTML in MSIE + try { + tinyMCE.setInnerHTML(doc.body, html_content); + } catch (e) { + if (this.isMSIE) + doc.body.createTextRange().pasteHTML(html_content); + } + + // Content duplication bug fix + if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) { + // Remove P elements in P elements + var paras = doc.getElementsByTagName("P"); + for (var i=0; i<\/o:p>", "
    "); + html = tinyMCE.regexpReplace(html, " <\/o:p>", ""); + html = tinyMCE.regexpReplace(html, "", ""); + html = tinyMCE.regexpReplace(html, "

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

    <\/p>\r\n

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

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

    \s*(

    \s*)?", "

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

    "); + }*/ + + // Always set the htmlText output + tinyMCE.setInnerHTML(doc.body, html); + } + + tinyMCE.cleanupAnchors(doc); + + if (tinyMCE.getParam("convert_fonts_to_spans")) + tinyMCE.convertSpansToFonts(doc); + }, + + getEditorId : function(form_element) { + var inst = this.getInstanceById(form_element); + if (!inst) + return null; + + return inst.editorId; + }, + + getInstanceById : function(editor_id) { + var inst = this.instances[editor_id]; + if (!inst) { + for (var n in tinyMCE.instances) { + var instance = tinyMCE.instances[n]; + if (!tinyMCE.isInstance(instance)) + continue; + + if (instance.formTargetElementId == editor_id) { + inst = instance; + break; + } + } + } + + return inst; + }, + + queryInstanceCommandValue : function(editor_id, command) { + var inst = tinyMCE.getInstanceById(editor_id); + if (inst) + return inst.queryCommandValue(command); + + return false; + }, + + queryInstanceCommandState : function(editor_id, command) { + var inst = tinyMCE.getInstanceById(editor_id); + if (inst) + return inst.queryCommandState(command); + + return null; + }, + + setWindowArg : function(n, v) { + this.windowArgs[n] = v; + }, + + getWindowArg : function(n, d) { + return (typeof(this.windowArgs[n]) == "undefined") ? d : this.windowArgs[n]; + }, + + getCSSClasses : function(editor_id, doc) { + var output = new Array(); + + // Is cached, use that + if (typeof(tinyMCE.cssClasses) != "undefined") + return tinyMCE.cssClasses; + + if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") { + var instance; + + for (var instanceName in tinyMCE.instances) { + instance = tinyMCE.instances[instanceName]; + if (!tinyMCE.isInstance(instance)) + continue; + + break; + } + + doc = instance.getDoc(); + } + + if (typeof(doc) == "undefined") { + var instance = tinyMCE.getInstanceById(editor_id); + doc = instance.getDoc(); + } + + if (doc) { + var styles = tinyMCE.isMSIE ? doc.styleSheets : doc.styleSheets; + + if (styles && styles.length > 0) { + for (var x=0; x 0) + tinyMCE.cssClasses = output; + + return output; + }, + + regexpReplace : function(in_str, reg_exp, replace_str, opts) { + if (in_str == null) + return in_str; + + if (typeof(opts) == "undefined") + opts = 'g'; + + var re = new RegExp(reg_exp, opts); + return in_str.replace(re, replace_str); + }, + + trim : function(s) { + return s.replace(/^\s*|\s*$/g, ""); + }, + + cleanupEventStr : function(s) { + s = "" + s; + s = s.replace('function anonymous()\n{\n', ''); + s = s.replace('\n}', ''); + s = s.replace(/^return true;/gi, ''); // Remove event blocker + + return s; + }, + + getControlHTML : function(c) { + var i, l, n, o, v; + + l = tinyMCE.plugins; + for (n in l) { + o = l[n]; + + if (o.getControlHTML && (v = o.getControlHTML(c)) != '') + return tinyMCE.replaceVar(v, "pluginurl", o.baseURL); + } + + o = tinyMCE.themes[tinyMCE.settings['theme']]; + if (o.getControlHTML && (v = o.getControlHTML(c)) != '') + return v; + + return ''; + }, + + evalFunc : function(f, idx, a) { + var s = '(', i; + + for (i=idx; i 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(o[n], 3, a)) == s && m > 0) + return true; + } + + return false; + }, + + xmlEncode : function(s) { + s = "" + s; + s = s.replace(/&/g, '&'); + s = s.replace(new RegExp('"', 'g'), '"'); + s = s.replace(/\'/g, '''); // ' is not working in MSIE + s = s.replace(//g, '>'); + + return s; + }, + + extend : function(p, np) { + var o = {}; + + 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; } } }; -TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) { - var id = "mce_editor_" + tinyMCE.idCounter++; - var inst = new TinyMCEControl(tinyMCE.settings); +// Global instances +var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors +var tinyMCE = new TinyMCE_Engine(); +var tinyMCELang = {}; - inst.editorId = id; - this.instances[id] = inst; +/* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */ - inst.onAdd(replace_element, form_element_name, target_document); +function TinyMCE_Control(settings) { + var t, i, to, fu, p, x, fn, fu, pn, s = settings; + + this.undoRedoLevel = true; + this.isTinyMCE_Control = true; + + // Default settings + 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 = new Array(); + this.hasMouseMoved = false; + + this.cleanup.init({ + valid_elements : s.valid_elements, + extended_valid_elements : s.extended_valid_elements, + entities : s.entities, + entity_encoding : s.entity_encoding, + debug : s.cleanup_debug, + url_converter : 'TinyMCE_Cleanup.prototype._urlConverter', + indent : s.apply_source_formatting, + invalid_elements : s.invalid_elements, + verify_html : s.verify_html, + fix_content_duplication : s.fix_content_duplication + }); + + // Wrap old theme + t = this.settings['theme']; + if (!tinyMCE.hasTheme(t)) { + fn = tinyMCE.callbacks; + to = {}; + + for (i=0; i 0) { + for (i=0; i 1 && tinyMCE.currentConfig != this.settings['index']) { + tinyMCE.settings = this.settings; + tinyMCE.currentConfig = this.settings['index']; + } + }, + + getBody : function() { + return this.getDoc().body; + }, + + getDoc : function() { + return this.contentWindow.document; + }, + + getWin : function() { + return this.contentWindow; + }, + + addShortcut : function(m, k, d, cmd, ui, va) { + var n = typeof(k) == "number", ie = tinyMCE.isMSIE, c, sc, i; + var 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 0) + rng.pasteHTML('
    ' + rng.htmlText + "
    "); + + tinyMCE.triggerNodeChange(); + return; + } + } + } + + switch (command) { + case "mceRepaint": + this.repaint(); + return true; + + case "InsertUnorderedList": + case "InsertOrderedList": + var tag = (command == "InsertUnorderedList") ? "ul" : "ol"; + + if (tinyMCE.isSafari) + this.execCommand("mceInsertContent", false, "<" + tag + ">
  •  
  • <" + tag + ">"); + else + this.getDoc().execCommand(command, user_interface, value); + + tinyMCE.triggerNodeChange(); + break; + + case "Strikethrough": + if (tinyMCE.isSafari) + this.execCommand("mceInsertContent", false, "" + this.selection.getSelectedHTML() + ""); + else + 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"); + + if (elm) + this.execCommand("mceRemoveNode", false, elm); + } else { + if (value == '
    ' && tinyMCE.isGecko) + value = 'div'; + + this.getDoc().execCommand("FormatBlock", false, value); + } + + tinyMCE.triggerNodeChange(); + + break; + + case "mceRemoveNode": + if (!value) + value = tinyMCE.getParentElement(this.getFocusElement()); + + if (tinyMCE.isMSIE) { + value.outerHTML = value.innerHTML; + } else { + var rng = value.ownerDocument.createRange(); + rng.setStartBefore(value); + rng.setEndAfter(value); + rng.deleteContents(); + rng.insertNode(rng.createContextualFragment(value.innerHTML)); + } + + tinyMCE.triggerNodeChange(); + + break; + + case "mceSelectNodeDepth": + var parentNode = this.getFocusElement(); + for (var i=0; parentNode; i++) { + if (parentNode.nodeName.toLowerCase() == "body") + break; + + if (parentNode.nodeName.toLowerCase() == "#text") { + i--; + parentNode = parentNode.parentNode; + continue; + } + + if (i == value) { + this.selection.selectNode(parentNode, false); + tinyMCE.triggerNodeChange(); + tinyMCE.selectedNode = parentNode; + return; + } + + parentNode = parentNode.parentNode; + } + + break; + + case "SetStyleInfo": + var rng = this.getRng(); + var sel = this.getSel(); + var scmd = value['command']; + var sname = value['name']; + var svalue = value['value'] == null ? '' : value['value']; + //var svalue = value['value'] == null ? '' : value['value']; + var wrapper = value['wrapper'] ? value['wrapper'] : "span"; + var parentElm = null; + var invalidRe = new RegExp("^BODY|HTML$", "g"); + var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null; + + // Whole element selected check + if (tinyMCE.isMSIE) { + // Control range + if (rng.item) + parentElm = rng.item(0); + else { + var pelm = rng.parentElement(); + var prng = doc.selection.createRange(); + prng.moveToElementText(pelm); + + if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) { + if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName)) + parentElm = pelm; + } + } + } else { + var felm = this.getFocusElement(); + if (sel.isCollapsed || (new RegExp('td|tr|tbody|table', '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, new Array(), 1); + for (var z=0; z=0; i--) { + var elm = nodes[i]; + var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; + + elm.removeAttribute("mce_new"); + + // Is only child a element + if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) { + //tinyMCE.debug("merge1" + isNew); + this._mergeElements(scmd, elm, elm.childNodes[0], isNew); + continue; + } + + // Is I the only child + if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) { + //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName); + if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName)) + this._mergeElements(scmd, elm.parentNode, elm, false); + } + } + + // Remove empty wrappers + var nodes = doc.getElementsByTagName(wrapper); + for (var i=nodes.length-1; i>=0; i--) { + var elm = nodes[i]; + var isEmpty = true; + + // Check if it has any attribs + var tmp = doc.createElement("body"); + tmp.appendChild(elm.cloneNode(false)); + + // Is empty span, remove it + tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); + //tinyMCE.debug(tmp.innerHTML); + if (new RegExp('', 'gi').test(tmp.innerHTML)) { + for (var x=0; x 0) { + value = tinyMCE.replaceVar(value, "selection", selectedText); + tinyMCE.execCommand('mceInsertContent', false, value); + } + + tinyMCE.triggerNodeChange(); + break; + + case "mceSetAttribute": + if (typeof(value) == 'object') { + var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets']; + var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); + + if (targetNode) { + targetNode.setAttribute(value['name'], value['value']); + tinyMCE.triggerNodeChange(); + } + } + break; + + case "mceSetCSSClass": + this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value}); + break; + + case "mceInsertRawHTML": + var key = 'tiny_mce_marker'; + + this.execCommand('mceBeginUndoLevel'); + + // Insert marker key + this.execCommand('mceInsertContent', false, key); + + // Store away scroll pos + var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft; + var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop; + + // Find marker and replace with RAW HTML + var html = this.getBody().innerHTML; + if ((pos = html.indexOf(key)) != -1) + tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length)); + + // Restore scoll pos + this.contentWindow.scrollTo(scrollX, scrollY); + + this.execCommand('mceEndUndoLevel'); + + break; + + case "mceInsertContent": + // Force empty string + if (!value) + value = ''; + + var insertHTMLFailed = false; + 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; + } + } + + // Ugly hack in Opera due to non working "inserthtml" + if (tinyMCE.isOpera && insertHTMLFailed) { + this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL); + var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL); + ar[0].outerHTML = value; + return; + } + + if (!tinyMCE.isMSIE) { + var isHTML = value.indexOf('<') != -1; + var sel = this.getSel(); + var rng = this.getRng(); + + if (isHTML) { + if (tinyMCE.isSafari) { + var tmpRng = this.getDoc().createRange(); + + tmpRng.setStart(this.getBody(), 0); + tmpRng.setEnd(this.getBody(), 0); + + value = tmpRng.createContextualFragment(value); + } else + value = rng.createContextualFragment(value); + } else { + // Setup text node + var el = document.createElement("div"); + el.innerHTML = value; + value = el.firstChild.nodeValue; + value = doc.createTextNode(value); + } + + // Insert plain text in Safari + if (tinyMCE.isSafari && !isHTML) { + this.execCommand('InsertText', false, value.nodeValue); + tinyMCE.triggerNodeChange(); + return true; + } else if (tinyMCE.isSafari && isHTML) { + rng.deleteContents(); + rng.insertNode(value); + tinyMCE.triggerNodeChange(); + return true; + } + + rng.deleteContents(); + + // If target node is text do special treatment, (Mozilla 1.3 fix) + if (rng.startContainer.nodeType == 3) { + var node = rng.startContainer.splitText(rng.startOffset); + node.parentNode.insertBefore(value, node); + } else + rng.insertNode(value); + + if (!isHTML) { + // Removes weird selection trails + sel.selectAllChildren(doc.body); + sel.removeAllRanges(); + + // Move cursor to end of content + var rng = doc.createRange(); + + rng.selectNode(value); + rng.collapse(false); + + sel.addRange(rng); + } else + rng.collapse(false); + + tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); + } else { + var rng = doc.selection.createRange(); + var c = value.indexOf('"; - - default: // Unknown - return "[UNKNOWN NODETYPE " + node.nodeType + "]"; + var fColor = s[i].style.color; + if (fColor != null && fColor != "") { + tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor)); + s[i].style.color = ''; + } } }; -TinyMCE.prototype.convertStringToXML = function(html_data) { - var output = ""; +TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) { + var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(','); - for (var i=0; i 127) - output += '&#' + chr + ";"; - else - output += String.fromCharCode(chr); + var fsClasses = tinyMCE.getParam('font_size_classes'); + if (fsClasses != '') + fsClasses = fsClasses.replace(/\s+/, '').split(','); + else + fsClasses = null; - continue; - } + var s = doc.getElementsByTagName("span"); + for (var i=0; i 0 && fSize < 8) { + if (fsClasses != null) + tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]); + else + s[i].style.fontSize = sizes[fSize-1]; } - // Force check - if ((pos = attribName.indexOf(':')) != -1) { - attribForce = attribName.substring(pos+1); - attribName = attribName.substring(0, pos); - } - - // Force check - if ((pos = attribName.indexOf('<')) != -1) { - attribMustBe = attribName.substring(pos+1).split('?'); - attribName = attribName.substring(0, pos); - } - - attribs[x] = new Array(attribName, attribDefault, attribForce, attribMustBe); + s[i].removeAttribute('size'); } - validElements[i] = attribs; + if (fFace != "") { + s[i].style.fontFamily = fFace; + s[i].removeAttribute('face'); + } + + if (fColor != "") { + s[i].style.color = fColor; + s[i].removeAttribute('color'); + } } - - var invalidElements = tinyMCE.settings['invalid_elements'].split(','); - for (var i=0; i/gi, '>'); - - return html; - } - - if (on_save && tinyMCE.getParam("convert_fonts_to_spans")) - tinyMCE.convertFontsToSpans(doc); - - // Call custom cleanup code - tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body); - - // Move bgcolor to style - var n = doc.getElementsByTagName("font"); - for (var i=0; i=0; x--) + tinyMCE.insertAfter(cn[x], an[i]); } } - - // Set these for performance - tinyMCE.cleanup_validElements = tinyMCE.settings['cleanup_validElements']; - tinyMCE.cleanup_invalidElements = tinyMCE.settings['cleanup_invalidElements']; - tinyMCE.cleanup_verify_html = tinyMCE.settings['verify_html']; - tinyMCE.cleanup_force_br_newlines = tinyMCE.settings['force_br_newlines']; - tinyMCE.cleanup_urlconverter_callback = tinyMCE.settings['urlconverter_callback']; - tinyMCE.cleanup_verify_css_classes = tinyMCE.settings['verify_css_classes']; - tinyMCE.cleanup_visual_table_class = tinyMCE.settings['visual_table_class']; - tinyMCE.cleanup_apply_source_formatting = tinyMCE.settings['apply_source_formatting']; - tinyMCE.cleanup_inline_styles = tinyMCE.settings['inline_styles']; - tinyMCE.cleanup_visual_aid = visual; - tinyMCE.cleanup_on_save = on_save; - tinyMCE.cleanup_idCount = 0; - tinyMCE.cleanup_elementLookupTable = new Array(); - - var startTime = new Date().getTime(); - - // Cleanup madness that breaks the editor in MSIE - if (tinyMCE.isMSIE) { - // Remove null ids from HR elements, results in runtime error - var nodes = element.getElementsByTagName("hr"); - for (var i=0; i[ \n\r]*[ \n\r]*

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


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

     


     

    ', '
    '); - html = tinyMCE.regexpReplace(html, '
    \\s*
    \\s*
     \s*
    \s*<\/td>/g, '
     '; break; - if (parentNode.nodeName.toLowerCase() == "#text") { - i--; - parentNode = parentNode.parentNode; - continue; - } + case 'title': + h += '
    ' + t + ''; + break; - if (i == value) { - this.selectNode(parentNode, false); - tinyMCE.triggerNodeChange(); - tinyMCE.selectedNode = parentNode; - return; - } + case 'disabled': + h += '
    ' + t + ''; + break; - parentNode = parentNode.parentNode; + default: + h += '
    ' + t + ''; } - break; + h += '
    '; - // Whole element selected check - if (tinyMCE.isMSIE) { - // Control range - if (rng.item) - parentElm = rng.item(0); - else { - var pelm = rng.parentElement(); - var prng = doc.selection.createRange(); - prng.moveToElementText(pelm); + e.innerHTML = h; - if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) { - if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName)) - parentElm = pelm; - } - } - } else { - var felm = this.getFocusElement(); - if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode)) - parentElm = felm; - } + this.needsUpdate = false; + this.updateBlocker(); + }, - // Whole element selected - if (parentElm && !invalidRe.test(parentElm.nodeName)) { - if (scmd == "setstyle") - tinyMCE.setStyleAttrib(parentElm, sname, svalue); - - if (scmd == "setattrib") - tinyMCE.setAttrib(parentElm, sname, svalue); - - if (scmd == "removeformat") { - parentElm.style.cssText = ''; - tinyMCE.setAttrib(parentElm, 'class', ''); - } - - // Remove style/attribs from all children - var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1); - for (var z=0; z=0; i--) { - var elm = nodes[i]; - var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true"; - - elm.removeAttribute("mce_new"); - - // Is only child a element - if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) { - //tinyMCE.debug("merge1" + isNew); - this._mergeElements(scmd, elm, elm.childNodes[0], isNew); - continue; - } - - // Is I the only child - if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) { - //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName); - if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName)) - this._mergeElements(scmd, elm.parentNode, elm, false); - } - } - - // Remove empty wrappers - var nodes = doc.getElementsByTagName(wrapper); - for (var i=nodes.length-1; i>=0; i--) { - var elm = nodes[i]; - var isEmpty = true; - - // Check if it has any attribs - var tmp = doc.createElement("body"); - tmp.appendChild(elm.cloneNode(false)); - - // Is empty span, remove it - tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), ''); - //tinyMCE.debug(tmp.innerHTML); - if (new RegExp('', 'gi').test(tmp.innerHTML)) { - for (var x=0; x 0) { - value = tinyMCE.replaceVar(value, "selection", selectedText); - tinyMCE.execCommand('mceInsertContent', false, value); - } - - tinyMCE.triggerNodeChange(); - break; - - case "mceSetAttribute": - if (typeof(value) == 'object') { - var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets']; - var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms); - - if (targetNode) { - targetNode.setAttribute(value['name'], value['value']); - tinyMCE.triggerNodeChange(); - } - } - break; - - case "mceSetCSSClass": - this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value}); - break; - - case "mceInsertRawHTML": - var key = 'tiny_mce_marker'; - - this.execCommand('mceBeginUndoLevel'); - - // Insert marker key - this.execCommand('mceInsertContent', false, key); - - // Store away scroll pos - var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft; - var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop; - - // Find marker and replace with RAW HTML - var html = this.getBody().innerHTML; - if ((pos = html.indexOf(key)) != -1) - tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length)); - - // Restore scoll pos - this.contentWindow.scrollTo(scrollX, scrollY); - - this.execCommand('mceEndUndoLevel'); - - break; - - case "mceInsertContent": - var insertHTMLFailed = false; - this.getWin().focus(); -/* WP - if (tinyMCE.isGecko || tinyMCE.isOpera) { - try { - // Is plain text or HTML - if (value.indexOf('<') == -1) { - var r = this.getRng(); - var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value)); - var s = this.getSel(); - var r2 = r.cloneRange(); - - // Insert text at cursor position - s.removeAllRanges(); - r.deleteContents(); - r.insertNode(n); - - // Move the cursor to the end of text - r2.selectNode(n); - r2.collapse(false); - s.removeAllRanges(); - s.addRange(r2); - } else { - value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value); - this.getDoc().execCommand('inserthtml', false, value); - tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value); - } - } catch (ex) { - insertHTMLFailed = true; - } - - if (!insertHTMLFailed) { - tinyMCE.triggerNodeChange(); - return; - } - } -*/ - // Ugly hack in Opera due to non working "inserthtml" - if (tinyMCE.isOpera && insertHTMLFailed) { - this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL); - var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL); - ar[0].outerHTML = value; - return; - } - - if (!tinyMCE.isMSIE) { - var isHTML = value.indexOf('<') != -1; - var sel = this.getSel(); - var rng = this.getRng(); - - if (isHTML) { - if (tinyMCE.isSafari) { - var tmpRng = this.getDoc().createRange(); - - tmpRng.setStart(this.getBody(), 0); - tmpRng.setEnd(this.getBody(), 0); - - value = tmpRng.createContextualFragment(value); - } else - value = rng.createContextualFragment(value); - } else { - // Setup text node - var el = document.createElement("div"); - el.innerHTML = value; - value = el.firstChild.nodeValue; - value = doc.createTextNode(value); - } - - // Insert plain text in Safari - if (tinyMCE.isSafari && !isHTML) { - this.execCommand('InsertText', false, value.nodeValue); - tinyMCE.triggerNodeChange(); - return true; - } else if (tinyMCE.isSafari && isHTML) { - rng.deleteContents(); - rng.insertNode(value); - tinyMCE.triggerNodeChange(); - return true; - } - - rng.deleteContents(); - - // If target node is text do special treatment, (Mozilla 1.3 fix) - if (rng.startContainer.nodeType == 3) { - var node = rng.startContainer.splitText(rng.startOffset); - node.parentNode.insertBefore(value, node); - } else - rng.insertNode(value); - - if (!isHTML) { - // Removes weird selection trails - sel.selectAllChildren(doc.body); - sel.removeAllRanges(); - - // Move cursor to end of content - var rng = doc.createRange(); - - rng.selectNode(value); - rng.collapse(false); - - sel.addRange(rng); - } else - rng.collapse(false); - } else { - var rng = doc.selection.createRange(); - var c = value.indexOf('