diff --git a/wp-admin/admin-header.php b/wp-admin/admin-header.php
index 184e672444..f665b7d130 100644
--- a/wp-admin/admin-header.php
+++ b/wp-admin/admin-header.php
@@ -99,7 +99,7 @@ tinyMCE.init({
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
theme_advanced_resizing : true,
- browsers : "msie,gecko",
+ browsers : "msie,gecko,opera",
dialog_type : "modal",
theme_advanced_resize_horizontal : false,
entity_encoding : "raw",
@@ -110,7 +110,7 @@ tinyMCE.init({
convert_newlines_to_brs : false,
remove_linebreaks : true,
save_callback : "wp_save_callback",
- valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],tr[class|rowspan|width|height|align|valign|dir],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
+ valid_elements : "-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border=0|cellspacing|cellpadding|width|height|class|align|dir],thead[class|rowspan|width|height|align|valign|dir],tr[class|rowspan|width|height|align|valign|dir],th[dir|class|colspan|rowspan|width|height|align|valign|scope],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr",
plugins : ""
});
diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
index fa6d9ca781..099a5ecda6 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
@@ -200,15 +200,28 @@ function TinyMCE_wordpress_cleanup(type, content) {
// If it says & in the WYSIWYG editor, it should say & in the html.
content = content.replace(new RegExp('&', 'g'), '&');
+ content = content.replace(new RegExp(' ', '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)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '$1><$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';
+ var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
content = content.replace(new RegExp('\\s*('+blocklist+')>\\s*', 'mg'), '$1>\n');
content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>');
- content = content.replace(new RegExp('', 'g'), '\t');
+ 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;
}
diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js
index a63d11937e..0340c47b0a 100644
--- a/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-includes/js/tinymce/tiny_mce.js
@@ -1,11 +1,6077 @@
/**
- * $RCSfile: tiny_mce.js,v $
- * $Revision: 1.301 $
- * $Date: 2005/10/30 16:06:56 $
+ * $RCSfile: tiny_mce_src.js,v $
+ * $Revision: 1.281 $
+ * $Date: 2005/12/02 08:12:07 $
*
* @author Moxiecode
* @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
*/
- function TinyMCE(){this.majorVersion="2";this.minorVersion="0RC4";this.releaseDate="2005-10-30";this.instances=new Array();this.stickyClassesLookup=new Array();this.windowArgs=new Array();this.loadedFiles=new Array();this.configs=new Array();this.currentConfig=0;this.eventHandlers=new Array();var ua=navigator.userAgent;this.isMSIE=(navigator.appName=="Microsoft Internet Explorer");this.isMSIE5=this.isMSIE&&(ua.indexOf('MSIE 5')!=-1);this.isMSIE5_0=this.isMSIE&&(ua.indexOf('MSIE 5.0')!=-1);this.isGecko=ua.indexOf('Gecko')!=-1;this.isGecko18=ua.indexOf('Gecko')!=-1&&ua.indexOf('rv:1.8')!=-1;this.isSafari=ua.indexOf('Safari')!=-1;this.isOpera=ua.indexOf('Opera')!=-1;this.isMac=ua.indexOf('Mac')!=-1;this.isNS7=ua.indexOf('Netscape/7')!=-1;this.isNS71=ua.indexOf('Netscape/7.1')!=-1;this.dialogCounter=0;if(this.isOpera){this.isMSIE=true;this.isGecko=false;this.isSafari=false;}this.idCounter=0;};TinyMCE.prototype.defParam=function(key,def_val){this.settings[key]=tinyMCE.getParam(key,def_val);};TinyMCE.prototype.init=function(settings){var theme;this.settings=settings;if(typeof(document.execCommand)=='undefined')return;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');if(this.isMSIE&&this.settings['browsers'].indexOf('msie')==-1)return;if(this.isGecko&&this.settings['browsers'].indexOf('gecko')==-1)return;if(this.isSafari&&this.settings['browsers'].indexOf('safari')==-1)return;if(this.isOpera&&this.settings['browsers'].indexOf('opera')==-1)return;var baseHREF=tinyMCE.settings['document_base_url'];if(baseHREF.indexOf('?')!=-1)baseHREF=baseHREF.substring(0,baseHREF.indexOf('?'));this.settings['base_href']=baseHREF.substring(0,baseHREF.lastIndexOf('/'))+"/";theme=this.settings['theme'];this.blockRegExp=new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$","i");this.posKeyCodes=new Array(13,45,36,35,33,34,37,38,39,40);this.uniqueURL='http://tinymce.moxiecode.cp/mce_temp_url';this.settings['theme_href']=tinyMCE.baseURL+"/themes/"+theme;if(!tinyMCE.isMSIE)this.settings['force_br_newlines']=false;if(tinyMCE.getParam("content_css",false)){var cssPath=tinyMCE.getParam("content_css","");if(cssPath.indexOf('://')==-1&&cssPath.charAt(0)!='/')this.settings['content_css']=this.documentBasePath+"/"+cssPath;else this.settings['content_css']=cssPath;}else this.settings['content_css']='';if(tinyMCE.getParam("popups_css",false)){var cssPath=tinyMCE.getParam("popups_css","");if(cssPath.indexOf('://')==-1&&cssPath.charAt(0)!='/')this.settings['popups_css']=this.documentBasePath+"/"+cssPath;else this.settings['popups_css']=cssPath;}else this.settings['popups_css']=tinyMCE.baseURL+"/themes/"+theme+"/css/editor_popup.css";if(tinyMCE.getParam("editor_css",false)){var cssPath=tinyMCE.getParam("editor_css","");if(cssPath.indexOf('://')==-1&&cssPath.charAt(0)!='/')this.settings['editor_css']=this.documentBasePath+"/"+cssPath;else this.settings['editor_css']=cssPath;}else this.settings['editor_css']=tinyMCE.baseURL+"/themes/"+theme+"/css/editor_ui.css";if(tinyMCE.settings['debug']){var msg="Debug: \n";msg+="baseURL: "+this.baseURL+"\n";msg+="documentBasePath: "+this.documentBasePath+"\n";msg+="content_css: "+this.settings['content_css']+"\n";msg+="popups_css: "+this.settings['popups_css']+"\n";msg+="editor_css: "+this.settings['editor_css']+"\n";alert(msg);}this._initCleanup();if(this.configs.length==0){if(this.isSafari&&this.getParam('safari_warning',true))alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");tinyMCE.addEvent(window,"load",TinyMCE.prototype.onLoad);if(tinyMCE.isMSIE){if(tinyMCE.settings['add_unload_trigger']){tinyMCE.addEvent(window,"unload",TinyMCE.prototype.unloadHandler);tinyMCE.addEvent(window.document,"beforeunload",TinyMCE.prototype.unloadHandler);}}else{if(tinyMCE.settings['add_unload_trigger'])tinyMCE.addEvent(window,"unload",function(){tinyMCE.triggerSave(true,true);});}}this.loadScript(tinyMCE.baseURL+'/themes/'+this.settings['theme']+'/editor_template'+tinyMCE.srcMode+'.js');this.loadScript(tinyMCE.baseURL+'/langs/'+this.settings['language']+'.js');this.loadCSS(this.settings['editor_css']);var themePlugins=tinyMCE.getParam('plugins','',true,',');if(this.settings['plugins']!=''){for(var i=0;i');this.loadedFiles[this.loadedFiles.length]=url;};TinyMCE.prototype.loadCSS=function(url){for(var i=0;i');this.loadedFiles[this.loadedFiles.length]=url;};TinyMCE.prototype.importCSS=function(doc,css_file){if(css_file=='')return;if(typeof(doc.createStyleSheet)=="undefined"){var elm=doc.createElement("link");elm.rel="stylesheet";elm.href=css_file;if((headArr=doc.getElementsByTagName("head"))!=null&&headArr.length>0)headArr[0].appendChild(elm);}else var styleSheet=doc.createStyleSheet(css_file);};TinyMCE.prototype.confirmAdd=function(e,settings){var elm=tinyMCE.isMSIE?event.srcElement:e.target;var elementId=elm.name?elm.name:elm.id;tinyMCE.settings=settings;if(!elm.getAttribute('mce_noask')&&confirm(tinyMCELang['lang_edit_confirm']))tinyMCE.addMCEControl(elm,elementId);elm.setAttribute('mce_noask','true');};TinyMCE.prototype.updateContent=function(form_element_name){var formElement=document.getElementById(form_element_name);for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(!tinyMCE.isInstance(inst))continue;inst.switchSettings();if(inst.formElement==formElement){var doc=inst.getDoc();tinyMCE._setHTML(doc,inst.formElement.value);if(!tinyMCE.isMSIE)doc.body.innerHTML=tinyMCE._cleanupHTML(inst,doc,this.settings,doc.body,inst.visualAid);}}};TinyMCE.prototype.addMCEControl=function(replace_element,form_element_name,target_document){var id="mce_editor_"+tinyMCE.idCounter++;var inst=new TinyMCEControl(tinyMCE.settings);inst.editorId=id;this.instances[id]=inst;inst.onAdd(replace_element,form_element_name,target_document);};TinyMCE.prototype.triggerSave=function(skip_cleanup,skip_callback){for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(!tinyMCE.isInstance(inst))continue;inst.switchSettings();tinyMCE.settings['preformatted']=false;if(typeof(skip_cleanup)=="undefined")skip_cleanup=false;if(typeof(skip_callback)=="undefined")skip_callback=false;tinyMCE._setHTML(inst.getDoc(),inst.getBody().innerHTML);if(inst.settings['cleanup']==false){tinyMCE.handleVisualAid(inst.getBody(),true,false,inst);tinyMCE._setEventsEnabled(inst.getBody(),true);}tinyMCE._customCleanup(inst,"submit_content_dom",inst.contentWindow.document.body);var htm=skip_cleanup?inst.getBody().innerHTML:tinyMCE._cleanupHTML(inst,inst.getDoc(),this.settings,inst.getBody(),this.visualAid,true);htm=tinyMCE._customCleanup(inst,"submit_content",htm);if(tinyMCE.settings["encoding"]=="xml"||tinyMCE.settings["encoding"]=="html")htm=tinyMCE.convertStringToXML(htm);if(!skip_callback&&tinyMCE.settings['save_callback']!="")var content=eval(tinyMCE.settings['save_callback']+"(inst.formTargetElementId,htm,inst.getBody());");if((typeof(content)!="undefined")&&content!=null)htm=content;htm=tinyMCE.regexpReplace(htm,"(","(","gi");htm=tinyMCE.regexpReplace(htm,")",")","gi");htm=tinyMCE.regexpReplace(htm,";",";","gi");htm=tinyMCE.regexpReplace(htm,""",""","gi");htm=tinyMCE.regexpReplace(htm,"^","^","gi");if(inst.formElement)inst.formElement.value=htm;}};TinyMCE.prototype._setEventsEnabled=function(node,state){var events=new Array('onfocus','onblur','onclick','ondblclick','onmousedown','onmouseup','onmouseover','onmousemove','onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');var evs=tinyMCE.settings['event_elements'].split(',');for(var y=0;y","gi");content=tinyMCE.regexpReplace(content,"\r","
","gi");content=tinyMCE.regexpReplace(content,"\n","
","gi");}content=tinyMCE._customCleanup(inst,"insert_to_editor",content);if(tinyMCE.isMSIE){window.setInterval('try{tinyMCE.getCSSClasses(document.frames["'+editor_id+'"].document, "'+editor_id+'");}catch(e){}',500);if(tinyMCE.settings["force_br_newlines"])document.frames[editor_id].document.styleSheets[0].addRule("p","margin: 0px;");var body=document.frames[editor_id].document.body;tinyMCE.addEvent(body,"beforepaste",TinyMCE.prototype.eventPatch);tinyMCE.addEvent(body,"beforecut",TinyMCE.prototype.eventPatch);body.editorId=editor_id;}content=tinyMCE.cleanupHTMLCode(content);if(!tinyMCE.isMSIE){var contentElement=inst.getDoc().createElement("body");var doc=inst.getDoc();contentElement.innerHTML=content;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{content=tinyMCE.regexpReplace(content,"","","gi");content=tinyMCE.regexpReplace(content,"","","gi");content=tinyMCE.regexpReplace(content,"","","gi");tinyMCE.setInnerHTML(inst.getBody(),content);}inst.convertAllRelativeURLs();}else{if(tinyMCE.settings['cleanup_on_startup']){tinyMCE._setHTML(inst.getDoc(),content);eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody());} catch(e) {}');}else tinyMCE._setHTML(inst.getDoc(),content);}var parentElm=document.getElementById(inst.editorId+'_parent');if(parentElm.lastChild.nodeName.toLowerCase()=="input")inst.formElement=parentElm.lastChild;else inst.formElement=parentElm.nextSibling;tinyMCE.handleVisualAid(inst.getBody(),true,tinyMCE.settings['visual'],inst);tinyMCE.executeCallback('setupcontent_callback','_setupContent',0,editor_id,inst.getBody(),inst.getDoc());if(!tinyMCE.isMSIE)TinyMCE.prototype.addEventHandlers(editor_id);if(tinyMCE.isMSIE)tinyMCE.addEvent(inst.getBody(),"blur",TinyMCE.prototype.eventPatch);tinyMCE.selectedInstance=inst;tinyMCE.selectedElement=inst.contentWindow.document.body;tinyMCE.triggerNodeChange(false,true);tinyMCE._customCleanup(inst,"insert_to_editor_dom",inst.getBody());tinyMCE._customCleanup(inst,"setup_content_dom",inst.getBody());tinyMCE._setEventsEnabled(inst.getBody(),false);tinyMCE.cleanupAnchors(inst.getDoc());if(tinyMCE.getParam("convert_fonts_to_spans"))tinyMCE.convertSpansToFonts(inst.getDoc());inst.startContent=tinyMCE.trim(inst.getBody().innerHTML);inst.undoLevels[inst.undoLevels.length]=inst.startContent;tinyMCE.operaOpacityCounter=-1;};TinyMCE.prototype.cleanupHTMLCode=function(s){s=s.replace(//gi,'
');s=s.replace(/\s*<\/p>/gi,'
');s=s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([^\\|>]*?)\/>/gi,'<$1$2>$1>');s=s.replace(new RegExp('\\s+>','gi'),'>');if(tinyMCE.isMSIE)s=s.replace(/
<\/p>/gi,"
");s=s.replace(new RegExp('(href=\"?)(\\s*?#)','gi'),'$1'+tinyMCE.settings['document_base_url']+"#");return s;};TinyMCE.prototype.cancelEvent=function(e){if(tinyMCE.isMSIE){e.returnValue=false;e.cancelBubble=true;}else e.preventDefault();};TinyMCE.prototype.removeTinyMCEFormElements=function(form_obj){while(form_obj.tagName.toUpperCase()!="FORM"&&form_obj.tagName!=null){form_obj=form_obj.parentNode;}if(typeof form_obj.elements=="undefined")return;for(var i=0;i");rng.collapse(false);rng.select();tinyMCE.execCommand("mceAddUndoLevel");tinyMCE.triggerNodeChange(false);return false;}}if(e.keyCode==8||e.keyCode==46){tinyMCE.selectedElement=e.target;tinyMCE.linkElement=tinyMCE.getParentElement(e.target,"a");tinyMCE.imgElement=tinyMCE.getParentElement(e.target,"img");tinyMCE.triggerNodeChange(false);}return false;break;case "keyup":case "keydown":if(e.target.editorId)tinyMCE.selectedInstance=tinyMCE.instances[e.target.editorId];else return;if(tinyMCE.selectedInstance)tinyMCE.selectedInstance.switchSettings();var inst=tinyMCE.selectedInstance;if(tinyMCE.isGecko&&tinyMCE.settings['force_p_newlines']&&(e.keyCode==8||e.keyCode==46)&&!e.shiftKey){if(tinyMCE.selectedInstance._handleBackSpace(e.type)){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;if(tinyMCE.isGecko&&e.type=="keyup"&&e.keyCode==9)tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(),true,tinyMCE.settings['visual'],tinyMCE.selectedInstance);if(tinyMCE.isGecko&&tinyMCE.settings['document_base_url']!=""+document.location.href&&e.type=="keyup"&&e.ctrlKey&&e.keyCode==86)tinyMCE.selectedInstance.fixBrokenURLs();if(tinyMCE.isMSIE&&e.type=="keydown"&&e.keyCode==13)tinyMCE.enterKeyElement=tinyMCE.selectedInstance.getFocusElement();if(tinyMCE.isMSIE&&e.type=="keyup"&&e.keyCode==13){var elm=tinyMCE.enterKeyElement;if(elm){var re=new RegExp('^HR|IMG|BR$','g');var dre=new RegExp('^H[1-6]$','g');if(!elm.hasChildNodes()&&!re.test(elm.nodeName)){if(dre.test(elm.nodeName))elm.innerHTML=" ";else elm.innerHTML=" ";}}}var keys=tinyMCE.posKeyCodes;var posKey=false;for(var i=0;i-1)suffix='?rnd='+this.operaOpacityCounter++;element.src=tinyMCE.baseURL+"/themes/"+tinyMCE.getParam("theme")+"/images/opacity.png"+suffix;element.style.backgroundImage="url('"+element.mceOldSrc+"')";}else{if(element.mceOldSrc){element.src=element.mceOldSrc;element.parentNode.style.backgroundImage="";element.mceOldSrc=null;}}}}};TinyMCE.prototype.restoreClass=function(element){if(element!=null&&element.oldClassName&&!element.classLock){element.className=element.oldClassName;element.oldClassName=null;}};TinyMCE.prototype.setClassLock=function(element,lock_state){if(element!=null)element.classLock=lock_state;};TinyMCE.prototype.addEvent=function(obj,name,handler){if(tinyMCE.isMSIE){obj.attachEvent("on"+name,handler);}else obj.addEventListener(name,handler,false);};TinyMCE.prototype.submitPatch=function(){tinyMCE.removeTinyMCEFormElements(this);tinyMCE.triggerSave();this.mceOldSubmit();tinyMCE.isNotDirty=true;};TinyMCE.prototype.onLoad=function(){for(var c=0;c0)return;if(val.indexOf('%')==-1)val+='px';break;case "vspace":case "hspace":elm.style.marginTop=val+"px";elm.style.marginBottom=val+"px";elm.removeAttribute(attrib);return;case "align":if(elm.nodeName=="IMG"){if(tinyMCE.isMSIE)elm.style.styleFloat=val;else elm.style.cssFloat=val;}else elm.style.textAlign=val;elm.removeAttribute(attrib);return;}if(val!=''){eval('elm.style.'+style+' = val;');elm.removeAttribute(attrib);}}}else{if(style=='')return;var val=eval('elm.style.'+style)==''?tinyMCE.getAttrib(elm,attrib):eval('elm.style.'+style);val=val==null?'':''+val;switch(attrib){case "background":if(val.indexOf('url')==-1&&val!='')val="url('"+val+"');";if(val!=''){elm.style.backgroundImage=val;elm.removeAttribute(attrib);}return;case "border":case "width":case "height":val=val.replace('px','');break;case "align":if(tinyMCE.getAttrib(elm,'align')==''){if(elm.nodeName=="IMG"){if(tinyMCE.isMSIE&&elm.style.styleFloat!=''){val=elm.style.styleFloat;style='styleFloat';}else if(tinyMCE.isGecko&&elm.style.cssFloat!=''){val=elm.style.cssFloat;style='cssFloat';}}}break;}if(val!=''){elm.removeAttribute(attrib);elm.setAttribute(attrib,val);eval('elm.style.'+style+' = "";');}}};TinyMCE.prototype._cleanupAttribute=function(valid_attributes,element_name,attribute_node,element_node){var attribName=attribute_node.nodeName.toLowerCase();var attribValue=attribute_node.nodeValue;var attribMustBeValue=null;var verified=false;if(attribName.indexOf('moz_')!=-1)return null;if(!tinyMCE.isMSIE&&(attribName=="mce_real_href"||attribName=="mce_real_src")){if(!tinyMCE.cleanup_on_save){var attrib=new Object();attrib.name=attribName;attrib.value=attribValue;return attrib;}else return null;}if(tinyMCE.cleanup_verify_html&&!verified){for(var i=1;i'+output;}}var re=new RegExp("^(TABLE|TD|TR)$");if(re.test(node.nodeName)){if((node.nodeName!="TABLE"||tinyMCE.cleanup_inline_styles)&&(width=tinyMCE.getAttrib(node,"width"))!=''){node.style.width=width.indexOf('%')!=-1?width:width.replace(/[^0-9]/gi,'')+"px";node.removeAttribute("width");}if((node.nodeName=="TABLE"&&!tinyMCE.cleanup_inline_styles)&&node.style.width!=''){tinyMCE.setAttrib(node,"width",node.style.width.replace('px',''));node.style.width='';}if((height=tinyMCE.getAttrib(node,"height"))!=''){node.style.height=height.indexOf('%')!=-1?height:height.replace(/[^0-9]/gi,'')+"px";node.removeAttribute("height");}}if(tinyMCE.cleanup_inline_styles){var re=new RegExp("^(TABLE|TD|TR|IMG|HR)$");if(re.test(node.nodeName)){tinyMCE._moveStyle(node,'width','width');tinyMCE._moveStyle(node,'height','height');tinyMCE._moveStyle(node,'borderWidth','border');tinyMCE._moveStyle(node,'','vspace');tinyMCE._moveStyle(node,'','hspace');tinyMCE._moveStyle(node,'textAlign','align');tinyMCE._moveStyle(node,'backgroundColor','bgColor');tinyMCE._moveStyle(node,'borderColor','borderColor');tinyMCE._moveStyle(node,'backgroundImage','background');if(tinyMCE.isMSIE5)node.outerHTML=node.outerHTML;}else if(tinyMCE.isBlockElement(node))tinyMCE._moveStyle(node,'textAlign','align');if(node.nodeName=="FONT")tinyMCE._moveStyle(node,'color','color');}if(elementValidAttribs){for(var a=1;a"+node.innerHTML+"";if(elementName=="table"&&!node.hasChildNodes())return "";if(node.attributes.length>0){var lastAttrib="";for(var i=0;i"+this.convertStringToXML(String.fromCharCode(160))+""+elementName+">";if(tinyMCE.isMSIE&&elementName=="script")return "<"+elementName+elementAttribs+">"+node.text+""+elementName+">";if(node.hasChildNodes()){if(!(elementName=="span"&&elementAttribs==""&&tinyMCE.getParam("trim_span_elements"))){if(elementName=="p"&&tinyMCE.cleanup_force_br_newlines)output+="";else output+="<"+elementName+elementAttribs+">";}for(var i=0;i
";else output+=""+elementName+">";}}else{if(!nonEmptyTag){if(openTag)output+="<"+elementName+elementAttribs+">"+elementName+">";else output+="<"+elementName+elementAttribs+" />";}}return output;case 3:if(node.parentNode.nodeName=="SCRIPT"||node.parentNode.nodeName=="STYLE")return node.nodeValue;return this.convertStringToXML(node.nodeValue);case 8:return "";default:return "[UNKNOWN NODETYPE "+node.nodeType+"]";}};TinyMCE.prototype.convertStringToXML=function(html_data){var output="";for(var i=0;i127)output+=''+chr+";";else output+=String.fromCharCode(chr);continue;}if(tinyMCE.settings['entity_encoding']=="raw"){output+=String.fromCharCode(chr);continue;}if(typeof(tinyMCE.cleanup_entities["c"+chr])!='undefined'&&tinyMCE.cleanup_entities["c"+chr]!='')output+='&'+tinyMCE.cleanup_entities["c"+chr]+';';else output+=''+String.fromCharCode(chr);}return output;};TinyMCE.prototype._getCleanupElementName=function(chunk){var pos;if(chunk.charAt(0)=='+')chunk=chunk.substring(1);if(chunk.charAt(0)=='-')chunk=chunk.substring(1);if((pos=chunk.indexOf('/'))!=-1)chunk=chunk.substring(0,pos);if((pos=chunk.indexOf('['))!=-1)chunk=chunk.substring(0,pos);return chunk;};TinyMCE.prototype._initCleanup=function(){var validElements=tinyMCE.settings["valid_elements"];validElements=validElements.split(',');var extendedValidElements=tinyMCE.settings["extended_valid_elements"];extendedValidElements=extendedValidElements.split(',');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.");html=tinyMCE.regexpReplace(html,'
','
');html=tinyMCE.regexpReplace(html,'
','
');html=tinyMCE.regexpReplace(html,'\\s* \\s* | ',' | ');html=tinyMCE.regexpReplace(html,'\\s*
\\s*
','
');html=tinyMCE.regexpReplace(html,'\\s* \\s*
\\s* \\s*
','
');html=tinyMCE.regexpReplace(html,'\\s* \\s*
\\s*
','
');html=tinyMCE.regexpReplace(html,'\\s*
\\s* \\s*
','
');html=html.replace(new RegExp('(.*?)','gi'),'$1');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$1$2>\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']){var re=new RegExp('<>','g');html=html.replace(re,"");}html=tinyMCE._customCleanup(inst,on_save?"get_from_editor":"insert_to_editor",html);var chk=tinyMCE.regexpReplace(html,"[ \t\r\n]","").toLowerCase();if(chk=="
"||chk=="
"||chk=="
"||chk=="
"||chk=="")html="";if(tinyMCE.settings["preformatted"])return ""+html+"
";return html;};TinyMCE.prototype.insertLink=function(href,target,title,onclick,style_class){tinyMCE.execCommand('mceBeginUndoLevel');if(this.selectedInstance&&this.selectedElement&&this.selectedElement.nodeName.toLowerCase()=="img"){var doc=this.selectedInstance.getDoc();var linkElement=tinyMCE.getParentElement(this.selectedElement,"a");var newLink=false;if(!linkElement){linkElement=doc.createElement("a");newLink=true;}href=eval(tinyMCE.settings['urlconverter_callback']+"(href, linkElement);");tinyMCE.setAttrib(linkElement,'href',href);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;src=eval(tinyMCE.settings['urlconverter_callback']+"(src, tinyMCE.imgElement);");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);")+"';";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_real_src',src);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);if(width&&width!="")this.imgElement.style.pixelWidth=width;if(height&&height!="")this.imgElement.style.pixelHeight=height;if(needsRepaint)tinyMCE.selectedInstance.repaint();}tinyMCE.execCommand('mceEndUndoLevel');};TinyMCE.prototype.getElementByAttributeValue=function(node,element_name,attrib,value){var elements=this.getElementsByAttributeValue(node,element_name,attrib,value);if(elements.length==0)return null;return elements[0];};TinyMCE.prototype.getElementsByAttributeValue=function(node,element_name,attrib,value){var elements=new Array();if(node&&node.nodeName.toLowerCase()==element_name){if(node.getAttribute(attrib)&&node.getAttribute(attrib).indexOf(value)!=-1)elements[elements.length]=node;}if(node&&node.hasChildNodes()){for(var x=0,n=node.childNodes.length;x=strTok2.length){for(var i=0;i=strTok2.length||strTok1[i]!=strTok2[i]){breakPoint=i+1;break;}}}if(strTok1.length=strTok1.length||strTok1[i]!=strTok2[i]){breakPoint=i+1;break;}}}if(breakPoint==1)return targetURL.path;for(var i=0;i<(strTok1.length-(breakPoint-1));i++)outPath+="../";for(var i=breakPoint-1;i=0;i--){if(baseURLParts[i].length==0)continue;newBaseURLParts[newBaseURLParts.length]=baseURLParts[i];}baseURLParts=newBaseURLParts.reverse();var newRelURLParts=new Array();var numBack=0;for(var i=relURLParts.length-1;i>=0;i--){if(relURLParts[i].length==0||relURLParts[i]==".")continue;if(relURLParts[i]=='..'){numBack++;continue;}if(numBack>0){numBack--;continue;}newRelURLParts[newRelURLParts.length]=relURLParts[i];}relURLParts=newRelURLParts.reverse();var len=baseURLParts.length-numBack;var absPath=(len<=0?"":"/")+baseURLParts.slice(0,len).join('/')+"/"+relURLParts.join('/');var start="",end="";relURL.protocol=baseURL.protocol;relURL.host=baseURL.host;relURL.port=baseURL.port;if(relURL.path.charAt(relURL.path.length-1)=="/")absPath+="/";relURL.path=absPath;return TinyMCE.prototype.serializeURL(relURL);};TinyMCE.prototype.getParam=function(name,default_value,strip_whitespace,split_chr){var value=(typeof(this.settings[name])=="undefined")?default_value:this.settings[name];if(value=="true"||value=="false")return(value=="true");if(strip_whitespace)value=tinyMCE.regexpReplace(value,"[ \t\r\n]","");if(typeof(split_chr)!="undefined"&&split_chr!=null){value=value.split(split_chr);var outArray=new Array();for(var i=0;i0);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){var customCleanup=tinyMCE.settings['cleanup_callback'];if(customCleanup!=""&&eval("typeof("+customCleanup+")")!="undefined")content=eval(customCleanup+"(type, content, inst);");var plugins=tinyMCE.getParam('plugins','',true,',');for(var i=0;i0)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;y0){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.setInnerHTML=function(e,h){if(tinyMCE.isMSIE&&!tinyMCE.isOpera){e.innerHTML='TMP
'+h;e.firstChild.removeNode(true);}else e.innerHTML=h;};TinyMCE.prototype.getOuterHTML=function(e){if(tinyMCE.isMSIE)return e.outerHTML;var d=e.ownerDocument.createElement("body");d.appendChild(e);return d.innerHTML;};TinyMCE.prototype.setOuterHTML=function(doc,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.prototype.insertAfter=function(nc,rc){if(rc.nextSibling)rc.parentNode.insertBefore(nc,rc.nextSibling);else rc.parentNode.appendChild(nc);};TinyMCE.prototype.cleanupAnchors=function(doc){var an=doc.getElementsByTagName("a");for(var i=0;i=0;x--)tinyMCE.insertAfter(cn[x],an[i]);}}};TinyMCE.prototype._setHTML=function(doc,html_content){html_content=tinyMCE.cleanupHTMLCode(html_content);try{tinyMCE.setInnerHTML(doc.body,html_content);}catch(e){if(this.isMSIE)doc.body.createTextRange().pasteHTML(html_content);}if(tinyMCE.isMSIE&&tinyMCE.settings['fix_content_duplication']){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*)?","
");}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){for(var j=0;j0){for(var x=0;x0)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,'');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;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;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;}}templateFunction='TinyMCE_'+tinyMCE.settings['theme']+"_execCommand";if(eval("typeof("+templateFunction+")")!='undefined')return eval(templateFunction+"(editor_id, element, command, user_interface, value);");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;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+'(';for(var i=3;i');
+ this.defParam("font_size_classes", '');
+ this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large');
+ this.defParam("event_elements", 'a,img');
+ this.defParam("convert_urls", true);
+ this.defParam("table_inline_editing", false);
+ this.defParam("object_resizing", true);
+
+ // Browser check IE
+ if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
+ return;
+
+ // Browser check Gecko
+ if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
+ return;
+
+ // Browser check Safari
+ if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
+ return;
+
+ // Browser check Opera
+ if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
+ return;
+
+ // If not super absolute make it so
+ var baseHREF = tinyMCE.settings['document_base_url'];
+ var h = document.location.href;
+ var p = h.indexOf('://');
+ if (p > 0 && document.location.protocol != "file:") {
+ p = h.indexOf('/', p + 3);
+ h = h.substring(0, p);
+
+ if (baseHREF.indexOf('://') == -1)
+ baseHREF = h + baseHREF;
+
+ tinyMCE.settings['document_base_url'] = baseHREF;
+ tinyMCE.settings['document_base_prefix'] = h;
+ }
+
+ // Trim away query part
+ if (baseHREF.indexOf('?') != -1)
+ baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
+
+ this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
+
+ theme = this.settings['theme'];
+ this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i");
+ this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
+ this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
+ this.uniqueTag = 'TMP
';
+
+ // Theme url
+ this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
+
+ if (!tinyMCE.isMSIE)
+ this.settings['force_br_newlines'] = false;
+
+ if (tinyMCE.getParam("content_css", false)) {
+ var cssPath = tinyMCE.getParam("content_css", "");
+
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['content_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['content_css'] = cssPath;
+ } else
+ this.settings['content_css'] = '';
+
+ if (tinyMCE.getParam("popups_css", false)) {
+ var cssPath = tinyMCE.getParam("popups_css", "");
+
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['popups_css'] = cssPath;
+ } else
+ this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
+
+ if (tinyMCE.getParam("editor_css", false)) {
+ var cssPath = tinyMCE.getParam("editor_css", "");
+
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['editor_css'] = cssPath;
+ } else
+ this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
+
+ if (tinyMCE.settings['debug']) {
+ var msg = "Debug: \n";
+
+ msg += "baseURL: " + this.baseURL + "\n";
+ msg += "documentBasePath: " + this.documentBasePath + "\n";
+ msg += "content_css: " + this.settings['content_css'] + "\n";
+ msg += "popups_css: " + this.settings['popups_css'] + "\n";
+ msg += "editor_css: " + this.settings['editor_css'] + "\n";
+
+ alert(msg);
+ }
+
+ // Init HTML cleanup
+ this._initCleanup();
+
+ // Only do this once
+ if (this.configs.length == 0) {
+ // Is Safari enabled
+ if (this.isSafari && this.getParam('safari_warning', true))
+ alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
+
+ tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad);
+
+ if (tinyMCE.isMSIE) {
+ if (tinyMCE.settings['add_unload_trigger']) {
+ tinyMCE.addEvent(window, "unload", TinyMCE.prototype.unloadHandler);
+ tinyMCE.addEvent(window.document, "beforeunload", TinyMCE.prototype.unloadHandler);
+ }
+ } else {
+ if (tinyMCE.settings['add_unload_trigger'])
+ tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);});
+ }
+ }
+
+ this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');
+ this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js');
+ this.loadCSS(this.settings['editor_css']);
+
+ // Add plugins
+ var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
+ if (this.settings['plugins'] != '') {
+ for (var i=0; i');
+
+ this.loadedFiles[this.loadedFiles.length] = url;
+};
+
+TinyMCE.prototype.loadCSS = function(url) {
+ for (var i=0; i');
+
+ this.loadedFiles[this.loadedFiles.length] = url;
+};
+
+TinyMCE.prototype.importCSS = function(doc, css_file) {
+ if (css_file == '')
+ return;
+
+ if (typeof(doc.createStyleSheet) == "undefined") {
+ var elm = doc.createElement("link");
+
+ elm.rel = "stylesheet";
+ elm.href = css_file;
+
+ if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
+ headArr[0].appendChild(elm);
+ } else
+ var styleSheet = doc.createStyleSheet(css_file);
+};
+
+TinyMCE.prototype.confirmAdd = function(e, settings) {
+ var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
+ var elementId = elm.name ? elm.name : elm.id;
+
+ tinyMCE.settings = settings;
+
+ if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm']))
+ tinyMCE.addMCEControl(elm, elementId);
+
+ elm.setAttribute('mce_noask', 'true');
+};
+
+TinyMCE.prototype.updateContent = function(form_element_name) {
+ // Find MCE instance linked to given form element and copy it's value
+ var formElement = document.getElementById(form_element_name);
+ for (var n in tinyMCE.instances) {
+ var inst = tinyMCE.instances[n];
+ if (!tinyMCE.isInstance(inst))
+ continue;
+
+ inst.switchSettings();
+
+ if (inst.formElement == formElement) {
+ var doc = inst.getDoc();
+
+ tinyMCE._setHTML(doc, inst.formElement.value);
+
+ if (!tinyMCE.isMSIE)
+ doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
+ }
+ }
+};
+
+TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) {
+ var id = "mce_editor_" + tinyMCE.idCounter++;
+ var inst = new TinyMCEControl(tinyMCE.settings);
+
+ inst.editorId = id;
+ this.instances[id] = inst;
+
+ inst.onAdd(replace_element, form_element_name, target_document);
+};
+
+TinyMCE.prototype.triggerSave = function(skip_cleanup, skip_callback) {
+ // Cleanup and set all form fields
+ for (var n in tinyMCE.instances) {
+ var inst = tinyMCE.instances[n];
+ if (!tinyMCE.isInstance(inst))
+ continue;
+
+ inst.switchSettings();
+
+ tinyMCE.settings['preformatted'] = false;
+
+ // Default to false
+ if (typeof(skip_cleanup) == "undefined")
+ skip_cleanup = false;
+
+ // Default to false
+ if (typeof(skip_callback) == "undefined")
+ skip_callback = false;
+
+ tinyMCE._setHTML(inst.getDoc(), inst.getBody().innerHTML);
+
+ // Remove visual aids when cleanup is disabled
+ if (inst.settings['cleanup'] == false) {
+ tinyMCE.handleVisualAid(inst.getBody(), true, false, inst);
+ tinyMCE._setEventsEnabled(inst.getBody(), true);
+ }
+
+ tinyMCE._customCleanup(inst, "submit_content_dom", inst.contentWindow.document.body);
+ var htm = skip_cleanup ? inst.getBody().innerHTML : tinyMCE._cleanupHTML(inst, inst.getDoc(), this.settings, inst.getBody(), this.visualAid, true);
+ htm = tinyMCE._customCleanup(inst, "submit_content", htm);
+
+ if (tinyMCE.settings["encoding"] == "xml" || tinyMCE.settings["encoding"] == "html")
+ htm = tinyMCE.convertStringToXML(htm);
+
+ if (!skip_callback && tinyMCE.settings['save_callback'] != "")
+ var content = eval(tinyMCE.settings['save_callback'] + "(inst.formTargetElementId,htm,inst.getBody());");
+
+ // Use callback content if available
+ if ((typeof(content) != "undefined") && content != null)
+ htm = content;
+
+ // Replace some weird entities (Bug: #1056343)
+ htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");
+ htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");
+ htm = tinyMCE.regexpReplace(htm, ";", ";", "gi");
+ htm = tinyMCE.regexpReplace(htm, """, """, "gi");
+ htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");
+
+ if (inst.formElement)
+ inst.formElement.value = htm;
+ }
+};
+
+TinyMCE.prototype._setEventsEnabled = function(node, state) {
+ var events = new Array('onfocus','onblur','onclick','ondblclick',
+ 'onmousedown','onmouseup','onmouseover','onmousemove',
+ 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');
+
+ var evs = tinyMCE.settings['event_elements'].split(',');
+ for (var y=0; y", "gi");
+ content = tinyMCE.regexpReplace(content, "\r", "
", "gi");
+ content = tinyMCE.regexpReplace(content, "\n", "
", "gi");
+ }
+
+ // Open closed anchors
+// content = content.replace(new RegExp('', 'gi'), '');
+
+ // Call custom cleanup code
+ content = tinyMCE.storeAwayURLs(content);
+ content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
+
+ if (tinyMCE.isMSIE) {
+ // Ugly!!!
+ window.setInterval('try{tinyMCE.getCSSClasses(document.frames["' + editor_id + '"].document, "' + editor_id + '");}catch(e){}', 500);
+
+ if (tinyMCE.settings["force_br_newlines"])
+ document.frames[editor_id].document.styleSheets[0].addRule("p", "margin: 0px;");
+
+ var body = document.frames[editor_id].document.body;
+
+ tinyMCE.addEvent(body, "beforepaste", TinyMCE.prototype.eventPatch);
+ tinyMCE.addEvent(body, "beforecut", TinyMCE.prototype.eventPatch);
+
+ body.editorId = editor_id;
+ }
+
+ content = tinyMCE.cleanupHTMLCode(content);
+
+ // Fix for bug #958637
+ if (!tinyMCE.isMSIE) {
+ var contentElement = inst.getDoc().createElement("body");
+ var doc = inst.getDoc();
+
+ contentElement.innerHTML = content;
+
+ // Remove weridness!
+ if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt'])
+ content = content.replace(new RegExp('<>', 'g'), "");
+
+ if (tinyMCE.settings['cleanup_on_startup'])
+ tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
+ else {
+ // Convert all strong/em to b/i
+ content = tinyMCE.regexpReplace(content, "", "", "gi");
+ content = tinyMCE.regexpReplace(content, "", "", "gi");
+ content = tinyMCE.regexpReplace(content, "", "", "gi");
+ tinyMCE.setInnerHTML(inst.getBody(), content);
+ }
+
+ inst.convertAllRelativeURLs();
+ } else {
+ if (tinyMCE.settings['cleanup_on_startup']) {
+ tinyMCE._setHTML(inst.getDoc(), content);
+
+ // Produces permission denied error in MSIE 5.5
+ eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}');
+ } else
+ tinyMCE._setHTML(inst.getDoc(), content);
+ }
+
+ // Fix for bug #957681
+ //inst.getDoc().designMode = inst.getDoc().designMode;
+
+ // Setup element references
+ var parentElm = document.getElementById(inst.editorId + '_parent');
+ if (parentElm.lastChild.nodeName == "INPUT")
+ inst.formElement = tinyMCE.isGecko ? parentElm.firstChild : parentElm.lastChild;
+ else
+ inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
+
+ tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
+ tinyMCE.executeCallback('setupcontent_callback', '_setupContent', 0, editor_id, inst.getBody(), inst.getDoc());
+
+ // Re-add design mode on mozilla
+ if (!tinyMCE.isMSIE)
+ TinyMCE.prototype.addEventHandlers(editor_id);
+
+ // Add blur handler
+ if (tinyMCE.isMSIE)
+ tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE.prototype.eventPatch);
+
+ // Trigger node change, this call locks buttons for tables and so forth
+ tinyMCE.selectedInstance = inst;
+ tinyMCE.selectedElement = inst.contentWindow.document.body;
+
+ if (!inst.isHidden())
+ tinyMCE.triggerNodeChange(false, true);
+
+ // Call custom DOM cleanup
+ tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
+ tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
+ tinyMCE._setEventsEnabled(inst.getBody(), false);
+ tinyMCE.cleanupAnchors(inst.getDoc());
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(inst.getDoc());
+
+ inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
+ inst.undoLevels[inst.undoLevels.length] = inst.startContent;
+
+ tinyMCE.operaOpacityCounter = -1;
+};
+
+TinyMCE.prototype.cleanupHTMLCode = function(s) {
+ s = s.replace(//gi, '
');
+ s = s.replace(/\s*<\/p>/gi, '
');
+
+ // Open closed tags like to
+// tinyMCE.debug("f:" + s);
+ s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3>$1$2>');
+// tinyMCE.debug("e:" + s);
+
+ // Remove trailing space to
+ s = s.replace(new RegExp('\\s+>', 'gi'), '>');
+
+ // Close tags to
+ s = s.replace(/<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />');
+
+ // Weird MSIE bug,
breaks runtime?
+ if (tinyMCE.isMSIE)
+ s = s.replace(/
<\/p>/gi, "
");
+
+ // Convert relative anchors to absolute URLs ex: #something to file.htm#something
+ s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
+
+ return s;
+};
+
+TinyMCE.prototype.storeAwayURLs = function(s) {
+ // Remove all mce_src, mce_href and replace them with new ones
+ s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
+ s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
+ s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"');
+ s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"');
+
+ return s;
+};
+
+TinyMCE.prototype.cancelEvent = function(e) {
+ if (tinyMCE.isMSIE) {
+ e.returnValue = false;
+ e.cancelBubble = true;
+ } else
+ e.preventDefault();
+};
+
+TinyMCE.prototype.removeTinyMCEFormElements = function(form_obj) {
+ // Check if form is valid
+ if (typeof(form_obj) == "undefined" || form_obj == null)
+ return;
+
+ // If not a form, find the form
+ if (form_obj.nodeName != "FORM") {
+ if (form_obj.form)
+ form_obj = form_obj.form;
+ else
+ form_obj = tinyMCE.getParentElement(form_obj, "form");
+ }
+
+ // Still nothing
+ if (form_obj == null)
+ return;
+
+ // Disable all UI form elements that TinyMCE created
+ for (var i=0; i");
+ rng.collapse(false);
+ rng.select();
+
+ tinyMCE.execCommand("mceAddUndoLevel");
+ tinyMCE.triggerNodeChange(false);
+ return false;
+ }
+ }
+
+ // Backspace or delete
+ if (e.keyCode == 8 || e.keyCode == 46) {
+ tinyMCE.selectedElement = e.target;
+ tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
+ tinyMCE.triggerNodeChange(false);
+ }
+
+ return false;
+ break;
+
+ case "keyup":
+ case "keydown":
+ if (e.target.editorId)
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ else
+ return;
+
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.switchSettings();
+
+ var inst = tinyMCE.selectedInstance;
+
+ // Handle backspace
+ if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
+ // Insert P element instead of BR
+ if (tinyMCE.selectedInstance._handleBackSpace(e.type)) {
+ // Cancel event
+ tinyMCE.execCommand("mceAddUndoLevel");
+ e.preventDefault();
+ return false;
+ }
+ }
+
+ tinyMCE.selectedElement = null;
+ tinyMCE.selectedNode = null;
+ var elm = tinyMCE.selectedInstance.getFocusElement();
+ tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
+ tinyMCE.selectedElement = elm;
+
+ // Update visualaids on tabs
+ if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
+ tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);
+
+ // Fix empty elements on return/enter, check where enter occured
+ if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
+ tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
+
+ // Fix empty elements on return/enter
+ if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
+ var elm = tinyMCE.enterKeyElement;
+ if (elm) {
+ var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
+ var dre = new RegExp('^H[1-6]$','g'); // Add double on these
+
+ if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
+ if (dre.test(elm.nodeName))
+ elm.innerHTML = " ";
+ else
+ elm.innerHTML = " ";
+ }
+ }
+ }
+
+ // Check if it's a position key
+ var keys = tinyMCE.posKeyCodes;
+ var posKey = false;
+ for (var i=0; i -1)
+ suffix = '?rnd=' + this.operaOpacityCounter++;
+
+ element.src = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/images/opacity.png" + suffix;
+ element.style.backgroundImage = "url('" + element.mceOldSrc + "')";
+ } else {
+ if (element.mceOldSrc) {
+ element.src = element.mceOldSrc;
+ element.parentNode.style.backgroundImage = "";
+ element.mceOldSrc = null;
+ }
+ }
+ }
+ }
+};
+
+TinyMCE.prototype.restoreClass = function(element) {
+ if (element != null && element.oldClassName && !element.classLock) {
+ element.className = element.oldClassName;
+ element.oldClassName = null;
+ }
+};
+
+TinyMCE.prototype.setClassLock = function(element, lock_state) {
+ if (element != null)
+ element.classLock = lock_state;
+};
+
+TinyMCE.prototype.addEvent = function(obj, name, handler) {
+ if (tinyMCE.isMSIE) {
+ obj.attachEvent("on" + name, handler);
+ } else
+ obj.addEventListener(name, handler, false);
+};
+
+TinyMCE.prototype.submitPatch = function() {
+ tinyMCE.removeTinyMCEFormElements(this);
+ tinyMCE.triggerSave();
+ this.mceOldSubmit();
+ tinyMCE.isNotDirty = true;
+};
+
+TinyMCE.prototype.onLoad = function() {
+ for (var c=0; c 0)
+ return;
+
+ if (val.indexOf('%') == -1)
+ val += 'px';
+ break;
+
+ case "vspace":
+ case "hspace":
+ elm.style.marginTop = val + "px";
+ elm.style.marginBottom = val + "px";
+ elm.removeAttribute(attrib);
+ return;
+
+ case "align":
+ if (elm.nodeName == "IMG") {
+ if (tinyMCE.isMSIE)
+ elm.style.styleFloat = val;
+ else
+ elm.style.cssFloat = val;
+ } else
+ elm.style.textAlign = val;
+
+ elm.removeAttribute(attrib);
+ return;
+ }
+
+ if (val != '') {
+ eval('elm.style.' + style + ' = val;');
+ elm.removeAttribute(attrib);
+ }
+ }
+ } else {
+ if (style == '')
+ return;
+
+ var val = eval('elm.style.' + style) == '' ? tinyMCE.getAttrib(elm, attrib) : eval('elm.style.' + style);
+ val = val == null ? '' : '' + val;
+
+ switch (attrib) {
+ // Always move background to style
+ case "background":
+ if (val.indexOf('url') == -1 && val != '')
+ val = "url('" + val + "');";
+
+ if (val != '') {
+ elm.style.backgroundImage = val;
+ elm.removeAttribute(attrib);
+ }
+ return;
+
+ case "border":
+ case "width":
+ case "height":
+ val = val.replace('px', '');
+ break;
+
+ case "align":
+ if (tinyMCE.getAttrib(elm, 'align') == '') {
+ if (elm.nodeName == "IMG") {
+ if (tinyMCE.isMSIE && elm.style.styleFloat != '') {
+ val = elm.style.styleFloat;
+ style = 'styleFloat';
+ } else if (tinyMCE.isGecko && elm.style.cssFloat != '') {
+ val = elm.style.cssFloat;
+ style = 'cssFloat';
+ }
+ }
+ }
+ break;
+ }
+
+ if (val != '') {
+ elm.removeAttribute(attrib);
+ elm.setAttribute(attrib, val);
+ eval('elm.style.' + style + ' = "";');
+ }
+ }
+};
+
+TinyMCE.prototype._cleanupAttribute = function(valid_attributes, element_name, attribute_node, element_node) {
+ var attribName = attribute_node.nodeName.toLowerCase();
+ var attribValue = attribute_node.nodeValue;
+ var attribMustBeValue = null;
+ var verified = false;
+
+ // Mozilla attibute, remove them
+ if (attribName.indexOf('moz_') != -1)
+ return null;
+
+ if (!tinyMCE.cleanup_on_save && (attribName == "mce_href" || attribName == "mce_src"))
+ return {name : attribName, value : attribValue};
+
+ // Verify attrib
+ if (tinyMCE.cleanup_verify_html && !verified) {
+ for (var i=1; i 1)
+ val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')";
+ }
+
+ // Force HEX colors
+ if (tinyMCE.getParam("force_hex_style_colors"))
+ val = tinyMCE.convertRGBToHex(val, true);
+
+ if (val != "url('')")
+ str += key.toLowerCase() + ": " + val + "; ";
+ }
+ }
+
+ if (new RegExp('; $').test(str))
+ str = str.substring(0, str.length - 2);
+
+ return str;
+};
+
+TinyMCE.prototype.convertRGBToHex = function(s, k) {
+ if (s.toLowerCase().indexOf('rgb') != -1) {
+ var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
+ var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(',');
+ if (rgb.length == 5) {
+ r = parseInt(rgb[1]).toString(16);
+ g = parseInt(rgb[2]).toString(16);
+ b = parseInt(rgb[3]).toString(16);
+
+ r = r.length == 1 ? '0' + r : r;
+ g = g.length == 1 ? '0' + g : g;
+ b = b.length == 1 ? '0' + b : b;
+
+ s = "#" + r + g + b;
+
+ if (k)
+ s = rgb[0] + s + rgb[4];
+ }
+ }
+
+ return s;
+};
+
+TinyMCE.prototype.convertHexToRGB = function(s) {
+ if (s.indexOf('#') != -1) {
+ s = s.replace(new RegExp('[^0-9A-F]', 'gi'), '');
+ return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")";
+ }
+
+ return s;
+};
+
+TinyMCE.prototype._verifyClass = function(node) {
+ // Sometimes the class gets set to null, weird Gecko bug?
+ if (tinyMCE.isGecko) {
+ var className = node.getAttribute('class');
+ if (!className)
+ return false;
+ }
+
+ // Trim CSS class
+ if (tinyMCE.isMSIE)
+ var className = node.getAttribute('className');
+
+ if (tinyMCE.cleanup_verify_css_classes && tinyMCE.cleanup_on_save) {
+ var csses = tinyMCE.getCSSClasses();
+ nonDefinedCSS = true;
+ for (var c=0; c' + output;
+ }
+ }
+
+ // Remove deprecated attributes
+ var re = new RegExp("^(TABLE|TD|TR)$");
+ if (re.test(node.nodeName)) {
+ // Move attrib to style
+ if ((node.nodeName != "TABLE" || tinyMCE.cleanup_inline_styles) && (width = tinyMCE.getAttrib(node, "width")) != '') {
+ node.style.width = width.indexOf('%') != -1 ? width : width.replace(/[^0-9]/gi, '') + "px";
+ node.removeAttribute("width");
+ }
+
+ // Is table and not inline
+ if ((node.nodeName == "TABLE" && !tinyMCE.cleanup_inline_styles) && node.style.width != '') {
+ tinyMCE.setAttrib(node, "width", node.style.width.replace('px',''));
+ node.style.width = '';
+ }
+
+ // Move attrib to style
+ if ((height = tinyMCE.getAttrib(node, "height")) != '') {
+ height = "" + height; // Force string
+ node.style.height = height.indexOf('%') != -1 ? height : height.replace(/[^0-9]/gi, '') + "px";
+ node.removeAttribute("height");
+ }
+ }
+
+ // Handle inline/outline styles
+ if (tinyMCE.cleanup_inline_styles) {
+ var re = new RegExp("^(TABLE|TD|TR|IMG|HR)$");
+ if (re.test(node.nodeName) && tinyMCE.getAttrib(node, "class").indexOf('mceItem') == -1) {
+ tinyMCE._moveStyle(node, 'width', 'width');
+ tinyMCE._moveStyle(node, 'height', 'height');
+ tinyMCE._moveStyle(node, 'borderWidth', 'border');
+ tinyMCE._moveStyle(node, '', 'vspace');
+ tinyMCE._moveStyle(node, '', 'hspace');
+ tinyMCE._moveStyle(node, 'textAlign', 'align');
+ tinyMCE._moveStyle(node, 'backgroundColor', 'bgColor');
+ tinyMCE._moveStyle(node, 'borderColor', 'borderColor');
+ tinyMCE._moveStyle(node, 'backgroundImage', 'background');
+
+ // Refresh element in old MSIE
+ if (tinyMCE.isMSIE5)
+ node.outerHTML = node.outerHTML;
+ } else if (tinyMCE.isBlockElement(node))
+ tinyMCE._moveStyle(node, 'textAlign', 'align');
+
+ if (node.nodeName == "FONT")
+ tinyMCE._moveStyle(node, 'color', 'color');
+ }
+
+ // Set attrib data
+ if (elementValidAttribs) {
+ for (var a=1; a" + node.innerHTML + "";
+
+ // Remove empty tables
+ if (elementName == "table" && !node.hasChildNodes())
+ return "";
+
+ // Handle element attributes
+ if (node.attributes.length > 0) {
+ var lastAttrib = "";
+
+ for (var i=0; i" + this.convertStringToXML(String.fromCharCode(160)) + "" + elementName + ">";
+
+ // Is MSIE script element
+ if (tinyMCE.isMSIE && elementName == "script")
+ return "<" + elementName + elementAttribs + ">" + node.text + "" + elementName + ">";
+
+ // Clean up children
+ if (node.hasChildNodes()) {
+ // If not empty span
+ if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) {
+ // Force BR
+ if (elementName == "p" && tinyMCE.cleanup_force_br_newlines)
+ output += "";
+ else
+ output += "<" + elementName + elementAttribs + ">";
+ }
+
+ for (var i=0; i
";
+ else
+ output += "" + elementName + ">";
+ }
+ } else {
+ if (!nonEmptyTag) {
+ if (openTag)
+ output += "<" + elementName + elementAttribs + ">" + elementName + ">";
+ else
+ output += "<" + elementName + elementAttribs + " />";
+ }
+ }
+
+ return output;
+
+ case 3: // Text
+ // Do not convert script elements
+ if (node.parentNode.nodeName == "SCRIPT" || node.parentNode.nodeName == "NOSCRIPT" || node.parentNode.nodeName == "STYLE")
+ return node.nodeValue;
+
+ return this.convertStringToXML(node.nodeValue);
+
+ case 8: // Comment
+ return "";
+
+ default: // Unknown
+ return "[UNKNOWN NODETYPE " + node.nodeType + "]";
+ }
+};
+
+TinyMCE.prototype.convertStringToXML = function(html_data) {
+ var output = "";
+
+ for (var i=0; i 127)
+ output += '' + chr + ";";
+ else
+ output += String.fromCharCode(chr);
+
+ continue;
+ }
+
+ // Raw entities
+ if (tinyMCE.settings['entity_encoding'] == "raw") {
+ output += String.fromCharCode(chr);
+ continue;
+ }
+
+ // Named entities
+ if (typeof(tinyMCE.settings['cleanup_entities']["c" + chr]) != 'undefined' && tinyMCE.settings['cleanup_entities']["c" + chr] != '')
+ output += '&' + tinyMCE.settings['cleanup_entities']["c" + chr] + ';';
+ else
+ output += '' + String.fromCharCode(chr);
+ }
+
+ return output;
+};
+
+TinyMCE.prototype._getCleanupElementName = function(chunk) {
+ var pos;
+
+ if (chunk.charAt(0) == '+')
+ chunk = chunk.substring(1);
+
+ if (chunk.charAt(0) == '-')
+ chunk = chunk.substring(1);
+
+ if ((pos = chunk.indexOf('/')) != -1)
+ chunk = chunk.substring(0, pos);
+
+ if ((pos = chunk.indexOf('[')) != -1)
+ chunk = chunk.substring(0, pos);
+
+ return chunk;
+};
+
+TinyMCE.prototype._initCleanup = function() {
+ // Parse valid elements and attributes
+ var validElements = tinyMCE.settings["valid_elements"];
+ validElements = validElements.split(',');
+
+ // Handle extended valid elements
+ var extendedValidElements = tinyMCE.settings["extended_valid_elements"];
+ extendedValidElements = extendedValidElements.split(',');
+ for (var i=0; i/gi, '>');
+
+ return html;
+ }
+
+ if (on_save && tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertFontsToSpans(doc);
+
+ // Call custom cleanup code
+ tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);
+
+ // Move bgcolor to style
+ var n = doc.getElementsByTagName("font");
+ for (var i=0; i[ \n\r]*[ \n\r]*', '
', 'gi'));
+ tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '', '', 'gi'));
+ }
+
+ var html = this.cleanupNode(element);
+
+ if (tinyMCE.settings['debug'])
+ tinyMCE.debug("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms.");
+
+ // Remove pesky HR paragraphs and other crap
+ html = tinyMCE.regexpReplace(html, '
', '
');
+ html = tinyMCE.regexpReplace(html, '
', '
');
+ html = tinyMCE.regexpReplace(html, '\\s* \\s* | ', ' | ');
+ html = tinyMCE.regexpReplace(html, '\\s*
\\s*
', '
');
+ html = tinyMCE.regexpReplace(html, '\\s* \\s*
\\s* \\s*
', '
');
+ html = tinyMCE.regexpReplace(html, '\\s* \\s*
\\s*
', '
');
+ html = tinyMCE.regexpReplace(html, '\\s*
\\s* \\s*
', '
');
+
+ // Remove empty anchors
+ html = html.replace(new RegExp('(.*?)', 'gi'), '$1');
+
+ // Remove some mozilla crap
+ if (!tinyMCE.isMSIE)
+ html = html.replace(new RegExp('', 'g'), "");
+
+ if (tinyMCE.settings['remove_linebreaks'])
+ html = html.replace(new RegExp('\r|\n', 'g'), ' ');
+
+ if (tinyMCE.getParam('apply_source_formatting')) {
+ html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n");
+ html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n$1$2>\n");
+ html = html.replace(new RegExp('
', 'g'), "
\n");
+ }
+
+ if (tinyMCE.settings['force_br_newlines']) {
+ var re = new RegExp('
', 'g');
+ html = html.replace(re, "
");
+ }
+
+ if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) {
+ // Remove weridness!
+ var re = new RegExp('<>', 'g');
+ html = html.replace(re, "");
+ }
+
+ // Call custom cleanup code
+ html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html);
+
+ // Emtpy node, return empty
+ var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase();
+ if (chk == "
" || chk == "
" || chk == "
" || chk == "
" || chk == "")
+ html = "";
+
+ if (tinyMCE.settings["preformatted"])
+ return "" + html + "
";
+
+ return html;
+};
+
+TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) {
+ tinyMCE.execCommand('mceBeginUndoLevel');
+
+ if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") {
+ var doc = this.selectedInstance.getDoc();
+ var linkElement = tinyMCE.getParentElement(this.selectedElement, "a");
+ var newLink = false;
+
+ if (!linkElement) {
+ linkElement = doc.createElement("a");
+ newLink = true;
+ }
+
+ var mhref = href;
+ var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
+ mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+
+ tinyMCE.setAttrib(linkElement, 'href', thref);
+ tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
+ tinyMCE.setAttrib(linkElement, 'target', target);
+ tinyMCE.setAttrib(linkElement, 'title', title);
+ tinyMCE.setAttrib(linkElement, 'onclick', onclick);
+ tinyMCE.setAttrib(linkElement, 'class', style_class);
+
+ if (newLink) {
+ linkElement.appendChild(this.selectedElement.cloneNode(true));
+ this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement);
+ }
+
+ return;
+ }
+
+ if (!this.linkElement && this.selectedInstance) {
+ if (tinyMCE.isSafari) {
+ tinyMCE.execCommand("mceInsertContent", false, '' + this.selectedInstance.getSelectedHTML() + '');
+ } else
+ this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
+
+ tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
+
+ var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
+
+ for (var i=0; i';
+
+ tinyMCE.execCommand("mceInsertContent", false, html);
+ } else {
+ if (!this.imgElement && this.selectedInstance) {
+ if (tinyMCE.isSafari)
+ tinyMCE.execCommand("mceInsertContent", false, '');
+ else
+ this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
+
+ tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
+ }
+ }
+
+ if (this.imgElement) {
+ var needsRepaint = false;
+ var msrc = src;
+
+ src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
+
+ if (tinyMCE.getParam('convert_urls'))
+ msrc = src;
+
+ if (onmouseover && onmouseover != "")
+ onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
+
+ if (onmouseout && onmouseout != "")
+ onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
+
+ // Use alt as title if it's undefined
+ if (typeof(title) == "undefined")
+ title = alt;
+
+ if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align"))
+ needsRepaint = true;
+
+ tinyMCE.setAttrib(this.imgElement, 'src', src);
+ tinyMCE.setAttrib(this.imgElement, 'mce_src', msrc);
+ tinyMCE.setAttrib(this.imgElement, 'alt', alt);
+ tinyMCE.setAttrib(this.imgElement, 'title', title);
+ tinyMCE.setAttrib(this.imgElement, 'align', align);
+ tinyMCE.setAttrib(this.imgElement, 'border', border, true);
+ tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true);
+ tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true);
+ tinyMCE.setAttrib(this.imgElement, 'width', width, true);
+ tinyMCE.setAttrib(this.imgElement, 'height', height, true);
+ tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover);
+ tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout);
+
+ // Fix for bug #989846 - Image resize bug
+ if (width && width != "")
+ this.imgElement.style.pixelWidth = width;
+
+ if (height && height != "")
+ this.imgElement.style.pixelHeight = height;
+
+ if (needsRepaint)
+ tinyMCE.selectedInstance.repaint();
+ }
+
+ tinyMCE.execCommand('mceEndUndoLevel');
+};
+
+TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) {
+ var elements = this.getElementsByAttributeValue(node, element_name, attrib, value);
+ if (elements.length == 0)
+ return null;
+
+ return elements[0];
+};
+
+TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) {
+ var elements = new Array();
+
+ if (node && node.nodeName.toLowerCase() == element_name) {
+ if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1)
+ elements[elements.length] = node;
+ }
+
+ if (node && node.hasChildNodes()) {
+ for (var x=0, n=node.childNodes.length; x= strTok2.length) {
+ for (var i=0; i= strTok2.length || strTok1[i] != strTok2[i]) {
+ breakPoint = i + 1;
+ break;
+ }
+ }
+ }
+
+ if (strTok1.length < strTok2.length) {
+ for (var i=0; i= strTok1.length || strTok1[i] != strTok2[i]) {
+ breakPoint = i + 1;
+ break;
+ }
+ }
+ }
+
+ if (breakPoint == 1)
+ return targetURL.path;
+
+ for (var i=0; i<(strTok1.length-(breakPoint-1)); i++)
+ outPath += "../";
+
+ for (var i=breakPoint-1; i=0; i--) {
+ if (baseURLParts[i].length == 0)
+ continue;
+
+ newBaseURLParts[newBaseURLParts.length] = baseURLParts[i];
+ }
+ baseURLParts = newBaseURLParts.reverse();
+
+ // Merge relURLParts chunks
+ var newRelURLParts = new Array();
+ var numBack = 0;
+ for (var i=relURLParts.length-1; i>=0; i--) {
+ if (relURLParts[i].length == 0 || relURLParts[i] == ".")
+ continue;
+
+ if (relURLParts[i] == '..') {
+ numBack++;
+ continue;
+ }
+
+ if (numBack > 0) {
+ numBack--;
+ continue;
+ }
+
+ newRelURLParts[newRelURLParts.length] = relURLParts[i];
+ }
+
+ relURLParts = newRelURLParts.reverse();
+
+ // Remove end from absolute path
+ var len = baseURLParts.length-numBack;
+ var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/');
+ var start = "", end = "";
+
+ // Build output URL
+ relURL.protocol = baseURL.protocol;
+ relURL.host = baseURL.host;
+ relURL.port = baseURL.port;
+
+ // Re-add trailing slash if it's removed
+ if (relURL.path.charAt(relURL.path.length-1) == "/")
+ absPath += "/";
+
+ relURL.path = absPath;
+
+ return TinyMCE.prototype.serializeURL(relURL);
+};
+
+TinyMCE.prototype.getParam = function(name, default_value, strip_whitespace, split_chr) {
+ var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
+
+ // Fix bool values
+ if (value == "true" || value == "false")
+ return (value == "true");
+
+ if (strip_whitespace)
+ value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "");
+
+ if (typeof(split_chr) != "undefined" && split_chr != null) {
+ value = value.split(split_chr);
+ var outArray = new Array();
+
+ for (var i=0; i 0);
+
+ if (tinyMCE.settings['custom_undo_redo']) {
+ undoIndex = inst.undoIndex;
+ undoLevels = inst.undoLevels.length;
+ }
+
+ tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
+ }
+ }
+
+ if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
+ this.selectedInstance.contentWindow.focus();
+};
+
+TinyMCE.prototype._customCleanup = function(inst, type, content) {
+ // Call custom cleanup
+ var customCleanup = tinyMCE.settings['cleanup_callback'];
+ if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
+ content = eval(customCleanup + "(type, content, inst);");
+
+ // Trigger plugin cleanups
+ var plugins = tinyMCE.getParam('plugins', '', true, ',');
+ for (var i=0; i 0)
+ className += " ";
+
+ className += classNames[i];
+ }
+
+ return className;
+};
+
+TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) {
+ if (!el)
+ return;
+
+ var tableElement = null;
+
+ switch (el.nodeName) {
+ case "TABLE":
+ var oldW = el.style.width;
+ var oldH = el.style.height;
+ var bo = tinyMCE.getAttrib(el, "border");
+
+ bo = bo == "" || bo == "0" ? true : false;
+
+ tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
+
+ el.style.width = oldW;
+ el.style.height = oldH;
+
+ for (var y=0; y 0) {
+ tinyMCE.setAttrib(s[i], 'size', fSize);
+ s[i].style.fontSize = '';
+ }
+
+ var fFace = s[i].style.fontFamily;
+ if (fFace != null && fFace != "") {
+ tinyMCE.setAttrib(s[i], 'face', fFace);
+ s[i].style.fontFamily = '';
+ }
+
+ var fColor = s[i].style.color;
+ if (fColor != null && fColor != "") {
+ tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor));
+ s[i].style.color = '';
+ }
+ }
+};
+
+TinyMCE.prototype.convertFontsToSpans = function(doc) {
+ var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
+
+ var h = doc.body.innerHTML;
+ h = h.replace(/ 0 && fSize < 8) {
+ if (fsClasses != null)
+ tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]);
+ else
+ s[i].style.fontSize = sizes[fSize-1];
+ }
+
+ s[i].removeAttribute('size');
+ }
+
+ if (fFace != "") {
+ s[i].style.fontFamily = fFace;
+ s[i].removeAttribute('face');
+ }
+
+ if (fColor != "") {
+ s[i].style.color = fColor;
+ s[i].removeAttribute('color');
+ }
+ }
+};
+
+/*
+TinyMCE.prototype.applyClassesToFonts = function(doc, size) {
+ var f = doc.getElementsByTagName("font");
+ for (var i=0; i=0; x--)
+ tinyMCE.insertAfter(cn[x], an[i]);
+ }
+ }
+};
+
+TinyMCE.prototype._setHTML = function(doc, html_content) {
+ // Force closed anchors open
+ //html_content = html_content.replace(new RegExp('', 'gi'), '');
+
+ html_content = tinyMCE.cleanupHTMLCode(html_content);
+
+ // Try innerHTML if it fails use pasteHTML in MSIE
+ try {
+ tinyMCE.setInnerHTML(doc.body, html_content);
+ } catch (e) {
+ if (this.isMSIE)
+ doc.body.createTextRange().pasteHTML(html_content);
+ }
+
+ // Content duplication bug fix
+ if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
+ // Remove P elements in P elements
+ var paras = doc.getElementsByTagName("P");
+ for (var i=0; i<\/o:p>", "
");
+ html = tinyMCE.regexpReplace(html, " <\/o:p>", "");
+ html = tinyMCE.regexpReplace(html, "", "");
+ html = tinyMCE.regexpReplace(html, "<\/p>", "");
+ html = tinyMCE.regexpReplace(html, "
<\/p>\r\n
<\/p>", "");
+ html = tinyMCE.regexpReplace(html, "
<\/p>", "
");
+ html = tinyMCE.regexpReplace(html, "
\s*(
\s*)?", "
");
+ html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "
");
+ }
+
+ // Always set the htmlText output
+ tinyMCE.setInnerHTML(doc.body, html);
+ }
+
+ tinyMCE.cleanupAnchors(doc);
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(doc);
+};
+
+TinyMCE.prototype.getImageSrc = function(str) {
+ var pos = -1;
+
+ if (!str)
+ return "";
+
+ if ((pos = str.indexOf('this.src=')) != -1) {
+ var src = str.substring(pos + 10);
+
+ src = src.substring(0, src.indexOf('\''));
+
+ return src;
+ }
+
+ return "";
+};
+
+TinyMCE.prototype._getElementById = function(element_id) {
+ var elm = document.getElementById(element_id);
+ if (!elm) {
+ // Check for element in forms
+ for (var j=0; j 0) {
+ for (var x=0; x 0)
+ tinyMCE.cssClasses = output;
+
+ return output;
+};
+
+TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) {
+ if (in_str == null)
+ return in_str;
+
+ if (typeof(opts) == "undefined")
+ opts = 'g';
+
+ var re = new RegExp(reg_exp, opts);
+ return in_str.replace(re, replace_str);
+};
+
+TinyMCE.prototype.trim = function(str) {
+ return str.replace(/^\s*|\s*$/g, "");
+};
+
+TinyMCE.prototype.cleanupEventStr = function(str) {
+ str = "" + str;
+ str = str.replace('function anonymous()\n{\n', '');
+ str = str.replace('\n}', '');
+ str = str.replace(/^return true;/gi, ''); // Remove event blocker
+
+ return str;
+};
+
+TinyMCE.prototype.getAbsPosition = function(node) {
+ var pos = new Object();
+
+ pos.absLeft = pos.absTop = 0;
+
+ var parentNode = node;
+ while (parentNode) {
+ pos.absLeft += parentNode.offsetLeft;
+ pos.absTop += parentNode.offsetTop;
+
+ parentNode = parentNode.offsetParent;
+ }
+
+ return pos;
+};
+
+TinyMCE.prototype.getControlHTML = function(control_name) {
+ var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
+ var templateFunction;
+
+ // Is it defined in any plugins
+ for (var i=themePlugins.length; i>=0; i--) {
+ templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML";
+ if (eval("typeof(" + templateFunction + ")") != 'undefined') {
+ var html = eval(templateFunction + "('" + control_name + "');");
+ if (html != "")
+ return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]);
+ }
+ }
+
+ return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');");
+};
+
+TinyMCE.prototype._themeExecCommand = function(editor_id, element, command, user_interface, value) {
+ var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
+ var templateFunction;
+
+ // Is it defined in any plugins
+ for (var i=themePlugins.length; i>=0; i--) {
+ templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand";
+ if (eval("typeof(" + templateFunction + ")") != 'undefined') {
+ if (eval(templateFunction + "(editor_id, element, command, user_interface, value);"))
+ return true;
+ }
+ }
+
+ // Theme funtion
+ templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand";
+ if (eval("typeof(" + templateFunction + ")") != 'undefined')
+ return eval(templateFunction + "(editor_id, element, command, user_interface, value);");
+
+ // Pass to normal
+ return false;
+};
+
+TinyMCE.prototype._getThemeFunction = function(suffix, skip_plugins) {
+ if (skip_plugins)
+ return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
+
+ var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
+ var templateFunction;
+
+ // Is it defined in any plugins
+ for (var i=themePlugins.length; i>=0; i--) {
+ templateFunction = 'TinyMCE_' + themePlugins[i] + suffix;
+ if (eval("typeof(" + templateFunction + ")") != 'undefined')
+ return templateFunction;
+ }
+
+ return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
+};
+
+
+TinyMCE.prototype.isFunc = function(func_name) {
+ if (func_name == null || func_name == "")
+ return false;
+
+ return eval("typeof(" + func_name + ")") != "undefined";
+};
+
+TinyMCE.prototype.exec = function(func_name, args) {
+ var str = func_name + '(';
+
+ // Add all arguments
+ for (var i=3; i1&&tinyMCE.currentConfig!=this.settings['index']){tinyMCE.settings=this.settings;tinyMCE.currentConfig=this.settings['index'];}};TinyMCEControl.prototype.fixBrokenURLs=function(){var body=this.getBody();var elms=body.getElementsByTagName("img");for(var i=0;i0)rng.selectNodeContents(nodes[0]);else rng.selectNodeContents(node);}else rng.selectNode(node);if(collapse){if(!to_start&&node.nodeType==3){rng.setStart(node,node.nodeValue.length);rng.setEnd(node,node.nodeValue.length);}else rng.collapse(to_start);}sel.removeAllRanges();sel.addRange(rng);}this.scrollToNode(node);tinyMCE.selectedElement=null;if(node.nodeType==1)tinyMCE.selectedElement=node;};TinyMCEControl.prototype.scrollToNode=function(node){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.settings['auto_resize']&&!(pos.absTop>scrollY&&pos.absTop<(scrollY-25+height)))this.contentWindow.scrollTo(pos.absLeft,pos.absTop-height+25);};TinyMCEControl.prototype.getBody=function(){return this.getDoc().body;};TinyMCEControl.prototype.getDoc=function(){return this.contentWindow.document;};TinyMCEControl.prototype.getWin=function(){return this.contentWindow;};TinyMCEControl.prototype.getSel=function(){if(tinyMCE.isMSIE&&!tinyMCE.isOpera)return this.getDoc().selection;var sel=this.contentWindow.getSelection();if(tinyMCE.isSafari&&!sel.getRangeAt){var newSel=new Object();var doc=this.getDoc();function getRangeAt(idx){var rng=new Object();rng.startContainer=this.focusNode;rng.endContainer=this.anchorNode;rng.commonAncestorContainer=this.focusNode;rng.createContextualFragment=function(html){if(html.charAt(0)=='<'){var elm=doc.createElement("div");elm.innerHTML=html;return elm.firstChild;}return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!");};rng.deleteContents=function(){doc.execCommand("Delete",false,"");};return rng;}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()=="";}if(para.getElementsByTagName("img").length>0)return false;if(para.getElementsByTagName("table").length>0)return false;if(para.getElementsByTagName("hr").length>0)return false;var nodes=tinyMCE.getNodeTree(para,new Array(),3);for(var i=0;i "+blockName+"><"+blockName+"> "+blockName+">";paraAfter=body.childNodes[1];}this.selectNode(paraAfter,true,true);return true;}if(startChop.nodeName==blockName)rngBefore.setStart(startChop,0);else rngBefore.setStartBefore(startChop);rngBefore.setEnd(startNode,startOffset);paraBefore.appendChild(rngBefore.cloneContents());rngAfter.setEndAfter(endChop);rngAfter.setStart(endNode,endOffset);var contents=rngAfter.cloneContents();if(contents.firstChild&&contents.firstChild.nodeName==blockName){paraAfter.innerHTML=contents.firstChild.innerHTML;}else paraAfter.appendChild(contents);if(isEmpty(paraBefore))paraBefore.innerHTML=" ";if(isEmpty(paraAfter))paraAfter.innerHTML=" ";var rng=doc.createRange();if(!startChop.previousSibling&&startChop.parentNode.nodeName.toUpperCase()==blockName){rng.setStartBefore(startChop.parentNode);}else{if(rngBefore.startContainer.nodeName.toUpperCase()==blockName&&rngBefore.startOffset==0)rng.setStartBefore(rngBefore.startContainer);else rng.setStart(rngBefore.startContainer,rngBefore.startOffset);}if(!endChop.nextSibling&&endChop.parentNode.nodeName.toUpperCase()==blockName)rng.setEndAfter(endChop.parentNode);else rng.setEnd(rngAfter.endContainer,rngAfter.endOffset);rng.deleteContents();rng.insertNode(paraAfter);rng.insertNode(paraBefore);paraAfter.normalize();paraBefore.normalize();this.selectNode(paraAfter,true,true);return true;};TinyMCEControl.prototype._handleBackSpace=function(evt_type){var doc=this.getDoc();var sel=this.getSel();if(sel==null)return false;var rng=sel.getRangeAt(0);var node=rng.startContainer;var elm=node.nodeType==3?node.parentNode:node;if(node==null)return;if(elm&&elm.nodeName==""){var para=doc.createElement("p");while(elm.firstChild)para.appendChild(elm.firstChild);elm.parentNode.insertBefore(para,elm);elm.parentNode.removeChild(elm);var rng=rng.cloneRange();rng.setStartBefore(node.nextSibling);rng.setEndAfter(node.nextSibling);rng.extractContents();this.selectNode(node.nextSibling,true,true);}var para=tinyMCE.getParentBlockElement(node);if(para!=null&¶.nodeName.toLowerCase()=='p'&&evt_type=="keypress"){var htm=para.innerHTML;var block=tinyMCE.getParentBlockElement(node);if(htm==""||htm==" "||block.nodeName.toLowerCase()=="li"){var prevElm=para.previousSibling;while(prevElm!=null&&prevElm.nodeType!=1)prevElm=prevElm.previousSibling;if(prevElm==null)return false;var nodes=tinyMCE.getNodeTree(prevElm,new Array(),3);var lastTextNode=nodes.length==0?null:nodes[nodes.length-1];if(lastTextNode!=null)this.selectNode(lastTextNode,true,false,false);para.parentNode.removeChild(para);return true;}}return false;};TinyMCEControl.prototype._insertSpace=function(){return true;};TinyMCEControl.prototype.autoResetDesignMode=function(){if(!tinyMCE.isMSIE&&tinyMCE.settings['auto_reset_designmode']){var sel=this.getSel();if(!sel||!sel.rangeCount||sel.rangeCount==0)eval('try { this.getDoc().designMode = "On"; } catch(e) {}');}};TinyMCEControl.prototype.isDirty=function(){return this.startContent!=tinyMCE.trim(this.getBody().innerHTML)&&!tinyMCE.isNotDirty;};TinyMCEControl.prototype._mergeElements=function(scmd,pa,ch,override){if(scmd=="removeformat"){pa.className="";pa.style.cssText="";ch.className="";ch.style.cssText="";return;}var st=tinyMCE.parseStyle(tinyMCE.getAttrib(pa,"style"));var stc=tinyMCE.parseStyle(tinyMCE.getAttrib(ch,"style"));var className=tinyMCE.getAttrib(pa,"class");className+=" "+tinyMCE.getAttrib(ch,"class");if(override){for(var n in st){if(typeof(st[n])=='function')continue;stc[n]=st[n];}}else{for(var n in stc){if(typeof(stc[n])=='function')continue;st[n]=stc[n];}}tinyMCE.setAttrib(pa,"style",tinyMCE.serializeStyle(st));tinyMCE.setAttrib(pa,"class",tinyMCE.trim(className));ch.className="";ch.style.cssText="";ch.removeAttribute("class");ch.removeAttribute("style");};TinyMCEControl.prototype.setUseCSS=function(b){var doc=this.getDoc();try{doc.execCommand("useCSS",false,!b);}catch(ex){}try{doc.execCommand("styleWithCSS",false,b);}catch(ex){}};TinyMCEControl.prototype.execCommand=function(command,user_interface,value){var doc=this.getDoc();var win=this.getWin();var focusElm=this.getFocusElement();if(this.lastSafariSelection&&!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel','gi').test(command)){this.moveToBookmark(this.lastSafariSelection);tinyMCE.selectedElement=this.lastSafariSelectedElement;}if(!tinyMCE.isMSIE&&!this.useCSS){this.setUseCSS(false);this.useCSS=true;}this.contentDocument=doc;if(tinyMCE._themeExecCommand(this.editorId,this.getBody(),command,user_interface,value))return;if(focusElm&&focusElm.nodeName=="IMG"){var align=focusElm.getAttribute('align');var img=command=="JustifyCenter"?focusElm.cloneNode(false):focusElm;switch(command){case "JustifyLeft":if(align=='left')img.removeAttribute('align');else img.setAttribute('align','left');var div=focusElm.parentNode;if(div&&div.nodeName=="DIV"&&div.childNodes.length==1&&div.parentNode)div.parentNode.replaceChild(img,div);this.selectNode(img);this.repaint();tinyMCE.triggerNodeChange();return;case "JustifyCenter":img.removeAttribute('align');var div=tinyMCE.getParentElement(focusElm,"div");if(div&&div.style.textAlign=="center"){if(div.nodeName=="DIV"&&div.childNodes.length==1&&div.parentNode)div.parentNode.replaceChild(img,div);}else{var div=this.getDoc().createElement("div");div.style.textAlign='center';div.appendChild(img);focusElm.parentNode.replaceChild(div,focusElm);}this.selectNode(img);this.repaint();tinyMCE.triggerNodeChange();return;case "JustifyRight":if(align=='right')img.removeAttribute('align');else img.setAttribute('align','right');var div=focusElm.parentNode;if(div&&div.nodeName=="DIV"&&div.childNodes.length==1&&div.parentNode)div.parentNode.replaceChild(img,div);this.selectNode(img);this.repaint();tinyMCE.triggerNodeChange();return;}}if(tinyMCE.settings['force_br_newlines']){var alignValue="";if(doc.selection.type!="Control"){switch(command){case "JustifyLeft":alignValue="left";break;case "JustifyCenter":alignValue="center";break;case "JustifyFull":alignValue="justify";break;case "JustifyRight":alignValue="right";break;}if(alignValue!=""){var rng=doc.selection.createRange();if((divElm=tinyMCE.getParentElement(rng.parentElement(),"div"))!=null)divElm.setAttribute("align",alignValue);else if(rng.pasteHTML&&rng.htmlText.length>0)rng.pasteHTML(''+rng.htmlText+"
");tinyMCE.triggerNodeChange();return;}}}switch(command){case "mceRepaint":this.repaint();return true;case "mceStoreSelection":this.selectionBookmark=this.getBookmark();return true;case "mceRestoreSelection":this.moveToBookmark(this.selectionBookmark);return true;case "InsertUnorderedList":case "InsertOrderedList":var tag=(command=="InsertUnorderedList")?"ul":"ol";if(tinyMCE.isSafari)this.execCommand("mceInsertContent",false,"<"+tag+"> <"+tag+">");else this.getDoc().execCommand(command,user_interface,value);tinyMCE.triggerNodeChange();break;case "Strikethrough":if(tinyMCE.isSafari)this.execCommand("mceInsertContent",false,""+this.getSelectedHTML()+"");else this.getDoc().execCommand(command,user_interface,value);tinyMCE.triggerNodeChange();break;case "mceSelectNode":this.selectNode(value);tinyMCE.triggerNodeChange();tinyMCE.selectedNode=value;break;case "FormatBlock":if(value==null||value==""){var elm=tinyMCE.getParentElement(this.getFocusElement(),"p,div,h1,h2,h3,h4,h5,h6,pre,address");if(elm)this.execCommand("mceRemoveNode",false,elm);}else this.getDoc().execCommand("FormatBlock",false,value);tinyMCE.triggerNodeChange();break;case "mceRemoveNode":if(!value)value=tinyMCE.getParentElement(this.getFocusElement());if(tinyMCE.isMSIE){value.outerHTML=value.innerHTML;}else{var rng=value.ownerDocument.createRange();rng.setStartBefore(value);rng.setEndAfter(value);rng.deleteContents();rng.insertNode(rng.createContextualFragment(value.innerHTML));}tinyMCE.triggerNodeChange();break;case "mceSelectNodeDepth":var parentNode=this.getFocusElement();for(var i=0;parentNode;i++){if(parentNode.nodeName.toLowerCase()=="body")break;if(parentNode.nodeName.toLowerCase()=="#text"){i--;parentNode=parentNode.parentNode;continue;}if(i==value){this.selectNode(parentNode,false);tinyMCE.triggerNodeChange();tinyMCE.selectedNode=parentNode;return;}parentNode=parentNode.parentNode;}break;case "SetStyleInfo":var rng=this.getRng();var sel=this.getSel();var scmd=value['command'];var sname=value['name'];var svalue=value['value']==null?'':value['value'];var 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;if(tinyMCE.isMSIE){if(rng.item)parentElm=rng.item(0);else{var pelm=rng.parentElement();var prng=doc.selection.createRange();prng.moveToElementText(pelm);if(rng.htmlText==prng.htmlText||rng.boundingWidth==0){if(invalidParentsRe==null||!invalidParentsRe.test(pelm.nodeName))parentElm=pelm;}}}else{var felm=this.getFocusElement();if(sel.isCollapsed||(/td|tr|tbody|table/ig.test(felm.nodeName)&&sel.anchorNode==felm.parentNode))parentElm=felm;}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','');}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");if(elm.childNodes&&elm.childNodes.length==1&&elm.childNodes[0].nodeType==1){this._mergeElements(scmd,elm,elm.childNodes[0],isNew);continue;}if(elm.parentNode.childNodes.length==1&&!invalidRe.test(elm.nodeName)&&!invalidRe.test(elm.parentNode.nodeName)){if(invalidParentsRe==null||!invalidParentsRe.test(elm.parentNode.nodeName))this._mergeElements(scmd,elm.parentNode,elm,false);}}var nodes=doc.getElementsByTagName(wrapper);for(var i=nodes.length-1;i>=0;i--){var elm=nodes[i];var isEmpty=true;var tmp=doc.createElement("body");tmp.appendChild(elm.cloneNode(false));tmp.innerHTML=tmp.innerHTML.replace(new RegExp('style=""|class=""','gi'),'');if(new RegExp('','gi').test(tmp.innerHTML)){for(var x=0;x0){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');this.execCommand('mceInsertContent',false,key);var scrollX=this.getDoc().body.scrollLeft+this.getDoc().documentElement.scrollLeft;var scrollY=this.getDoc().body.scrollTop+this.getDoc().documentElement.scrollTop;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));this.contentWindow.scrollTo(scrollX,scrollY);this.execCommand('mceEndUndoLevel');break;case "mceInsertContent":var insertHTMLFailed=false;this.getWin().focus();if(tinyMCE.isGecko||tinyMCE.isOpera){try{this.getDoc().execCommand('inserthtml',false,value);}catch(ex){insertHTMLFailed=true;}if(!insertHTMLFailed){tinyMCE.triggerNodeChange();return;}}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{var el=document.createElement("div");el.innerHTML=value;value=el.firstChild.nodeValue;value=doc.createTextNode(value);}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(rng.startContainer.nodeType==3){var node=rng.startContainer.splitText(rng.startOffset);node.parentNode.insertBefore(value,node);}else rng.insertNode(value);if(!isHTML){sel.selectAllChildren(doc.body);sel.removeAllRanges();var rng=doc.createRange();rng.selectNode(value);rng.collapse(false);sel.addRange(rng);}else rng.collapse(false);}else{var rng=doc.selection.createRange();if(rng.item)rng.item(0).outerHTML=value;else rng.pasteHTML(value);}tinyMCE.triggerNodeChange();break;case "mceStartTyping":if(tinyMCE.settings['custom_undo_redo']&&this.typingUndoIndex==-1){this.typingUndoIndex=this.undoIndex;this.execCommand('mceAddUndoLevel');}break;case "mceEndTyping":if(tinyMCE.settings['custom_undo_redo']&&this.typingUndoIndex!=-1){this.execCommand('mceAddUndoLevel');this.typingUndoIndex=-1;}break;case "mceBeginUndoLevel":this.undoRedo=false;break;case "mceEndUndoLevel":this.undoRedo=true;this.execCommand('mceAddUndoLevel');break;case "mceAddUndoLevel":if(tinyMCE.settings['custom_undo_redo']&&this.undoRedo){if(this.typingUndoIndex!=-1){this.undoIndex=this.typingUndoIndex;}var newHTML=tinyMCE.trim(this.getBody().innerHTML);if(newHTML!=this.undoLevels[this.undoIndex]){tinyMCE.executeCallback('onchange_callback','_onchange',0,this);var customUndoLevels=tinyMCE.settings['custom_undo_redo_levels'];if(customUndoLevels!=-1&&this.undoLevels.length>customUndoLevels){for(var i=0;i0){this.undoIndex--;tinyMCE.setInnerHTML(this.getBody(),this.undoLevels[this.undoIndex]);this.repaint();}tinyMCE.triggerNodeChange();}else this.getDoc().execCommand(command,user_interface,value);break;case "Redo":if(tinyMCE.settings['custom_undo_redo']){tinyMCE.execCommand("mceEndTyping");if(this.undoIndex<(this.undoLevels.length-1)){this.undoIndex++;tinyMCE.setInnerHTML(this.getBody(),this.undoLevels[this.undoIndex]);this.repaint();}tinyMCE.triggerNodeChange();}else this.getDoc().execCommand(command,user_interface,value);break;case "mceToggleVisualAid":this.visualAid=!this.visualAid;tinyMCE.handleVisualAid(this.getBody(),true,this.visualAid,this);tinyMCE.triggerNodeChange();break;case "Indent":this.getDoc().execCommand(command,user_interface,value);tinyMCE.triggerNodeChange();if(tinyMCE.isMSIE){var n=tinyMCE.getParentElement(this.getFocusElement(),"blockquote");do{if(n&&n.nodeName=="BLOCKQUOTE"){n.removeAttribute("dir");n.removeAttribute("style");}}while(n!=null&&(n=n.parentNode)!=null);}break;case "removeformat":var text=this.getSelectedText();if(tinyMCE.isOpera){this.getDoc().execCommand("RemoveFormat",false,null);return;}if(tinyMCE.isMSIE){try{var rng=doc.selection.createRange();rng.execCommand("RemoveFormat",false,null);}catch(e){}this.execCommand("SetStyleInfo",false,{command:"removeformat"});}else{this.getDoc().execCommand(command,user_interface,value);this.execCommand("SetStyleInfo",false,{command:"removeformat"});}if(text.length==0)this.execCommand("mceSetCSSClass",false,"");tinyMCE.triggerNodeChange();break;default:this.getDoc().execCommand(command,user_interface,value);if(tinyMCE.isGecko)window.setTimeout('tinyMCE.triggerNodeChange(false);',1);else tinyMCE.triggerNodeChange();}if(command!="mceAddUndoLevel"&&command!="Undo"&&command!="Redo"&&command!="mceStartTyping"&&command!="mceEndTyping")tinyMCE.execCommand("mceAddUndoLevel");};TinyMCEControl.prototype.queryCommandValue=function(command){return this.getDoc().queryCommandValue(command);};TinyMCEControl.prototype.queryCommandState=function(command){return this.getDoc().queryCommandState(command);};TinyMCEControl.prototype.onAdd=function(replace_element,form_element_name,target_document){var targetDoc=target_document?target_document:document;this.targetDoc=targetDoc;tinyMCE.themeURL=tinyMCE.baseURL+"/themes/"+this.settings['theme'];this.settings['themeurl']=tinyMCE.themeURL;if(!replace_element){alert("Error: Could not find the target element.");return false;}var templateFunction=tinyMCE._getThemeFunction('_getInsertLinkTemplate');if(eval("typeof("+templateFunction+")")!='undefined')this.insertLinkTemplate=eval(templateFunction+'(this.settings);');var templateFunction=tinyMCE._getThemeFunction('_getInsertImageTemplate');if(eval("typeof("+templateFunction+")")!='undefined')this.insertImageTemplate=eval(templateFunction+'(this.settings);');var templateFunction=tinyMCE._getThemeFunction('_getEditorTemplate');if(eval("typeof("+templateFunction+")")=='undefined'){alert("Error: Could not find the template function: "+templateFunction);return false;}var editorTemplate=eval(templateFunction+'(this.settings, this.editorId);');var deltaWidth=editorTemplate['delta_width']?editorTemplate['delta_width']:0;var deltaHeight=editorTemplate['delta_height']?editorTemplate['delta_height']:0;var html=''+editorTemplate['html'];var templateFunction=tinyMCE._getThemeFunction('_handleNodeChange',true);if(eval("typeof("+templateFunction+")")!='undefined')this.settings['handleNodeChangeCallback']=templateFunction;html=tinyMCE.replaceVar(html,"editor_id",this.editorId);this.settings['default_document']=tinyMCE.baseURL+"/blank.htm";this.settings['old_width']=this.settings['width'];this.settings['old_height']=this.settings['height'];if(this.settings['width']==-1)this.settings['width']=replace_element.offsetWidth;if(this.settings['height']==-1)this.settings['height']=replace_element.offsetHeight;if(this.settings['width']==0)this.settings['width']=replace_element.style.width;if(this.settings['height']==0)this.settings['height']=replace_element.style.height;if(this.settings['width']==0)this.settings['width']=320;if(this.settings['height']==0)this.settings['height']=240;this.settings['area_width']=parseInt(this.settings['width']);this.settings['area_height']=parseInt(this.settings['height']);this.settings['area_width']+=deltaWidth;this.settings['area_height']+=deltaHeight;if((""+this.settings['width']).indexOf('%')!=-1)this.settings['area_width']="100%";if((""+this.settings['height']).indexOf('%')!=-1)this.settings['area_height']="100%";if((""+replace_element.style.width).indexOf('%')!=-1){this.settings['width']=replace_element.style.width;this.settings['area_width']="100%";}if((""+replace_element.style.height).indexOf('%')!=-1){this.settings['height']=replace_element.style.height;this.settings['area_height']="100%";}html=tinyMCE.applyTemplate(html);this.settings['width']=this.settings['old_width'];this.settings['height']=this.settings['old_height'];this.visualAid=this.settings['visual'];this.formTargetElementId=form_element_name;if(replace_element.nodeName=="TEXTAREA"||replace_element.nodeName=="INPUT")this.startContent=replace_element.value;else this.startContent=replace_element.innerHTML;if(replace_element.nodeName.toLowerCase()!="textarea"){this.oldTargetElement=replace_element.cloneNode(true);if(tinyMCE.settings['debug'])html+='';else html+='';html+='';if(!tinyMCE.isMSIE){var rng=replace_element.ownerDocument.createRange();rng.setStartBefore(replace_element);var fragment=rng.createContextualFragment(html);replace_element.parentNode.replaceChild(fragment,replace_element);}else replace_element.outerHTML=html;}else{html+='';this.oldTargetElement=replace_element;if(!tinyMCE.settings['debug'])this.oldTargetElement.style.display="none";if(!tinyMCE.isMSIE){var rng=replace_element.ownerDocument.createRange();rng.setStartBefore(replace_element);var fragment=rng.createContextualFragment(html);replace_element.parentNode.insertBefore(fragment,replace_element);}else replace_element.insertAdjacentHTML("beforeBegin",html);}var dynamicIFrame=false;var tElm=targetDoc.getElementById(this.editorId);if(!tinyMCE.isMSIE){if(tElm&&tElm.nodeName.toLowerCase()=="span"){tElm=tinyMCE._createIFrame(tElm);dynamicIFrame=true;}this.targetElement=tElm;this.iframeElement=tElm;this.contentDocument=tElm.contentDocument;this.contentWindow=tElm.contentWindow;}else{if(tElm&&tElm.nodeName.toLowerCase()=="span")tElm=tinyMCE._createIFrame(tElm);else tElm=targetDoc.frames[this.editorId];this.targetElement=tElm;this.iframeElement=targetDoc.getElementById(this.editorId);if(tinyMCE.isOpera){this.contentDocument=this.iframeElement.contentDocument;this.contentWindow=this.iframeElement.contentWindow;dynamicIFrame=true;}else{this.contentDocument=tElm.window.document;this.contentWindow=tElm.window;}this.getDoc().designMode="on";}var doc=this.contentDocument;if(dynamicIFrame){var html=tinyMCE.getParam('doctype')+'blank_page';try{this.getDoc().designMode="on";doc.open();doc.write(html);doc.close();}catch(e){this.getDoc().location.href=tinyMCE.baseURL+"/blank.htm";}}if(tinyMCE.isMSIE)window.setTimeout("TinyMCE.prototype.addEventHandlers('"+this.editorId+"');",1);tinyMCE.setupContent(this.editorId,true);return true;};TinyMCEControl.prototype.getFocusElement=function(){if(tinyMCE.isMSIE&&!tinyMCE.isOpera){var doc=this.getDoc();var rng=doc.selection.createRange();var elm=rng.item?rng.item(0):rng.parentElement();}else{var sel=this.getSel();var rng=this.getRng();var elm=rng.commonAncestorContainer;if(!rng.collapsed){if(rng.startContainer==rng.endContainer){if(rng.startOffset-rng.endOffset<2){if(rng.startContainer.hasChildNodes())elm=rng.startContainer.childNodes[rng.startOffset];}}}elm=tinyMCE.getParentElement(elm);}return elm;};var tinyMCE=new TinyMCE();var tinyMCELang=new Array();
+ ';
+
+ document.body.appendChild(debugDiv);
+ elm = document.getElementById("tinymce_debug");
+ }
+
+ var args = this.debug.arguments;
+ for (var i=0; i 1 && tinyMCE.currentConfig != this.settings['index']) {
+ tinyMCE.settings = this.settings;
+ tinyMCE.currentConfig = this.settings['index'];
+ }
+};
+
+TinyMCEControl.prototype.convertAllRelativeURLs = function() {
+ var body = this.getBody();
+
+ // Convert all image URL:s to absolute URL
+ var elms = body.getElementsByTagName("img");
+ for (var i=0; i 0)
+ rng.selectNodeContents(nodes[0]);
+ else
+ rng.selectNodeContents(node);
+ } else
+ rng.selectNode(node);
+
+ if (collapse) {
+ // Special treatment of textnode collapse
+ if (!to_start && node.nodeType == 3) {
+ rng.setStart(node, node.nodeValue.length);
+ rng.setEnd(node, node.nodeValue.length);
+ } else
+ rng.collapse(to_start);
+ }
+
+ sel.removeAllRanges();
+ sel.addRange(rng);
+ }
+
+ this.scrollToNode(node);
+
+ // Set selected element
+ tinyMCE.selectedElement = null;
+ if (node.nodeType == 1)
+ tinyMCE.selectedElement = node;
+};
+
+TinyMCEControl.prototype.scrollToNode = function(node) {
+ // Scroll to node position
+ var pos = tinyMCE.getAbsPosition(node);
+ var doc = this.getDoc();
+ var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
+ var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
+ var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : this.targetElement.clientHeight;
+
+ // Only scroll if out of visible area
+ if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
+ this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
+};
+
+TinyMCEControl.prototype.getBody = function() {
+ return this.getDoc().body;
+};
+
+TinyMCEControl.prototype.getDoc = function() {
+ return this.contentWindow.document;
+};
+
+TinyMCEControl.prototype.getWin = function() {
+ return this.contentWindow;
+};
+
+TinyMCEControl.prototype.getSel = function() {
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return this.getDoc().selection;
+
+ var sel = this.contentWindow.getSelection();
+
+ // Fake getRangeAt
+ if (tinyMCE.isSafari && !sel.getRangeAt) {
+ var newSel = new Object();
+ var doc = this.getDoc();
+
+ function getRangeAt(idx) {
+ var rng = new Object();
+
+ rng.startContainer = this.focusNode;
+ rng.endContainer = this.anchorNode;
+ rng.commonAncestorContainer = this.focusNode;
+ rng.createContextualFragment = function (html) {
+ // Seems to be a tag
+ if (html.charAt(0) == '<') {
+ var elm = doc.createElement("div");
+
+ elm.innerHTML = html;
+
+ return elm.firstChild;
+ }
+
+ return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!");
+ };
+
+ rng.deleteContents = function () {
+ doc.execCommand("Delete", false, "");
+ };
+
+ return rng;
+ }
+
+ // Patch selection
+
+ newSel.focusNode = sel.baseNode;
+ newSel.focusOffset = sel.baseOffset;
+ newSel.anchorNode = sel.extentNode;
+ newSel.anchorOffset = sel.extentOffset;
+ newSel.getRangeAt = getRangeAt;
+ newSel.text = "" + sel;
+ newSel.realSelection = sel;
+
+ newSel.toString = function () {return this.text;};
+
+ return newSel;
+ }
+
+ return sel;
+};
+
+TinyMCEControl.prototype.getRng = function() {
+ var sel = this.getSel();
+ if (sel == null)
+ return null;
+
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return sel.createRange();
+
+ if (tinyMCE.isSafari) {
+ var rng = this.getDoc().createRange();
+ var sel = this.getSel().realSelection;
+
+ rng.setStart(sel.baseNode, sel.baseOffset);
+ rng.setEnd(sel.extentNode, sel.extentOffset);
+
+ return rng;
+ }
+
+ return this.getSel().getRangeAt(0);
+};
+
+TinyMCEControl.prototype._insertPara = function(e) {
+ function isEmpty(para) {
+ function isEmptyHTML(html) {
+ return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
+ }
+
+ // Check for images
+ if (para.getElementsByTagName("img").length > 0)
+ return false;
+
+ // Check for tables
+ if (para.getElementsByTagName("table").length > 0)
+ return false;
+
+ // Check for HRs
+ if (para.getElementsByTagName("hr").length > 0)
+ return false;
+
+ // Check all textnodes
+ var nodes = tinyMCE.getNodeTree(para, new Array(), 3);
+ for (var i=0; i " + blockName + "><" + blockName + "> " + blockName + ">";
+ paraAfter = body.childNodes[1];
+ }
+
+ this.selectNode(paraAfter, true, true);
+
+ return true;
+ }
+
+ // Place first part within new paragraph
+ if (startChop.nodeName == blockName)
+ rngBefore.setStart(startChop, 0);
+ else
+ rngBefore.setStartBefore(startChop);
+
+ rngBefore.setEnd(startNode, startOffset);
+ paraBefore.appendChild(rngBefore.cloneContents());
+
+ // Place secound part within new paragraph
+ rngAfter.setEndAfter(endChop);
+ rngAfter.setStart(endNode, endOffset);
+ var contents = rngAfter.cloneContents();
+
+ if (contents.firstChild && contents.firstChild.nodeName == blockName) {
+/* var nodes = contents.firstChild.childNodes;
+ for (var i=0; i 0)
+ rng.pasteHTML('' + rng.htmlText + "
");
+
+ tinyMCE.triggerNodeChange();
+ return;
+ }
+ }
+ }
+
+ switch (command) {
+ case "mceRepaint":
+ this.repaint();
+ return true;
+
+ case "mceStoreSelection":
+ this.selectionBookmark = this.getBookmark();
+ return true;
+
+ case "mceRestoreSelection":
+ this.moveToBookmark(this.selectionBookmark);
+ return true;
+
+ case "InsertUnorderedList":
+ case "InsertOrderedList":
+ var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
+
+ if (tinyMCE.isSafari)
+ this.execCommand("mceInsertContent", false, "<" + tag + "> <" + tag + ">");
+ else
+ this.getDoc().execCommand(command, user_interface, value);
+
+ tinyMCE.triggerNodeChange();
+ break;
+
+ case "Strikethrough":
+ if (tinyMCE.isSafari)
+ this.execCommand("mceInsertContent", false, "" + this.getSelectedHTML() + "");
+ else
+ this.getDoc().execCommand(command, user_interface, value);
+
+ tinyMCE.triggerNodeChange();
+ break;
+
+ case "mceSelectNode":
+ this.selectNode(value);
+ tinyMCE.triggerNodeChange();
+ tinyMCE.selectedNode = value;
+ break;
+
+ case "FormatBlock":
+ if (value == null || value == "") {
+ var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");
+
+ if (elm)
+ this.execCommand("mceRemoveNode", false, elm);
+ } else
+ this.getDoc().execCommand("FormatBlock", false, value);
+
+ tinyMCE.triggerNodeChange();
+
+ break;
+
+ case "mceRemoveNode":
+ if (!value)
+ value = tinyMCE.getParentElement(this.getFocusElement());
+
+ if (tinyMCE.isMSIE) {
+ value.outerHTML = value.innerHTML;
+ } else {
+ var rng = value.ownerDocument.createRange();
+ rng.setStartBefore(value);
+ rng.setEndAfter(value);
+ rng.deleteContents();
+ rng.insertNode(rng.createContextualFragment(value.innerHTML));
+ }
+
+ tinyMCE.triggerNodeChange();
+
+ break;
+
+ case "mceSelectNodeDepth":
+ var parentNode = this.getFocusElement();
+ for (var i=0; parentNode; i++) {
+ if (parentNode.nodeName.toLowerCase() == "body")
+ break;
+
+ if (parentNode.nodeName.toLowerCase() == "#text") {
+ i--;
+ parentNode = parentNode.parentNode;
+ continue;
+ }
+
+ if (i == value) {
+ this.selectNode(parentNode, false);
+ tinyMCE.triggerNodeChange();
+ tinyMCE.selectedNode = parentNode;
+ return;
+ }
+
+ parentNode = parentNode.parentNode;
+ }
+
+ break;
+
+ case "SetStyleInfo":
+ var rng = this.getRng();
+ var sel = this.getSel();
+ var scmd = value['command'];
+ var sname = value['name'];
+ var svalue = value['value'] == null ? '' : value['value'];
+ //var svalue = value['value'] == null ? '' : value['value'];
+ var wrapper = value['wrapper'] ? value['wrapper'] : "span";
+ var parentElm = null;
+ var invalidRe = new RegExp("^BODY|HTML$", "g");
+ var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;
+
+ // Whole element selected check
+ if (tinyMCE.isMSIE) {
+ // Control range
+ if (rng.item)
+ parentElm = rng.item(0);
+ else {
+ var pelm = rng.parentElement();
+ var prng = doc.selection.createRange();
+ prng.moveToElementText(pelm);
+
+ if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
+ if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
+ parentElm = pelm;
+ }
+ }
+ } else {
+ var felm = this.getFocusElement();
+ if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode))
+ parentElm = felm;
+ }
+
+ // Whole element selected
+ if (parentElm && !invalidRe.test(parentElm.nodeName)) {
+ if (scmd == "setstyle")
+ tinyMCE.setStyleAttrib(parentElm, sname, svalue);
+
+ if (scmd == "setattrib")
+ tinyMCE.setAttrib(parentElm, sname, svalue);
+
+ if (scmd == "removeformat") {
+ parentElm.style.cssText = '';
+ tinyMCE.setAttrib(parentElm, 'class', '');
+ }
+
+ // Remove style/attribs from all children
+ var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);
+ for (var z=0; z=0; i--) {
+ var elm = nodes[i];
+ var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
+
+ elm.removeAttribute("mce_new");
+
+ // Is only child a element
+ if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
+ //tinyMCE.debug("merge1" + isNew);
+ this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
+ continue;
+ }
+
+ // Is I the only child
+ if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
+ //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
+ if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
+ this._mergeElements(scmd, elm.parentNode, elm, false);
+ }
+ }
+
+ // Remove empty wrappers
+ var nodes = doc.getElementsByTagName(wrapper);
+ for (var i=nodes.length-1; i>=0; i--) {
+ var elm = nodes[i];
+ var isEmpty = true;
+
+ // Check if it has any attribs
+ var tmp = doc.createElement("body");
+ tmp.appendChild(elm.cloneNode(false));
+
+ // Is empty span, remove it
+ tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
+ //tinyMCE.debug(tmp.innerHTML);
+ if (new RegExp('', 'gi').test(tmp.innerHTML)) {
+ for (var x=0; x 0) {
+ value = tinyMCE.replaceVar(value, "selection", selectedText);
+ tinyMCE.execCommand('mceInsertContent', false, value);
+ }
+
+ tinyMCE.triggerNodeChange();
+ break;
+
+ case "mceSetAttribute":
+ if (typeof(value) == 'object') {
+ var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];
+ var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
+
+ if (targetNode) {
+ targetNode.setAttribute(value['name'], value['value']);
+ tinyMCE.triggerNodeChange();
+ }
+ }
+ break;
+
+ case "mceSetCSSClass":
+ this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value});
+ break;
+
+ case "mceInsertRawHTML":
+ var key = 'tiny_mce_marker';
+
+ this.execCommand('mceBeginUndoLevel');
+
+ // Insert marker key
+ this.execCommand('mceInsertContent', false, key);
+
+ // Store away scroll pos
+ var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
+ var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
+
+ // Find marker and replace with RAW HTML
+ var html = this.getBody().innerHTML;
+ if ((pos = html.indexOf(key)) != -1)
+ tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
+
+ // Restore scoll pos
+ this.contentWindow.scrollTo(scrollX, scrollY);
+
+ this.execCommand('mceEndUndoLevel');
+
+ break;
+
+ case "mceInsertContent":
+ var insertHTMLFailed = false;
+ this.getWin().focus();
+
+ 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('