Changeset 3136
- Timestamp:
- 11/17/2005 05:47:29 PM (20 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-header.php
r3135 r3136 101 101 relative_urls : false, 102 102 remove_script_host : false, 103 force_p_newlines : true, 104 force_br_newlines : false, 105 convert_newlines_to_brs : false, 106 remove_linebreaks : true, 107 save_callback : "wp_save_callback", 103 108 valid_elements : "-a[href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote,-table[border=0|cellspacing|cellpadding|width|height|class|align],tr[class|rowspan|width|height|align|valign],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],address,-h1[class|align],-h2[class|align],-h3[class|align],-h4[class|align],-h5[class|align],-h6[class|align],hr", 104 109 plugins : "wordpress,autosave" … … 336 341 require(ABSPATH . '/wp-admin/menu-header.php'); 337 342 338 if ( $parent_file == 'options- general.php' ) {343 if ( $parent_file == 'options-personal.php' ) { 339 344 require(ABSPATH . '/wp-admin/options-head.php'); 340 345 } -
trunk/wp-admin/edit-form-advanced.php
r3135 r3136 8 8 <?php endif; ?> 9 9 10 <?php $richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true; ?> 11 10 12 <form name="post" action="post.php" method="post" id="post"> 11 <?php if ( (isset($mode) && 'bookmarklet' == $mode) ||12 isset($_GET['popupurl']) ): ?>13 <input type="hidden" name="mode" value="bookmarklet" />14 <?php endif; ?>15 13 16 14 <div class="wrap"> … … 138 136 </fieldset> 139 137 140 <fieldset id="<?php echo ( 'true' != get_user_option('rich_editing') ) ? 'postdiv' : 'postdivrich'; ?>">138 <fieldset id="<?php echo $richedit ? 'postdivrich' : 'postdiv'; ?>"> 141 139 <legend><?php _e('Post') ?></legend> 142 140 … … 147 145 } 148 146 ?> 149 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo $post->post_content ?></textarea></div> 150 </fieldset> 151 152 <?php if ( 'true' != get_user_option('rich_editing') ) : ?> 153 <?php the_quicktags(); ?> 147 <?php if ( !$richedit ) the_quicktags(); ?> 148 149 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo $richedit ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div> 150 </fieldset> 151 152 <?php if ( !$richedit ) : ?> 154 153 <script type="text/javascript"> 155 154 <!-- … … 202 201 <p class="submit"><?php echo $saveasdraft; ?> <input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" /> 203 202 <?php 204 if ('publish' != $post ->post_status || 0 == $post_ID) {203 if ('publish' != $post_status || 0 == $post_ID) { 205 204 ?> 206 205 <?php if ( current_user_can('publish_posts') ) : ?> … … 211 210 ?> 212 211 <input name="referredby" type="hidden" id="referredby" value="<?php 213 if ( !empty($_REQUEST['popupurl']) ) 214 echo wp_specialchars($_REQUEST['popupurl']); 215 else if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID ) 212 if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID ) 216 213 echo 'redo'; 217 214 else … … 224 221 $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID); 225 222 $uploading_iframe_src = "inline-uploading.php?action=view&post=$uploading_iframe_ID"; 226 if ( !$attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$uploading_iframe_ID'") )227 $uploading_iframe_src = "inline-uploading.php?action=upload&post=$uploading_iframe_ID";228 223 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 229 224 if ( false != $uploading_iframe_src ) -
trunk/wp-admin/edit-form-comment.php
r2789 r3136 5 5 $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment->comment_ID . "' />\n<input type='hidden' name='comment_post_ID' value='".$comment->comment_post_ID; 6 6 ?> 7 <?php $richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true; ?> 7 8 8 9 <form name="post" action="post.php" method="post" id="post"> … … 38 39 <fieldset style="clear: both;"> 39 40 <legend><?php _e('Comment') ?></legend> 40 <?php if ( 'true' != get_user_option('rich_editing') ) : ?> 41 <?php the_quicktags(); ?> 42 <script type="text/javascript"> 43 <!-- 44 edCanvas = document.getElementById('content'); 45 //--> 46 </script> 47 <?php endif; ?> 41 <?php if ( !$richedit ) the_quicktags(); ?> 42 48 43 <?php 49 44 $rows = get_settings('default_post_edit_rows'); … … 55 50 </fieldset> 56 51 52 <?php if ( !$richedit ) : ?> 53 <script type="text/javascript"> 54 <!-- 55 edCanvas = document.getElementById('content'); 56 //--> 57 </script> 58 <?php endif; ?> 57 59 58 60 <p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" /> -
trunk/wp-admin/edit-page-form.php
r3126 r3136 20 20 21 21 ?> 22 23 <?php $richedit = ( 'true' != get_user_option('rich_editing') ) ? false : true; ?> 22 24 23 25 <form name="post" action="post.php" method="post" id="post"> … … 118 120 119 121 120 <fieldset id="<?php echo ( 'true' != get_user_option('rich_editing') ) ? 'postdiv' : 'postdivrich'; ?>">122 <fieldset id="<?php echo ( $richedit) ? 'postdivrich' : 'postdiv'; ?>"> 121 123 <legend><?php _e('Page Content') ?></legend> 122 124 <?php … … 126 128 } 127 129 ?> 128 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $post->post_content ?></textarea></div> 130 <?php if (! $richedit ) the_quicktags(); ?> 131 132 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo $richedit ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div> 129 133 </fieldset> 130 134 131 <?php if ( 'true' != get_user_option('rich_editing') ) : ?> 132 <?php the_quicktags(); ?> 135 <?php if ( !$richedit ) : ?> 133 136 <script type="text/javascript"> 134 137 <!-- … … 141 144 <?php if ( $post_ID ) : ?> 142 145 <input name="save" type="submit" id="save" tabindex="5" value=" <?php _e('Save and Continue Editing'); ?> "/> 143 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e(' Save') : _e('Create New Page') ?> »" style="font-weight: bold;"/>146 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Edit Page') : _e('Create New Page') ?> »" /> 144 147 <?php else : ?> 145 148 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?> »" /> … … 151 154 $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID); 152 155 $uploading_iframe_src = "inline-uploading.php?action=view&post=$uploading_iframe_ID"; 153 if ( !$attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$uploading_iframe_ID'") )154 $uploading_iframe_src = "inline-uploading.php?action=upload&post=$uploading_iframe_ID";155 156 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 156 157 if ( false != $uploading_iframe_src ) -
trunk/wp-includes/functions-formatting.php
r3114 r3136 63 63 $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines 64 64 $pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates 65 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', " \t<p>$1</p>\n", $pee); // make paragraphs, including one at the end65 $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end 66 66 $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace 67 67 $pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag … … 994 994 } 995 995 996 function wp_richedit_pre($text) { 997 // Filtering a blank results in an annoying <br />\n 998 if ( empty($text) ) return ''; 999 1000 $output = $text; 1001 $output = html_entity_decode($output); // undoes format_to_edit() 1002 $output = wptexturize($output); 1003 $output = convert_chars($output); 1004 $output = wpautop($output); 1005 1006 // These must be double-escaped or planets will collide. 1007 $output = str_replace('<', '&lt;', $output); 1008 $output = str_replace('>', '&gt;', $output); 1009 1010 return $output; 1011 } 1012 996 1013 ?> -
trunk/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css
r2916 r3136 1 /* Window classes */2 3 .mceWindow {4 position: absolute;5 left: 0px;6 top: 0px;7 border: 1px solid black;8 background-color: #D4D0C8;9 }10 11 .mceWindowHead {12 background-color: #334F8D;13 width: 100%;14 height: 18px;15 cursor: move;16 overflow: hidden;17 }18 19 .mceWindowBody {20 clear: both;21 background-color: white;22 }23 24 .mceWindowStatusbar {25 background-color: #D4D0C8;26 height: 12px;27 border-top: 1px solid black;28 }29 30 .mceWindowTitle {31 float: left;32 font-family: "MS Sans Serif";33 font-size: 9pt;34 font-weight: bold;35 line-height: 18px;36 color: white;37 margin-left: 2px;38 overflow: hidden;39 }40 41 .mceWindowHeadTools {42 margin-right: 2px;43 }44 45 .mceWindowClose, .mceWindowMinimize, .mceWindowMaximize {46 display: block;47 float: right;48 overflow: hidden;49 margin-top: 2px;50 }51 52 .mceWindowClose {53 margin-left: 2px;54 }55 56 .mceWindowMinimize {57 }58 59 .mceWindowMaximize {60 }61 62 .mceWindowResize {63 display: block;64 float: right;65 overflow: hidden;66 cursor: se-resize;67 width: 12px;68 height: 12px;69 } -
trunk/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
r2993 r3136 1 /**2 * $RCSfile: editor_plugin.js,v $3 * $Revision: 1.42 $4 * $Date: 2005/10/30 16:06:56 $5 *6 * Moxiecode DHTML Windows script.7 *8 * @author Moxiecode9 * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.10 */11 function TinyMCE_inlinepopups_getInfo(){return{longname:'Inline Popups',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};};TinyMCE.prototype.orgOpenWindow=TinyMCE.prototype.openWindow;TinyMCE.prototype.openWindow=function(template,args){if(args['inline']!="yes"){mcWindows.selectedWindow=null;args['mce_inside_iframe']=false;this.orgOpenWindow(template,args);return;}var url,resizable,scrollbars;args['mce_inside_iframe']=true;tinyMCE.windowArgs=args;if(template['file'].charAt(0)!='/'&&template['file'].indexOf('://')==-1)url=tinyMCE.baseURL+"/themes/"+tinyMCE.getParam("theme")+"/"+template['file'];else url=template['file'];if(!(width=parseInt(template['width'])))width=320;if(!(height=parseInt(template['height'])))height=200;resizable=(args&&args['resizable'])?args['resizable']:"no";scrollbars=(args&&args['scrollbars'])?args['scrollbars']:"no";height+=18;for(var name in args){if(typeof(args[name])=='function')continue;url=tinyMCE.replaceVar(url,name,escape(args[name]));}var elm=document.getElementById(this.selectedInstance.editorId+'_parent');var pos=tinyMCE.getAbsPosition(elm);pos.absLeft+=Math.round((elm.firstChild.clientWidth/2)-(width/2));pos.absTop+=Math.round((elm.firstChild.clientHeight/2)-(height/2));mcWindows.open(url,mcWindows.idCounter++,"modal=yes,width="+width+",height="+height+",resizable="+resizable+",scrollbars="+scrollbars+",statusbar="+resizable+",left="+pos.absLeft+",top="+pos.absTop);};TinyMCE.prototype.orgCloseWindow=TinyMCE.prototype.closeWindow;TinyMCE.prototype.closeWindow=function(win){if(mcWindows.selectedWindow!=null)mcWindows.selectedWindow.close();else this.orgCloseWindow(win);};TinyMCE.prototype.setWindowTitle=function(win_ref,title){for(var n in mcWindows.windows){var win=mcWindows.windows[n];if(typeof(win)=='function')continue;if(win_ref.name==win.id+"_iframe")window.frames[win.id+"_iframe"].document.getElementById(win.id+'_title').innerHTML=title;}};function MCWindows(){this.settings=new Array();this.windows=new Array();this.isMSIE=(navigator.appName=="Microsoft Internet Explorer");this.isGecko=navigator.userAgent.indexOf('Gecko')!=-1;this.isSafari=navigator.userAgent.indexOf('Safari')!=-1;this.isMac=navigator.userAgent.indexOf('Mac')!=-1;this.isMSIE5_0=this.isMSIE&&(navigator.userAgent.indexOf('MSIE 5.0')!=-1);this.action="none";this.selectedWindow=null;this.lastSelectedWindow=null;this.zindex=100;this.mouseDownScreenX=0;this.mouseDownScreenY=0;this.mouseDownLayerX=0;this.mouseDownLayerY=0;this.mouseDownWidth=0;this.mouseDownHeight=0;this.idCounter=0;};MCWindows.prototype.init=function(settings){this.settings=settings;if(this.isMSIE)this.addEvent(document,"mousemove",mcWindows.eventDispatcher);else this.addEvent(window,"mousemove",mcWindows.eventDispatcher);this.addEvent(document,"mouseup",mcWindows.eventDispatcher);this.doc=document;};MCWindows.prototype.getParam=function(name,default_value){var value=null;value=(typeof(this.settings[name])=="undefined")?default_value:this.settings[name];if(value=="true"||value=="false")return(value=="true");return value;};MCWindows.prototype.eventDispatcher=function(e){e=typeof(e)=="undefined"?window.event:e;if(mcWindows.selectedWindow==null)return;if(mcWindows.isGecko&&e.type=="mousedown"){var elm=e.currentTarget;for(var n in mcWindows.windows){var win=mcWindows.windows[n];if(win.headElement==elm||win.resizeElement==elm){win.focus();break;}}}switch(e.type){case "mousemove":mcWindows.selectedWindow.onMouseMove(e);break;case "mouseup":mcWindows.selectedWindow.onMouseUp(e);break;case "mousedown":mcWindows.selectedWindow.onMouseDown(e);break;case "focus":mcWindows.selectedWindow.onFocus(e);break;}};MCWindows.prototype.addEvent=function(obj,name,handler){if(this.isMSIE)obj.attachEvent("on"+name,handler);else obj.addEventListener(name,handler,true);};MCWindows.prototype.cancelEvent=function(e){if(this.isMSIE){e.returnValue=false;e.cancelBubble=true;}else e.preventDefault();};MCWindows.prototype.parseFeatures=function(opts){opts=opts.toLowerCase();opts=opts.replace(/;/g,",");opts=opts.replace(/[^0-9a-z=,]/g,"");var optionChunks=opts.split(',');var options=new Array();options['left']="10";options['top']="10";options['width']="300";options['height']="300";options['resizable']="yes";options['minimizable']="yes";options['maximizable']="yes";options['close']="yes";options['movable']="yes";options['statusbar']="yes";options['scrollbars']="auto";options['modal']="no";if(opts=="")return options;for(var i=0;i<optionChunks.length;i++){var parts=optionChunks[i].split('=');if(parts.length==2)options[parts[0]]=parts[1];}options['left']=parseInt(options['left']);options['top']=parseInt(options['top']);options['width']=parseInt(options['width']);options['height']=parseInt(options['height']);return options;};MCWindows.prototype.open=function(url,name,features){this.lastSelectedWindow=this.selectedWindow;var win=new MCWindow();var winDiv,html="",id;var imgPath=this.getParam("images_path");features=this.parseFeatures(features);id="mcWindow_"+name;win.deltaHeight=18;if(features['statusbar']=="yes"){win.deltaHeight+=13;if(this.isMSIE)win.deltaHeight+=1;}width=parseInt(features['width']);height=parseInt(features['height'])-win.deltaHeight;if(this.isMSIE)width-=2;win.id=id;win.url=url;win.name=name;win.features=features;this.windows[name]=win;iframeWidth=width;iframeHeight=height;html+='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';html+='<html>';html+='<head>';html+='<title>Wrapper iframe</title>';html+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';html+='<link href="'+this.getParam("css_file")+'" rel="stylesheet" type="text/css" />';html+='</head>';html+='<body onload="parent.mcWindows.onLoad(\''+name+'\');">';html+='<div id="'+id+'_container" class="mceWindow">';html+='<div id="'+id+'_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\''+name+'\'].focus();">';html+=' <div id="'+id+'_title" class="mceWindowTitle"';html+=' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';html+=' <div class="mceWindowHeadTools">';html+=' <a href="javascript:parent.mcWindows.windows[\''+name+'\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="'+imgPath+'/window_close.gif" /></a>';html+=' </div>';html+='</div><div id="'+id+'_body" class="mceWindowBody" style="width: '+width+'px; height: '+height+'px;">';html+='<iframe id="'+id+'_iframe" name="'+id+'_iframe" frameborder="0" width="'+iframeWidth+'" height="'+iframeHeight+'" src="'+url+'" class="mceWindowBodyIframe" scrolling="'+features['scrollbars']+'"></iframe></div>';if(features['statusbar']=="yes"){html+='<div id="'+id+'_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\''+name+'\'].focus();">';if(features['resizable']=="yes"){if(this.isGecko)html+='<div id="'+id+'_resize" class="mceWindowResize"><div style="background-image: url(\''+imgPath+'/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';else html+='<div id="'+id+'_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\''+name+'\'].focus();" border="0" src="'+imgPath+'/window_resize.gif" /></div>';}html+='</div>';}html+='</div>';html+='</body>';html+='</html>';this.createFloatingIFrame(id,features['left'],features['top'],features['width'],features['height'],html);};MCWindows.prototype.setDocumentLock=function(state){if(state){var elm=document.getElementById('mcWindowEventBlocker');if(elm==null){elm=document.createElement("div");elm.id="mcWindowEventBlocker";elm.style.position="absolute";elm.style.left="0px";elm.style.top="0px";document.body.appendChild(elm);}elm.style.display="none";var imgPath=this.getParam("images_path");var width=document.body.clientWidth;var height=document.body.clientHeight;elm.style.width=width;elm.style.height=height;elm.innerHTML='<img src="'+imgPath+'/spacer.gif" width="'+width+'" height="'+height+'" />';elm.style.zIndex=mcWindows.zindex-1;elm.style.display="block";}else{var elm=document.getElementById('mcWindowEventBlocker');if(mcWindows.windows.length==0)elm.parentNode.removeChild(elm);else elm.style.zIndex=mcWindows.zindex-1;}};MCWindows.prototype.onLoad=function(name){var win=mcWindows.windows[name];var id="mcWindow_"+name;var wrapperIframe=window.frames[id+"_iframe"].frames[0];var wrapperDoc=window.frames[id+"_iframe"].document;var doc=window.frames[id+"_iframe"].document;var winDiv=document.getElementById("mcWindow_"+name+"_div");var realIframe=window.frames[id+"_iframe"].frames[0];win.id="mcWindow_"+name;win.winElement=winDiv;win.bodyElement=doc.getElementById(id+'_body');win.iframeElement=doc.getElementById(id+'_iframe');win.headElement=doc.getElementById(id+'_head');win.titleElement=doc.getElementById(id+'_title');win.resizeElement=doc.getElementById(id+'_resize');win.containerElement=doc.getElementById(id+'_container');win.left=win.features['left'];win.top=win.features['top'];win.frame=window.frames[id+'_iframe'].frames[0];win.wrapperFrame=window.frames[id+'_iframe'];win.wrapperIFrameElement=document.getElementById(id+"_iframe");mcWindows.addEvent(win.headElement,"mousedown",mcWindows.eventDispatcher);if(win.resizeElement!=null)mcWindows.addEvent(win.resizeElement,"mousedown",mcWindows.eventDispatcher);if(mcWindows.isMSIE){mcWindows.addEvent(realIframe.document,"mousemove",mcWindows.eventDispatcher);mcWindows.addEvent(realIframe.document,"mouseup",mcWindows.eventDispatcher);}else{mcWindows.addEvent(realIframe,"mousemove",mcWindows.eventDispatcher);mcWindows.addEvent(realIframe,"mouseup",mcWindows.eventDispatcher);mcWindows.addEvent(realIframe,"focus",mcWindows.eventDispatcher);}for(var i=0;i<window.frames.length;i++){if(!window.frames[i]._hasMouseHandlers){if(mcWindows.isMSIE){mcWindows.addEvent(window.frames[i].document,"mousemove",mcWindows.eventDispatcher);mcWindows.addEvent(window.frames[i].document,"mouseup",mcWindows.eventDispatcher);}else{mcWindows.addEvent(window.frames[i],"mousemove",mcWindows.eventDispatcher);mcWindows.addEvent(window.frames[i],"mouseup",mcWindows.eventDispatcher);}window.frames[i]._hasMouseHandlers=true;}}if(mcWindows.isMSIE){mcWindows.addEvent(win.frame.document,"mousemove",mcWindows.eventDispatcher);mcWindows.addEvent(win.frame.document,"mouseup",mcWindows.eventDispatcher);}else{mcWindows.addEvent(win.frame,"mousemove",mcWindows.eventDispatcher);mcWindows.addEvent(win.frame,"mouseup",mcWindows.eventDispatcher);mcWindows.addEvent(win.frame,"focus",mcWindows.eventDispatcher);}var func=this.getParam("on_open_window","");if(func!="")eval(func+"(win);");win.focus();if(win.features['modal']=="yes")mcWindows.setDocumentLock(true);};MCWindows.prototype.createFloatingIFrame=function(id_prefix,left,top,width,height,html){var iframe=document.createElement("iframe");var div=document.createElement("div");width=parseInt(width);height=parseInt(height)+1;div.setAttribute("id",id_prefix+"_div");div.setAttribute("width",width);div.setAttribute("height",(height));div.style.position="absolute";div.style.left=left+"px";div.style.top=top+"px";div.style.width=width+"px";div.style.height=(height)+"px";div.style.backgroundColor="white";div.style.display="none";if(this.isGecko){iframeWidth=width+2;iframeHeight=height+2;}else{iframeWidth=width;iframeHeight=height+1;}iframe.setAttribute("id",id_prefix+"_iframe");iframe.setAttribute("name",id_prefix+"_iframe");iframe.setAttribute("border","0");iframe.setAttribute("frameBorder","0");iframe.setAttribute("marginWidth","0");iframe.setAttribute("marginHeight","0");iframe.setAttribute("leftMargin","0");iframe.setAttribute("topMargin","0");iframe.setAttribute("width",iframeWidth);iframe.setAttribute("height",iframeHeight);iframe.setAttribute("scrolling","no");iframe.style.width=iframeWidth+"px";iframe.style.height=iframeHeight+"px";iframe.style.backgroundColor="white";div.appendChild(iframe);document.body.appendChild(div);div.innerHTML=div.innerHTML;if(this.isSafari){window.setTimeout(function(){doc=window.frames[id_prefix+'_iframe'].document;doc.open();doc.write(html);doc.close();},10);}else{doc=window.frames[id_prefix+'_iframe'].window.document;doc.open();doc.write(html);doc.close();}div.style.display="block";return div;};function MCWindow(){};MCWindow.prototype.focus=function(){if(this!=mcWindows.selectedWindow){this.winElement.style.zIndex=++mcWindows.zindex;mcWindows.lastSelectedWindow=mcWindows.selectedWindow;mcWindows.selectedWindow=this;}};MCWindow.prototype.minimize=function(){};MCWindow.prototype.maximize=function(){};MCWindow.prototype.startResize=function(){mcWindows.action="resize";};MCWindow.prototype.startMove=function(e){mcWindows.action="move";};MCWindow.prototype.close=function(){if(mcWindows.lastSelectedWindow!=null)mcWindows.lastSelectedWindow.focus();var mcWindowsNew=new Array();for(var n in mcWindows.windows){var win=mcWindows.windows[n];if(typeof(win)=='function')continue;if(win.name!=this.name)mcWindowsNew[n]=win;}mcWindows.windows=mcWindowsNew;var e=mcWindows.doc.getElementById(this.id+"_iframe");e.parentNode.removeChild(e);var e=mcWindows.doc.getElementById(this.id+"_div");e.parentNode.removeChild(e);mcWindows.setDocumentLock(false);};MCWindow.prototype.onMouseMove=function(e){var scrollX=0;var scrollY=0;var dx=e.screenX-mcWindows.mouseDownScreenX;var dy=e.screenY-mcWindows.mouseDownScreenY;switch(mcWindows.action){case "resize":width=mcWindows.mouseDownWidth+(e.screenX-mcWindows.mouseDownScreenX);height=mcWindows.mouseDownHeight+(e.screenY-mcWindows.mouseDownScreenY);width=width<100?100:width;height=height<100?100:height;this.wrapperIFrameElement.style.width=width+2;this.wrapperIFrameElement.style.height=height+2;this.wrapperIFrameElement.width=width+2;this.wrapperIFrameElement.height=height+2;this.winElement.style.width=width;this.winElement.style.height=height;height=height-this.deltaHeight;this.containerElement.style.width=width;this.iframeElement.style.width=width;this.iframeElement.style.height=height;this.bodyElement.style.width=width;this.bodyElement.style.height=height;this.headElement.style.width=width;mcWindows.cancelEvent(e);break;case "move":this.left=mcWindows.mouseDownLayerX+(e.screenX-mcWindows.mouseDownScreenX);this.top=mcWindows.mouseDownLayerY+(e.screenY-mcWindows.mouseDownScreenY);this.winElement.style.left=this.left+"px";this.winElement.style.top=this.top+"px";mcWindows.cancelEvent(e);break;}};function debug(msg){document.getElementById('debug').value+=msg+"\n";}MCWindow.prototype.onMouseUp=function(e){mcWindows.action="none";};MCWindow.prototype.onFocus=function(e){var winRef=e.currentTarget;for(var n in mcWindows.windows){var win=mcWindows.windows[n];if(typeof(win)=='function')continue;if(winRef.name==win.id+"_iframe"){win.focus();return;}}};MCWindow.prototype.onMouseDown=function(e){var elm=mcWindows.isMSIE?this.wrapperFrame.event.srcElement:e.target;var scrollX=0;var scrollY=0;mcWindows.mouseDownScreenX=e.screenX;mcWindows.mouseDownScreenY=e.screenY;mcWindows.mouseDownLayerX=this.left;mcWindows.mouseDownLayerY=this.top;mcWindows.mouseDownWidth=parseInt(this.winElement.style.width);mcWindows.mouseDownHeight=parseInt(this.winElement.style.height);if(this.resizeElement!=null&&elm==this.resizeElement.firstChild)this.startResize(e);else this.startMove(e);mcWindows.cancelEvent(e);};var mcWindows=new MCWindows();mcWindows.init({images_path:tinyMCE.baseURL+"/plugins/inlinepopups/images",css_file:tinyMCE.baseURL+"/plugins/inlinepopups/css/inlinepopup.css"}); -
trunk/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js
r2993 r3136 1 /**2 * $RCSfile: editor_plugin_src.js,v $3 * $Revision: 1.3 $4 * $Date: 2005/10/18 13:59:43 $5 *6 * Moxiecode DHTML Windows script.7 *8 * @author Moxiecode9 * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.10 */11 12 // Patch openWindow, closeWindow TinyMCE functions13 14 function TinyMCE_inlinepopups_getInfo() {15 return {16 longname : 'Inline Popups',17 author : 'Moxiecode Systems',18 authorurl : 'http://tinymce.moxiecode.com',19 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',20 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion21 };22 };23 24 TinyMCE.prototype.orgOpenWindow = TinyMCE.prototype.openWindow;25 26 TinyMCE.prototype.openWindow = function(template, args) {27 // Does the caller support inline28 if (args['inline'] != "yes") {29 mcWindows.selectedWindow = null;30 args['mce_inside_iframe'] = false;31 this.orgOpenWindow(template, args);32 return;33 }34 35 var url, resizable, scrollbars;36 37 args['mce_inside_iframe'] = true;38 tinyMCE.windowArgs = args;39 40 if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)41 url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];42 else43 url = template['file'];44 45 if (!(width = parseInt(template['width'])))46 width = 320;47 48 if (!(height = parseInt(template['height'])))49 height = 200;50 51 resizable = (args && args['resizable']) ? args['resizable'] : "no";52 scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";53 54 height += 18;55 56 // Replace all args as variables in URL57 for (var name in args) {58 if (typeof(args[name]) == 'function')59 continue;60 61 url = tinyMCE.replaceVar(url, name, escape(args[name]));62 }63 64 var elm = document.getElementById(this.selectedInstance.editorId + '_parent');65 var pos = tinyMCE.getAbsPosition(elm);66 67 // Center div in editor area68 pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));69 pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));70 71 mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);72 };73 74 TinyMCE.prototype.orgCloseWindow = TinyMCE.prototype.closeWindow;75 76 TinyMCE.prototype.closeWindow = function(win) {77 if (mcWindows.selectedWindow != null)78 mcWindows.selectedWindow.close();79 else80 this.orgCloseWindow(win);81 };82 83 TinyMCE.prototype.setWindowTitle = function(win_ref, title) {84 for (var n in mcWindows.windows) {85 var win = mcWindows.windows[n];86 if (typeof(win) == 'function')87 continue;88 89 if (win_ref.name == win.id + "_iframe")90 window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title;91 }92 };93 94 // * * * * * MCWindows classes below95 96 // Windows handler97 function MCWindows() {98 this.settings = new Array();99 this.windows = new Array();100 this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");101 this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;102 this.isSafari = navigator.userAgent.indexOf('Safari') != -1;103 this.isMac = navigator.userAgent.indexOf('Mac') != -1;104 this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);105 this.action = "none";106 this.selectedWindow = null;107 this.lastSelectedWindow = null;108 this.zindex = 100;109 this.mouseDownScreenX = 0;110 this.mouseDownScreenY = 0;111 this.mouseDownLayerX = 0;112 this.mouseDownLayerY = 0;113 this.mouseDownWidth = 0;114 this.mouseDownHeight = 0;115 this.idCounter = 0;116 };117 118 MCWindows.prototype.init = function(settings) {119 this.settings = settings;120 121 if (this.isMSIE)122 this.addEvent(document, "mousemove", mcWindows.eventDispatcher);123 else124 this.addEvent(window, "mousemove", mcWindows.eventDispatcher);125 126 this.addEvent(document, "mouseup", mcWindows.eventDispatcher);127 128 this.doc = document;129 };130 131 MCWindows.prototype.getParam = function(name, default_value) {132 var value = null;133 134 value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];135 136 // Fix bool values137 if (value == "true" || value == "false")138 return (value == "true");139 140 return value;141 };142 143 MCWindows.prototype.eventDispatcher = function(e) {144 e = typeof(e) == "undefined" ? window.event : e;145 146 if (mcWindows.selectedWindow == null)147 return;148 149 // Switch focus150 if (mcWindows.isGecko && e.type == "mousedown") {151 var elm = e.currentTarget;152 153 for (var n in mcWindows.windows) {154 var win = mcWindows.windows[n];155 156 if (win.headElement == elm || win.resizeElement == elm) {157 win.focus();158 break;159 }160 }161 }162 163 switch (e.type) {164 case "mousemove":165 mcWindows.selectedWindow.onMouseMove(e);166 break;167 168 case "mouseup":169 mcWindows.selectedWindow.onMouseUp(e);170 break;171 172 case "mousedown":173 mcWindows.selectedWindow.onMouseDown(e);174 break;175 176 case "focus":177 mcWindows.selectedWindow.onFocus(e);178 break;179 }180 };181 182 MCWindows.prototype.addEvent = function(obj, name, handler) {183 if (this.isMSIE)184 obj.attachEvent("on" + name, handler);185 else186 obj.addEventListener(name, handler, true);187 };188 189 MCWindows.prototype.cancelEvent = function(e) {190 if (this.isMSIE) {191 e.returnValue = false;192 e.cancelBubble = true;193 } else194 e.preventDefault();195 };196 197 MCWindows.prototype.parseFeatures = function(opts) {198 // Cleanup the options199 opts = opts.toLowerCase();200 opts = opts.replace(/;/g, ",");201 opts = opts.replace(/[^0-9a-z=,]/g, "");202 203 var optionChunks = opts.split(',');204 var options = new Array();205 206 options['left'] = "10";207 options['top'] = "10";208 options['width'] = "300";209 options['height'] = "300";210 options['resizable'] = "yes";211 options['minimizable'] = "yes";212 options['maximizable'] = "yes";213 options['close'] = "yes";214 options['movable'] = "yes";215 options['statusbar'] = "yes";216 options['scrollbars'] = "auto";217 options['modal'] = "no";218 219 if (opts == "")220 return options;221 222 for (var i=0; i<optionChunks.length; i++) {223 var parts = optionChunks[i].split('=');224 225 if (parts.length == 2)226 options[parts[0]] = parts[1];227 }228 229 options['left'] = parseInt(options['left']);230 options['top'] = parseInt(options['top']);231 options['width'] = parseInt(options['width']);232 options['height'] = parseInt(options['height']);233 234 return options;235 };236 237 MCWindows.prototype.open = function(url, name, features) {238 this.lastSelectedWindow = this.selectedWindow;239 240 var win = new MCWindow();241 var winDiv, html = "", id;242 var imgPath = this.getParam("images_path");243 244 features = this.parseFeatures(features);245 246 // Create div247 id = "mcWindow_" + name;248 win.deltaHeight = 18;249 250 if (features['statusbar'] == "yes") {251 win.deltaHeight += 13;252 253 if (this.isMSIE)254 win.deltaHeight += 1;255 }256 257 width = parseInt(features['width']);258 height = parseInt(features['height'])-win.deltaHeight;259 260 if (this.isMSIE)261 width -= 2;262 263 // Setup first part of window264 win.id = id;265 win.url = url;266 win.name = name;267 win.features = features;268 this.windows[name] = win;269 270 iframeWidth = width;271 iframeHeight = height;272 273 // Create inner content274 html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';275 html += '<html>';276 html += '<head>';277 html += '<title>Wrapper iframe</title>';278 html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';279 html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';280 html += '</head>';281 html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';282 283 html += '<div id="' + id + '_container" class="mceWindow">';284 html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';285 html += ' <div id="' + id + '_title" class="mceWindowTitle"';286 html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';287 html += ' <div class="mceWindowHeadTools">';288 html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';289 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';290 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';291 html += ' </div>';292 html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';293 html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';294 295 if (features['statusbar'] == "yes") {296 html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';297 298 if (features['resizable'] == "yes") {299 if (this.isGecko)300 html += '<div id="' + id + '_resize" class="mceWindowResize"><div style="background-image: url(\'' + imgPath + '/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';301 else302 html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="' + imgPath + '/window_resize.gif" /></div>';303 }304 305 html += '</div>';306 }307 308 html += '</div>';309 310 html += '</body>';311 html += '</html>';312 313 // Create iframe314 this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);315 };316 317 // Blocks the document events by placing a image over the whole document318 MCWindows.prototype.setDocumentLock = function(state) {319 if (state) {320 var elm = document.getElementById('mcWindowEventBlocker');321 if (elm == null) {322 elm = document.createElement("div");323 324 elm.id = "mcWindowEventBlocker";325 elm.style.position = "absolute";326 elm.style.left = "0px";327 elm.style.top = "0px";328 329 document.body.appendChild(elm);330 }331 332 elm.style.display = "none";333 334 var imgPath = this.getParam("images_path");335 var width = document.body.clientWidth;336 var height = document.body.clientHeight;337 338 elm.style.width = width;339 elm.style.height = height;340 elm.innerHTML = '<img src="' + imgPath + '/spacer.gif" width="' + width + '" height="' + height + '" />';341 342 elm.style.zIndex = mcWindows.zindex-1;343 elm.style.display = "block";344 } else {345 var elm = document.getElementById('mcWindowEventBlocker');346 347 if (mcWindows.windows.length == 0)348 elm.parentNode.removeChild(elm);349 else350 elm.style.zIndex = mcWindows.zindex-1;351 }352 };353 354 // Gets called when wrapper iframe is initialized355 MCWindows.prototype.onLoad = function(name) {356 var win = mcWindows.windows[name];357 var id = "mcWindow_" + name;358 var wrapperIframe = window.frames[id + "_iframe"].frames[0];359 var wrapperDoc = window.frames[id + "_iframe"].document;360 var doc = window.frames[id + "_iframe"].document;361 var winDiv = document.getElementById("mcWindow_" + name + "_div");362 var realIframe = window.frames[id + "_iframe"].frames[0];363 364 // Set window data365 win.id = "mcWindow_" + name;366 win.winElement = winDiv;367 win.bodyElement = doc.getElementById(id + '_body');368 win.iframeElement = doc.getElementById(id + '_iframe');369 win.headElement = doc.getElementById(id + '_head');370 win.titleElement = doc.getElementById(id + '_title');371 win.resizeElement = doc.getElementById(id + '_resize');372 win.containerElement = doc.getElementById(id + '_container');373 win.left = win.features['left'];374 win.top = win.features['top'];375 win.frame = window.frames[id + '_iframe'].frames[0];376 win.wrapperFrame = window.frames[id + '_iframe'];377 win.wrapperIFrameElement = document.getElementById(id + "_iframe");378 379 // Add event handlers380 mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);381 382 if (win.resizeElement != null)383 mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);384 385 if (mcWindows.isMSIE) {386 mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);387 mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);388 } else {389 mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);390 mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);391 mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);392 }393 394 for (var i=0; i<window.frames.length; i++) {395 if (!window.frames[i]._hasMouseHandlers) {396 if (mcWindows.isMSIE) {397 mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);398 mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);399 } else {400 mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);401 mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);402 }403 404 window.frames[i]._hasMouseHandlers = true;405 }406 }407 408 if (mcWindows.isMSIE) {409 mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);410 mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);411 } else {412 mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);413 mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);414 mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);415 }416 417 // Dispatch open window event418 var func = this.getParam("on_open_window", "");419 if (func != "")420 eval(func + "(win);");421 422 win.focus();423 424 if (win.features['modal'] == "yes")425 mcWindows.setDocumentLock(true);426 };427 428 MCWindows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {429 var iframe = document.createElement("iframe");430 var div = document.createElement("div");431 432 width = parseInt(width);433 height = parseInt(height)+1;434 435 // Create wrapper div436 div.setAttribute("id", id_prefix + "_div");437 div.setAttribute("width", width);438 div.setAttribute("height", (height));439 div.style.position = "absolute";440 div.style.left = left + "px";441 div.style.top = top + "px";442 div.style.width = width + "px";443 div.style.height = (height) + "px";444 div.style.backgroundColor = "white";445 div.style.display = "none";446 447 if (this.isGecko) {448 iframeWidth = width + 2;449 iframeHeight = height + 2;450 } else {451 iframeWidth = width;452 iframeHeight = height + 1;453 }454 455 // Create iframe456 iframe.setAttribute("id", id_prefix + "_iframe");457 iframe.setAttribute("name", id_prefix + "_iframe");458 iframe.setAttribute("border", "0");459 iframe.setAttribute("frameBorder", "0");460 iframe.setAttribute("marginWidth", "0");461 iframe.setAttribute("marginHeight", "0");462 iframe.setAttribute("leftMargin", "0");463 iframe.setAttribute("topMargin", "0");464 iframe.setAttribute("width", iframeWidth);465 iframe.setAttribute("height", iframeHeight);466 // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");467 // iframe.setAttribute("allowtransparency", "false");468 iframe.setAttribute("scrolling", "no");469 iframe.style.width = iframeWidth + "px";470 iframe.style.height = iframeHeight + "px";471 iframe.style.backgroundColor = "white";472 div.appendChild(iframe);473 474 document.body.appendChild(div);475 476 // Fixed MSIE 5.0 issue477 div.innerHTML = div.innerHTML;478 479 if (this.isSafari) {480 // Give Safari some time to setup481 window.setTimeout(function() {482 doc = window.frames[id_prefix + '_iframe'].document;483 doc.open();484 doc.write(html);485 doc.close();486 }, 10);487 } else {488 doc = window.frames[id_prefix + '_iframe'].window.document;489 doc.open();490 doc.write(html);491 doc.close();492 }493 494 div.style.display = "block";495 496 return div;497 };498 499 // Window instance500 function MCWindow() {501 };502 503 MCWindow.prototype.focus = function() {504 if (this != mcWindows.selectedWindow) {505 this.winElement.style.zIndex = ++mcWindows.zindex;506 mcWindows.lastSelectedWindow = mcWindows.selectedWindow;507 mcWindows.selectedWindow = this;508 }509 };510 511 MCWindow.prototype.minimize = function() {512 };513 514 MCWindow.prototype.maximize = function() {515 516 };517 518 MCWindow.prototype.startResize = function() {519 mcWindows.action = "resize";520 };521 522 MCWindow.prototype.startMove = function(e) {523 mcWindows.action = "move";524 };525 526 MCWindow.prototype.close = function() {527 if (mcWindows.lastSelectedWindow != null)528 mcWindows.lastSelectedWindow.focus();529 530 var mcWindowsNew = new Array();531 for (var n in mcWindows.windows) {532 var win = mcWindows.windows[n];533 if (typeof(win) == 'function')534 continue;535 536 if (win.name != this.name)537 mcWindowsNew[n] = win;538 }539 540 mcWindows.windows = mcWindowsNew;541 542 // alert(mcWindows.doc.getElementById(this.id + "_iframe"));543 544 var e = mcWindows.doc.getElementById(this.id + "_iframe");545 e.parentNode.removeChild(e);546 547 var e = mcWindows.doc.getElementById(this.id + "_div");548 e.parentNode.removeChild(e);549 550 mcWindows.setDocumentLock(false);551 };552 553 MCWindow.prototype.onMouseMove = function(e) {554 var scrollX = 0;//this.doc.body.scrollLeft;555 var scrollY = 0;//this.doc.body.scrollTop;556 557 // Calculate real X, Y558 var dx = e.screenX - mcWindows.mouseDownScreenX;559 var dy = e.screenY - mcWindows.mouseDownScreenY;560 561 switch (mcWindows.action) {562 case "resize":563 width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);564 height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);565 566 width = width < 100 ? 100 : width;567 height = height < 100 ? 100 : height;568 569 this.wrapperIFrameElement.style.width = width+2;570 this.wrapperIFrameElement.style.height = height+2;571 this.wrapperIFrameElement.width = width+2;572 this.wrapperIFrameElement.height = height+2;573 this.winElement.style.width = width;574 this.winElement.style.height = height;575 576 height = height - this.deltaHeight;577 578 this.containerElement.style.width = width;579 580 this.iframeElement.style.width = width;581 this.iframeElement.style.height = height;582 this.bodyElement.style.width = width;583 this.bodyElement.style.height = height;584 this.headElement.style.width = width;585 //this.statusElement.style.width = width;586 587 mcWindows.cancelEvent(e);588 break;589 590 case "move":591 this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);592 this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);593 this.winElement.style.left = this.left + "px";594 this.winElement.style.top = this.top + "px";595 596 mcWindows.cancelEvent(e);597 break;598 }599 };600 601 function debug(msg) {602 document.getElementById('debug').value += msg + "\n";603 }604 605 MCWindow.prototype.onMouseUp = function(e) {606 mcWindows.action = "none";607 };608 609 MCWindow.prototype.onFocus = function(e) {610 // Gecko only handler611 var winRef = e.currentTarget;612 613 for (var n in mcWindows.windows) {614 var win = mcWindows.windows[n];615 if (typeof(win) == 'function')616 continue;617 618 if (winRef.name == win.id + "_iframe") {619 win.focus();620 return;621 }622 }623 };624 625 MCWindow.prototype.onMouseDown = function(e) {626 var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;627 628 var scrollX = 0;//this.doc.body.scrollLeft;629 var scrollY = 0;//this.doc.body.scrollTop;630 631 mcWindows.mouseDownScreenX = e.screenX;632 mcWindows.mouseDownScreenY = e.screenY;633 mcWindows.mouseDownLayerX = this.left;634 mcWindows.mouseDownLayerY = this.top;635 mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);636 mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);637 638 if (this.resizeElement != null && elm == this.resizeElement.firstChild)639 this.startResize(e);640 else641 this.startMove(e);642 643 mcWindows.cancelEvent(e);644 };645 646 // Global instance647 var mcWindows = new MCWindows();648 649 // Initialize windows650 mcWindows.init({651 images_path : tinyMCE.baseURL + "/plugins/inlinepopups/images",652 css_file : tinyMCE.baseURL + "/plugins/inlinepopups/css/inlinepopup.css"653 }); -
trunk/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
r2993 r3136 1 /**2 * $RCSfile: mcwindows.js,v $3 * $Revision: 1.2 $4 * $Date: 2005/10/18 13:59:43 $5 *6 * Moxiecode DHTML Windows script.7 *8 * @author Moxiecode9 * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.10 */11 12 // Windows handler13 function MCWindows() {14 this.settings = new Array();15 this.windows = new Array();16 this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");17 this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;18 this.isSafari = navigator.userAgent.indexOf('Safari') != -1;19 this.isMac = navigator.userAgent.indexOf('Mac') != -1;20 this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);21 this.action = "none";22 this.selectedWindow = null;23 this.zindex = 100;24 this.mouseDownScreenX = 0;25 this.mouseDownScreenY = 0;26 this.mouseDownLayerX = 0;27 this.mouseDownLayerY = 0;28 this.mouseDownWidth = 0;29 this.mouseDownHeight = 0;30 };31 32 MCWindows.prototype.init = function(settings) {33 this.settings = settings;34 35 if (this.isMSIE)36 this.addEvent(document, "mousemove", mcWindows.eventDispatcher);37 else38 this.addEvent(window, "mousemove", mcWindows.eventDispatcher);39 40 this.addEvent(document, "mouseup", mcWindows.eventDispatcher);41 };42 43 MCWindows.prototype.getParam = function(name, default_value) {44 var value = null;45 46 value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];47 48 // Fix bool values49 if (value == "true" || value == "false")50 return (value == "true");51 52 return value;53 };54 55 MCWindows.prototype.eventDispatcher = function(e) {56 e = typeof(e) == "undefined" ? window.event : e;57 58 if (mcWindows.selectedWindow == null)59 return;60 61 // Switch focus62 if (mcWindows.isGecko && e.type == "mousedown") {63 var elm = e.currentTarget;64 65 for (var n in mcWindows.windows) {66 var win = mcWindows.windows[n];67 if (typeof(win) == 'function')68 continue;69 70 if (win.headElement == elm || win.resizeElement == elm) {71 win.focus();72 break;73 }74 }75 }76 77 switch (e.type) {78 case "mousemove":79 mcWindows.selectedWindow.onMouseMove(e);80 break;81 82 case "mouseup":83 mcWindows.selectedWindow.onMouseUp(e);84 break;85 86 case "mousedown":87 mcWindows.selectedWindow.onMouseDown(e);88 break;89 90 case "focus":91 mcWindows.selectedWindow.onFocus(e);92 break;93 }94 }95 96 MCWindows.prototype.addEvent = function(obj, name, handler) {97 if (this.isMSIE)98 obj.attachEvent("on" + name, handler);99 else100 obj.addEventListener(name, handler, true);101 };102 103 MCWindows.prototype.cancelEvent = function(e) {104 if (this.isMSIE) {105 e.returnValue = false;106 e.cancelBubble = true;107 } else108 e.preventDefault();109 };110 111 MCWindows.prototype.parseFeatures = function(opts) {112 // Cleanup the options113 opts = opts.toLowerCase();114 opts = opts.replace(/;/g, ",");115 opts = opts.replace(/[^0-9a-z=,]/g, "");116 117 var optionChunks = opts.split(',');118 var options = new Array();119 120 options['left'] = 10;121 options['top'] = 10;122 options['width'] = 300;123 options['height'] = 300;124 options['resizable'] = true;125 options['minimizable'] = true;126 options['maximizable'] = true;127 options['close'] = true;128 options['movable'] = true;129 130 if (opts == "")131 return options;132 133 for (var i=0; i<optionChunks.length; i++) {134 var parts = optionChunks[i].split('=');135 136 if (parts.length == 2)137 options[parts[0]] = parts[1];138 }139 140 return options;141 };142 143 MCWindows.prototype.open = function(url, name, features) {144 var win = new MCWindow();145 var winDiv, html = "", id;146 147 features = this.parseFeatures(features);148 149 // Create div150 id = "mcWindow_" + name;151 152 width = parseInt(features['width']);153 height = parseInt(features['height'])-12-19;154 155 if (this.isMSIE)156 width -= 2;157 158 // Setup first part of window159 win.id = id;160 win.url = url;161 win.name = name;162 win.features = features;163 this.windows[name] = win;164 165 iframeWidth = width;166 iframeHeight = height;167 168 // Create inner content169 html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';170 html += '<html>';171 html += '<head>';172 html += '<title>Wrapper iframe</title>';173 html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';174 html += '<link href="../jscripts/tiny_mce/themes/advanced/css/editor_ui.css" rel="stylesheet" type="text/css" />';175 html += '</head>';176 html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';177 178 html += '<div id="' + id + '_container" class="mceWindow">';179 html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';180 html += ' <div id="' + id + '_title" class="mceWindowTitle"';181 html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;">No name window</div>';182 html += ' <div class="mceWindowHeadTools">';183 html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" onmousedown="return false;" class="mceWindowClose"><img border="0" src="../jscripts/tiny_mce/themes/advanced/images/window_close.gif" /></a>';184 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" onmousedown="return false;" class="mceWindowMaximize"></a>';185 // html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" onmousedown="return false;" class="mceWindowMinimize"></a>';186 html += ' </div>';187 html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';188 html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" onfocus="parent.mcWindows.windows[\'' + name + '\'].focus();" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe"></iframe></div>';189 html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';190 html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="../jscripts/tiny_mce/themes/advanced/images/window_resize.gif" /></div>';191 html += '</div>';192 html += '</div>';193 194 html += '</body>';195 html += '</html>';196 197 // Create iframe198 this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);199 };200 201 // Gets called when wrapper iframe is initialized202 MCWindows.prototype.onLoad = function(name) {203 var win = mcWindows.windows[name];204 var id = "mcWindow_" + name;205 var wrapperIframe = window.frames[id + "_iframe"].frames[0];206 var wrapperDoc = window.frames[id + "_iframe"].document;207 var doc = window.frames[id + "_iframe"].document;208 var winDiv = document.getElementById("mcWindow_" + name + "_div");209 var realIframe = window.frames[id + "_iframe"].frames[0];210 211 // Set window data212 win.id = "mcWindow_" + name + "_iframe";213 win.winElement = winDiv;214 win.bodyElement = doc.getElementById(id + '_body');215 win.iframeElement = doc.getElementById(id + '_iframe');216 win.headElement = doc.getElementById(id + '_head');217 win.titleElement = doc.getElementById(id + '_title');218 win.resizeElement = doc.getElementById(id + '_resize');219 win.containerElement = doc.getElementById(id + '_container');220 win.left = win.features['left'];221 win.top = win.features['top'];222 win.frame = window.frames[id + '_iframe'].frames[0];223 win.wrapperFrame = window.frames[id + '_iframe'];224 win.wrapperIFrameElement = document.getElementById(id + "_iframe");225 226 // Add event handlers227 mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);228 mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);229 230 if (mcWindows.isMSIE) {231 mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);232 mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);233 } else {234 mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);235 mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);236 mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);237 }238 239 for (var i=0; i<window.frames.length; i++) {240 if (!window.frames[i]._hasMouseHandlers) {241 if (mcWindows.isMSIE) {242 mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);243 mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);244 } else {245 mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);246 mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);247 }248 249 window.frames[i]._hasMouseHandlers = true;250 }251 }252 253 if (mcWindows.isMSIE) {254 mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);255 mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);256 } else {257 mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);258 mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);259 mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);260 }261 262 this.selectedWindow = win;263 };264 265 MCWindows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {266 var iframe = document.createElement("iframe");267 var div = document.createElement("div");268 269 width = parseInt(width);270 height = parseInt(height)+1;271 272 // Create wrapper div273 div.setAttribute("id", id_prefix + "_div");274 div.setAttribute("width", width);275 div.setAttribute("height", (height));276 div.style.position = "absolute";277 div.style.left = left + "px";278 div.style.top = top + "px";279 div.style.width = width + "px";280 div.style.height = (height) + "px";281 div.style.backgroundColor = "white";282 div.style.display = "none";283 284 if (this.isGecko) {285 iframeWidth = width + 2;286 iframeHeight = height + 2;287 } else {288 iframeWidth = width;289 iframeHeight = height + 1;290 }291 292 // Create iframe293 iframe.setAttribute("id", id_prefix + "_iframe");294 iframe.setAttribute("name", id_prefix + "_iframe");295 iframe.setAttribute("border", "0");296 iframe.setAttribute("frameBorder", "0");297 iframe.setAttribute("marginWidth", "0");298 iframe.setAttribute("marginHeight", "0");299 iframe.setAttribute("leftMargin", "0");300 iframe.setAttribute("topMargin", "0");301 iframe.setAttribute("width", iframeWidth);302 iframe.setAttribute("height", iframeHeight);303 // iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");304 // iframe.setAttribute("allowtransparency", "false");305 iframe.setAttribute("scrolling", "no");306 iframe.style.width = iframeWidth + "px";307 iframe.style.height = iframeHeight + "px";308 iframe.style.backgroundColor = "white";309 div.appendChild(iframe);310 311 document.body.appendChild(div);312 313 // Fixed MSIE 5.0 issue314 div.innerHTML = div.innerHTML;315 316 if (this.isSafari) {317 // Give Safari some time to setup318 window.setTimeout(function() {319 doc = window.frames[id_prefix + '_iframe'].document;320 doc.open();321 doc.write(html);322 doc.close();323 }, 10);324 } else {325 doc = window.frames[id_prefix + '_iframe'].window.document326 doc.open();327 doc.write(html);328 doc.close();329 }330 331 div.style.display = "block";332 333 return div;334 };335 336 // Window instance337 function MCWindow() {338 };339 340 MCWindow.prototype.focus = function() {341 this.winElement.style.zIndex = mcWindows.zindex++;342 mcWindows.selectedWindow = this;343 };344 345 MCWindow.prototype.minimize = function() {346 };347 348 MCWindow.prototype.maximize = function() {349 350 };351 352 MCWindow.prototype.startResize = function() {353 mcWindows.action = "resize";354 };355 356 MCWindow.prototype.startMove = function(e) {357 mcWindows.action = "move";358 };359 360 MCWindow.prototype.close = function() {361 document.body.removeChild(this.winElement);362 mcWindows.windows[this.name] = null;363 };364 365 MCWindow.prototype.onMouseMove = function(e) {366 var scrollX = 0;//this.doc.body.scrollLeft;367 var scrollY = 0;//this.doc.body.scrollTop;368 369 // Calculate real X, Y370 var dx = e.screenX - mcWindows.mouseDownScreenX;371 var dy = e.screenY - mcWindows.mouseDownScreenY;372 373 switch (mcWindows.action) {374 case "resize":375 width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);376 height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);377 378 width = width < 100 ? 100 : width;379 height = height < 100 ? 100 : height;380 381 this.wrapperIFrameElement.style.width = width+2;382 this.wrapperIFrameElement.style.height = height+2;383 this.wrapperIFrameElement.width = width+2;384 this.wrapperIFrameElement.height = height+2;385 this.winElement.style.width = width;386 this.winElement.style.height = height;387 388 height = height-12-19;389 390 this.containerElement.style.width = width;391 392 this.iframeElement.style.width = width;393 this.iframeElement.style.height = height;394 this.bodyElement.style.width = width;395 this.bodyElement.style.height = height;396 this.headElement.style.width = width;397 //this.statusElement.style.width = width;398 399 mcWindows.cancelEvent(e);400 break;401 402 case "move":403 this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);404 this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);405 this.winElement.style.left = this.left + "px";406 this.winElement.style.top = this.top + "px";407 408 mcWindows.cancelEvent(e);409 break;410 }411 };412 413 MCWindow.prototype.onMouseUp = function(e) {414 mcWindows.action = "none";415 };416 417 MCWindow.prototype.onFocus = function(e) {418 // Gecko only handler419 var winRef = e.currentTarget;420 421 for (var n in mcWindows.windows) {422 var win = mcWindows.windows[n];423 if (typeof(win) == 'function')424 continue;425 426 if (winRef.name == win.id) {427 win.focus();428 return;429 }430 }431 };432 433 MCWindow.prototype.onMouseDown = function(e) {434 var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;435 436 var scrollX = 0;//this.doc.body.scrollLeft;437 var scrollY = 0;//this.doc.body.scrollTop;438 439 mcWindows.mouseDownScreenX = e.screenX;440 mcWindows.mouseDownScreenY = e.screenY;441 mcWindows.mouseDownLayerX = this.left;442 mcWindows.mouseDownLayerY = this.top;443 mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);444 mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);445 446 if (elm == this.resizeElement.firstChild)447 this.startResize(e);448 else449 this.startMove(e);450 451 mcWindows.cancelEvent(e);452 };453 454 // Global instance455 var mcWindows = new MCWindows(); -
trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
r3020 r3136 12 12 var titleMore = tinyMCE.getLang('lang_wordpress_more_button'); 13 13 var titlePage = tinyMCE.getLang('lang_wordpress_page_button'); 14 var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="'+titleMore+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a><!--<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onclick="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="'+titlePage+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>-->'; 14 var titleHelp = tinyMCE.getLang('lang_wordpress_help_button'); 15 var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="'+titleMore+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>' 16 + '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresshelp\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresshelp\');return false;"><img id="{$editor_id}_wordpress_help" src="{$pluginurl}/images/help.gif" title="'+titleHelp+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>'; 17 // Add this to the buttons var to put the Page button into the toolbar. 18 // '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onclick="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="'+titlePage+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>'; 15 19 var hiddenControls = '<div class="zerosize">' 16 20 + '<input type="button" accesskey="b" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Bold\',false);" />' 17 21 + '<input type="button" accesskey="i" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Italic\',false);" />' 18 22 + '<input type="button" accesskey="d" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Strikethrough\',false);" />' 19 + '<input type="button" accesskey=" n" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />'23 + '<input type="button" accesskey="l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />' 20 24 + '<input type="button" accesskey="o" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertOrderedList\',false);" />' 21 + '<input type="button" accesskey=" a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />'22 + '<input type="button" accesskey=" s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />'25 + '<input type="button" accesskey="w" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />' 26 + '<input type="button" accesskey="q" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />' 23 27 + '<input type="button" accesskey="f" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyLeft\',false);" />' 24 28 + '<input type="button" accesskey="c" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyCenter\',false);" />' 25 29 + '<input type="button" accesskey="r" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyRight\',false);" />' 26 + '<input type="button" accesskey=" l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />'27 + '<input type="button" accesskey=" k" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />'30 + '<input type="button" accesskey="a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />' 31 + '<input type="button" accesskey="s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />' 28 32 + '<input type="button" accesskey="m" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceImage\',true);" />' 29 33 + '<input type="button" accesskey="t" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');" />' … … 87 91 88 92 function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interface, value) { 93 var inst = tinyMCE.getInstanceById(editor_id); 94 var focusElm = inst.getFocusElement(); 95 var doc = inst.getDoc(); 96 89 97 function getAttrib(elm, name) { 90 98 return elm.getAttribute(name) ? elm.getAttribute(name) : ""; … … 96 104 var flag = ""; 97 105 var template = new Array(); 98 var inst = tinyMCE.getInstanceById(editor_id);99 var focusElm = inst.getFocusElement();100 106 var altMore = tinyMCE.getLang('lang_wordpress_more_alt'); 101 107 … … 120 126 var flag = ""; 121 127 var template = new Array(); 122 var inst = tinyMCE.getInstanceById(editor_id);123 var focusElm = inst.getFocusElement();124 128 var altPage = tinyMCE.getLang('lang_wordpress_more_alt'); 125 129 … … 140 144 tinyMCE.execCommand("mceInsertContent",true,html); 141 145 tinyMCE.selectedInstance.repaint(); 146 return true; 147 case "mcewordpresshelp": 148 var helpText = tinyMCE.getLang('lang_wordpress_help_text'); 149 alert(helpText); 142 150 return true; 143 151 } … … 181 189 startPos++; 182 190 } 191 192 // It's supposed to be WYSIWYG, right? 193 content = content.replace(new RegExp('&', 'g'), '&'); 194 183 195 break; 184 196 … … 212 224 } 213 225 214 // The Curse of the Trailing <br /> 215 content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), ''); 216 217 // The Curse of the Trailing <br /> 218 content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), ''); 219 226 // If it says & in the WYSIWYG editor, it should say & in the html. 227 content = content.replace(new RegExp('&', 'g'), '&'); 228 229 // Pretty it up for the source editor. 230 var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\d|pre|p'; 231 content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n'); 232 content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>'); 233 content = content.replace(new RegExp('<li>', 'g'), '\t<li>'); 234 content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n'); 235 content = content.replace(new RegExp('^\\s*', ''), ''); 236 content = content.replace(new RegExp('\\s*$', ''), ''); 220 237 break; 221 238 } … … 245 262 return true; 246 263 } 264 265 function wp_save_callback(el, content, body) { 266 // We have a TON of cleanup to do. 267 268 // Mark </p> if it has any attributes. 269 content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>'); 270 271 // Decode the ampersands of time. 272 content = content.replace(new RegExp('&', 'g'), '&'); 273 274 // Get it ready for wpautop. 275 content = content.replace(new RegExp('[\\s]*<p>[\\s]*', 'mgi'), ''); 276 content = content.replace(new RegExp('[\\s]*</p>[\\s]*', 'mgi'), '\n\n'); 277 content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n'); 278 content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n'); 279 280 // Fix some block element newline issues 281 var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\d|pre'; 282 content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>'); 283 content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n'); 284 content = content.replace(new RegExp('<li>', 'g'), '\t<li>'); 285 286 // Unmark special paragraph closing tags 287 content = content.replace(new RegExp('</p#>', 'g'), '</p>\n'); 288 content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1'); 289 290 // Trim any whitespace 291 content = content.replace(new RegExp('^\\s*', ''), ''); 292 content = content.replace(new RegExp('\\s*$', ''), ''); 293 294 // Hope. 295 return content; 296 297 } -
trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js
r3020 r3136 1 /* Import plugin specific language pack */2 tinyMCE.importPluginLanguagePack('wordpress', '');3 4 function TinyMCE_wordpress_initInstance(inst) {5 if (!tinyMCE.settings['wordpress_skip_plugin_css'])6 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css");7 }8 9 function TinyMCE_wordpress_getControlHTML(control_name) {10 switch (control_name) {11 case "wordpress":12 var titleMore = tinyMCE.getLang('lang_wordpress_more_button');13 var titlePage = tinyMCE.getLang('lang_wordpress_page_button');14 var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="'+titleMore+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a><!--<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onclick="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="'+titlePage+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>-->';15 var hiddenControls = '<div class="zerosize">'16 + '<input type="button" accesskey="b" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Bold\',false);" />'17 + '<input type="button" accesskey="i" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Italic\',false);" />'18 + '<input type="button" accesskey="d" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Strikethrough\',false);" />'19 + '<input type="button" accesskey="n" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />'20 + '<input type="button" accesskey="o" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertOrderedList\',false);" />'21 + '<input type="button" accesskey="a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />'22 + '<input type="button" accesskey="s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />'23 + '<input type="button" accesskey="f" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyLeft\',false);" />'24 + '<input type="button" accesskey="c" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyCenter\',false);" />'25 + '<input type="button" accesskey="r" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyRight\',false);" />'26 + '<input type="button" accesskey="l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />'27 + '<input type="button" accesskey="k" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />'28 + '<input type="button" accesskey="m" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceImage\',true);" />'29 + '<input type="button" accesskey="t" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');" />'30 + '<input type="button" accesskey="u" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Undo\',false);" />'31 + '<input type="button" accesskey="y" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Redo\',false);" />'32 + '<input type="button" accesskey="e" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceCodeEditor\',false);" />'33 + '<input type="button" accesskey="h" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresshelp\',false);" />'34 + '</div>';35 return buttons+hiddenControls;36 }37 38 return "";39 }40 41 function TinyMCE_wordpress_parseAttributes(attribute_string) {42 var attributeName = "";43 var attributeValue = "";44 var withInName;45 var withInValue;46 var attributes = new Array();47 var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');48 var titleText = tinyMCE.getLang('lang_wordpress_more');49 var titleTextPage = tinyMCE.getLang('lang_wordpress_page');50 51 if (attribute_string == null || attribute_string.length < 2)52 return null;53 54 withInName = withInValue = false;55 56 for (var i=0; i<attribute_string.length; i++) {57 var chr = attribute_string.charAt(i);58 59 if ((chr == '"' || chr == "'") && !withInValue)60 withInValue = true;61 else if ((chr == '"' || chr == "'") && withInValue) {62 withInValue = false;63 64 var pos = attributeName.lastIndexOf(' ');65 if (pos != -1)66 attributeName = attributeName.substring(pos+1);67 68 attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();69 70 attributeName = "";71 attributeValue = "";72 } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)73 withInName = true;74 75 if (chr == '=' && withInName)76 withInName = false;77 78 if (withInName)79 attributeName += chr;80 81 if (withInValue)82 attributeValue += chr;83 }84 85 return attributes;86 }87 88 function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interface, value) {89 function getAttrib(elm, name) {90 return elm.getAttribute(name) ? elm.getAttribute(name) : "";91 }92 93 // Handle commands94 switch (command) {95 case "mcewordpressmore":96 var flag = "";97 var template = new Array();98 var inst = tinyMCE.getInstanceById(editor_id);99 var focusElm = inst.getFocusElement();100 var altMore = tinyMCE.getLang('lang_wordpress_more_alt');101 102 // Is selection a image103 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {104 flag = getAttrib(focusElm, 'class');105 106 if (flag != 'mce_plugin_wordpress_more') // Not a wordpress107 return true;108 109 action = "update";110 }111 112 html = ''113 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '114 + ' width="100%" height="10px" '115 + 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';116 tinyMCE.execCommand("mceInsertContent",true,html);117 tinyMCE.selectedInstance.repaint();118 return true;119 case "mcewordpresspage":120 var flag = "";121 var template = new Array();122 var inst = tinyMCE.getInstanceById(editor_id);123 var focusElm = inst.getFocusElement();124 var altPage = tinyMCE.getLang('lang_wordpress_more_alt');125 126 // Is selection a image127 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {128 flag = getAttrib(focusElm, 'name');129 130 if (flag != 'mce_plugin_wordpress_page') // Not a wordpress131 return true;132 133 action = "update";134 }135 136 html = ''137 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '138 + ' width="100%" height="10px" '139 + 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';140 tinyMCE.execCommand("mceInsertContent",true,html);141 tinyMCE.selectedInstance.repaint();142 return true;143 }144 145 // Pass to next handler in chain146 return false;147 }148 149 function TinyMCE_wordpress_cleanup(type, content) {150 switch (type) {151 152 case "insert_to_editor":153 var startPos = 0;154 var altMore = tinyMCE.getLang('lang_wordpress_more_alt');155 var altPage = tinyMCE.getLang('lang_wordpress_page_alt');156 157 // Parse all <!--more--> tags and replace them with images158 while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) {159 // Insert image160 var contentAfter = content.substring(startPos + 11);161 content = content.substring(0, startPos);162 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';163 content += ' width="100%" height="10px" ';164 content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" />';165 content += contentAfter;166 167 startPos++;168 }169 var startPos = 0;170 171 // Parse all <!--page--> tags and replace them with images172 while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {173 // Insert image174 var contentAfter = content.substring(startPos + 15);175 content = content.substring(0, startPos);176 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';177 content += ' width="100%" height="10px" ';178 content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" />';179 content += contentAfter;180 181 startPos++;182 }183 break;184 185 case "get_from_editor":186 // Parse all img tags and replace them with <!--more-->187 var startPos = -1;188 while ((startPos = content.indexOf('<img', startPos+1)) != -1) {189 var endPos = content.indexOf('/>', startPos);190 var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));191 192 if (attribs['class'] == "mce_plugin_wordpress_more") {193 endPos += 2;194 195 var embedHTML = '<!--more-->';196 197 // Insert embed/object chunk198 chunkBefore = content.substring(0, startPos);199 chunkAfter = content.substring(endPos);200 content = chunkBefore + embedHTML + chunkAfter;201 }202 if (attribs['class'] == "mce_plugin_wordpress_page") {203 endPos += 2;204 205 var embedHTML = '<!--nextpage-->';206 207 // Insert embed/object chunk208 chunkBefore = content.substring(0, startPos);209 chunkAfter = content.substring(endPos);210 content = chunkBefore + embedHTML + chunkAfter;211 }212 }213 214 // The Curse of the Trailing <br />215 content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), '');216 217 // The Curse of the Trailing <br />218 content = content.replace(new RegExp('<br ?/?>[ \t]*$', ''), '');219 220 break;221 }222 223 // Pass through to next handler in chain224 return content;225 }226 227 function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {228 function getAttrib(elm, name) {229 return elm.getAttribute(name) ? elm.getAttribute(name) : "";230 }231 232 tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal');233 tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal');234 235 if (node == null)236 return;237 238 do {239 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)240 tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');241 if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)242 tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');243 } while ((node = node.parentNode));244 245 return true;246 } -
trunk/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
r2993 r3136 4 4 wordpress_more_button : 'Split post with More tag', 5 5 wordpress_page_button : 'Split post with Page tag', 6 wordpress_help_button : 'Help', 6 7 wordpress_more_alt : 'More...', 7 wordpress_page_alt : '...page...' 8 wordpress_page_alt : '...page...', 9 wordpress_help_text : 'This is the Rich Editor. It shows you approximately what your entry will look like as you type. Pasting formatted text from other editors is not recommended. One character, less-than (<), is reserved for HTML and must be represented in code: to represent "<" type "<" without the quotes.\n\nThere are several hotkeys you can use instead of clicking on the toolbar. Windows and Linux use Alt+<letter>. Macintosh computers use Ctrl+<letter>.\nb: Bold\ni: Italic\ns: Strikethrough\nl: Unordered list\no: Ordered list\nq: Quote, indent list\nw: Unquote, outdent list\nf: Left align\nc: Center align\nr: Right align\na: Link\ns: Unlink\ni: Image\nt: "More" tag\nu: Undo\ny: Redo\ne: Edit HTML\nh: Help' 8 10 }); -
trunk/wp-includes/js/tinymce/themes/advanced/editor_template.js
r2993 r3136 9 9 <option value="6">6 (24 pt)</option>\ 10 10 <option value="7">7 (36 pt)</option>\ 11 </select>';case "|":case "separator":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';case "spacer":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';case "rowseparator":return '<br />';}return "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=tinyMCE.getAttrib(elm,"color");if(inputColor=='')inputColor=elm.style.color;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=elm.style.backgroundColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;template['width']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"HiliteColor",input_color:inputColor});return true;case "mceColorPicker":if(user_interface){var template=new Array();var inputColor=value['document'].getElementById(value['element_id']).value;template['file']='color_picker.htm';template['width']=220;template['height']=190;template['close_previous']="no";template['width']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height',0);if(typeof(value['store_selection'])=="undefined")value['store_selection']=true;tinyMCE.lastColorPickerValue=value;tinyMCE.openWindow(template,{editor_id:editor_id,mce_store_selection:value['store_selection'],inline:"yes",command:"mceColorPicker",input_color:inputColor});}else{var savedVal=tinyMCE.lastColorPickerValue;var elm=savedVal['document'].getElementById(savedVal['element_id']);elm.value=value;eval('elm.onchange();');}return true;case "mceCodeEditor":var template=new Array();template['file']='source_editor.htm';template['width']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_width",500));template['height']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_height",400));tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"no",inline:"yes"});return true;case "mceCharMap":var template=new Array();template['file']='charmap.htm';template['width']=550+(tinyMCE.isOpera?40:0);template['height']=250;template['width']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceInsertAnchor":var template=new Array();template['file']='anchor.htm';template['width']=320;template['height']=90+(tinyMCE.isNS7?30:0);template['width']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceNewDocument":if(confirm(tinyMCE.getLang('lang_newdocument')))tinyMCE.execInstanceCommand(editor_id,'mceSetContent',false,'');return true;}return false;}function TinyMCE_advanced_getEditorTemplate(settings,editorId){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i<in_array.length;i++){skip=false;for(var j=0;j<remove_array.length;j++){if(in_array[i]==remove_array[j]){skip=true;}}if(!skip){outArray[outArray.length]=in_array[i];}}return outArray;}function addToArray(in_array,add_array){for(var i=0;i<add_array.length;i++){in_array[in_array.length]=add_array[i];}return in_array;}var template=new Array();var deltaHeight=0;var resizing=tinyMCE.getParam("theme_advanced_resizing",false);var path=tinyMCE.getParam("theme_advanced_path",true);var statusbarHTML='<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: '+(path?"block":"none")+'"> </div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: '+(resizing?"block":"none")+'" onmousedown="TinyMCE_advanced_setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';var layoutManager=tinyMCE.getParam("theme_advanced_layout_manager","SimpleLayout");var styleSelectHTML='<option value="">{$lang_theme_style_select}</option>';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i<stylesAr.length;i++){var key,value;key=stylesAr[i].split('=')[0];value=stylesAr[i].split('=')[1];styleSelectHTML+='<option value="'+value+'">'+key+'</option>';}TinyMCE_advanced_autoImportCSSClasses=false;}switch(layoutManager){case "SimpleLayout":var toolbarHTML="";var toolbarLocation=tinyMCE.getParam("theme_advanced_toolbar_location","bottom");var toolbarAlign=tinyMCE.getParam("theme_advanced_toolbar_align","center");var pathLocation=tinyMCE.getParam("theme_advanced_path_location","none");var statusbarLocation=tinyMCE.getParam("theme_advanced_statusbar_location",pathLocation);var defVals={theme_advanced_buttons1:"bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,separator,sub,sup,separator,charmap"}; toolbarHTML+='<a href="#" accesskey="q" title="'+tinyMCE.getLang("lang_toolbar_focus")+'"></a>';for(var i=1;i<100;i++){var def=defVals["theme_advanced_buttons"+i];var buttons=tinyMCE.getParam("theme_advanced_buttons"+i,def==null?'':def,true,',');if(buttons.length==0)break;buttons=removeFromArray(buttons,tinyMCE.getParam("theme_advanced_disable","",true,','));buttons=addToArray(buttons,tinyMCE.getParam("theme_advanced_buttons"+i+"_add","",true,','));buttons=addToArray(tinyMCE.getParam("theme_advanced_buttons"+i+"_add_before","",true,','),buttons);for(var b=0;b<buttons.length;b++)toolbarHTML+=tinyMCE.getControlHTML(buttons[b]);if(buttons.length>0){toolbarHTML+="<br />";deltaHeight-=23;}}toolbarHTML+='<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\''+editorId+'\').getWin().focus();"></a>';template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';if(toolbarLocation=="top"){template['html']+='<tr><td class="mceToolbarTop" align="'+toolbarAlign+'" height="1" nowrap="nowrap">'+toolbarHTML+'</td></tr>';}if(statusbarLocation=="top"){template['html']+='<tr><td class="mceStatusbarTop" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';if(toolbarLocation=="bottom"){template['html']+='<tr><td class="mceToolbarBottom" align="'+toolbarAlign+'" height="1">'+toolbarHTML+'</td></tr>';}if(toolbarLocation=="external"){var bod=document.body;var elm=document.createElement("div");toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCE.settings);toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCELang);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,'style_select_options',styleSelectHTML);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,"editor_id",editorId);toolbarHTML=tinyMCE.applyTemplate(toolbarHTML);elm.className="mceToolbarExternal";elm.id=editorId+"_toolbar";elm.innerHTML='<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';bod.appendChild(elm);deltaHeight=0;tinyMCE.getInstanceById(editorId).toolbarElement=elm;}else{tinyMCE.getInstanceById(editorId).toolbarElement=null;}if(statusbarLocation=="bottom"){template['html']+='<tr><td class="mceStatusbarBottom" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='</tbody></table>';break;case "RowLayout":template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';var containers=tinyMCE.getParam("theme_advanced_containers","",true,",");var defaultContainerCSS=tinyMCE.getParam("theme_advanced_containers_default_class","container");var defaultContainerAlign=tinyMCE.getParam("theme_advanced_containers_default_align","center");for(var i=0;i<containers.length;i++){if(containers[i]=="mceEditor"){template['html']+='<tr><td align="center" class="mceEditor_border">\11 </select>';case "|":case "separator":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';case "spacer":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';case "rowseparator":return '<br />';}return "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=tinyMCE.getAttrib(elm,"color");if(inputColor=='')inputColor=elm.style.color;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=elm.style.backgroundColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;template['width']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"HiliteColor",input_color:inputColor});return true;case "mceColorPicker":if(user_interface){var template=new Array();var inputColor=value['document'].getElementById(value['element_id']).value;template['file']='color_picker.htm';template['width']=220;template['height']=190;template['close_previous']="no";template['width']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height',0);if(typeof(value['store_selection'])=="undefined")value['store_selection']=true;tinyMCE.lastColorPickerValue=value;tinyMCE.openWindow(template,{editor_id:editor_id,mce_store_selection:value['store_selection'],inline:"yes",command:"mceColorPicker",input_color:inputColor});}else{var savedVal=tinyMCE.lastColorPickerValue;var elm=savedVal['document'].getElementById(savedVal['element_id']);elm.value=value;eval('elm.onchange();');}return true;case "mceCodeEditor":var template=new Array();template['file']='source_editor.htm';template['width']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_width",500));template['height']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_height",400));tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"no",inline:"yes"});return true;case "mceCharMap":var template=new Array();template['file']='charmap.htm';template['width']=550+(tinyMCE.isOpera?40:0);template['height']=250;template['width']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceInsertAnchor":var template=new Array();template['file']='anchor.htm';template['width']=320;template['height']=90+(tinyMCE.isNS7?30:0);template['width']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceNewDocument":if(confirm(tinyMCE.getLang('lang_newdocument')))tinyMCE.execInstanceCommand(editor_id,'mceSetContent',false,'');return true;}return false;}function TinyMCE_advanced_getEditorTemplate(settings,editorId){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i<in_array.length;i++){skip=false;for(var j=0;j<remove_array.length;j++){if(in_array[i]==remove_array[j]){skip=true;}}if(!skip){outArray[outArray.length]=in_array[i];}}return outArray;}function addToArray(in_array,add_array){for(var i=0;i<add_array.length;i++){in_array[in_array.length]=add_array[i];}return in_array;}var template=new Array();var deltaHeight=0;var resizing=tinyMCE.getParam("theme_advanced_resizing",false);var path=tinyMCE.getParam("theme_advanced_path",true);var statusbarHTML='<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: '+(path?"block":"none")+'"> </div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: '+(resizing?"block":"none")+'" onmousedown="TinyMCE_advanced_setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';var layoutManager=tinyMCE.getParam("theme_advanced_layout_manager","SimpleLayout");var styleSelectHTML='<option value="">{$lang_theme_style_select}</option>';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i<stylesAr.length;i++){var key,value;key=stylesAr[i].split('=')[0];value=stylesAr[i].split('=')[1];styleSelectHTML+='<option value="'+value+'">'+key+'</option>';}TinyMCE_advanced_autoImportCSSClasses=false;}switch(layoutManager){case "SimpleLayout":var toolbarHTML="";var toolbarLocation=tinyMCE.getParam("theme_advanced_toolbar_location","bottom");var toolbarAlign=tinyMCE.getParam("theme_advanced_toolbar_align","center");var pathLocation=tinyMCE.getParam("theme_advanced_path_location","none");var statusbarLocation=tinyMCE.getParam("theme_advanced_statusbar_location",pathLocation);var defVals={theme_advanced_buttons1:"bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,separator,sub,sup,separator,charmap"};/*toolbarHTML+='<a href="#" accesskey="q" title="'+tinyMCE.getLang("lang_toolbar_focus")+'"></a>';*/for(var i=1;i<100;i++){var def=defVals["theme_advanced_buttons"+i];var buttons=tinyMCE.getParam("theme_advanced_buttons"+i,def==null?'':def,true,',');if(buttons.length==0)break;buttons=removeFromArray(buttons,tinyMCE.getParam("theme_advanced_disable","",true,','));buttons=addToArray(buttons,tinyMCE.getParam("theme_advanced_buttons"+i+"_add","",true,','));buttons=addToArray(tinyMCE.getParam("theme_advanced_buttons"+i+"_add_before","",true,','),buttons);for(var b=0;b<buttons.length;b++)toolbarHTML+=tinyMCE.getControlHTML(buttons[b]);if(buttons.length>0){toolbarHTML+="<br />";deltaHeight-=23;}}toolbarHTML+='<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\''+editorId+'\').getWin().focus();"></a>';template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';if(toolbarLocation=="top"){template['html']+='<tr><td class="mceToolbarTop" align="'+toolbarAlign+'" height="1" nowrap="nowrap">'+toolbarHTML+'</td></tr>';}if(statusbarLocation=="top"){template['html']+='<tr><td class="mceStatusbarTop" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';if(toolbarLocation=="bottom"){template['html']+='<tr><td class="mceToolbarBottom" align="'+toolbarAlign+'" height="1">'+toolbarHTML+'</td></tr>';}if(toolbarLocation=="external"){var bod=document.body;var elm=document.createElement("div");toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCE.settings);toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCELang);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,'style_select_options',styleSelectHTML);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,"editor_id",editorId);toolbarHTML=tinyMCE.applyTemplate(toolbarHTML);elm.className="mceToolbarExternal";elm.id=editorId+"_toolbar";elm.innerHTML='<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';bod.appendChild(elm);deltaHeight=0;tinyMCE.getInstanceById(editorId).toolbarElement=elm;}else{tinyMCE.getInstanceById(editorId).toolbarElement=null;}if(statusbarLocation=="bottom"){template['html']+='<tr><td class="mceStatusbarBottom" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='</tbody></table>';break;case "RowLayout":template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';var containers=tinyMCE.getParam("theme_advanced_containers","",true,",");var defaultContainerCSS=tinyMCE.getParam("theme_advanced_containers_default_class","container");var defaultContainerAlign=tinyMCE.getParam("theme_advanced_containers_default_align","center");for(var i=0;i<containers.length;i++){if(containers[i]=="mceEditor"){template['html']+='<tr><td align="center" class="mceEditor_border">\ 12 12 <span id="{$editor_id}"></span>\ 13 13 </td></tr>';}else if(containers[i]=="mceElementpath"||containers[i]=="mceStatusbar"){var pathClass="mceStatusbar";if(i==containers.length-1){pathClass="mceStatusbarBottom";}else if(i==0){pathClass="mceStatusbar";}else{deltaHeight-=2;}template['html']+='<tr><td class="'+pathClass+'" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=22;}else{var curContainer=tinyMCE.getParam("theme_advanced_container_"+containers[i],"",true,',');var curContainerHTML="";var curAlign=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align",defaultContainerAlign);var curCSS=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class",defaultContainerCSS);for(var j=0;j<curContainer.length;j++){curContainerHTML+=tinyMCE.getControlHTML(curContainer[j]);}if(curContainer.length>0){curContainerHTML+="<br />";deltaHeight-=23;}template['html']+='<tr><td class="'+curCSS+'" align="'+curAlign+'" height="1">'+curContainerHTML+'</td></tr>';}}template['html']+='</tbody></table>';break;case "BorderLayout":break;case "CustomLayout":var customLayout=tinyMCE.getParam("theme_advanced_custom_layout","");if(customLayout!=""&&eval("typeof("+customLayout+")")!="undefined"){template=eval(customLayout+"(template);");}break;default:alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');break;}template['html']+='<div id="{$editor_id}_resize_box" class="mceResizeBox"></div>';template['html']=tinyMCE.replaceVar(template['html'],'style_select_options',styleSelectHTML);template['delta_width']=0;template['delta_height']=deltaHeight;return template;}function TinyMCE_advanced_setResizing(e,editor_id,state){e=typeof(e)=="undefined"?window.event:e;var resizer=TinyMCE_advanced_resizer;var editorContainer=document.getElementById(editor_id+'_parent');var editorArea=document.getElementById(editor_id+'_parent').firstChild;var resizeBox=document.getElementById(editor_id+'_resize_box');var inst=tinyMCE.getInstanceById(editor_id);if(state){var width=editorArea.clientWidth;var height=editorArea.clientHeight;resizeBox.style.width=width+"px";resizeBox.style.height=height+"px";resizer.iframeWidth=inst.iframeElement.clientWidth;resizer.iframeHeight=inst.iframeElement.clientHeight;editorArea.style.display="none";resizeBox.style.display="block";if(!resizer.eventHandlers){if(tinyMCE.isMSIE)tinyMCE.addEvent(document,"mousemove",TinyMCE_advanced_resizeEventHandler);else tinyMCE.addEvent(window,"mousemove",TinyMCE_advanced_resizeEventHandler);tinyMCE.addEvent(document,"mouseup",TinyMCE_advanced_resizeEventHandler);resizer.eventHandlers=true;}resizer.resizing=true;resizer.downX=e.screenX;resizer.downY=e.screenY;resizer.width=parseInt(resizeBox.style.width);resizer.height=parseInt(resizeBox.style.height);resizer.editorId=editor_id;resizer.resizeBox=resizeBox;resizer.horizontal=tinyMCE.getParam("theme_advanced_resize_horizontal",true);}else{resizer.resizing=false;resizeBox.style.display="none";editorArea.style.display=tinyMCE.isMSIE?"block":"table";tinyMCE.execCommand('mceResetDesignMode');}}function TinyMCE_advanced_initInstance(inst){if(tinyMCE.getParam("theme_advanced_resizing",false)){if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var w=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_width");var h=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_height");TinyMCE_advanced_resizeTo(inst,w,h,tinyMCE.getParam("theme_advanced_resize_horizontal",true));}}}function TinyMCE_advanced_setCookie(name,value,expires,path,domain,secure){var curCookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+escape(path):"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");document.cookie=curCookie;}function TinyMCE_advanced_getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else begin+=2;var end=document.cookie.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin+prefix.length,end));}function TinyMCE_advanced_resizeTo(inst,w,h,set_w){var editorContainer=document.getElementById(inst.editorId+'_parent');var tableElm=editorContainer.firstChild;var iframe=inst.iframeElement;if(w==null||w=="null"){set_w=false;w=0;}if(h==null||h=="null")return;w=parseInt(w);h=parseInt(h);if(tinyMCE.isGecko){w+=2;h+=2;}var dx=w-tableElm.clientWidth;var dy=h-tableElm.clientHeight;if(set_w)tableElm.style.width=w+"px";tableElm.style.height=h+"px";iw=iframe.clientWidth+dx;ih=iframe.clientHeight+dy;if(tinyMCE.isGecko){iw-=2;ih-=2;}if(set_w)iframe.style.width=iw+"px";iframe.style.height=ih+"px";if(set_w){var tableBodyElm=tableElm.firstChild;var minIframeWidth=tableBodyElm.scrollWidth;if(inst.iframeElement.clientWidth<minIframeWidth){dx=minIframeWidth-inst.iframeElement.clientWidth;inst.iframeElement.style.width=(iw+dx)+"px";}}}function TinyMCE_advanced_resizeEventHandler(e){var resizer=TinyMCE_advanced_resizer;if(!resizer.resizing)return;e=typeof(e)=="undefined"?window.event:e;var dx=e.screenX-resizer.downX;var dy=e.screenY-resizer.downY;var resizeBox=resizer.resizeBox;var editorId=resizer.editorId;switch(e.type){case "mousemove":if(resizer.horizontal)resizeBox.style.width=(resizer.width+dx)+"px";resizeBox.style.height=(resizer.height+dy)+"px";break;case "mouseup":TinyMCE_advanced_setResizing(e,editorId,false);TinyMCE_advanced_resizeTo(tinyMCE.getInstanceById(editorId),resizer.width+dx,resizer.height+dy,resizer.horizontal);if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var expires=new Date();expires.setTime(expires.getTime()+3600000*24*30);TinyMCE_advanced_setCookie("TinyMCE_"+editorId+"_width",""+(resizer.horizontal?resizer.width+dx:""),expires);TinyMCE_advanced_setCookie("TinyMCE_"+editorId+"_height",""+(resizer.height+dy),expires);}break;}}function TinyMCE_advanced_getInsertLinkTemplate(){var template=new Array();template['file']='link.htm';template['width']=330;template['height']=170;template['width']+=tinyMCE.getLang('lang_insert_link_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_link_delta_height',0);return template;};function TinyMCE_advanced_getInsertImageTemplate(){var template=new Array();template['file']='image.htm?src={$src}';template['width']=340;template['height']=245;template['width']+=tinyMCE.getLang('lang_insert_image_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_image_delta_height',0);return template;};function TinyMCE_advanced_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection,setup_content){function selectByValue(select_elm,value,first_index){first_index=typeof(first_index)=="undefined"?false:true;if(select_elm){for(var i=0;i<select_elm.options.length;i++){var ov=""+select_elm.options[i].value;if(first_index&&ov.toLowerCase().indexOf(value.toLowerCase())==0){select_elm.selectedIndex=i;return true;}if(ov==value){select_elm.selectedIndex=i;return true;}}}return false;};function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";};if(node==null){return;}var pathElm=document.getElementById(editor_id+"_path");var inst=tinyMCE.getInstanceById(editor_id);var doc=inst.getDoc();if(pathElm){var parentNode=node;var path=new Array();while(parentNode!=null){if(parentNode.nodeName.toUpperCase()=="BODY"){break;}if(parentNode.nodeType==1){path[path.length]=parentNode;}parentNode=parentNode.parentNode;}var html="";for(var i=path.length-1;i>=0;i--){var nodeName=path[i].nodeName.toLowerCase();var nodeData="";if(nodeName=="b"){nodeName="strong";}if(nodeName=="i"){nodeName="em";}if(nodeName=="span"){var cn=tinyMCE.getAttrib(path[i],"class");if(cn!=""&&cn.indexOf('mceItem')==-1)nodeData+="class: "+cn+" ";var st=tinyMCE.getAttrib(path[i],"style");if(st!=""){st=tinyMCE.serializeStyle(tinyMCE.parseStyle(st));nodeData+="style: "+st+" ";}}if(nodeName=="font"){if(tinyMCE.getParam("convert_fonts_to_spans"))nodeName="span";var face=tinyMCE.getAttrib(path[i],"face");if(face!="")nodeData+="font: "+face+" ";var size=tinyMCE.getAttrib(path[i],"size");if(size!="")nodeData+="size: "+size+" ";var color=tinyMCE.getAttrib(path[i],"color");if(color!="")nodeData+="color: "+color+" ";}if(getAttrib(path[i],'id')!=""){nodeData+="id: "+path[i].getAttribute('id')+" ";}var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1)nodeData+="class: "+className+" ";if(getAttrib(path[i],'src')!=""){nodeData+="src: "+path[i].getAttribute('src')+" ";}if(getAttrib(path[i],'href')!=""){nodeData+="href: "+path[i].getAttribute('href')+" ";}if(nodeName=="img"&&tinyMCE.getAttrib(path[i],"class").indexOf('mceItemFlash')!=-1){nodeName="flash";nodeData="src: "+path[i].getAttribute('title');}if(nodeName=="a"&&(anchor=tinyMCE.getAttrib(path[i],"name"))!=""){nodeName="a";nodeName+="#"+anchor;nodeData="";}if(getAttrib(path[i],'name').indexOf("mce_")!=0){var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1){nodeName+="."+className;}}var cmd='tinyMCE.execInstanceCommand(\''+editor_id+'\',\'mceSelectNodeDepth\',false,\''+i+'\');';html+='<a title="'+nodeData+'" href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" target="_self" class="mcePathItem">'+nodeName+'</a>';if(i>0){html+=" » ";}}pathElm.innerHTML='<a href="#" accesskey="x"></a>'+tinyMCE.getLang('lang_theme_path')+": "+html+' ';}tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_link','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_unlink','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_image','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonNormal');if(node.nodeName=="A"&&tinyMCE.getAttrib(node,"class").indexOf('mceItemAnchor')!=-1)tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonSelected');var anchorLink=tinyMCE.getParentElement(node,"a","href");if(anchorLink||any_selection){tinyMCE.switchClassSticky(editor_id+'_link',anchorLink?'mceButtonSelected':'mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_unlink',anchorLink?'mceButtonSelected':'mceButtonNormal',false);}tinyMCE.switchClassSticky(editor_id+'_visualaid',visual_aid?'mceButtonSelected':'mceButtonNormal',false);if(undo_levels!=-1){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonDisabled',true);}if(tinyMCE.getParentElement(node,"li,blockquote")){tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index<undo_levels-1&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index>0&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonNormal',false);}var selectElm=document.getElementById(editor_id+"_styleSelect");if(selectElm){TinyMCE_advanced_setupCSSClasses(editor_id);classNode=node;breakOut=false;var index=0;do{if(classNode&&classNode.className){for(var i=0;i<selectElm.options.length;i++){if(selectElm.options[i].value==classNode.className){index=i;breakOut=true;break;}}}}while(!breakOut&&classNode!=null&&(classNode=classNode.parentNode)!=null);selectElm.selectedIndex=index;}var selectElm=document.getElementById(editor_id+"_formatSelect");if(selectElm){var elm=tinyMCE.getParentElement(node,"p,div,h1,h2,h3,h4,h5,h6,pre,address");if(elm){selectByValue(selectElm,"<"+elm.nodeName.toLowerCase()+">");}else{selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontNameSelect");if(selectElm){if(!tinyMCE.isSafari&&!(tinyMCE.isMSIE&&!tinyMCE.isOpera)){var face=doc.queryCommandValue('FontName');face=face==null||face==""?"":face;selectByValue(selectElm,face,face!="");}else{var elm=tinyMCE.getParentElement(node,"font","face");if(elm){var family=tinyMCE.getAttrib(elm,"face");if(family=='')family=''+elm.style.fontFamily;if(!selectByValue(selectElm,family,family!=""))selectByValue(selectElm,"");}else selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontSizeSelect");if(selectElm){if(!tinyMCE.isSafari&&!tinyMCE.isOpera){var size=doc.queryCommandValue('FontSize');selectByValue(selectElm,size==null||size==""?"0":size);}else{var elm=tinyMCE.getParentElement(node,"font","size");if(elm){var size=tinyMCE.getAttrib(elm,"size");if(size==''){var sizes=new Array('','8px','10px','12px','14px','18px','24px','36px');size=''+elm.style.fontSize;for(var i=0;i<sizes.length;i++){if((''+sizes[i])==size){size=i;break;}}}if(!selectByValue(selectElm,size))selectByValue(selectElm,"");}else selectByValue(selectElm,"0");}}alignNode=node;breakOut=false;do{if(!alignNode.getAttribute||!alignNode.getAttribute('align')){continue;}switch(alignNode.getAttribute('align').toLowerCase()){case "left":tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonSelected');breakOut=true;break;case "right":tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonSelected');breakOut=true;break;case "middle":case "center":tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');breakOut=true;break;case "justify":tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonSelected');breakOut=true;break;}}while(!breakOut&&(alignNode=alignNode.parentNode)!=null);var div=tinyMCE.getParentElement(node,"div");if(div&&div.style.textAlign=="center")tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');if(!setup_content){var ar=new Array("Bold","_bold","Italic","_italic","Strikethrough","_strikethrough","superscript","_sup","subscript","_sub");for(var i=0;i<ar.length;i+=2){if(doc.queryCommandState(ar[i]))tinyMCE.switchClassSticky(editor_id+ar[i+1],'mceButtonSelected');}if(doc.queryCommandState("Underline")&&(node.parentNode==null||node.parentNode.nodeName!="A")){tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonSelected');}}do{switch(node.nodeName){case "UL":tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonSelected');break;case "OL":tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonSelected');break;case "HR":tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonSelected');break;case "IMG":if(getAttrib(node,'name').indexOf('mce_')!=0){tinyMCE.switchClassSticky(editor_id+'_image','mceButtonSelected');}break;}}while((node=node.parentNode)!=null);};function TinyMCE_advanced_setupCSSClasses(editor_id){if(!TinyMCE_advanced_autoImportCSSClasses){return;}var selectElm=document.getElementById(editor_id+'_styleSelect');if(selectElm&&selectElm.getAttribute('cssImported')!='true'){var csses=tinyMCE.getCSSClasses(editor_id);if(csses&&selectElm){for(var i=0;i<csses.length;i++){selectElm.options[selectElm.length]=new Option(csses[i],csses[i]);}}if(csses!=null&&csses.length>0){selectElm.setAttribute('cssImported','true');}}}; -
trunk/wp-includes/js/tinymce/themes/advanced/editor_template_src.js
r2993 r3136 361 361 362 362 // Add accessibility control 363 toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"></a>';363 //toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"></a>'; 364 364 365 365 // Render rows -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
r3062 r3136 6 6 // Fixes some charcode issues 7 7 function fixContent(html) { 8 // WP 9 return html; 10 8 11 html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1'); 9 12 html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n'); -
trunk/wp-includes/js/tinymce/tiny_mce.js
r2993 r3136 9 9 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<elements.length;i++){if(elements[i].src&&(elements[i].src.indexOf("tiny_mce.js")!=-1||elements[i].src.indexOf("tiny_mce_src.js")!=-1||elements[i].src.indexOf("tiny_mce_gzip.php")!=-1)){var src=elements[i].src;tinyMCE.srcMode=(src.indexOf('_src')!=-1)?'_src':'';src=src.substring(0,src.lastIndexOf('/'));tinyMCE.baseURL=src;break;}}}this.documentBasePath=document.location.href;if(this.documentBasePath.indexOf('?')!=-1)this.documentBasePath=this.documentBasePath.substring(0,this.documentBasePath.indexOf('?'));this.documentURL=this.documentBasePath;this.documentBasePath=this.documentBasePath.substring(0,this.documentBasePath.lastIndexOf('/'));if(tinyMCE.baseURL.indexOf('://')==-1&&tinyMCE.baseURL.charAt(0)!='/'){tinyMCE.baseURL=this.documentBasePath+"/"+tinyMCE.baseURL;}this.defParam("mode","none");this.defParam("theme","advanced");this.defParam("plugins","",true);this.defParam("language","en");this.defParam("docs_language",this.settings['language']);this.defParam("elements","");this.defParam("textarea_trigger","mce_editable");this.defParam("editor_selector","");this.defParam("editor_deselector","mceNoEditor");this.defParam("valid_elements","+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/b[class|style],-em/i[class|style],-strike[class|style],-u[class|style],+p[style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border=0|alt|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[style|dir|class|align],-h2[style|dir|class|align],-h3[style|dir|class|align],-h4[style|dir|class|align],-h5[style|dir|class|align],-h6[style|dir|class|align],hr[class|style],font[face|size|style|id|class|dir|color]");this.defParam("extended_valid_elements","");this.defParam("invalid_elements","");this.defParam("encoding","");this.defParam("urlconverter_callback",tinyMCE.getParam("urlconvertor_callback","TinyMCE.prototype.convertURL"));this.defParam("save_callback","");this.defParam("debug",false);this.defParam("force_br_newlines",false);this.defParam("force_p_newlines",true);this.defParam("add_form_submit_trigger",true);this.defParam("relative_urls",true);this.defParam("remove_script_host",true);this.defParam("focus_alert",true);this.defParam("document_base_url",this.documentURL);this.defParam("visual",true);this.defParam("visual_table_class","mceVisualAid");this.defParam("setupcontent_callback","");this.defParam("fix_content_duplication",true);this.defParam("custom_undo_redo",true);this.defParam("custom_undo_redo_levels",-1);this.defParam("custom_undo_redo_keyboard_shortcuts",true);this.defParam("verify_css_classes",false);this.defParam("verify_html",true);this.defParam("apply_source_formatting",false);this.defParam("directionality","ltr");this.defParam("cleanup_on_startup",false);this.defParam("inline_styles",false);this.defParam("convert_newlines_to_brs",false);this.defParam("auto_reset_designmode",true);this.defParam("entities","160,nbsp,38,amp,34,quot,162,cent,8364,euro,163,pound,165,yen,169,copy,174,reg,8482,trade,8240,permil,181,micro,183,middot,8226,bull,8230,hellip,8242,prime,8243,Prime,167,sect,182,para,223,szlig,8249,lsaquo,8250,rsaquo,171,laquo,187,raquo,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8218,sbquo,8222,bdquo,60,lt,62,gt,8804,le,8805,ge,8211,ndash,8212,mdash,175,macr,8254,oline,164,curren,166,brvbar,168,uml,161,iexcl,191,iquest,710,circ,732,tilde,176,deg,8722,minus,177,plusmn,247,divide,8260,frasl,215,times,185,sup1,178,sup2,179,sup3,188,frac14,189,frac12,190,frac34,402,fnof,8747,int,8721,sum,8734,infin,8730,radic,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8712,isin,8713,notin,8715,ni,8719,prod,8743,and,8744,or,172,not,8745,cap,8746,cup,8706,part,8704,forall,8707,exist,8709,empty,8711,nabla,8727,lowast,8733,prop,8736,ang,180,acute,184,cedil,170,ordf,186,ordm,8224,dagger,8225,Dagger,192,Agrave,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,202,Ecirc,203,Euml,204,Igrave,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,212,Ocirc,213,Otilde,214,Ouml,216,Oslash,338,OElig,217,Ugrave,219,Ucirc,220,Uuml,376,Yuml,222,THORN,224,agrave,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,234,ecirc,235,euml,236,igrave,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,244,ocirc,245,otilde,246,ouml,248,oslash,339,oelig,249,ugrave,251,ucirc,252,uuml,254,thorn,255,yuml,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,8501,alefsym,982,piv,8476,real,977,thetasym,978,upsih,8472,weierp,8465,image,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8756,there4,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,173,shy,233,eacute,237,iacute,243,oacute,250,uacute,193,Aacute,225,aacute,201,Eacute,205,Iacute,211,Oacute,218,Uacute,221,Yacute,253,yacute");this.defParam("entity_encoding","named");this.defParam("cleanup_callback","");this.defParam("add_unload_trigger",true);this.defParam("ask",false);this.defParam("nowrap",false);this.defParam("auto_resize",false);this.defParam("auto_focus",false);this.defParam("cleanup",true);this.defParam("remove_linebreaks",true);this.defParam("button_tile_map",false);this.defParam("submit_patch",true);this.defParam("browsers","msie,safari,gecko,opera");this.defParam("dialog_type","window");this.defParam("accessibility_warnings",true);this.defParam("merge_styles_invalid_parents","");this.defParam("force_hex_style_colors",true);this.defParam("trim_span_elements",true);this.defParam("convert_fonts_to_spans",false);this.defParam("doctype",'<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');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<themePlugins.length;i++)this.loadScript(tinyMCE.baseURL+'/plugins/'+themePlugins[i]+'/editor_plugin'+tinyMCE.srcMode+'.js');}settings['index']=this.configs.length;this.configs[this.configs.length]=settings;};TinyMCE.prototype.loadScript=function(url){for(var i=0;i<this.loadedFiles.length;i++){if(this.loadedFiles[i]==url)return;}document.write('<sc'+'ript language="javascript" type="text/javascript" src="'+url+'"></script>');this.loadedFiles[this.loadedFiles.length]=url;};TinyMCE.prototype.loadCSS=function(url){for(var i=0;i<this.loadedFiles.length;i++){if(this.loadedFiles[i]==url)return;}document.write('<link href="'+url+'" rel="stylesheet" type="text/css" />');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<evs.length;y++){var elms=node.getElementsByTagName(evs[y]);for(var i=0;i<elms.length;i++){var event="";for(var x=0;x<events.length;x++){if((event=tinyMCE.getAttrib(elms[i],events[x]))!=''){event=tinyMCE.cleanupEventStr(""+event);if(!state)event="return true;"+event;else event=event.replace(/^return true;/gi,'');elms[i].removeAttribute(events[x]);elms[i].setAttribute(events[x],event);}}}}};TinyMCE.prototype.resetForm=function(form_index){var formObj=document.forms[form_index];for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(!tinyMCE.isInstance(inst))continue;inst.switchSettings();for(var i=0;i<formObj.elements.length;i++){if(inst.formTargetElementId==formObj.elements[i].name){inst.getBody().innerHTML=formObj.elements[i].value;return;}}}};TinyMCE.prototype.execInstanceCommand=function(editor_id,command,user_interface,value,focus){var inst=tinyMCE.getInstanceById(editor_id);if(inst){if(typeof(focus)=="undefined")focus=true;if(focus)inst.contentWindow.focus();inst.autoResetDesignMode();this.selectedElement=inst.getFocusElement();this.selectedInstance=inst;tinyMCE.execCommand(command,user_interface,value);if(tinyMCE.isMSIE&&window.event!=null)tinyMCE.cancelEvent(window.event);}};TinyMCE.prototype.execCommand=function(command,user_interface,value){user_interface=user_interface?user_interface:false;value=value?value:null;if(tinyMCE.selectedInstance)tinyMCE.selectedInstance.switchSettings();switch(command){case 'mceHelp':var template=new Array();template['file']='about.htm';template['width']=480;template['height']=380;tinyMCE.openWindow(template,{tinymce_version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion,tinymce_releasedate:tinyMCE.releaseDate,inline:"yes"});return;case 'mceFocus':var inst=tinyMCE.getInstanceById(value);if(inst)inst.contentWindow.focus();return;case "mceAddControl":case "mceAddEditor":tinyMCE.addMCEControl(tinyMCE._getElementById(value),value);return;case "mceAddFrameControl":tinyMCE.addMCEControl(tinyMCE._getElementById(value),value['element'],value['document']);return;case "mceRemoveControl":case "mceRemoveEditor":tinyMCE.removeMCEControl(value);return;case "mceResetDesignMode":if(!tinyMCE.isMSIE){for(var n in tinyMCE.instances){if(!tinyMCE.isInstance(tinyMCE.instances[n]))continue;try{tinyMCE.instances[n].getDoc().designMode="on";}catch(e){}}}return;}if(this.selectedInstance){this.selectedInstance.execCommand(command,user_interface,value);}else if(tinyMCE.settings['focus_alert'])alert(tinyMCELang['lang_focus_alert']);};TinyMCE.prototype.eventPatch=function(editor_id){if(typeof(tinyMCE)=="undefined")return true;for(var i=0;i<document.frames.length;i++){try{if(document.frames[i].event){var event=document.frames[i].event;if(!event.target)event.target=event.srcElement;TinyMCE.prototype.handleEvent(event);return;}}catch(ex){}}};TinyMCE.prototype.unloadHandler=function(){tinyMCE.triggerSave(true,true);};TinyMCE.prototype.addEventHandlers=function(editor_id){if(tinyMCE.isMSIE){var doc=document.frames[editor_id].document;tinyMCE.addEvent(doc,"keypress",TinyMCE.prototype.eventPatch);tinyMCE.addEvent(doc,"keyup",TinyMCE.prototype.eventPatch);tinyMCE.addEvent(doc,"keydown",TinyMCE.prototype.eventPatch);tinyMCE.addEvent(doc,"mouseup",TinyMCE.prototype.eventPatch);tinyMCE.addEvent(doc,"click",TinyMCE.prototype.eventPatch);}else{var inst=tinyMCE.instances[editor_id];var doc=inst.getDoc();inst.switchSettings();tinyMCE.addEvent(doc,"keypress",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"keydown",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"keyup",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"click",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"mouseup",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"mousedown",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"focus",tinyMCE.handleEvent);tinyMCE.addEvent(doc,"blur",tinyMCE.handleEvent);eval('try { doc.designMode = "On"; } catch(e) {}');}};TinyMCE.prototype._createIFrame=function(replace_element){var iframe=document.createElement("iframe");var id=replace_element.getAttribute("id");var aw,ah;aw=""+tinyMCE.settings['area_width'];ah=""+tinyMCE.settings['area_height'];if(aw.indexOf('%')==-1){aw=parseInt(aw);aw=aw<0?300:aw;aw=aw+"px";}if(ah.indexOf('%')==-1){ah=parseInt(ah);ah=ah<0?240:ah;ah=ah+"px";}iframe.setAttribute("id",id);iframe.setAttribute("border","0");iframe.setAttribute("frameBorder","0");iframe.setAttribute("marginWidth","0");iframe.setAttribute("marginHeight","0");iframe.setAttribute("leftMargin","0");iframe.setAttribute("topMargin","0");iframe.setAttribute("width",aw);iframe.setAttribute("height",ah);iframe.setAttribute("allowtransparency","true");if(tinyMCE.settings["auto_resize"])iframe.setAttribute("scrolling","no");if(tinyMCE.isMSIE&&!tinyMCE.isOpera)iframe.setAttribute("src",this.settings['default_document']);iframe.style.width=aw;iframe.style.height=ah;if(tinyMCE.isMSIE&&!tinyMCE.isOpera)replace_element.outerHTML=iframe.outerHTML;else replace_element.parentNode.replaceChild(iframe,replace_element);if(tinyMCE.isMSIE)return window.frames[id];else return iframe;};TinyMCE.prototype.setupContent=function(editor_id){var inst=tinyMCE.instances[editor_id];var doc=inst.getDoc();var head=doc.getElementsByTagName('head').item(0);var content=inst.startContent;tinyMCE.operaOpacityCounter=100*tinyMCE.idCounter;inst.switchSettings();if(!tinyMCE.isMSIE&&doc.title!="blank_page"){try{doc.location.href=tinyMCE.baseURL+"/blank.htm";}catch(ex){}window.setTimeout("tinyMCE.setupContent('"+editor_id+"');",1000);return;}if(!head){window.setTimeout("tinyMCE.setupContent('"+editor_id+"');",10);return;}tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/themes/"+inst.settings['theme']+"/css/editor_content.css");tinyMCE.importCSS(inst.getDoc(),inst.settings['content_css']);tinyMCE.executeCallback('init_instance_callback','_initInstance',0,inst);if(tinyMCE.getParam("convert_fonts_to_spans"))inst.getDoc().body.setAttribute('id','mceSpanFonts');if(tinyMCE.settings['nowrap'])doc.body.style.whiteSpace="nowrap";doc.body.dir=this.settings['directionality'];doc.editorId=editor_id;if(!tinyMCE.isMSIE)doc.documentElement.editorId=editor_id;var base=doc.createElement("base");base.setAttribute('href',tinyMCE.settings['base_href']);head.appendChild(base);if(tinyMCE.settings['convert_newlines_to_brs']){content=tinyMCE.regexpReplace(content,"\r\n","<br />","gi");content=tinyMCE.regexpReplace(content,"\r","<br />","gi");content=tinyMCE.regexpReplace(content,"\n","<br />","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,"<strong","<b","gi");content=tinyMCE.regexpReplace(content,"<em(/?)>","<i$1>","gi");content=tinyMCE.regexpReplace(content,"<em ","<i ","gi");content=tinyMCE.regexpReplace(content,"</strong>","</b>","gi");content=tinyMCE.regexpReplace(content,"</em>","</i>","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(/<p\/>/gi,'<p> </p>');s=s.replace(/<p>\s*<\/p>/gi,'<p> </p>');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><hr\/><\/p>/gi,"<hr>");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){for(var i=0;i<form_obj.elements.length;i++){var elementId=form_obj.elements[i].name?form_obj.elements[i].name:form_obj.elements[i].id;if(elementId.indexOf('mce_editor_')==0)form_obj.elements[i].disabled=true;}};TinyMCE.prototype.accessibleEventHandler=function(e){var win=this._win;e=tinyMCE.isMSIE?win.event:e;var elm=tinyMCE.isMSIE?e.srcElement:e.target;if(elm.nodeName=="SELECT"&&!elm.oldonchange){elm.oldonchange=elm.onchange;elm.onchange=null;}if(e.keyCode==13||e.keyCode==32){elm.onchange=elm.oldonchange;elm.onchange();elm.oldonchange=null;tinyMCE.cancelEvent(e);}};TinyMCE.prototype.addSelectAccessibility=function(e,select,win){if(!select._isAccessible){select.onkeydown=tinyMCE.accessibleEventHandler;select._isAccessible=true;select._win=win;}};TinyMCE.prototype.handleEvent=function(e){if(typeof(tinyMCE)=="undefined")return true;switch(e.type){case "blur":if(tinyMCE.selectedInstance)tinyMCE.selectedInstance.execCommand('mceEndTyping');return;case "submit":tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE?window.event.srcElement:e.target);tinyMCE.triggerSave();tinyMCE.isNotDirty=true;return;case "reset":var formObj=tinyMCE.isMSIE?window.event.srcElement:e.target;for(var i=0;i<document.forms.length;i++){if(document.forms[i]==formObj)window.setTimeout('tinyMCE.resetForm('+i+');',10);}return;case "keypress":if(e.target.editorId){tinyMCE.selectedInstance=tinyMCE.instances[e.target.editorId];}else{if(e.target.ownerDocument.editorId)tinyMCE.selectedInstance=tinyMCE.instances[e.target.ownerDocument.editorId];}if(tinyMCE.selectedInstance)tinyMCE.selectedInstance.switchSettings();if(tinyMCE.isGecko&&tinyMCE.settings['force_p_newlines']&&e.keyCode==13&&!e.shiftKey){if(tinyMCE.selectedInstance._insertPara(e)){tinyMCE.execCommand("mceAddUndoLevel");tinyMCE.cancelEvent(e);return false;}}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;}}if(tinyMCE.isGecko&&(e.ctrlKey&&!e.altKey)&&tinyMCE.settings['custom_undo_redo']){if(tinyMCE.settings['custom_undo_redo_keyboard_shortcuts']){if(e.charCode==122){tinyMCE.selectedInstance.execCommand("Undo");e.preventDefault();return false;}if(e.charCode==121){tinyMCE.selectedInstance.execCommand("Redo");e.preventDefault();return false;}}if(e.charCode==98){tinyMCE.selectedInstance.execCommand("Bold");e.preventDefault();return false;}if(e.charCode==105){tinyMCE.selectedInstance.execCommand("Italic");e.preventDefault();return false;}if(e.charCode==117){tinyMCE.selectedInstance.execCommand("Underline");e.preventDefault();return false;}}if(tinyMCE.isMSIE&&tinyMCE.settings['force_br_newlines']&&e.keyCode==13){if(e.target.editorId)tinyMCE.selectedInstance=tinyMCE.instances[e.target.editorId];if(tinyMCE.selectedInstance){var sel=tinyMCE.selectedInstance.getDoc().selection;var rng=sel.createRange();if(tinyMCE.getParentElement(rng.parentElement(),"li")!=null)return false;e.returnValue=false;e.cancelBubble=true;rng.pasteHTML("<br />");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<keys.length;i++){if(keys[i]==e.keyCode){posKey=true;break;}}if(tinyMCE.isMSIE&&tinyMCE.settings['custom_undo_redo']){var keys=new Array(8,46);for(var i=0;i<keys.length;i++){if(keys[i]==e.keyCode){if(e.type=="keyup")tinyMCE.triggerNodeChange(false);}}if(tinyMCE.settings['custom_undo_redo_keyboard_shortcuts']){if(e.keyCode==90&&(e.ctrlKey&&!e.altKey)&&e.type=="keydown"){tinyMCE.selectedInstance.execCommand("Undo");tinyMCE.triggerNodeChange(false);}if(e.keyCode==89&&(e.ctrlKey&&!e.altKey)&&e.type=="keydown"){tinyMCE.selectedInstance.execCommand("Redo");tinyMCE.triggerNodeChange(false);}if((e.keyCode==90||e.keyCode==89)&&(e.ctrlKey&&!e.altKey)){e.returnValue=false;e.cancelBubble=true;return false;}}}if(!posKey&&e.type=="keyup")tinyMCE.execCommand("mceStartTyping");if(e.type=="keyup"&&(posKey||e.ctrlKey))tinyMCE.execCommand("mceEndTyping");if(posKey&&e.type=="keyup")tinyMCE.triggerNodeChange(false);if(tinyMCE.isMSIE&&e.ctrlKey)window.setTimeout('tinyMCE.triggerNodeChange(false);',1);break;case "mousedown":case "mouseup":case "click":case "focus":if(tinyMCE.selectedInstance)tinyMCE.selectedInstance.switchSettings();var targetBody=tinyMCE.getParentElement(e.target,"body");for(var instanceName in tinyMCE.instances){if(!tinyMCE.isInstance(tinyMCE.instances[instanceName]))continue;var inst=tinyMCE.instances[instanceName];inst.autoResetDesignMode();if(inst.getBody()==targetBody){tinyMCE.selectedInstance=inst;tinyMCE.selectedElement=e.target;tinyMCE.linkElement=tinyMCE.getParentElement(tinyMCE.selectedElement,"a");tinyMCE.imgElement=tinyMCE.getParentElement(tinyMCE.selectedElement,"img");break;}}if(tinyMCE.isSafari){tinyMCE.selectedInstance.lastSafariSelection=tinyMCE.selectedInstance.getBookmark();tinyMCE.selectedInstance.lastSafariSelectedElement=tinyMCE.selectedElement;var lnk=tinyMCE.getParentElement(tinyMCE.selectedElement,"a");if(lnk&&e.type=="mousedown"){lnk.setAttribute("mce_real_href",lnk.getAttribute("href"));lnk.setAttribute("href","javascript:void(0);");}if(lnk&&e.type=="click"){window.setTimeout(function(){lnk.setAttribute("href",lnk.getAttribute("mce_real_href"));lnk.removeAttribute("mce_real_href");},10);}}if(e.type!="focus")tinyMCE.selectedNode=null;tinyMCE.triggerNodeChange(false);tinyMCE.execCommand("mceEndTyping");if(e.type=="mouseup")tinyMCE.execCommand("mceAddUndoLevel");if(!tinyMCE.selectedInstance&&e.target.editorId)tinyMCE.selectedInstance=tinyMCE.instances[e.target.editorId];if(tinyMCE.isGecko&&tinyMCE.settings['document_base_url']!=""+document.location.href)window.setTimeout('tinyMCE.getInstanceById("'+inst.editorId+'").fixBrokenURLs();',10);return false;break;}};TinyMCE.prototype.switchClass=function(element,class_name,lock_state){var lockChanged=false;if(typeof(lock_state)!="undefined"&&element!=null){element.classLock=lock_state;lockChanged=true;}if(element!=null&&(lockChanged||!element.classLock)){element.oldClassName=element.className;element.className=class_name;}};TinyMCE.prototype.restoreAndSwitchClass=function(element,class_name){if(element!=null&&!element.classLock){this.restoreClass(element);this.switchClass(element,class_name);}};TinyMCE.prototype.switchClassSticky=function(element_name,class_name,lock_state){var element,lockChanged=false;if(!this.stickyClassesLookup[element_name])this.stickyClassesLookup[element_name]=document.getElementById(element_name);element=this.stickyClassesLookup[element_name];if(typeof(lock_state)!="undefined"&&element!=null){element.classLock=lock_state;lockChanged=true;}if(element!=null&&(lockChanged||!element.classLock)){element.className=class_name;element.oldClassName=class_name;if(tinyMCE.isOpera){if(class_name=="mceButtonDisabled"){var suffix="";if(!element.mceOldSrc)element.mceOldSrc=element.src;if(this.operaOpacityCounter>-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<tinyMCE.configs.length;c++){tinyMCE.settings=tinyMCE.configs[c];var selector=tinyMCE.getParam("editor_selector");var deselector=tinyMCE.getParam("editor_deselector");var elementRefAr=new Array();if(document.forms&&tinyMCE.settings['add_form_submit_trigger']&&!tinyMCE.submitTriggers){for(var i=0;i<document.forms.length;i++){var form=document.forms[i];tinyMCE.addEvent(form,"submit",TinyMCE.prototype.handleEvent);tinyMCE.addEvent(form,"reset",TinyMCE.prototype.handleEvent);tinyMCE.submitTriggers=true;if(tinyMCE.settings['submit_patch']){try{form.mceOldSubmit=form.submit;form.submit=TinyMCE.prototype.submitPatch;}catch(e){}}}}var mode=tinyMCE.settings['mode'];switch(mode){case "exact":var elements=tinyMCE.getParam('elements','',true,',');for(var i=0;i<elements.length;i++){var element=tinyMCE._getElementById(elements[i]);var trigger=element?element.getAttribute(tinyMCE.settings['textarea_trigger']):"";if(tinyMCE.getAttrib(element,"class").indexOf(deselector)!=-1)continue;if(trigger=="false")continue;if(tinyMCE.settings['ask']&&element){elementRefAr[elementRefAr.length]=element;continue;}if(element)tinyMCE.addMCEControl(element,elements[i]);else if(tinyMCE.settings['debug'])alert("Error: Could not find element by id or name: "+elements[i]);}break;case "specific_textareas":case "textareas":var nodeList=document.getElementsByTagName("textarea");for(var i=0;i<nodeList.length;i++){var elm=nodeList.item(i);var trigger=elm.getAttribute(tinyMCE.settings['textarea_trigger']);if(selector!=''&&tinyMCE.getAttrib(elm,"class").indexOf(selector)==-1)continue;if(tinyMCE.getAttrib(elm,"class").indexOf(deselector)!=-1)continue;if((mode=="specific_textareas"&&trigger=="true")||(mode=="textareas"&&trigger!="false"))elementRefAr[elementRefAr.length]=elm;}break;}for(var i=0;i<elementRefAr.length;i++){var element=elementRefAr[i];var elementId=element.name?element.name:element.id;if(tinyMCE.settings['ask']){if(tinyMCE.isGecko){var settings=tinyMCE.settings;tinyMCE.addEvent(element,"focus",function(e){window.setTimeout(function(){TinyMCE.prototype.confirmAdd(e,settings);},10);});}else{var settings=tinyMCE.settings;tinyMCE.addEvent(element,"focus",function(){TinyMCE.prototype.confirmAdd(null,settings);});}}else tinyMCE.addMCEControl(element,elementId);}if(tinyMCE.settings['auto_focus']){window.setTimeout(function(){var inst=tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']);inst.selectNode(inst.getBody(),true,true);inst.contentWindow.focus();},10);}tinyMCE.executeCallback('oninit','_oninit',0);}};TinyMCE.prototype.removeMCEControl=function(editor_id){var inst=tinyMCE.getInstanceById(editor_id);if(inst){inst.switchSettings();editor_id=inst.editorId;var html=tinyMCE.getContent(editor_id);var tmpInstances=new Array();for(var instanceName in tinyMCE.instances){var instance=tinyMCE.instances[instanceName];if(!tinyMCE.isInstance(instance))continue;if(instanceName!=editor_id)tmpInstances[instanceName]=instance;}tinyMCE.instances=tmpInstances;tinyMCE.selectedElement=null;tinyMCE.selectedInstance=null;var replaceElement=document.getElementById(editor_id+"_parent");var oldTargetElement=inst.oldTargetElement;var targetName=oldTargetElement.nodeName.toLowerCase();if(targetName=="textarea"||targetName=="input"){replaceElement.parentNode.removeChild(replaceElement);oldTargetElement.style.display="inline";oldTargetElement.value=html;}else{oldTargetElement.innerHTML=html;replaceElement.parentNode.insertBefore(oldTargetElement,replaceElement);replaceElement.parentNode.removeChild(replaceElement);}}};TinyMCE.prototype._cleanupElementName=function(element_name,element){var name="";element_name=element_name.toLowerCase();if(element_name=="body")return null;if(tinyMCE.cleanup_verify_html){for(var i=0;i<tinyMCE.cleanup_invalidElements.length;i++){if(tinyMCE.cleanup_invalidElements[i]==element_name)return null;}var validElement=false;var elementAttribs=null;for(var i=0;i<tinyMCE.cleanup_validElements.length&&!elementAttribs;i++){for(var x=0,n=tinyMCE.cleanup_validElements[i][0].length;x<n;x++){var elmMatch=tinyMCE.cleanup_validElements[i][0][x];if(elmMatch.charAt(0)=='+'||elmMatch.charAt(0)=='-')elmMatch=elmMatch.substring(1);if(elmMatch.match(new RegExp('\\*|\\?|\\+','g'))!=null){elmMatch=elmMatch.replace(new RegExp('\\?','g'),'(\\S?)');elmMatch=elmMatch.replace(new RegExp('\\+','g'),'(\\S+)');elmMatch=elmMatch.replace(new RegExp('\\*','g'),'(\\S*)');elmMatch="^"+elmMatch+"$";if(element_name.match(new RegExp(elmMatch,'g'))){elementAttribs=tinyMCE.cleanup_validElements[i];validElement=true;break;}}if(element_name==elmMatch){elementAttribs=tinyMCE.cleanup_validElements[i];validElement=true;element_name=elementAttribs[0][0];break;}}}if(!validElement)return null;}if(element_name.charAt(0)=='+'||element_name.charAt(0)=='-')name=element_name.substring(1);if(!tinyMCE.isMSIE){if(name=="strong"&&!tinyMCE.cleanup_on_save)element_name="b";else if(name=="em"&&!tinyMCE.cleanup_on_save)element_name="i";}var elmData=new Object();elmData.element_name=element_name;elmData.valid_attribs=elementAttribs;return elmData;};TinyMCE.prototype._moveStyle=function(elm,style,attrib){if(tinyMCE.cleanup_inline_styles){var val=tinyMCE.getAttrib(elm,attrib);if(val!=''){val=''+val;switch(attrib){case "background":val="url('"+val+"');";break;case "bordercolor":if(elm.style.borderStyle==''||elm.style.borderStyle=='none')elm.style.borderStyle='solid';break;case "border":case "width":case "height":if(attrib=="border"&&elm.style.borderWidth>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){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<valid_attributes.length;i++){var attribMatch=valid_attributes[i][0];var re=null;if(attribMatch.match(new RegExp('\\*|\\?|\\+','g'))!=null){attribMatch=attribMatch.replace(new RegExp('\\?','g'),'(\\S?)');attribMatch=attribMatch.replace(new RegExp('\\+','g'),'(\\S+)');attribMatch=attribMatch.replace(new RegExp('\\*','g'),'(\\S*)');attribMatch="^"+attribMatch+"$";re=new RegExp(attribMatch,'g');}if((re&&attribName.match(re)!=null)||attribName==attribMatch){verified=true;attribMustBeValue=valid_attributes[i][3];break;}}if(!verified)return false;}else verified=true;switch(attribName){case "size":if(tinyMCE.isMSIE5&&element_name=="font")attribValue=element_node.size;break;case "width":case "height":case "border":if(tinyMCE.isMSIE5)attribValue=eval("element_node."+attribName);break;case "shape":attribValue=attribValue.toLowerCase();break;case "cellspacing":if(tinyMCE.isMSIE5)attribValue=element_node.cellSpacing;break;case "cellpadding":if(tinyMCE.isMSIE5)attribValue=element_node.cellPadding;break;case "color":if(tinyMCE.isMSIE5&&element_name=="font")attribValue=element_node.color;break;case "class":if(tinyMCE.cleanup_on_save&&attribValue.indexOf('mceItemAnchor')!=-1)attribValue=attribValue.replace(/mceItem[a-z0-9]+/gi,'');if(element_name=="table"||element_name=="td"){if(tinyMCE.cleanup_visual_table_class!="")attribValue=tinyMCE.getVisualAidClass(attribValue,!tinyMCE.cleanup_on_save);}if(!tinyMCE._verifyClass(element_node)||attribValue=="")return null;break;case "onfocus":case "onblur":case "onclick":case "ondblclick":case "onmousedown":case "onmouseup":case "onmouseover":case "onmousemove":case "onmouseout":case "onkeypress":case "onkeydown":case "onkeydown":case "onkeyup":attribValue=tinyMCE.cleanupEventStr(""+attribValue);if(attribValue.indexOf('return false;')==0)attribValue=attribValue.substring(14);break;case "style":attribValue=tinyMCE.serializeStyle(tinyMCE.parseStyle(tinyMCE.getAttrib(element_node,"style")));break;case "href":case "src":if(tinyMCE.isGecko18&&attribName=="src")attribValue=element_node.src;if(!tinyMCE.isMSIE&&attribName=="href"&&element_node.getAttribute("mce_real_href"))attribValue=element_node.getAttribute("mce_real_href");if(!tinyMCE.isMSIE&&attribName=="src"&&element_node.getAttribute("mce_real_src"))attribValue=element_node.getAttribute("mce_real_src");if(tinyMCE.isGecko&&!tinyMCE.getParam('relative_urls'))attribValue=tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'],attribValue);attribValue=eval(tinyMCE.cleanup_urlconverter_callback+"(attribValue, element_node, tinyMCE.cleanup_on_save);");break;case "colspan":case "rowspan":if(attribValue=="1")return null;break;case "_moz-userdefined":case "editorid":case "mce_real_href":case "mce_real_src":return null;}if(attribMustBeValue!=null){var isCorrect=false;for(var i=0;i<attribMustBeValue.length;i++){if(attribValue==attribMustBeValue[i]){isCorrect=true;break;}}if(!isCorrect)return null;}var attrib=new Object();attrib.name=attribName;attrib.value=attribValue;return attrib;};TinyMCE.prototype.clearArray=function(ar){for(var key in ar)ar[key]=null;};TinyMCE.prototype.isInstance=function(inst){return inst!=null&&typeof(inst)=="object"&&inst.isTinyMCEControl;};TinyMCE.prototype.parseStyle=function(str){var ar=new Array();if(str==null)return ar;var st=str.split(';');tinyMCE.clearArray(ar);for(var i=0;i<st.length;i++){if(st[i]=='')continue;var re=new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');var pa=st[i].replace(re,'$1||$2').split('||');if(pa.length==2)ar[pa[0].toLowerCase()]=pa[1];}return ar;};TinyMCE.prototype.compressStyle=function(ar,pr,sf,res){var box=new Array();box[0]=ar[pr+'-top'+sf];box[1]=ar[pr+'-left'+sf];box[2]=ar[pr+'-right'+sf];box[3]=ar[pr+'-bottom'+sf];for(var i=0;i<box.length;i++){if(box[i]==null)return;for(var a=0;a<box.length;a++){if(box[a]!=box[i])return;}}ar[res]=box[0];ar[pr+'-top'+sf]=null;ar[pr+'-left'+sf]=null;ar[pr+'-right'+sf]=null;ar[pr+'-bottom'+sf]=null;};TinyMCE.prototype.serializeStyle=function(ar){var str="";tinyMCE.compressStyle(ar,"border","","border");tinyMCE.compressStyle(ar,"border","-width","border-width");tinyMCE.compressStyle(ar,"border","-color","border-color");for(var key in ar){var val=ar[key];if(typeof(val)=='function')continue;if(val!=null&&val!=''){val=''+val;val=val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)",'gi'),"url('$1')");if(tinyMCE.getParam("force_hex_style_colors"))val=tinyMCE.convertRGBToHex(val);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){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").split(',');if(rgb.length==3){r=parseInt(rgb[0]).toString(16);g=parseInt(rgb[1]).toString(16);b=parseInt(rgb[2]).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;}}return s;};TinyMCE.prototype._verifyClass=function(node){if(tinyMCE.isGecko){var className=node.getAttribute('class');if(!className)return false;}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<csses.length;c++){if(csses[c]==className){nonDefinedCSS=false;break;}}if(nonDefinedCSS&&className.indexOf('mce_')!=0){node.removeAttribute('className');node.removeAttribute('class');return false;}}return true;};TinyMCE.prototype.cleanupNode=function(node){var output="";switch(node.nodeType){case 1:var elementData=tinyMCE._cleanupElementName(node.nodeName,node);var elementName=elementData?elementData.element_name:null;var elementValidAttribs=elementData?elementData.valid_attribs:null;var elementAttribs="";var openTag=false,nonEmptyTag=false;if(elementName!=null&&elementName.charAt(0)=='+'){elementName=elementName.substring(1);openTag=true;}if(elementName!=null&&elementName.charAt(0)=='-'){elementName=elementName.substring(1);nonEmptyTag=true;}if(tinyMCE.isMSIE&&tinyMCE.settings['fix_content_duplication']){var lookup=tinyMCE.cleanup_elementLookupTable;for(var i=0;i<lookup.length;i++){if(lookup[i]==node)return output;}lookup[lookup.length]=node;}if(!elementName){if(node.hasChildNodes()){for(var i=0;i<node.childNodes.length;i++)output+=this.cleanupNode(node.childNodes[i]);}return output;}if(tinyMCE.cleanup_on_save){if(node.nodeName=="A"&&node.className=="mceItemAnchor"){if(node.hasChildNodes()){for(var i=0;i<node.childNodes.length;i++)output+=this.cleanupNode(node.childNodes[i]);}return '<a name="'+this.convertStringToXML(node.getAttribute("name"))+'"></a>'+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<elementValidAttribs.length;a++){var attribName,attribDefaultValue,attribForceValue,attribValue;attribName=elementValidAttribs[a][0];attribDefaultValue=elementValidAttribs[a][1];attribForceValue=elementValidAttribs[a][2];if(attribDefaultValue!=null||attribForceValue!=null){var attribValue=node.getAttribute(attribName);if(node.getAttribute(attribName)==null||node.getAttribute(attribName)=="")attribValue=attribDefaultValue;attribValue=attribForceValue?attribForceValue:attribValue;if(attribValue=="{$uid}")attribValue="uid_"+(tinyMCE.cleanup_idCount++);if(attribName=="class")attribValue=tinyMCE.getVisualAidClass(attribValue,tinyMCE.cleanup_on_save);node.setAttribute(attribName,attribValue);}}}if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&elementName=="style")return "<style>"+node.innerHTML+"</style>";if(elementName=="table"&&!node.hasChildNodes())return "";if(node.attributes.length>0){var lastAttrib="";for(var i=0;i<node.attributes.length;i++){if(node.attributes[i].specified){if(tinyMCE.isOpera){if(node.attributes[i].nodeName==lastAttrib)continue;lastAttrib=node.attributes[i].nodeName;}var attrib=tinyMCE._cleanupAttribute(elementValidAttribs,elementName,node.attributes[i],node);if(attrib&&attrib.value!="")elementAttribs+=" "+attrib.name+"="+'"'+this.convertStringToXML(""+attrib.value)+'"';}}}if(tinyMCE.isMSIE&&elementName=="table"&&node.getAttribute("summary")!=null&&elementAttribs.indexOf('summary')==-1){var summary=tinyMCE.getAttrib(node,'summary');if(summary!='')elementAttribs+=" summary="+'"'+this.convertStringToXML(summary)+'"';}if(tinyMCE.isMSIE5&&/^(td|img|a)$/.test(elementName)){var ma=new Array("scope","longdesc","hreflang","charset","type");for(var u=0;u<ma.length;u++){if(node.getAttribute(ma[u])!=null){var s=tinyMCE.getAttrib(node,ma[u]);if(s!='')elementAttribs+=" "+ma[u]+"="+'"'+this.convertStringToXML(s)+'"';}}}if(tinyMCE.isMSIE&&elementName=="input"){if(node.type){if(!elementAttribs.match(/type=/g))elementAttribs+=" type="+'"'+node.type+'"';}if(node.value){if(!elementAttribs.match(/value=/g))elementAttribs+=" value="+'"'+node.value+'"';}}if((elementName=="p"||elementName=="td")&&(node.innerHTML==""||node.innerHTML==" "))return "<"+elementName+elementAttribs+">"+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+="<div"+elementAttribs+">";else output+="<"+elementName+elementAttribs+">";}for(var i=0;i<node.childNodes.length;i++)output+=this.cleanupNode(node.childNodes[i]);if(!(elementName=="span"&&elementAttribs==""&&tinyMCE.getParam("trim_span_elements"))){if(elementName=="p"&&tinyMCE.cleanup_force_br_newlines)output+="</div><br />";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 "<!--"+node.nodeValue+"-->";default:return "[UNKNOWN NODETYPE "+node.nodeType+"]";}};TinyMCE.prototype.convertStringToXML=function(html_data){var output="";for(var i=0;i<html_data.length;i++){var chr=html_data.charCodeAt(i);if(tinyMCE.settings['entity_encoding']=="numeric"){if(chr>127)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<extendedValidElements.length;i++){var elementName=this._getCleanupElementName(extendedValidElements[i]);var skipAdd=false;for(var x=0;x<validElements.length;x++){if(this._getCleanupElementName(validElements[x])==elementName){validElements[x]=extendedValidElements[i];skipAdd=true;break;}}if(!skipAdd)validElements[validElements.length]=extendedValidElements[i];}for(var i=0;i<validElements.length;i++){var item=validElements[i];item=item.replace('[','|');item=item.replace(']','');var attribs=item.split('|');for(var x=0;x<attribs.length;x++)attribs[x]=attribs[x].toLowerCase();attribs[0]=attribs[0].split('/');for(var x=1;x<attribs.length;x++){var attribName=attribs[x];var attribDefault=null;var attribForce=null;var attribMustBe=null;if((pos=attribName.indexOf('='))!=-1){attribDefault=attribName.substring(pos+1);attribName=attribName.substring(0,pos);}if((pos=attribName.indexOf(':'))!=-1){attribForce=attribName.substring(pos+1);attribName=attribName.substring(0,pos);}if((pos=attribName.indexOf('<'))!=-1){attribMustBe=attribName.substring(pos+1).split('?');attribName=attribName.substring(0,pos);}attribs[x]=new Array(attribName,attribDefault,attribForce,attribMustBe);}validElements[i]=attribs;}var invalidElements=tinyMCE.settings['invalid_elements'].split(',');for(var i=0;i<invalidElements.length;i++)invalidElements[i]=invalidElements[i].toLowerCase();tinyMCE.settings['cleanup_validElements']=validElements;tinyMCE.settings['cleanup_invalidElements']=invalidElements;tinyMCE.settings['cleanup_entities']=new Array();var entities=tinyMCE.getParam('entities','',true,',');for(var i=0;i<entities.length;i+=2)tinyMCE.settings['cleanup_entities']['c'+entities[i]]=entities[i+1];};TinyMCE.prototype._cleanupHTML=function(inst,doc,config,element,visual,on_save){if(!tinyMCE.settings['cleanup'])return element.innerHTML;if(on_save&&tinyMCE.getParam("convert_fonts_to_spans"))tinyMCE.convertFontsToSpans(doc);tinyMCE._customCleanup(inst,on_save?"get_from_editor_dom":"insert_to_editor_dom",doc.body);tinyMCE.cleanup_validElements=tinyMCE.settings['cleanup_validElements'];tinyMCE.cleanup_entities=tinyMCE.settings['cleanup_entities'];tinyMCE.cleanup_invalidElements=tinyMCE.settings['cleanup_invalidElements'];tinyMCE.cleanup_verify_html=tinyMCE.settings['verify_html'];tinyMCE.cleanup_force_br_newlines=tinyMCE.settings['force_br_newlines'];tinyMCE.cleanup_urlconverter_callback=tinyMCE.settings['urlconverter_callback'];tinyMCE.cleanup_verify_css_classes=tinyMCE.settings['verify_css_classes'];tinyMCE.cleanup_visual_table_class=tinyMCE.settings['visual_table_class'];tinyMCE.cleanup_apply_source_formatting=tinyMCE.settings['apply_source_formatting'];tinyMCE.cleanup_inline_styles=tinyMCE.settings['inline_styles'];tinyMCE.cleanup_visual_aid=visual;tinyMCE.cleanup_on_save=on_save;tinyMCE.cleanup_idCount=0;tinyMCE.cleanup_elementLookupTable=new Array();var startTime=new Date().getTime();if(tinyMCE.isMSIE){var nodes=element.getElementsByTagName("hr");for(var i=0;i<nodes.length;i++){if(nodes[i].id=="null")nodes[i].removeAttribute("id");}tinyMCE.setInnerHTML(element,tinyMCE.regexpReplace(element.innerHTML,'<p>[ \n\r]*<hr.*>[ \n\r]*</p>','<hr />','gi'));tinyMCE.setInnerHTML(element,tinyMCE.regexpReplace(element.innerHTML,'<!([^-(DOCTYPE)]* )|<!/[^-]*>','','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,'<p><hr /></p>','<hr />');html=tinyMCE.regexpReplace(html,'<p> </p><hr /><p> </p>','<hr />');html=tinyMCE.regexpReplace(html,'<td>\\s*<br />\\s*</td>','<td> </td>');html=tinyMCE.regexpReplace(html,'<p>\\s*<br />\\s*</p>','<p> </p>');html=tinyMCE.regexpReplace(html,'<p>\\s* \\s*<br />\\s* \\s*</p>','<p> </p>');html=tinyMCE.regexpReplace(html,'<p>\\s* \\s*<br />\\s*</p>','<p> </p>');html=tinyMCE.regexpReplace(html,'<p>\\s*<br />\\s* \\s*</p>','<p> </p>');html=html.replace(new RegExp('<a>(.*?)</a>','gi'),'$1');if(!tinyMCE.isMSIE)html=html.replace(new RegExp('<o:p _moz-userdefined="" />','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('<br />','g'),"<br />\n");}if(tinyMCE.settings['force_br_newlines']){var re=new RegExp('<p> </p>','g');html=html.replace(re,"<br />");}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=="<br/>"||chk=="<br>"||chk=="<p> </p>"||chk=="<p> </p>"||chk=="<p></p>")html="";if(tinyMCE.settings["preformatted"])return "<pre>"+html+"</pre>";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,'<a href="'+tinyMCE.uniqueURL+'">'+this.selectedInstance.getSelectedHTML()+'</a>');}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<elementArray.length;i++){href=eval(tinyMCE.settings['urlconverter_callback']+"(href, elementArray[i]);");tinyMCE.setAttrib(elementArray[i],'href',href);tinyMCE.setAttrib(elementArray[i],'mce_real_href',href);tinyMCE.setAttrib(elementArray[i],'target',target);tinyMCE.setAttrib(elementArray[i],'title',title);tinyMCE.setAttrib(elementArray[i],'onclick',onclick);tinyMCE.setAttrib(elementArray[i],'class',style_class);}tinyMCE.linkElement=elementArray[0];}if(this.linkElement){href=eval(tinyMCE.settings['urlconverter_callback']+"(href, this.linkElement);");tinyMCE.setAttrib(this.linkElement,'href',href);tinyMCE.setAttrib(this.linkElement,'mce_real_href',href);tinyMCE.setAttrib(this.linkElement,'target',target);tinyMCE.setAttrib(this.linkElement,'title',title);tinyMCE.setAttrib(this.linkElement,'onclick',onclick);tinyMCE.setAttrib(this.linkElement,'class',style_class);}tinyMCE.execCommand('mceEndUndoLevel');};TinyMCE.prototype.insertImage=function(src,alt,border,hspace,vspace,width,height,align,title,onmouseover,onmouseout){tinyMCE.execCommand('mceBeginUndoLevel');if(src=="")return;if(!this.imgElement&&tinyMCE.isSafari){var html="";html+='<img src="'+src+'" alt="'+alt+'"';html+=' border="'+border+'" hspace="'+hspace+'"';html+=' vspace="'+vspace+'" width="'+width+'"';html+=' height="'+height+'" align="'+align+'" title="'+title+'" onmouseover="'+onmouseover+'" onmouseout="'+onmouseout+'" />';tinyMCE.execCommand("mceInsertContent",false,html);}else{if(!this.imgElement&&this.selectedInstance){if(tinyMCE.isSafari)tinyMCE.execCommand("mceInsertContent",false,'<img src="'+tinyMCE.uniqueURL+'" />');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<n;x++){var childElements=this.getElementsByAttributeValue(node.childNodes[x],element_name,attrib,value);for(var i=0,m=childElements.length;i<m;i++)elements[elements.length]=childElements[i];}}return elements;};TinyMCE.prototype.isBlockElement=function(node){return node!=null&&node.nodeType==1&&this.blockRegExp.test(node.nodeName);};TinyMCE.prototype.getParentBlockElement=function(node){while(node){if(this.blockRegExp.test(node.nodeName))return node;node=node.parentNode;}return null;};TinyMCE.prototype.getNodeTree=function(node,node_array,type,node_name){if(typeof(type)=="undefined"||node.nodeType==type&&(typeof(node_name)=="undefined"||node.nodeName==node_name))node_array[node_array.length]=node;if(node.hasChildNodes()){for(var i=0;i<node.childNodes.length;i++)tinyMCE.getNodeTree(node.childNodes[i],node_array,type,node_name);}return node_array;};TinyMCE.prototype.getParentElement=function(node,names,attrib_name,attrib_value){if(typeof(names)=="undefined"){if(node.nodeType==1)return node;while((node=node.parentNode)!=null&&node.nodeType!=1);return node;}var namesAr=names.split(',');if(node==null)return null;do{for(var i=0;i<namesAr.length;i++){if(node.nodeName.toLowerCase()==namesAr[i].toLowerCase()||names=="*"){if(typeof(attrib_name)=="undefined")return node;else if(node.getAttribute(attrib_name)){if(typeof(attrib_value)=="undefined"){if(node.getAttribute(attrib_name)!="")return node;}else if(node.getAttribute(attrib_name)==attrib_value)return node;}}}}while((node=node.parentNode)!=null);return null;};TinyMCE.prototype.convertURL=function(url,node,on_save){var prot=document.location.protocol;var host=document.location.hostname;var port=document.location.port;var fileProto=(prot=="file:");url=tinyMCE.regexpReplace(url,'(http|https):///','/');if(url.indexOf('mailto:')!=-1||url.indexOf('javascript:')!=-1||tinyMCE.regexpReplace(url,'[ \t\r\n\+]|%20','').charAt(0)=="#")return url;if(!tinyMCE.isMSIE&&!on_save&&url.indexOf("://")==-1&&url.charAt(0)!='/')return tinyMCE.settings['base_href']+url;if(!tinyMCE.getParam('relative_urls')){var urlParts=tinyMCE.parseURL(url);var baseUrlParts=tinyMCE.parseURL(tinyMCE.settings['base_href']);if(urlParts['anchor']&&urlParts['path']==baseUrlParts['path'])return "#"+urlParts['anchor'];}if(on_save&&tinyMCE.getParam('relative_urls')){var urlParts=tinyMCE.parseURL(url);var tmpUrlParts=tinyMCE.parseURL(tinyMCE.settings['document_base_url']);if(urlParts['host']==tmpUrlParts['host']&&(!urlParts['port']||urlParts['port']==tmpUrlParts['port']))return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings['document_base_url'],url);}if(!fileProto&&tinyMCE.getParam('remove_script_host')){var start="",portPart="";if(port!="")portPart=":"+port;start=prot+"//"+host+portPart+"/";if(url.indexOf(start)==0)url=url.substring(start.length-1);if(!tinyMCE.getParam('relative_urls')&&url.indexOf('://')==-1&&url.charAt(0)!='/')url='/'+url;}return url;};TinyMCE.prototype.parseURL=function(url_str){var urlParts=new Array();if(url_str){var pos,lastPos;pos=url_str.indexOf('://');if(pos!=-1){urlParts['protocol']=url_str.substring(0,pos);lastPos=pos+3;}for(var i=lastPos;i<url_str.length;i++){var chr=url_str.charAt(i);if(chr==':')break;if(chr=='/')break;}pos=i;urlParts['host']=url_str.substring(lastPos,pos);lastPos=pos;if(url_str.charAt(pos)==':'){pos=url_str.indexOf('/',lastPos);urlParts['port']=url_str.substring(lastPos+1,pos);}lastPos=pos;pos=url_str.indexOf('?',lastPos);if(pos==-1)pos=url_str.indexOf('#',lastPos);if(pos==-1)pos=url_str.length;urlParts['path']=url_str.substring(lastPos,pos);lastPos=pos;if(url_str.charAt(pos)=='?'){pos=url_str.indexOf('#');pos=(pos==-1)?url_str.length:pos;urlParts['query']=url_str.substring(lastPos+1,pos);}lastPos=pos;if(url_str.charAt(pos)=='#'){pos=url_str.length;urlParts['anchor']=url_str.substring(lastPos+1,pos);}}return urlParts;};TinyMCE.prototype.serializeURL=function(up){var url="";if(up['protocol'])url+=up['protocol']+"://";if(up['host'])url+=up['host'];if(up['port'])url+=":"+up['port'];if(up['path'])url+=up['path'];if(up['query'])url+="?"+up['query'];if(up['anchor'])url+="#"+up['anchor'];return url;};TinyMCE.prototype.convertAbsoluteURLToRelativeURL=function(base_url,url_to_relative){var baseURL=this.parseURL(base_url);var targetURL=this.parseURL(url_to_relative);var strTok1;var strTok2;var breakPoint=0;var outPath="";var forceSlash=false;if(targetURL.path=="")targetURL.path="/";else forceSlash=true;base_url=baseURL.path.substring(0,baseURL.path.lastIndexOf('/'));strTok1=base_url.split('/');strTok2=targetURL.path.split('/');if(strTok1.length>=strTok2.length){for(var i=0;i<strTok1.length;i++){if(i>=strTok2.length||strTok1[i]!=strTok2[i]){breakPoint=i+1;break;}}}if(strTok1.length<strTok2.length){for(var i=0;i<strTok2.length;i++){if(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<strTok2.length;i++){if(i!=(breakPoint-1))outPath+="/"+strTok2[i];else outPath+=strTok2[i];}targetURL.protocol=null;targetURL.host=null;targetURL.port=null;targetURL.path=outPath==""&&forceSlash?"/":outPath;return this.serializeURL(targetURL);};TinyMCE.prototype.convertRelativeToAbsoluteURL=function(base_url,relative_url){var baseURL=TinyMCE.prototype.parseURL(base_url);var relURL=TinyMCE.prototype.parseURL(relative_url);if(relative_url==""||relative_url.charAt(0)=='/'||relative_url.indexOf('://')!=-1||relative_url.indexOf('mailto:')!=-1||relative_url.indexOf('javascript:')!=-1)return relative_url;baseURLParts=baseURL['path'].split('/');relURLParts=relURL['path'].split('/');var newBaseURLParts=new Array();for(var i=baseURLParts.length-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;i<value.length;i++){if(value[i]&&value[i]!="")outArray[outArray.length]=value[i];}value=outArray;}return value;};TinyMCE.prototype.getLang=function(name,default_value,parse_entities){var value=(typeof(tinyMCELang[name])=="undefined")?default_value:tinyMCELang[name];if(parse_entities){var el=document.createElement("div");el.innerHTML=value;value=el.innerHTML;}return value;};TinyMCE.prototype.addToLang=function(prefix,ar){for(var key in ar){if(typeof(ar[key])=='function')continue;tinyMCELang[(key.indexOf('lang_')==-1?'lang_':'')+(prefix!=''?(prefix+"_"):'')+key]=ar[key];}};TinyMCE.prototype.replaceVar=function(replace_haystack,replace_var,replace_str){var re=new RegExp('{\\\$'+replace_var+'}','g');return replace_haystack.replace(re,replace_str);};TinyMCE.prototype.replaceVars=function(replace_haystack,replace_vars){for(var key in replace_vars){var value=replace_vars[key];if(typeof(value)=='function')continue;replace_haystack=tinyMCE.replaceVar(replace_haystack,key,value);}return replace_haystack;};TinyMCE.prototype.triggerNodeChange=function(focus,setup_content){if(tinyMCE.settings['handleNodeChangeCallback']){if(tinyMCE.selectedInstance){var inst=tinyMCE.selectedInstance;var editorId=inst.editorId;var elm=(typeof(setup_content)!="undefined"&&setup_content)?tinyMCE.selectedElement:inst.getFocusElement();var undoIndex=-1;var undoLevels=-1;var anySelection=false;var selectedText=inst.getSelectedText();if(tinyMCE.settings["auto_resize"]){var doc=inst.getDoc();inst.iframeElement.style.width=doc.body.offsetWidth+"px";inst.iframeElement.style.height=doc.body.offsetHeight+"px";}if(tinyMCE.selectedElement)anySelection=(tinyMCE.selectedElement.nodeName.toLowerCase()=="img")||(selectedText&&selectedText.length>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){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;i<plugins.length;i++){if(eval("typeof(TinyMCE_"+plugins[i]+"_cleanup)")!="undefined")content=eval("TinyMCE_"+plugins[i]+"_cleanup(type, content, inst);");}return content;};TinyMCE.prototype.getContent=function(editor_id){if(typeof(editor_id)!="undefined")tinyMCE.selectedInstance=tinyMCE.getInstanceById(editor_id);if(tinyMCE.selectedInstance){var old=this.selectedInstance.getBody().innerHTML;var html=tinyMCE._cleanupHTML(this.selectedInstance,this.selectedInstance.getDoc(),tinyMCE.settings,this.selectedInstance.getBody(),false,true);tinyMCE.setInnerHTML(this.selectedInstance.getBody(),old);return html;}return null;};TinyMCE.prototype.setContent=function(html_content){if(tinyMCE.selectedInstance){tinyMCE.selectedInstance.execCommand('mceSetContent',false,html_content);tinyMCE.selectedInstance.repaint();}};TinyMCE.prototype.importThemeLanguagePack=function(name){if(typeof(name)=="undefined")name=tinyMCE.settings['theme'];tinyMCE.loadScript(tinyMCE.baseURL+'/themes/'+name+'/langs/'+tinyMCE.settings['language']+'.js');};TinyMCE.prototype.importPluginLanguagePack=function(name,valid_languages){var lang="en";valid_languages=valid_languages.split(',');for(var i=0;i<valid_languages.length;i++){if(tinyMCE.settings['language']==valid_languages[i])lang=tinyMCE.settings['language'];}tinyMCE.loadScript(tinyMCE.baseURL+'/plugins/'+name+'/langs/'+lang+'.js');};TinyMCE.prototype.applyTemplate=function(html,args){html=tinyMCE.replaceVar(html,"themeurl",tinyMCE.themeURL);if(typeof(args)!="undefined")html=tinyMCE.replaceVars(html,args);html=tinyMCE.replaceVars(html,tinyMCE.settings);html=tinyMCE.replaceVars(html,tinyMCELang);return html;};TinyMCE.prototype.openWindow=function(template,args){var html,width,height,x,y,resizable,scrollbars,url;args['mce_template_file']=template['file'];args['mce_width']=template['width'];args['mce_height']=template['height'];tinyMCE.windowArgs=args;html=template['html'];if(!(width=parseInt(template['width'])))width=320;if(!(height=parseInt(template['height'])))height=200;if(tinyMCE.isMSIE)height+=40;else height+=20;x=parseInt(screen.width/2.0)-(width/2.0);y=parseInt(screen.height/2.0)-(height/2.0);resizable=(args&&args['resizable'])?args['resizable']:"no";scrollbars=(args&&args['scrollbars'])?args['scrollbars']:"no";if(template['file'].charAt(0)!='/'&&template['file'].indexOf('://')==-1)url=tinyMCE.baseURL+"/themes/"+tinyMCE.getParam("theme")+"/"+template['file'];else url=template['file'];for(var name in args){if(typeof(args[name])=='function')continue;url=tinyMCE.replaceVar(url,name,escape(args[name]));}if(html){html=tinyMCE.replaceVar(html,"css",this.settings['popups_css']);html=tinyMCE.applyTemplate(html,args);var win=window.open("","mcePopup"+new Date().getTime(),"top="+y+",left="+x+",scrollbars="+scrollbars+",dialog=yes,minimizable="+resizable+",modal=yes,width="+width+",height="+height+",resizable="+resizable);if(win==null){alert(tinyMCELang['lang_popup_blocked']);return;}win.document.write(html);win.document.close();win.resizeTo(width,height);win.focus();}else{if(tinyMCE.isMSIE&&resizable!='yes'&&tinyMCE.settings["dialog_type"]=="modal"){var features="resizable:"+resizable+";scroll:"+scrollbars+";status:yes;center:yes;help:no;dialogWidth:"+width+"px;dialogHeight:"+height+"px;";window.showModalDialog(url,window,features);}else{var modal=(resizable=="yes")?"no":"yes";if(tinyMCE.isGecko&&tinyMCE.isMac)modal="no";if(template['close_previous']!="no")try{tinyMCE.lastWindow.close();}catch(ex){}var win=window.open(url,"mcePopup"+new Date().getTime(),"top="+y+",left="+x+",scrollbars="+scrollbars+",dialog="+modal+",minimizable="+resizable+",modal="+modal+",width="+width+",height="+height+",resizable="+resizable);if(win==null){alert(tinyMCELang['lang_popup_blocked']);return;}if(template['close_previous']!="no")tinyMCE.lastWindow=win;eval('try { win.resizeTo(width, height); } catch(e) { }');if(tinyMCE.isGecko){if(win.document.defaultView.statusbar.visible)win.resizeBy(0,tinyMCE.isMac?10:24);}win.focus();}}};TinyMCE.prototype.closeWindow=function(win){win.close();};TinyMCE.prototype.getVisualAidClass=function(class_name,state){var aidClass=tinyMCE.settings['visual_table_class'];if(typeof(state)=="undefined")state=tinyMCE.settings['visual'];var classNames=new Array();var ar=class_name.split(' ');for(var i=0;i<ar.length;i++){if(ar[i]==aidClass)ar[i]="";if(ar[i]!="")classNames[classNames.length]=ar[i];}if(state)classNames[classNames.length]=aidClass;var className="";for(var i=0;i<classNames.length;i++){if(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<el.rows.length;y++){for(var x=0;x<el.rows[y].cells.length;x++){var cn=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x],"class"),state&&bo);tinyMCE.setAttrib(el.rows[y].cells[x],"class",cn);}}break;case "A":var anchorName=tinyMCE.getAttrib(el,"name");if(anchorName!=''&&state){el.title=anchorName;el.className='mceItemAnchor';}else if(anchorName!=''&&!state)el.className='';break;}if(deep&&el.hasChildNodes()){for(var i=0;i<el.childNodes.length;i++)tinyMCE.handleVisualAid(el.childNodes[i],deep,state,inst);}};TinyMCE.prototype.getAttrib=function(elm,name,default_value){if(typeof(default_value)=="undefined")default_value="";if(!elm||elm.nodeType!=1)return default_value;var v=elm.getAttribute(name);if(name=="class"&&!v)v=elm.className;if(name=="style"&&!tinyMCE.isOpera)v=elm.style.cssText;return(v&&v!="")?v:default_value;};TinyMCE.prototype.setAttrib=function(element,name,value,fix_value){if(typeof(value)=="number"&&value!=null)value=""+value;if(fix_value){if(value==null)value="";var re=new RegExp('[^0-9%]','g');value=value.replace(re,'');}if(name=="style")element.style.cssText=value;if(name=="class")element.className=value;if(value!=null&&value!=""&&value!=-1)element.setAttribute(name,value);else element.removeAttribute(name);};TinyMCE.prototype.setStyleAttrib=function(elm,name,value){eval('elm.style.'+name+'=value;');if(tinyMCE.isMSIE&&value==null||value==''){var str=tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));elm.style.cssText=str;elm.setAttribute("style",str);}};TinyMCE.prototype.convertSpansToFonts=function(doc){var sizes=tinyMCE.getParam('font_size_style_values').replace(/\s+/,'').split(',');var h=doc.body.innerHTML;h=h.replace(/<span/gi,'<font');h=h.replace(/<\/span/gi,'</font');doc.body.innerHTML=h;var s=doc.getElementsByTagName("font");for(var i=0;i<s.length;i++){var size=tinyMCE.trim(s[i].style.fontSize).toLowerCase();var fSize=0;for(var x=0;x<sizes.length;x++){if(sizes[x]==size){fSize=x+1;break;}}if(fSize>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(/<font/gi,'<span');h=h.replace(/<\/font/gi,'</span');doc.body.innerHTML=h;var fsClasses=tinyMCE.getParam('font_size_classes');if(fsClasses!='')fsClasses=fsClasses.replace(/\s+/,'').split(',');else fsClasses=null;var s=doc.getElementsByTagName("span");for(var i=0;i<s.length;i++){var fSize,fFace,fColor;fSize=tinyMCE.getAttrib(s[i],'size');fFace=tinyMCE.getAttrib(s[i],'face');fColor=tinyMCE.getAttrib(s[i],'color');if(fSize!=""){fSize=parseInt(fSize);if(fSize>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='<div id="mceTMPElement" style="display: none">TMP</div>'+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<an.length;i++){if(tinyMCE.getAttrib(an[i],"name")!=""){var cn=an[i].childNodes;for(var x=cn.length-1;x>=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<paras.length;i++){var node=paras[i];while((node=node.parentNode)!=null){if(node.nodeName.toLowerCase()=="p")node.outerHTML=node.innerHTML;}}var html=doc.body.innerHTML;if(html.indexOf('="mso')!=-1){for(var i=0;i<doc.body.all.length;i++){var el=doc.body.all[i];el.removeAttribute("className","",0);el.removeAttribute("style","",0);}html=doc.body.innerHTML;html=tinyMCE.regexpReplace(html,"<o:p><\/o:p>","<br />");html=tinyMCE.regexpReplace(html,"<o:p> <\/o:p>","");html=tinyMCE.regexpReplace(html,"<st1:.*?>","");html=tinyMCE.regexpReplace(html,"<p><\/p>","");html=tinyMCE.regexpReplace(html,"<p><\/p>\r\n<p><\/p>","");html=tinyMCE.regexpReplace(html,"<p> <\/p>","<br />");html=tinyMCE.regexpReplace(html,"<p>\s*(<p>\s*)?","<p>");html=tinyMCE.regexpReplace(html,"<\/p>\s*(<\/p>\s*)?","</p>");}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;j<document.forms.length;j++){for(var k=0;k<document.forms[j].elements.length;k++){if(document.forms[j].elements[k].name==element_id){elm=document.forms[j].elements[k];break;}}}}return elm;};TinyMCE.prototype.getEditorId=function(form_element){var inst=this.getInstanceById(form_element);if(!inst)return null;return inst.editorId;};TinyMCE.prototype.getInstanceById=function(editor_id){var inst=this.instances[editor_id];if(!inst){for(var n in tinyMCE.instances){var instance=tinyMCE.instances[n];if(!tinyMCE.isInstance(instance))continue;if(instance.formTargetElementId==editor_id){inst=instance;break;}}}return inst;};TinyMCE.prototype.queryInstanceCommandValue=function(editor_id,command){var inst=tinyMCE.getInstanceById(editor_id);if(inst)return inst.queryCommandValue(command);return false;};TinyMCE.prototype.queryInstanceCommandState=function(editor_id,command){var inst=tinyMCE.getInstanceById(editor_id);if(inst)return inst.queryCommandState(command);return null;};TinyMCE.prototype.setWindowArg=function(name,value){this.windowArgs[name]=value;};TinyMCE.prototype.getWindowArg=function(name,default_value){return(typeof(this.windowArgs[name])=="undefined")?default_value:this.windowArgs[name];};TinyMCE.prototype.getCSSClasses=function(editor_id,doc){var output=new Array();if(typeof(tinyMCE.cssClasses)!="undefined")return tinyMCE.cssClasses;if(typeof(editor_id)=="undefined"&&typeof(doc)=="undefined"){var instance;for(var instanceName in tinyMCE.instances){instance=tinyMCE.instances[instanceName];if(!tinyMCE.isInstance(instance))continue;break;}doc=instance.getDoc();}if(typeof(doc)=="undefined"){var instance=tinyMCE.getInstanceById(editor_id);doc=instance.getDoc();}if(doc){var styles=tinyMCE.isMSIE?doc.styleSheets:doc.styleSheets;if(styles&&styles.length>0){for(var x=0;x<styles.length;x++){var csses=null;eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets("+x+").rules : doc.styleSheets["+x+"].cssRules;} catch(e) {}");if(!csses)return new Array();for(var i=0;i<csses.length;i++){var selectorText=csses[i].selectorText;if(selectorText){var rules=selectorText.split(',');for(var c=0;c<rules.length;c++){if(rules[c].indexOf(' ')!=-1||rules[c].indexOf(':')!=-1||rules[c].indexOf('mceItem')!=-1)continue;if(rules[c]=="."+tinyMCE.settings['visual_table_class'])continue;if(rules[c].indexOf('.')!=-1){output[output.length]=rules[c].substring(rules[c].indexOf('.')+1);}}}}}}}if(output.length>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,'');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<args.length;i++){str+='args['+i+']';if(i<args.length-1)str+=',';}str+=');';return eval(str);};TinyMCE.prototype.executeCallback=function(param,suffix,mode){switch(mode){case 0:var state=false;var plugins=tinyMCE.getParam('plugins','',true,',');for(var i=0;i<plugins.length;i++){var func="TinyMCE_"+plugins[i]+suffix;if(tinyMCE.isFunc(func)){tinyMCE.exec(func,this.executeCallback.arguments);state=true;}}var func='TinyMCE_'+tinyMCE.settings['theme']+suffix;if(tinyMCE.isFunc(func)){tinyMCE.exec(func,this.executeCallback.arguments);state=true;}var func=tinyMCE.getParam(param,'');if(tinyMCE.isFunc(func)){tinyMCE.exec(func,this.executeCallback.arguments);state=true;}return state;case 1:var plugins=tinyMCE.getParam('plugins','',true,',');for(var i=0;i<plugins.length;i++){var func="TinyMCE_"+plugins[i]+suffix;if(tinyMCE.isFunc(func)){if(tinyMCE.exec(func,this.executeCallback.arguments))return true;}}var func='TinyMCE_'+tinyMCE.settings['theme']+suffix;if(tinyMCE.isFunc(func)){if(tinyMCE.exec(func,this.executeCallback.arguments))return true;}var func=tinyMCE.getParam(param,'');if(tinyMCE.isFunc(func)){if(tinyMCE.exec(func,this.executeCallback.arguments))return true;}return false;}};TinyMCE.prototype.debug=function(){var msg="";var elm=document.getElementById("tinymce_debug");if(!elm){var debugDiv=document.createElement("div");debugDiv.setAttribute("className","debugger");debugDiv.className="debugger";debugDiv.innerHTML='\ 10 10 Debug output:\ 11 <textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap"></textarea>';document.body.appendChild(debugDiv);elm=document.getElementById("tinymce_debug");}var args=this.debug.arguments;for(var i=0;i<args.length;i++){msg+=args[i];if(i<args.length-1)msg+=', ';}elm.value+=msg+"\n";};function TinyMCEControl(settings){this.undoLevels=new Array();this.undoIndex=0;this.typingUndoIndex=-1;this.undoRedo=true;this.isTinyMCEControl=true;this.settings=settings;this.settings['theme']=tinyMCE.getParam("theme","default");this.settings['width']=tinyMCE.getParam("width",-1);this.settings['height']=tinyMCE.getParam("height",-1);};TinyMCEControl.prototype.repaint=function(){if(tinyMCE.isMSIE)return;this.getBody().style.display='none';this.getBody().style.display='block';};TinyMCEControl.prototype.switchSettings=function(){if(tinyMCE.configs.length>1&&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;i<elms.length;i++){var src=elms[i].getAttribute('mce_real_src');if(src&&src!="")elms[i].setAttribute("src",src);}var elms=body.getElementsByTagName("a");for(var i=0;i<elms.length;i++){var href=elms[i].getAttribute('mce_real_href');if(href&&href!="")elms[i].setAttribute("href",href);}};TinyMCEControl.prototype.convertAllRelativeURLs=function(){var body=this.getBody();var elms=body.getElementsByTagName("img");for(var i=0;i<elms.length;i++){var src=elms[i].getAttribute('src');if(src&&src!=""){src=tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'],src);elms[i].setAttribute("src",src);elms[i].setAttribute("mce_real_src",src);}}var elms=body.getElementsByTagName("a");for(var i=0;i<elms.length;i++){var href=elms[i].getAttribute('href');if(href&&href!=""){href=tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'],href);elms[i].setAttribute("href",href);elms[i].setAttribute("mce_real_href",href);}}};TinyMCEControl.prototype.getSelectedHTML=function(){if(tinyMCE.isSafari){return this.getRng().toString();}var elm=document.createElement("body");if(tinyMCE.isGecko)elm.appendChild(this.getRng().cloneContents());else elm.innerHTML=this.getRng().htmlText;return tinyMCE._cleanupHTML(this,this.contentDocument,this.settings,elm,this.visualAid);};TinyMCEControl.prototype.getBookmark=function(){var rng=this.getRng();if(tinyMCE.isSafari)return rng;if(tinyMCE.isMSIE)return rng;if(tinyMCE.isGecko)return rng.cloneRange();return null;};TinyMCEControl.prototype.moveToBookmark=function(bookmark){if(tinyMCE.isSafari){var sel=this.getSel().realSelection;sel.setBaseAndExtent(bookmark.startContainer,bookmark.startOffset,bookmark.endContainer,bookmark.endOffset);return true;}if(tinyMCE.isMSIE)return bookmark.select();if(tinyMCE.isGecko){var rng=this.getDoc().createRange();var sel=this.getSel();rng.setStart(bookmark.startContainer,bookmark.startOffset);rng.setEnd(bookmark.endContainer,bookmark.endOffset);sel.removeAllRanges();sel.addRange(rng);return true;}return false;};TinyMCEControl.prototype.getSelectedText=function(){if(tinyMCE.isMSIE){var doc=this.getDoc();if(doc.selection.type=="Text"){var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText='';}else{var sel=this.getSel();if(sel&&sel.toString)selectedText=sel.toString();else selectedText='';}return selectedText;};TinyMCEControl.prototype.selectNode=function(node,collapse,select_text_node,to_start){if(!node)return;if(typeof(collapse)=="undefined")collapse=true;if(typeof(select_text_node)=="undefined")select_text_node=false;if(typeof(to_start)=="undefined")to_start=true;if(tinyMCE.isMSIE){var rng=this.getBody().createTextRange();try{rng.moveToElementText(node);if(collapse)rng.collapse(to_start);rng.select();}catch(e){}}else{var sel=this.getSel();if(!sel)return;if(tinyMCE.isSafari){sel.realSelection.setBaseAndExtent(node,0,node,node.innerText.length);if(collapse){if(to_start)sel.realSelection.collapseToStart();else sel.realSelection.collapseToEnd();}this.scrollToNode(node);return;}var rng=this.getDoc().createRange();if(select_text_node){var nodes=tinyMCE.getNodeTree(node,new Array(),3);if(nodes.length>0)rng.selectNodeContents(nodes[0]);else rng.selectNodeContents(node);}else rng.selectNode(node);if(collapse){if(!to_start&&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<nodes.length;i++){if(!isEmptyHTML(nodes[i].nodeValue))return false;}return true;}var doc=this.getDoc();var sel=this.getSel();var win=this.contentWindow;var rng=sel.getRangeAt(0);var body=doc.body;var rootElm=doc.documentElement;var self=this;var blockName="P";var rngBefore=doc.createRange();rngBefore.setStart(sel.anchorNode,sel.anchorOffset);rngBefore.collapse(true);var rngAfter=doc.createRange();rngAfter.setStart(sel.focusNode,sel.focusOffset);rngAfter.collapse(true);var direct=rngBefore.compareBoundaryPoints(rngBefore.START_TO_END,rngAfter)<0;var startNode=direct?sel.anchorNode:sel.focusNode;var startOffset=direct?sel.anchorOffset:sel.focusOffset;var endNode=direct?sel.focusNode:sel.anchorNode;var endOffset=direct?sel.focusOffset:sel.anchorOffset;startNode=startNode.nodeName=="BODY"?startNode.firstChild:startNode;endNode=endNode.nodeName=="BODY"?endNode.firstChild:endNode;var startBlock=tinyMCE.getParentBlockElement(startNode);var endBlock=tinyMCE.getParentBlockElement(endNode);if(startBlock!=null){blockName=startBlock.nodeName;if(blockName=="TD"||blockName=="TABLE"||(blockName=="DIV"&&new RegExp('left|right','gi').test(startBlock.style.cssFloat)))blockName="P";}if(tinyMCE.getParentElement(startBlock,"OL,UL")!=null)return false;if((startBlock!=null&&startBlock.nodeName=="TABLE")||(endBlock!=null&&endBlock.nodeName=="TABLE"))startBlock=endBlock=null;var paraBefore=(startBlock!=null&&startBlock.nodeName==blockName)?startBlock.cloneNode(false):doc.createElement(blockName);var paraAfter=(endBlock!=null&&endBlock.nodeName==blockName)?endBlock.cloneNode(false):doc.createElement(blockName);if(/^(H[1-6])$/.test(blockName))paraAfter=doc.createElement("p");var startChop=startNode;var endChop=endNode;node=startChop;do{if(node==body||node.nodeType==9||tinyMCE.isBlockElement(node))break;startChop=node;}while((node=node.previousSibling?node.previousSibling:node.parentNode));node=endChop;do{if(node==body||node.nodeType==9||tinyMCE.isBlockElement(node))break;endChop=node;}while((node=node.nextSibling?node.nextSibling:node.parentNode));if(startChop.nodeName=="TD")startChop=startChop.firstChild;if(endChop.nodeName=="TD")endChop=endChop.lastChild;if(startBlock==null){rng.deleteContents();sel.removeAllRanges();if(startChop!=rootElm&&endChop!=rootElm){rngBefore=rng.cloneRange();if(startChop==body)rngBefore.setStart(startChop,0);else rngBefore.setStartBefore(startChop);paraBefore.appendChild(rngBefore.cloneContents());if(endChop.parentNode.nodeName==blockName)endChop=endChop.parentNode;rng.setEndAfter(endChop);if(endChop.nodeName!="#text"&&endChop.nodeName!="BODY")rngBefore.setEndAfter(endChop);var contents=rng.cloneContents();if(contents.firstChild&&(contents.firstChild.nodeName==blockName||contents.firstChild.nodeName=="BODY"))paraAfter.innerHTML=contents.firstChild.innerHTML;else paraAfter.appendChild(contents);if(isEmpty(paraBefore))paraBefore.innerHTML=" ";if(isEmpty(paraAfter))paraAfter.innerHTML=" ";rng.deleteContents();rngAfter.deleteContents();rngBefore.deleteContents();paraAfter.normalize();rngBefore.insertNode(paraAfter);paraBefore.normalize();rngBefore.insertNode(paraBefore);}else{body.innerHTML="<"+blockName+"> </"+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('<div align="'+alignValue+'">'+rng.htmlText+"</div>");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+"><li> </li><"+tag+">");else this.getDoc().execCommand(command,user_interface,value);tinyMCE.triggerNodeChange();break;case "Strikethrough":if(tinyMCE.isSafari)this.execCommand("mceInsertContent",false,"<strike>"+this.getSelectedHTML()+"</strike>");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<ch.length;z++){if(ch[z]==parentElm)continue;if(scmd=="setstyle")tinyMCE.setStyleAttrib(ch[z],sname,'');if(scmd=="setattrib")tinyMCE.setAttrib(ch[z],sname,'');if(scmd=="removeformat"){ch[z].style.cssText='';tinyMCE.setAttrib(ch[z],'class','');}}}else{doc.execCommand("fontname",false,"#mce_temp_font#");var elementArray=tinyMCE.getElementsByAttributeValue(this.getBody(),"font","face","#mce_temp_font#");for(var x=0;x<elementArray.length;x++){elm=elementArray[x];if(elm){var spanElm=doc.createElement(wrapper);if(scmd=="setstyle")tinyMCE.setStyleAttrib(spanElm,sname,svalue);if(scmd=="setattrib")tinyMCE.setAttrib(spanElm,sname,svalue);if(scmd=="removeformat"){spanElm.style.cssText='';tinyMCE.setAttrib(spanElm,'class','');}if(elm.hasChildNodes()){for(var i=0;i<elm.childNodes.length;i++)spanElm.appendChild(elm.childNodes[i].cloneNode(true));}spanElm.setAttribute("mce_new","true");elm.parentNode.replaceChild(spanElm,elm);var ch=tinyMCE.getNodeTree(spanElm,new Array(),1);for(var z=0;z<ch.length;z++){if(ch[z]==spanElm)continue;if(scmd=="setstyle")tinyMCE.setStyleAttrib(ch[z],sname,'');if(scmd=="setattrib")tinyMCE.setAttrib(ch[z],sname,'');if(scmd=="removeformat"){ch[z].style.cssText='';tinyMCE.setAttrib(ch[z],'class','');}}}}}var nodes=doc.getElementsByTagName(wrapper);for(var i=nodes.length-1;i>=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('<span>','gi').test(tmp.innerHTML)){for(var x=0;x<elm.childNodes.length;x++){if(elm.parentNode!=null)elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true),elm);}elm.parentNode.removeChild(elm);}}if(scmd=="removeformat")tinyMCE.handleVisualAid(this.getBody(),true,this.visualAid,this);tinyMCE.triggerNodeChange();break;case "FontName":this.getDoc().execCommand('FontName',false,value);if(tinyMCE.isGecko)window.setTimeout('tinyMCE.triggerNodeChange(false);',1);return;case "FontSize":this.getDoc().execCommand('FontSize',false,value);if(tinyMCE.isGecko)window.setTimeout('tinyMCE.triggerNodeChange(false);',1);return;case "forecolor":this.getDoc().execCommand('forecolor',false,value);break;case "HiliteColor":if(tinyMCE.isGecko){this.setUseCSS(true);this.getDoc().execCommand('hilitecolor',false,value);this.setUseCSS(false);}else this.getDoc().execCommand('BackColor',false,value);break;case "Cut":case "Copy":case "Paste":var cmdFailed=false;eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');if(tinyMCE.isOpera&&cmdFailed)alert('Currently not supported by your browser, use keyboard shortcuts instead.');if(tinyMCE.isGecko&&cmdFailed){if(confirm(tinyMCE.getLang('lang_clipboard_msg')))window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');return;}else tinyMCE.triggerNodeChange();break;case "mceSetContent":if(!value)value=""; value=tinyMCE._customCleanup(this,"insert_to_editor",value);tinyMCE._setHTML(doc,value);tinyMCE.setInnerHTML(doc.body,tinyMCE._cleanupHTML(this,doc,tinyMCE.settings,doc.body));tinyMCE.handleVisualAid(doc.body,true,this.visualAid,this);tinyMCE._setEventsEnabled(doc.body,false);return true;case "mceLink":var selectedText="";if(tinyMCE.isMSIE){var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText=this.getSel().toString();if(!tinyMCE.linkElement){if((tinyMCE.selectedElement.nodeName.toLowerCase()!="img")&&(selectedText.length<=0))return;}var href="",target="",title="",onclick="",action="insert",style_class="";if(tinyMCE.selectedElement.nodeName.toLowerCase()=="a")tinyMCE.linkElement=tinyMCE.selectedElement;if(tinyMCE.linkElement!=null&&tinyMCE.getAttrib(tinyMCE.linkElement,'href')=="")tinyMCE.linkElement=null;if(tinyMCE.linkElement){href=tinyMCE.getAttrib(tinyMCE.linkElement,'href');target=tinyMCE.getAttrib(tinyMCE.linkElement,'target');title=tinyMCE.getAttrib(tinyMCE.linkElement,'title');onclick=tinyMCE.getAttrib(tinyMCE.linkElement,'onclick');style_class=tinyMCE.getAttrib(tinyMCE.linkElement,'class');if(onclick=="")onclick=tinyMCE.getAttrib(tinyMCE.linkElement,'onclick');onclick=tinyMCE.cleanupEventStr(onclick);mceRealHref=tinyMCE.getAttrib(tinyMCE.linkElement,'mce_real_href');if(mceRealHref!="")href=mceRealHref;href=eval(tinyMCE.settings['urlconverter_callback']+"(href, tinyMCE.linkElement, true);");action="update";}if(this.settings['insertlink_callback']){var returnVal=eval(this.settings['insertlink_callback']+"(href, target, title, onclick, action, style_class);");if(returnVal&&returnVal['href'])tinyMCE.insertLink(returnVal['href'],returnVal['target'],returnVal['title'],returnVal['onclick'],returnVal['style_class']);}else{tinyMCE.openWindow(this.insertLinkTemplate,{href:href,target:target,title:title,onclick:onclick,action:action,className:style_class});}break;case "mceImage":var src="",alt="",border="",hspace="",vspace="",width="",height="",align="";var title="",onmouseover="",onmouseout="",action="insert";var img=tinyMCE.imgElement;if(tinyMCE.selectedElement!=null&&tinyMCE.selectedElement.nodeName.toLowerCase()=="img"){img=tinyMCE.selectedElement;tinyMCE.imgElement=img;}if(img){if(tinyMCE.getAttrib(img,'name').indexOf('mce_')==0)return;src=tinyMCE.getAttrib(img,'src');alt=tinyMCE.getAttrib(img,'alt');if(alt=="")alt=tinyMCE.getAttrib(img,'title');if(tinyMCE.isGecko){var w=img.style.width;if(w!=null&&w!="")img.setAttribute("width",w);var h=img.style.height;if(h!=null&&h!="")img.setAttribute("height",h);}border=tinyMCE.getAttrib(img,'border');hspace=tinyMCE.getAttrib(img,'hspace');vspace=tinyMCE.getAttrib(img,'vspace');width=tinyMCE.getAttrib(img,'width');height=tinyMCE.getAttrib(img,'height');align=tinyMCE.getAttrib(img,'align');onmouseover=tinyMCE.getAttrib(img,'onmouseover');onmouseout=tinyMCE.getAttrib(img,'onmouseout');title=tinyMCE.getAttrib(img,'title');if(tinyMCE.isMSIE){width=img.attributes['width'].specified?width:"";height=img.attributes['height'].specified?height:"";}onmouseover=tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));onmouseout=tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));mceRealSrc=tinyMCE.getAttrib(img,'mce_real_src');if(mceRealSrc!="")src=mceRealSrc;src=eval(tinyMCE.settings['urlconverter_callback']+"(src, img, true);");if(onmouseover!="")onmouseover=eval(tinyMCE.settings['urlconverter_callback']+"(onmouseover, img, true);");if(onmouseout!="")onmouseout=eval(tinyMCE.settings['urlconverter_callback']+"(onmouseout, img, true);");action="update";}if(this.settings['insertimage_callback']){var returnVal=eval(this.settings['insertimage_callback']+"(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");if(returnVal&&returnVal['src'])tinyMCE.insertImage(returnVal['src'],returnVal['alt'],returnVal['border'],returnVal['hspace'],returnVal['vspace'],returnVal['width'],returnVal['height'],returnVal['align'],returnVal['title'],returnVal['onmouseover'],returnVal['onmouseout']);}else tinyMCE.openWindow(this.insertImageTemplate,{src:src,alt:alt,border:border,hspace:hspace,vspace:vspace,width:width,height:height,align:align,title:title,onmouseover:onmouseover,onmouseout:onmouseout,action:action});break;case "mceCleanup":tinyMCE._setHTML(this.contentDocument,this.getBody().innerHTML);tinyMCE.setInnerHTML(this.getBody(),tinyMCE._cleanupHTML(this,this.contentDocument,this.settings,this.getBody(),this.visualAid));tinyMCE.handleVisualAid(this.getBody(),true,this.visualAid,this);tinyMCE._setEventsEnabled(this.getBody(),false);this.repaint();tinyMCE.triggerNodeChange();break;case "mceReplaceContent":this.getWin().focus();var selectedText="";if(tinyMCE.isMSIE){var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText=this.getSel().toString();if(selectedText.length>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');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;i<this.undoLevels.length-1;i++){this.undoLevels[i]=this.undoLevels[i+1];}this.undoLevels.length--;this.undoIndex--;}this.undoIndex++;this.undoLevels[this.undoIndex]=newHTML;this.undoLevels.length=this.undoIndex+1;tinyMCE.triggerNodeChange(false);}}break;case "Undo":if(tinyMCE.settings['custom_undo_redo']){tinyMCE.execCommand("mceEndTyping");if(this.undoIndex>0){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='<span id="'+this.editorId+'_parent">'+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+='<textarea wrap="off" id="'+form_element_name+'" name="'+form_element_name+'" cols="100" rows="15"></textarea>';else html+='<input type="hidden" type="text" id="'+form_element_name+'" name="'+form_element_name+'" />';html+='</span>';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+='</span>';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')+'<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="'+tinyMCE.settings['base_href']+'" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';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();11 <textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap"></textarea>';document.body.appendChild(debugDiv);elm=document.getElementById("tinymce_debug");}var args=this.debug.arguments;for(var i=0;i<args.length;i++){msg+=args[i];if(i<args.length-1)msg+=', ';}elm.value+=msg+"\n";};function TinyMCEControl(settings){this.undoLevels=new Array();this.undoIndex=0;this.typingUndoIndex=-1;this.undoRedo=true;this.isTinyMCEControl=true;this.settings=settings;this.settings['theme']=tinyMCE.getParam("theme","default");this.settings['width']=tinyMCE.getParam("width",-1);this.settings['height']=tinyMCE.getParam("height",-1);};TinyMCEControl.prototype.repaint=function(){if(tinyMCE.isMSIE)return;this.getBody().style.display='none';this.getBody().style.display='block';};TinyMCEControl.prototype.switchSettings=function(){if(tinyMCE.configs.length>1&&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;i<elms.length;i++){var src=elms[i].getAttribute('mce_real_src');if(src&&src!="")elms[i].setAttribute("src",src);}var elms=body.getElementsByTagName("a");for(var i=0;i<elms.length;i++){var href=elms[i].getAttribute('mce_real_href');if(href&&href!="")elms[i].setAttribute("href",href);}};TinyMCEControl.prototype.convertAllRelativeURLs=function(){var body=this.getBody();var elms=body.getElementsByTagName("img");for(var i=0;i<elms.length;i++){var src=elms[i].getAttribute('src');if(src&&src!=""){src=tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'],src);elms[i].setAttribute("src",src);elms[i].setAttribute("mce_real_src",src);}}var elms=body.getElementsByTagName("a");for(var i=0;i<elms.length;i++){var href=elms[i].getAttribute('href');if(href&&href!=""){href=tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'],href);elms[i].setAttribute("href",href);elms[i].setAttribute("mce_real_href",href);}}};TinyMCEControl.prototype.getSelectedHTML=function(){if(tinyMCE.isSafari){return this.getRng().toString();}var elm=document.createElement("body");if(tinyMCE.isGecko)elm.appendChild(this.getRng().cloneContents());else elm.innerHTML=this.getRng().htmlText;return tinyMCE._cleanupHTML(this,this.contentDocument,this.settings,elm,this.visualAid);};TinyMCEControl.prototype.getBookmark=function(){var rng=this.getRng();if(tinyMCE.isSafari)return rng;if(tinyMCE.isMSIE)return rng;if(tinyMCE.isGecko)return rng.cloneRange();return null;};TinyMCEControl.prototype.moveToBookmark=function(bookmark){if(tinyMCE.isSafari){var sel=this.getSel().realSelection;sel.setBaseAndExtent(bookmark.startContainer,bookmark.startOffset,bookmark.endContainer,bookmark.endOffset);return true;}if(tinyMCE.isMSIE)return bookmark.select();if(tinyMCE.isGecko){var rng=this.getDoc().createRange();var sel=this.getSel();rng.setStart(bookmark.startContainer,bookmark.startOffset);rng.setEnd(bookmark.endContainer,bookmark.endOffset);sel.removeAllRanges();sel.addRange(rng);return true;}return false;};TinyMCEControl.prototype.getSelectedText=function(){if(tinyMCE.isMSIE){var doc=this.getDoc();if(doc.selection.type=="Text"){var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText='';}else{var sel=this.getSel();if(sel&&sel.toString)selectedText=sel.toString();else selectedText='';}return selectedText;};TinyMCEControl.prototype.selectNode=function(node,collapse,select_text_node,to_start){if(!node)return;if(typeof(collapse)=="undefined")collapse=true;if(typeof(select_text_node)=="undefined")select_text_node=false;if(typeof(to_start)=="undefined")to_start=true;if(tinyMCE.isMSIE){var rng=this.getBody().createTextRange();try{rng.moveToElementText(node);if(collapse)rng.collapse(to_start);rng.select();}catch(e){}}else{var sel=this.getSel();if(!sel)return;if(tinyMCE.isSafari){sel.realSelection.setBaseAndExtent(node,0,node,node.innerText.length);if(collapse){if(to_start)sel.realSelection.collapseToStart();else sel.realSelection.collapseToEnd();}this.scrollToNode(node);return;}var rng=this.getDoc().createRange();if(select_text_node){var nodes=tinyMCE.getNodeTree(node,new Array(),3);if(nodes.length>0)rng.selectNodeContents(nodes[0]);else rng.selectNodeContents(node);}else rng.selectNode(node);if(collapse){if(!to_start&&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<nodes.length;i++){if(!isEmptyHTML(nodes[i].nodeValue))return false;}return true;}var doc=this.getDoc();var sel=this.getSel();var win=this.contentWindow;var rng=sel.getRangeAt(0);var body=doc.body;var rootElm=doc.documentElement;var self=this;var blockName="P";var rngBefore=doc.createRange();rngBefore.setStart(sel.anchorNode,sel.anchorOffset);rngBefore.collapse(true);var rngAfter=doc.createRange();rngAfter.setStart(sel.focusNode,sel.focusOffset);rngAfter.collapse(true);var direct=rngBefore.compareBoundaryPoints(rngBefore.START_TO_END,rngAfter)<0;var startNode=direct?sel.anchorNode:sel.focusNode;var startOffset=direct?sel.anchorOffset:sel.focusOffset;var endNode=direct?sel.focusNode:sel.anchorNode;var endOffset=direct?sel.focusOffset:sel.anchorOffset;startNode=startNode.nodeName=="BODY"?startNode.firstChild:startNode;endNode=endNode.nodeName=="BODY"?endNode.firstChild:endNode;var startBlock=tinyMCE.getParentBlockElement(startNode);var endBlock=tinyMCE.getParentBlockElement(endNode);if(startBlock!=null){blockName=startBlock.nodeName;if(blockName=="TD"||blockName=="TABLE"||(blockName=="DIV"&&new RegExp('left|right','gi').test(startBlock.style.cssFloat)))blockName="P";}if(tinyMCE.getParentElement(startBlock,"OL,UL")!=null)return false;if((startBlock!=null&&startBlock.nodeName=="TABLE")||(endBlock!=null&&endBlock.nodeName=="TABLE"))startBlock=endBlock=null;var paraBefore=(startBlock!=null&&startBlock.nodeName==blockName)?startBlock.cloneNode(false):doc.createElement(blockName);var paraAfter=(endBlock!=null&&endBlock.nodeName==blockName)?endBlock.cloneNode(false):doc.createElement(blockName);if(/^(H[1-6])$/.test(blockName))paraAfter=doc.createElement("p");var startChop=startNode;var endChop=endNode;node=startChop;do{if(node==body||node.nodeType==9||tinyMCE.isBlockElement(node))break;startChop=node;}while((node=node.previousSibling?node.previousSibling:node.parentNode));node=endChop;do{if(node==body||node.nodeType==9||tinyMCE.isBlockElement(node))break;endChop=node;}while((node=node.nextSibling?node.nextSibling:node.parentNode));if(startChop.nodeName=="TD")startChop=startChop.firstChild;if(endChop.nodeName=="TD")endChop=endChop.lastChild;if(startBlock==null){rng.deleteContents();sel.removeAllRanges();if(startChop!=rootElm&&endChop!=rootElm){rngBefore=rng.cloneRange();if(startChop==body)rngBefore.setStart(startChop,0);else rngBefore.setStartBefore(startChop);paraBefore.appendChild(rngBefore.cloneContents());if(endChop.parentNode.nodeName==blockName)endChop=endChop.parentNode;rng.setEndAfter(endChop);if(endChop.nodeName!="#text"&&endChop.nodeName!="BODY")rngBefore.setEndAfter(endChop);var contents=rng.cloneContents();if(contents.firstChild&&(contents.firstChild.nodeName==blockName||contents.firstChild.nodeName=="BODY"))paraAfter.innerHTML=contents.firstChild.innerHTML;else paraAfter.appendChild(contents);if(isEmpty(paraBefore))paraBefore.innerHTML=" ";if(isEmpty(paraAfter))paraAfter.innerHTML=" ";rng.deleteContents();rngAfter.deleteContents();rngBefore.deleteContents();paraAfter.normalize();rngBefore.insertNode(paraAfter);paraBefore.normalize();rngBefore.insertNode(paraBefore);}else{body.innerHTML="<"+blockName+"> </"+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('<div align="'+alignValue+'">'+rng.htmlText+"</div>");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+"><li> </li><"+tag+">");else this.getDoc().execCommand(command,user_interface,value);tinyMCE.triggerNodeChange();break;case "Strikethrough":if(tinyMCE.isSafari)this.execCommand("mceInsertContent",false,"<strike>"+this.getSelectedHTML()+"</strike>");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<ch.length;z++){if(ch[z]==parentElm)continue;if(scmd=="setstyle")tinyMCE.setStyleAttrib(ch[z],sname,'');if(scmd=="setattrib")tinyMCE.setAttrib(ch[z],sname,'');if(scmd=="removeformat"){ch[z].style.cssText='';tinyMCE.setAttrib(ch[z],'class','');}}}else{doc.execCommand("fontname",false,"#mce_temp_font#");var elementArray=tinyMCE.getElementsByAttributeValue(this.getBody(),"font","face","#mce_temp_font#");for(var x=0;x<elementArray.length;x++){elm=elementArray[x];if(elm){var spanElm=doc.createElement(wrapper);if(scmd=="setstyle")tinyMCE.setStyleAttrib(spanElm,sname,svalue);if(scmd=="setattrib")tinyMCE.setAttrib(spanElm,sname,svalue);if(scmd=="removeformat"){spanElm.style.cssText='';tinyMCE.setAttrib(spanElm,'class','');}if(elm.hasChildNodes()){for(var i=0;i<elm.childNodes.length;i++)spanElm.appendChild(elm.childNodes[i].cloneNode(true));}spanElm.setAttribute("mce_new","true");elm.parentNode.replaceChild(spanElm,elm);var ch=tinyMCE.getNodeTree(spanElm,new Array(),1);for(var z=0;z<ch.length;z++){if(ch[z]==spanElm)continue;if(scmd=="setstyle")tinyMCE.setStyleAttrib(ch[z],sname,'');if(scmd=="setattrib")tinyMCE.setAttrib(ch[z],sname,'');if(scmd=="removeformat"){ch[z].style.cssText='';tinyMCE.setAttrib(ch[z],'class','');}}}}}var nodes=doc.getElementsByTagName(wrapper);for(var i=nodes.length-1;i>=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('<span>','gi').test(tmp.innerHTML)){for(var x=0;x<elm.childNodes.length;x++){if(elm.parentNode!=null)elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true),elm);}elm.parentNode.removeChild(elm);}}if(scmd=="removeformat")tinyMCE.handleVisualAid(this.getBody(),true,this.visualAid,this);tinyMCE.triggerNodeChange();break;case "FontName":this.getDoc().execCommand('FontName',false,value);if(tinyMCE.isGecko)window.setTimeout('tinyMCE.triggerNodeChange(false);',1);return;case "FontSize":this.getDoc().execCommand('FontSize',false,value);if(tinyMCE.isGecko)window.setTimeout('tinyMCE.triggerNodeChange(false);',1);return;case "forecolor":this.getDoc().execCommand('forecolor',false,value);break;case "HiliteColor":if(tinyMCE.isGecko){this.setUseCSS(true);this.getDoc().execCommand('hilitecolor',false,value);this.setUseCSS(false);}else this.getDoc().execCommand('BackColor',false,value);break;case "Cut":case "Copy":case "Paste":var cmdFailed=false;eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');if(tinyMCE.isOpera&&cmdFailed)alert('Currently not supported by your browser, use keyboard shortcuts instead.');if(tinyMCE.isGecko&&cmdFailed){if(confirm(tinyMCE.getLang('lang_clipboard_msg')))window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html','mceExternal');return;}else tinyMCE.triggerNodeChange();break;case "mceSetContent":if(!value)value="";/*value=tinyMCE._customCleanup(this,"insert_to_editor",value);*/tinyMCE._setHTML(doc,value);tinyMCE.setInnerHTML(doc.body,tinyMCE._cleanupHTML(this,doc,tinyMCE.settings,doc.body));tinyMCE.handleVisualAid(doc.body,true,this.visualAid,this);tinyMCE._setEventsEnabled(doc.body,false);return true;case "mceLink":var selectedText="";if(tinyMCE.isMSIE){var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText=this.getSel().toString();if(!tinyMCE.linkElement){if((tinyMCE.selectedElement.nodeName.toLowerCase()!="img")&&(selectedText.length<=0))return;}var href="",target="",title="",onclick="",action="insert",style_class="";if(tinyMCE.selectedElement.nodeName.toLowerCase()=="a")tinyMCE.linkElement=tinyMCE.selectedElement;if(tinyMCE.linkElement!=null&&tinyMCE.getAttrib(tinyMCE.linkElement,'href')=="")tinyMCE.linkElement=null;if(tinyMCE.linkElement){href=tinyMCE.getAttrib(tinyMCE.linkElement,'href');target=tinyMCE.getAttrib(tinyMCE.linkElement,'target');title=tinyMCE.getAttrib(tinyMCE.linkElement,'title');onclick=tinyMCE.getAttrib(tinyMCE.linkElement,'onclick');style_class=tinyMCE.getAttrib(tinyMCE.linkElement,'class');if(onclick=="")onclick=tinyMCE.getAttrib(tinyMCE.linkElement,'onclick');onclick=tinyMCE.cleanupEventStr(onclick);mceRealHref=tinyMCE.getAttrib(tinyMCE.linkElement,'mce_real_href');if(mceRealHref!="")href=mceRealHref;href=eval(tinyMCE.settings['urlconverter_callback']+"(href, tinyMCE.linkElement, true);");action="update";}if(this.settings['insertlink_callback']){var returnVal=eval(this.settings['insertlink_callback']+"(href, target, title, onclick, action, style_class);");if(returnVal&&returnVal['href'])tinyMCE.insertLink(returnVal['href'],returnVal['target'],returnVal['title'],returnVal['onclick'],returnVal['style_class']);}else{tinyMCE.openWindow(this.insertLinkTemplate,{href:href,target:target,title:title,onclick:onclick,action:action,className:style_class});}break;case "mceImage":var src="",alt="",border="",hspace="",vspace="",width="",height="",align="";var title="",onmouseover="",onmouseout="",action="insert";var img=tinyMCE.imgElement;if(tinyMCE.selectedElement!=null&&tinyMCE.selectedElement.nodeName.toLowerCase()=="img"){img=tinyMCE.selectedElement;tinyMCE.imgElement=img;}if(img){if(tinyMCE.getAttrib(img,'name').indexOf('mce_')==0)return;src=tinyMCE.getAttrib(img,'src');alt=tinyMCE.getAttrib(img,'alt');if(alt=="")alt=tinyMCE.getAttrib(img,'title');if(tinyMCE.isGecko){var w=img.style.width;if(w!=null&&w!="")img.setAttribute("width",w);var h=img.style.height;if(h!=null&&h!="")img.setAttribute("height",h);}border=tinyMCE.getAttrib(img,'border');hspace=tinyMCE.getAttrib(img,'hspace');vspace=tinyMCE.getAttrib(img,'vspace');width=tinyMCE.getAttrib(img,'width');height=tinyMCE.getAttrib(img,'height');align=tinyMCE.getAttrib(img,'align');onmouseover=tinyMCE.getAttrib(img,'onmouseover');onmouseout=tinyMCE.getAttrib(img,'onmouseout');title=tinyMCE.getAttrib(img,'title');if(tinyMCE.isMSIE){width=img.attributes['width'].specified?width:"";height=img.attributes['height'].specified?height:"";}onmouseover=tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));onmouseout=tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));mceRealSrc=tinyMCE.getAttrib(img,'mce_real_src');if(mceRealSrc!="")src=mceRealSrc;src=eval(tinyMCE.settings['urlconverter_callback']+"(src, img, true);");if(onmouseover!="")onmouseover=eval(tinyMCE.settings['urlconverter_callback']+"(onmouseover, img, true);");if(onmouseout!="")onmouseout=eval(tinyMCE.settings['urlconverter_callback']+"(onmouseout, img, true);");action="update";}if(this.settings['insertimage_callback']){var returnVal=eval(this.settings['insertimage_callback']+"(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");if(returnVal&&returnVal['src'])tinyMCE.insertImage(returnVal['src'],returnVal['alt'],returnVal['border'],returnVal['hspace'],returnVal['vspace'],returnVal['width'],returnVal['height'],returnVal['align'],returnVal['title'],returnVal['onmouseover'],returnVal['onmouseout']);}else tinyMCE.openWindow(this.insertImageTemplate,{src:src,alt:alt,border:border,hspace:hspace,vspace:vspace,width:width,height:height,align:align,title:title,onmouseover:onmouseover,onmouseout:onmouseout,action:action});break;case "mceCleanup":tinyMCE._setHTML(this.contentDocument,this.getBody().innerHTML);tinyMCE.setInnerHTML(this.getBody(),tinyMCE._cleanupHTML(this,this.contentDocument,this.settings,this.getBody(),this.visualAid));tinyMCE.handleVisualAid(this.getBody(),true,this.visualAid,this);tinyMCE._setEventsEnabled(this.getBody(),false);this.repaint();tinyMCE.triggerNodeChange();break;case "mceReplaceContent":this.getWin().focus();var selectedText="";if(tinyMCE.isMSIE){var rng=doc.selection.createRange();selectedText=rng.text;}else selectedText=this.getSel().toString();if(selectedText.length>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');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;i<this.undoLevels.length-1;i++){this.undoLevels[i]=this.undoLevels[i+1];}this.undoLevels.length--;this.undoIndex--;}this.undoIndex++;this.undoLevels[this.undoIndex]=newHTML;this.undoLevels.length=this.undoIndex+1;tinyMCE.triggerNodeChange(false);}}break;case "Undo":if(tinyMCE.settings['custom_undo_redo']){tinyMCE.execCommand("mceEndTyping");if(this.undoIndex>0){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='<span id="'+this.editorId+'_parent">'+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+='<textarea wrap="off" id="'+form_element_name+'" name="'+form_element_name+'" cols="100" rows="15"></textarea>';else html+='<input type="hidden" type="text" id="'+form_element_name+'" name="'+form_element_name+'" />';html+='</span>';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+='</span>';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')+'<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="'+tinyMCE.settings['base_href']+'" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';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(); -
trunk/wp-includes/js/tinymce/tiny_mce_src.js
r2993 r3136 1 /**2 * $RCSfile: tiny_mce_src.js,v $3 * $Revision: 1.249 $4 * $Date: 2005/10/30 16:06:57 $5 *6 * @author Moxiecode7 * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.8 */9 10 function TinyMCE() {11 this.majorVersion = "2";12 this.minorVersion = "0RC4";13 this.releaseDate = "2005-10-30";14 15 this.instances = new Array();16 this.stickyClassesLookup = new Array();17 this.windowArgs = new Array();18 this.loadedFiles = new Array();19 this.configs = new Array();20 this.currentConfig = 0;21 this.eventHandlers = new Array();22 23 // Browser check24 var ua = navigator.userAgent;25 this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");26 this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);27 this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);28 this.isGecko = ua.indexOf('Gecko') != -1;29 this.isGecko18 = ua.indexOf('Gecko') != -1 && ua.indexOf('rv:1.8') != -1;30 this.isSafari = ua.indexOf('Safari') != -1;31 this.isOpera = ua.indexOf('Opera') != -1;32 this.isMac = ua.indexOf('Mac') != -1;33 this.isNS7 = ua.indexOf('Netscape/7') != -1;34 this.isNS71 = ua.indexOf('Netscape/7.1') != -1;35 this.dialogCounter = 0;36 37 // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those38 if (this.isOpera) {39 this.isMSIE = true;40 this.isGecko = false;41 this.isSafari = false;42 }43 44 // TinyMCE editor id instance counter45 this.idCounter = 0;46 };47 48 TinyMCE.prototype.defParam = function(key, def_val) {49 this.settings[key] = tinyMCE.getParam(key, def_val);50 };51 52 TinyMCE.prototype.init = function(settings) {53 var theme;54 55 this.settings = settings;56 57 // Check if valid browser has execcommand support58 if (typeof(document.execCommand) == 'undefined')59 return;60 61 // Get script base path62 if (!tinyMCE.baseURL) {63 var elements = document.getElementsByTagName('script');64 65 for (var i=0; i<elements.length; i++) {66 if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip.php") != -1)) {67 var src = elements[i].src;68 69 tinyMCE.srcMode = (src.indexOf('_src') != -1) ? '_src' : '';70 src = src.substring(0, src.lastIndexOf('/'));71 72 tinyMCE.baseURL = src;73 break;74 }75 }76 }77 78 // Get document base path79 this.documentBasePath = document.location.href;80 if (this.documentBasePath.indexOf('?') != -1)81 this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));82 this.documentURL = this.documentBasePath;83 this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));84 85 // If not HTTP absolute86 if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {87 // If site absolute88 tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;89 }90 91 // Set default values on settings92 this.defParam("mode", "none");93 this.defParam("theme", "advanced");94 this.defParam("plugins", "", true);95 this.defParam("language", "en");96 this.defParam("docs_language", this.settings['language']);97 this.defParam("elements", "");98 this.defParam("textarea_trigger", "mce_editable");99 this.defParam("editor_selector", "");100 this.defParam("editor_deselector", "mceNoEditor");101 this.defParam("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/b[class|style],-em/i[class|style],-strike[class|style],-u[class|style],+p[style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border=0|alt|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[style|dir|class|align],-h2[style|dir|class|align],-h3[style|dir|class|align],-h4[style|dir|class|align],-h5[style|dir|class|align],-h6[style|dir|class|align],hr[class|style],font[face|size|style|id|class|dir|color]");102 this.defParam("extended_valid_elements", "");103 this.defParam("invalid_elements", "");104 this.defParam("encoding", "");105 this.defParam("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE.prototype.convertURL"));106 this.defParam("save_callback", "");107 this.defParam("debug", false);108 this.defParam("force_br_newlines", false);109 this.defParam("force_p_newlines", true);110 this.defParam("add_form_submit_trigger", true);111 this.defParam("relative_urls", true);112 this.defParam("remove_script_host", true);113 this.defParam("focus_alert", true);114 this.defParam("document_base_url", this.documentURL);115 this.defParam("visual", true);116 this.defParam("visual_table_class", "mceVisualAid");117 this.defParam("setupcontent_callback", "");118 this.defParam("fix_content_duplication", true);119 this.defParam("custom_undo_redo", true);120 this.defParam("custom_undo_redo_levels", -1);121 this.defParam("custom_undo_redo_keyboard_shortcuts", true);122 this.defParam("verify_css_classes", false);123 this.defParam("verify_html", true);124 this.defParam("apply_source_formatting", false);125 this.defParam("directionality", "ltr");126 this.defParam("cleanup_on_startup", false);127 this.defParam("inline_styles", false);128 this.defParam("convert_newlines_to_brs", false);129 this.defParam("auto_reset_designmode", true);130 this.defParam("entities", "160,nbsp,38,amp,34,quot,162,cent,8364,euro,163,pound,165,yen,169,copy,174,reg,8482,trade,8240,permil,181,micro,183,middot,8226,bull,8230,hellip,8242,prime,8243,Prime,167,sect,182,para,223,szlig,8249,lsaquo,8250,rsaquo,171,laquo,187,raquo,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8218,sbquo,8222,bdquo,60,lt,62,gt,8804,le,8805,ge,8211,ndash,8212,mdash,175,macr,8254,oline,164,curren,166,brvbar,168,uml,161,iexcl,191,iquest,710,circ,732,tilde,176,deg,8722,minus,177,plusmn,247,divide,8260,frasl,215,times,185,sup1,178,sup2,179,sup3,188,frac14,189,frac12,190,frac34,402,fnof,8747,int,8721,sum,8734,infin,8730,radic,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8712,isin,8713,notin,8715,ni,8719,prod,8743,and,8744,or,172,not,8745,cap,8746,cup,8706,part,8704,forall,8707,exist,8709,empty,8711,nabla,8727,lowast,8733,prop,8736,ang,180,acute,184,cedil,170,ordf,186,ordm,8224,dagger,8225,Dagger,192,Agrave,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,202,Ecirc,203,Euml,204,Igrave,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,212,Ocirc,213,Otilde,214,Ouml,216,Oslash,338,OElig,217,Ugrave,219,Ucirc,220,Uuml,376,Yuml,222,THORN,224,agrave,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,234,ecirc,235,euml,236,igrave,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,244,ocirc,245,otilde,246,ouml,248,oslash,339,oelig,249,ugrave,251,ucirc,252,uuml,254,thorn,255,yuml,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,8501,alefsym,982,piv,8476,real,977,thetasym,978,upsih,8472,weierp,8465,image,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8756,there4,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,173,shy,233,eacute,237,iacute,243,oacute,250,uacute,193,Aacute,225,aacute,201,Eacute,205,Iacute,211,Oacute,218,Uacute,221,Yacute,253,yacute");131 this.defParam("entity_encoding", "named");132 this.defParam("cleanup_callback", "");133 this.defParam("add_unload_trigger", true);134 this.defParam("ask", false);135 this.defParam("nowrap", false);136 this.defParam("auto_resize", false);137 this.defParam("auto_focus", false);138 this.defParam("cleanup", true);139 this.defParam("remove_linebreaks", true);140 this.defParam("button_tile_map", false);141 this.defParam("submit_patch", true);142 this.defParam("browsers", "msie,safari,gecko,opera");143 this.defParam("dialog_type", "window");144 this.defParam("accessibility_warnings", true);145 this.defParam("merge_styles_invalid_parents", "");146 this.defParam("force_hex_style_colors", true);147 this.defParam("trim_span_elements", true);148 this.defParam("convert_fonts_to_spans", false);149 this.defParam("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');150 this.defParam("font_size_classes", '');151 this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large');152 this.defParam("event_elements", 'a,img');153 154 // Browser check IE155 if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)156 return;157 158 // Browser check Gecko159 if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)160 return;161 162 // Browser check Safari163 if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)164 return;165 166 // Browser check Opera167 if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)168 return;169 170 // Setup baseHREF171 var baseHREF = tinyMCE.settings['document_base_url'];172 if (baseHREF.indexOf('?') != -1)173 baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));174 this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";175 176 theme = this.settings['theme'];177 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");178 this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);179 this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url';180 181 // Theme url182 this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;183 184 if (!tinyMCE.isMSIE)185 this.settings['force_br_newlines'] = false;186 187 if (tinyMCE.getParam("content_css", false)) {188 var cssPath = tinyMCE.getParam("content_css", "");189 190 // Is relative191 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')192 this.settings['content_css'] = this.documentBasePath + "/" + cssPath;193 else194 this.settings['content_css'] = cssPath;195 } else196 this.settings['content_css'] = '';197 198 if (tinyMCE.getParam("popups_css", false)) {199 var cssPath = tinyMCE.getParam("popups_css", "");200 201 // Is relative202 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')203 this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;204 else205 this.settings['popups_css'] = cssPath;206 } else207 this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";208 209 if (tinyMCE.getParam("editor_css", false)) {210 var cssPath = tinyMCE.getParam("editor_css", "");211 212 // Is relative213 if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')214 this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;215 else216 this.settings['editor_css'] = cssPath;217 } else218 this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";219 220 if (tinyMCE.settings['debug']) {221 var msg = "Debug: \n";222 223 msg += "baseURL: " + this.baseURL + "\n";224 msg += "documentBasePath: " + this.documentBasePath + "\n";225 msg += "content_css: " + this.settings['content_css'] + "\n";226 msg += "popups_css: " + this.settings['popups_css'] + "\n";227 msg += "editor_css: " + this.settings['editor_css'] + "\n";228 229 alert(msg);230 }231 232 // Init HTML cleanup233 this._initCleanup();234 235 // Only do this once236 if (this.configs.length == 0) {237 // Is Safari enabled238 if (this.isSafari && this.getParam('safari_warning', true))239 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");240 241 tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad);242 243 if (tinyMCE.isMSIE) {244 if (tinyMCE.settings['add_unload_trigger']) {245 tinyMCE.addEvent(window, "unload", TinyMCE.prototype.unloadHandler);246 tinyMCE.addEvent(window.document, "beforeunload", TinyMCE.prototype.unloadHandler);247 }248 } else {249 if (tinyMCE.settings['add_unload_trigger'])250 tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);});251 }252 }253 254 this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');255 this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js');256 this.loadCSS(this.settings['editor_css']);257 258 // Add plugins259 var themePlugins = tinyMCE.getParam('plugins', '', true, ',');260 if (this.settings['plugins'] != '') {261 for (var i=0; i<themePlugins.length; i++)262 this.loadScript(tinyMCE.baseURL + '/plugins/' + themePlugins[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');263 }264 265 // Save away this config266 settings['index'] = this.configs.length;267 this.configs[this.configs.length] = settings;268 };269 270 TinyMCE.prototype.loadScript = function(url) {271 for (var i=0; i<this.loadedFiles.length; i++) {272 if (this.loadedFiles[i] == url)273 return;274 }275 276 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');277 278 this.loadedFiles[this.loadedFiles.length] = url;279 };280 281 TinyMCE.prototype.loadCSS = function(url) {282 for (var i=0; i<this.loadedFiles.length; i++) {283 if (this.loadedFiles[i] == url)284 return;285 }286 287 document.write('<link href="' + url + '" rel="stylesheet" type="text/css" />');288 289 this.loadedFiles[this.loadedFiles.length] = url;290 };291 292 TinyMCE.prototype.importCSS = function(doc, css_file) {293 if (css_file == '')294 return;295 296 if (typeof(doc.createStyleSheet) == "undefined") {297 var elm = doc.createElement("link");298 299 elm.rel = "stylesheet";300 elm.href = css_file;301 302 if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)303 headArr[0].appendChild(elm);304 } else305 var styleSheet = doc.createStyleSheet(css_file);306 };307 308 TinyMCE.prototype.confirmAdd = function(e, settings) {309 var elm = tinyMCE.isMSIE ? event.srcElement : e.target;310 var elementId = elm.name ? elm.name : elm.id;311 312 tinyMCE.settings = settings;313 314 if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm']))315 tinyMCE.addMCEControl(elm, elementId);316 317 elm.setAttribute('mce_noask', 'true');318 };319 320 TinyMCE.prototype.updateContent = function(form_element_name) {321 // Find MCE instance linked to given form element and copy it's value322 var formElement = document.getElementById(form_element_name);323 for (var n in tinyMCE.instances) {324 var inst = tinyMCE.instances[n];325 if (!tinyMCE.isInstance(inst))326 continue;327 328 inst.switchSettings();329 330 if (inst.formElement == formElement) {331 var doc = inst.getDoc();332 333 tinyMCE._setHTML(doc, inst.formElement.value);334 335 if (!tinyMCE.isMSIE)336 doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);337 }338 }339 };340 341 TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) {342 var id = "mce_editor_" + tinyMCE.idCounter++;343 var inst = new TinyMCEControl(tinyMCE.settings);344 345 inst.editorId = id;346 this.instances[id] = inst;347 348 inst.onAdd(replace_element, form_element_name, target_document);349 };350 351 TinyMCE.prototype.triggerSave = function(skip_cleanup, skip_callback) {352 // Cleanup and set all form fields353 for (var n in tinyMCE.instances) {354 var inst = tinyMCE.instances[n];355 if (!tinyMCE.isInstance(inst))356 continue;357 358 inst.switchSettings();359 360 tinyMCE.settings['preformatted'] = false;361 362 // Default to false363 if (typeof(skip_cleanup) == "undefined")364 skip_cleanup = false;365 366 // Default to false367 if (typeof(skip_callback) == "undefined")368 skip_callback = false;369 370 tinyMCE._setHTML(inst.getDoc(), inst.getBody().innerHTML);371 372 // Remove visual aids when cleanup is disabled373 if (inst.settings['cleanup'] == false) {374 tinyMCE.handleVisualAid(inst.getBody(), true, false, inst);375 tinyMCE._setEventsEnabled(inst.getBody(), true);376 }377 378 tinyMCE._customCleanup(inst, "submit_content_dom", inst.contentWindow.document.body);379 var htm = skip_cleanup ? inst.getBody().innerHTML : tinyMCE._cleanupHTML(inst, inst.getDoc(), this.settings, inst.getBody(), this.visualAid, true);380 htm = tinyMCE._customCleanup(inst, "submit_content", htm);381 382 if (tinyMCE.settings["encoding"] == "xml" || tinyMCE.settings["encoding"] == "html")383 htm = tinyMCE.convertStringToXML(htm);384 385 if (!skip_callback && tinyMCE.settings['save_callback'] != "")386 var content = eval(tinyMCE.settings['save_callback'] + "(inst.formTargetElementId,htm,inst.getBody());");387 388 // Use callback content if available389 if ((typeof(content) != "undefined") && content != null)390 htm = content;391 392 // Replace some weird entities (Bug: #1056343)393 htm = tinyMCE.regexpReplace(htm, "(", "(", "gi");394 htm = tinyMCE.regexpReplace(htm, ")", ")", "gi");395 htm = tinyMCE.regexpReplace(htm, ";", ";", "gi");396 htm = tinyMCE.regexpReplace(htm, """, """, "gi");397 htm = tinyMCE.regexpReplace(htm, "^", "^", "gi");398 399 if (inst.formElement)400 inst.formElement.value = htm;401 }402 };403 404 TinyMCE.prototype._setEventsEnabled = function(node, state) {405 var events = new Array('onfocus','onblur','onclick','ondblclick',406 'onmousedown','onmouseup','onmouseover','onmousemove',407 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');408 409 var evs = tinyMCE.settings['event_elements'].split(',');410 for (var y=0; y<evs.length; y++){411 var elms = node.getElementsByTagName(evs[y]);412 for (var i=0; i<elms.length; i++) {413 var event = "";414 415 for (var x=0; x<events.length; x++) {416 if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') {417 event = tinyMCE.cleanupEventStr("" + event);418 419 if (!state)420 event = "return true;" + event;421 else422 event = event.replace(/^return true;/gi, '');423 424 elms[i].removeAttribute(events[x]);425 elms[i].setAttribute(events[x], event);426 }427 }428 }429 }430 };431 432 TinyMCE.prototype.resetForm = function(form_index) {433 var formObj = document.forms[form_index];434 435 for (var n in tinyMCE.instances) {436 var inst = tinyMCE.instances[n];437 if (!tinyMCE.isInstance(inst))438 continue;439 440 inst.switchSettings();441 442 for (var i=0; i<formObj.elements.length; i++) {443 if (inst.formTargetElementId == formObj.elements[i].name) {444 inst.getBody().innerHTML = formObj.elements[i].value;445 return;446 }447 }448 }449 };450 var asdf = 0;451 TinyMCE.prototype.execInstanceCommand = function(editor_id, command, user_interface, value, focus) {452 var inst = tinyMCE.getInstanceById(editor_id);453 if (inst) {454 if (typeof(focus) == "undefined")455 focus = true;456 457 if (focus)458 inst.contentWindow.focus();459 460 // Reset design mode if lost461 inst.autoResetDesignMode();462 asdf = asdf + 1; if ( asdf == 1 ) alert ( 'asdf = 1' );463 this.selectedElement = inst.getFocusElement();464 this.selectedInstance = inst;465 tinyMCE.execCommand(command, user_interface, value);466 467 // Cancel event so it doesn't call onbeforeonunlaod468 if (tinyMCE.isMSIE && window.event != null)469 tinyMCE.cancelEvent(window.event);470 }471 };472 473 TinyMCE.prototype.execCommand = function(command, user_interface, value) {474 // Default input475 user_interface = user_interface ? user_interface : false;476 value = value ? value : null;477 478 if (tinyMCE.selectedInstance)479 tinyMCE.selectedInstance.switchSettings();480 481 switch (command) {482 case 'mceHelp':483 var template = new Array();484 485 template['file'] = 'about.htm';486 template['width'] = 480;487 template['height'] = 380;488 489 tinyMCE.openWindow(template, {490 tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,491 tinymce_releasedate : tinyMCE.releaseDate,492 inline : "yes"493 });494 return;495 496 case 'mceFocus':497 var inst = tinyMCE.getInstanceById(value);498 if (inst)499 inst.contentWindow.focus();500 return;501 502 case "mceAddControl":503 case "mceAddEditor":504 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);505 return;506 507 case "mceAddFrameControl":508 tinyMCE.addMCEControl(tinyMCE._getElementById(value), value['element'], value['document']);509 return;510 511 case "mceRemoveControl":512 case "mceRemoveEditor":513 tinyMCE.removeMCEControl(value);514 return;515 516 case "mceResetDesignMode":517 // Resets the designmode state of the editors in Gecko518 if (!tinyMCE.isMSIE) {519 for (var n in tinyMCE.instances) {520 if (!tinyMCE.isInstance(tinyMCE.instances[n]))521 continue;522 523 try {524 tinyMCE.instances[n].getDoc().designMode = "on";525 } catch (e) {526 // Ignore any errors527 }528 }529 }530 531 return;532 }533 534 if (this.selectedInstance) {535 this.selectedInstance.execCommand(command, user_interface, value);536 } else if (tinyMCE.settings['focus_alert'])537 alert(tinyMCELang['lang_focus_alert']);538 };539 540 TinyMCE.prototype.eventPatch = function(editor_id) {541 // Remove odd, error542 if (typeof(tinyMCE) == "undefined")543 return true;544 545 for (var i=0; i<document.frames.length; i++) {546 try {547 if (document.frames[i].event) {548 var event = document.frames[i].event;549 550 if (!event.target)551 event.target = event.srcElement;552 553 TinyMCE.prototype.handleEvent(event);554 return;555 }556 } catch (ex) {557 // Ignore error if iframe is pointing to external URL558 }559 }560 };561 562 TinyMCE.prototype.unloadHandler = function() {563 tinyMCE.triggerSave(true, true);564 };565 566 TinyMCE.prototype.addEventHandlers = function(editor_id) {567 if (tinyMCE.isMSIE) {568 var doc = document.frames[editor_id].document;569 570 // Event patch571 tinyMCE.addEvent(doc, "keypress", TinyMCE.prototype.eventPatch);572 tinyMCE.addEvent(doc, "keyup", TinyMCE.prototype.eventPatch);573 tinyMCE.addEvent(doc, "keydown", TinyMCE.prototype.eventPatch);574 tinyMCE.addEvent(doc, "mouseup", TinyMCE.prototype.eventPatch);575 tinyMCE.addEvent(doc, "click", TinyMCE.prototype.eventPatch);576 } else {577 var inst = tinyMCE.instances[editor_id];578 var doc = inst.getDoc();579 580 inst.switchSettings();581 582 tinyMCE.addEvent(doc, "keypress", tinyMCE.handleEvent);583 tinyMCE.addEvent(doc, "keydown", tinyMCE.handleEvent);584 tinyMCE.addEvent(doc, "keyup", tinyMCE.handleEvent);585 tinyMCE.addEvent(doc, "click", tinyMCE.handleEvent);586 tinyMCE.addEvent(doc, "mouseup", tinyMCE.handleEvent);587 tinyMCE.addEvent(doc, "mousedown", tinyMCE.handleEvent);588 tinyMCE.addEvent(doc, "focus", tinyMCE.handleEvent);589 tinyMCE.addEvent(doc, "blur", tinyMCE.handleEvent);590 591 eval('try { doc.designMode = "On"; } catch(e) {}');592 }593 };594 595 TinyMCE.prototype._createIFrame = function(replace_element) {596 var iframe = document.createElement("iframe");597 var id = replace_element.getAttribute("id");598 var aw, ah;599 600 aw = "" + tinyMCE.settings['area_width'];601 ah = "" + tinyMCE.settings['area_height'];602 603 if (aw.indexOf('%') == -1) {604 aw = parseInt(aw);605 aw = aw < 0 ? 300 : aw;606 aw = aw + "px";607 }608 609 if (ah.indexOf('%') == -1) {610 ah = parseInt(ah);611 ah = ah < 0 ? 240 : ah;612 ah = ah + "px";613 }614 615 iframe.setAttribute("id", id);616 //iframe.setAttribute("className", "mceEditorArea");617 iframe.setAttribute("border", "0");618 iframe.setAttribute("frameBorder", "0");619 iframe.setAttribute("marginWidth", "0");620 iframe.setAttribute("marginHeight", "0");621 iframe.setAttribute("leftMargin", "0");622 iframe.setAttribute("topMargin", "0");623 iframe.setAttribute("width", aw);624 iframe.setAttribute("height", ah);625 iframe.setAttribute("allowtransparency", "true");626 627 if (tinyMCE.settings["auto_resize"])628 iframe.setAttribute("scrolling", "no");629 630 // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs631 if (tinyMCE.isMSIE && !tinyMCE.isOpera)632 iframe.setAttribute("src", this.settings['default_document']);633 634 iframe.style.width = aw;635 iframe.style.height = ah;636 637 // MSIE 5.0 issue638 if (tinyMCE.isMSIE && !tinyMCE.isOpera)639 replace_element.outerHTML = iframe.outerHTML;640 else641 replace_element.parentNode.replaceChild(iframe, replace_element);642 643 if (tinyMCE.isMSIE)644 return window.frames[id];645 else646 return iframe;647 };648 649 TinyMCE.prototype.setupContent = function(editor_id) {650 var inst = tinyMCE.instances[editor_id];651 var doc = inst.getDoc();652 var head = doc.getElementsByTagName('head').item(0);653 var content = inst.startContent;654 655 tinyMCE.operaOpacityCounter = 100 * tinyMCE.idCounter;656 657 inst.switchSettings();658 659 // Not loaded correctly hit it again, Mozilla bug #997860660 if (!tinyMCE.isMSIE && doc.title != "blank_page") {661 // This part will remove the designMode status662 // Failes first time in Firefox 1.5b2 on Mac663 try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}664 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);665 return;666 }667 668 if (!head) {669 window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);670 return;671 }672 673 // Import theme specific content CSS the user specific674 tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings['theme'] + "/css/editor_content.css");675 tinyMCE.importCSS(inst.getDoc(), inst.settings['content_css']);676 tinyMCE.executeCallback('init_instance_callback', '_initInstance', 0, inst);677 678 // Setup span styles679 if (tinyMCE.getParam("convert_fonts_to_spans"))680 inst.getDoc().body.setAttribute('id', 'mceSpanFonts');681 682 if (tinyMCE.settings['nowrap'])683 doc.body.style.whiteSpace = "nowrap";684 685 doc.body.dir = this.settings['directionality'];686 doc.editorId = editor_id;687 688 // Add on document element in Mozilla689 if (!tinyMCE.isMSIE)690 doc.documentElement.editorId = editor_id;691 692 // Setup base element693 var base = doc.createElement("base");694 base.setAttribute('href', tinyMCE.settings['base_href']);695 head.appendChild(base);696 697 // Replace new line characters to BRs698 if (tinyMCE.settings['convert_newlines_to_brs']) {699 content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");700 content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");701 content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");702 }703 704 // Open closed anchors705 // content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');706 707 // Call custom cleanup code708 content = tinyMCE._customCleanup(inst, "insert_to_editor", content);709 710 if (tinyMCE.isMSIE) {711 // Ugly!!!712 window.setInterval('try{tinyMCE.getCSSClasses(document.frames["' + editor_id + '"].document, "' + editor_id + '");}catch(e){}', 500);713 714 if (tinyMCE.settings["force_br_newlines"])715 document.frames[editor_id].document.styleSheets[0].addRule("p", "margin: 0px;");716 717 var body = document.frames[editor_id].document.body;718 719 tinyMCE.addEvent(body, "beforepaste", TinyMCE.prototype.eventPatch);720 tinyMCE.addEvent(body, "beforecut", TinyMCE.prototype.eventPatch);721 722 body.editorId = editor_id;723 }724 725 content = tinyMCE.cleanupHTMLCode(content);726 727 // Fix for bug #958637728 if (!tinyMCE.isMSIE) {729 var contentElement = inst.getDoc().createElement("body");730 var doc = inst.getDoc();731 732 contentElement.innerHTML = content;733 734 // Remove weridness!735 if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt'])736 content = content.replace(new RegExp('<>', 'g'), "");737 738 if (tinyMCE.settings['cleanup_on_startup'])739 tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));740 else {741 // Convert all strong/em to b/i742 content = tinyMCE.regexpReplace(content, "<strong", "<b", "gi");743 content = tinyMCE.regexpReplace(content, "<em(/?)>", "<i$1>", "gi");744 content = tinyMCE.regexpReplace(content, "<em ", "<i ", "gi");745 content = tinyMCE.regexpReplace(content, "</strong>", "</b>", "gi");746 content = tinyMCE.regexpReplace(content, "</em>", "</i>", "gi");747 tinyMCE.setInnerHTML(inst.getBody(), content);748 }749 750 inst.convertAllRelativeURLs();751 } else {752 if (tinyMCE.settings['cleanup_on_startup']) {753 tinyMCE._setHTML(inst.getDoc(), content);754 755 // Produces permission denied error in MSIE 5.5756 eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody());} catch(e) {}');757 } else758 tinyMCE._setHTML(inst.getDoc(), content);759 }760 761 // Fix for bug #957681762 //inst.getDoc().designMode = inst.getDoc().designMode;763 764 // Setup element references765 var parentElm = document.getElementById(inst.editorId + '_parent');766 if (parentElm.lastChild.nodeName.toLowerCase() == "input")767 inst.formElement = parentElm.lastChild;768 else769 inst.formElement = parentElm.nextSibling;770 771 tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);772 tinyMCE.executeCallback('setupcontent_callback', '_setupContent', 0, editor_id, inst.getBody(), inst.getDoc());773 774 // Re-add design mode on mozilla775 if (!tinyMCE.isMSIE)776 TinyMCE.prototype.addEventHandlers(editor_id);777 778 // Add blur handler779 if (tinyMCE.isMSIE)780 tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE.prototype.eventPatch);781 782 // Trigger node change, this call locks buttons for tables and so forth783 tinyMCE.selectedInstance = inst;784 tinyMCE.selectedElement = inst.contentWindow.document.body;785 tinyMCE.triggerNodeChange(false, true);786 787 // Call custom DOM cleanup788 tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());789 tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());790 tinyMCE._setEventsEnabled(inst.getBody(), false);791 tinyMCE.cleanupAnchors(inst.getDoc());792 793 if (tinyMCE.getParam("convert_fonts_to_spans"))794 tinyMCE.convertSpansToFonts(inst.getDoc());795 796 inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);797 inst.undoLevels[inst.undoLevels.length] = inst.startContent;798 799 tinyMCE.operaOpacityCounter = -1;800 };801 802 TinyMCE.prototype.cleanupHTMLCode = function(s) {803 s = s.replace(/<p \/>/gi, '<p> </p>');804 s = s.replace(/<p>\s*<\/p>/gi, '<p> </p>');805 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>');806 s = s.replace(new RegExp('\\s+></', 'gi'), '></');807 808 // Weird MSIE bug, <p><hr /></p> breaks runtime?809 if (tinyMCE.isMSIE)810 s = s.replace(/<p><hr \/><\/p>/gi, "<hr>");811 812 // Convert relative anchors to absolute URLs ex: #something to file.htm#something813 s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");814 815 return s;816 };817 818 TinyMCE.prototype.cancelEvent = function(e) {819 if (tinyMCE.isMSIE) {820 e.returnValue = false;821 e.cancelBubble = true;822 } else823 e.preventDefault();824 };825 826 TinyMCE.prototype.removeTinyMCEFormElements = function(form_obj) {827 // Disable all UI form elements that TinyMCE created828 for (var i=0; i<form_obj.elements.length; i++) {829 var elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;830 831 if (elementId.indexOf('mce_editor_') == 0)832 form_obj.elements[i].disabled = true;833 }834 };835 836 TinyMCE.prototype.accessibleEventHandler = function(e) {837 var win = this._win;838 e = tinyMCE.isMSIE ? win.event : e;839 var elm = tinyMCE.isMSIE ? e.srcElement : e.target;840 841 // Piggyback onchange842 if (elm.nodeName == "SELECT" && !elm.oldonchange) {843 elm.oldonchange = elm.onchange;844 elm.onchange = null;845 }846 847 // Execute onchange and remove piggyback848 if (e.keyCode == 13 || e.keyCode == 32) {849 elm.onchange = elm.oldonchange;850 elm.onchange();851 elm.oldonchange = null;852 tinyMCE.cancelEvent(e);853 }854 };855 856 TinyMCE.prototype.addSelectAccessibility = function(e, select, win) {857 // Add event handlers858 if (!select._isAccessible) {859 select.onkeydown = tinyMCE.accessibleEventHandler;860 select._isAccessible = true;861 select._win = win;862 }863 };864 865 TinyMCE.prototype.handleEvent = function(e) {866 // Remove odd, error867 if (typeof(tinyMCE) == "undefined")868 return true;869 870 //tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""));871 872 switch (e.type) {873 case "blur":874 if (tinyMCE.selectedInstance)875 tinyMCE.selectedInstance.execCommand('mceEndTyping');876 877 return;878 879 case "submit":880 tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);881 tinyMCE.triggerSave();882 tinyMCE.isNotDirty = true;883 return;884 885 case "reset":886 var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;887 888 for (var i=0; i<document.forms.length; i++) {889 if (document.forms[i] == formObj)890 window.setTimeout('tinyMCE.resetForm(' + i + ');', 10);891 }892 893 return;894 895 case "keypress":896 if (e.target.editorId) {897 tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];898 } else {899 if (e.target.ownerDocument.editorId)900 tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];901 }902 903 if (tinyMCE.selectedInstance)904 tinyMCE.selectedInstance.switchSettings();905 906 // Insert space instead of 907 /* if (tinyMCE.isGecko && e.charCode == 32) {908 if (tinyMCE.selectedInstance._insertSpace()) {909 // Cancel event910 e.preventDefault();911 return false;912 }913 }*/914 915 // Insert P element916 if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {917 // Insert P element instead of BR918 if (tinyMCE.selectedInstance._insertPara(e)) {919 // Cancel event920 tinyMCE.execCommand("mceAddUndoLevel");921 tinyMCE.cancelEvent(e);922 return false;923 }924 }925 926 // Handle backspace927 if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {928 // Insert P element instead of BR929 if (tinyMCE.selectedInstance._handleBackSpace(e.type)) {930 // Cancel event931 tinyMCE.execCommand("mceAddUndoLevel");932 e.preventDefault();933 return false;934 }935 }936 937 // Mozilla custom key handling938 if (tinyMCE.isGecko && (e.ctrlKey && !e.altKey) && tinyMCE.settings['custom_undo_redo']) {939 if (tinyMCE.settings['custom_undo_redo_keyboard_shortcuts']) {940 if (e.charCode == 122) { // Ctrl+Z941 tinyMCE.selectedInstance.execCommand("Undo");942 943 // Cancel event944 e.preventDefault();945 return false;946 }947 948 if (e.charCode == 121) { // Ctrl+Y949 tinyMCE.selectedInstance.execCommand("Redo");950 951 // Cancel event952 e.preventDefault();953 return false;954 }955 }956 957 if (e.charCode == 98) { // Ctrl+B958 tinyMCE.selectedInstance.execCommand("Bold");959 960 // Cancel event961 e.preventDefault();962 return false;963 }964 965 if (e.charCode == 105) { // Ctrl+I966 tinyMCE.selectedInstance.execCommand("Italic");967 968 // Cancel event969 e.preventDefault();970 return false;971 }972 973 if (e.charCode == 117) { // Ctrl+U974 tinyMCE.selectedInstance.execCommand("Underline");975 976 // Cancel event977 e.preventDefault();978 return false;979 }980 }981 982 // Return key pressed983 if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {984 if (e.target.editorId)985 tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];986 987 if (tinyMCE.selectedInstance) {988 var sel = tinyMCE.selectedInstance.getDoc().selection;989 var rng = sel.createRange();990 991 if (tinyMCE.getParentElement(rng.parentElement(), "li") != null)992 return false;993 994 // Cancel event995 e.returnValue = false;996 e.cancelBubble = true;997 998 // Insert BR element999 rng.pasteHTML("<br />");1000 rng.collapse(false);1001 rng.select();1002 1003 tinyMCE.execCommand("mceAddUndoLevel");1004 tinyMCE.triggerNodeChange(false);1005 return false;1006 }1007 }1008 1009 // Backspace or delete1010 if (e.keyCode == 8 || e.keyCode == 46) {1011 tinyMCE.selectedElement = e.target;1012 tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");1013 tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");1014 tinyMCE.triggerNodeChange(false);1015 }1016 1017 return false;1018 break;1019 1020 case "keyup":1021 case "keydown":1022 if (e.target.editorId)1023 tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];1024 else1025 return;1026 1027 if (tinyMCE.selectedInstance)1028 tinyMCE.selectedInstance.switchSettings();1029 1030 var inst = tinyMCE.selectedInstance;1031 1032 // Handle backspace1033 if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {1034 // Insert P element instead of BR1035 if (tinyMCE.selectedInstance._handleBackSpace(e.type)) {1036 // Cancel event1037 tinyMCE.execCommand("mceAddUndoLevel");1038 e.preventDefault();1039 return false;1040 }1041 }1042 1043 tinyMCE.selectedElement = null;1044 tinyMCE.selectedNode = null;1045 var elm = tinyMCE.selectedInstance.getFocusElement();1046 tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");1047 tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");1048 tinyMCE.selectedElement = elm;1049 1050 // Update visualaids on tabs1051 if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)1052 tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);1053 1054 // Run image/link fix on Gecko if diffrent document base on paste1055 if (tinyMCE.isGecko && tinyMCE.settings['document_base_url'] != "" + document.location.href && e.type == "keyup" && e.ctrlKey && e.keyCode == 86)1056 tinyMCE.selectedInstance.fixBrokenURLs();1057 1058 // Fix empty elements on return/enter, check where enter occured1059 if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)1060 tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();1061 1062 // Fix empty elements on return/enter1063 if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {1064 var elm = tinyMCE.enterKeyElement;1065 if (elm) {1066 var re = new RegExp('^HR|IMG|BR$','g'); // Skip these1067 var dre = new RegExp('^H[1-6]$','g'); // Add double on these1068 1069 if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {1070 if (dre.test(elm.nodeName))1071 elm.innerHTML = " ";1072 else1073 elm.innerHTML = " ";1074 }1075 }1076 }1077 1078 // Check if it's a position key1079 var keys = tinyMCE.posKeyCodes;1080 var posKey = false;1081 for (var i=0; i<keys.length; i++) {1082 if (keys[i] == e.keyCode) {1083 posKey = true;1084 break;1085 }1086 }1087 1088 // MSIE custom key handling1089 if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {1090 var keys = new Array(8,46); // Backspace,Delete1091 for (var i=0; i<keys.length; i++) {1092 if (keys[i] == e.keyCode) {1093 if (e.type == "keyup")1094 tinyMCE.triggerNodeChange(false);1095 }1096 }1097 1098 if (tinyMCE.settings['custom_undo_redo_keyboard_shortcuts']) {1099 if (e.keyCode == 90 && (e.ctrlKey && !e.altKey) && e.type == "keydown") { // Ctrl+Z1100 tinyMCE.selectedInstance.execCommand("Undo");1101 tinyMCE.triggerNodeChange(false);1102 }1103 1104 if (e.keyCode == 89 && (e.ctrlKey && !e.altKey) && e.type == "keydown") { // Ctrl+Y1105 tinyMCE.selectedInstance.execCommand("Redo");1106 tinyMCE.triggerNodeChange(false);1107 }1108 1109 if ((e.keyCode == 90 || e.keyCode == 89) && (e.ctrlKey && !e.altKey)) {1110 // Cancel event1111 e.returnValue = false;1112 e.cancelBubble = true;1113 return false;1114 }1115 }1116 }1117 1118 // Handle Undo/Redo when typing content1119 1120 // Start typing (non position key)1121 if (!posKey && e.type == "keyup")1122 tinyMCE.execCommand("mceStartTyping");1123 1124 // End typing (position key) or some Ctrl event1125 if (e.type == "keyup" && (posKey || e.ctrlKey))1126 tinyMCE.execCommand("mceEndTyping");1127 1128 if (posKey && e.type == "keyup")1129 tinyMCE.triggerNodeChange(false);1130 1131 if (tinyMCE.isMSIE && e.ctrlKey)1132 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);1133 break;1134 1135 case "mousedown":1136 case "mouseup":1137 case "click":1138 case "focus":1139 if (tinyMCE.selectedInstance)1140 tinyMCE.selectedInstance.switchSettings();1141 1142 // Check instance event trigged on1143 var targetBody = tinyMCE.getParentElement(e.target, "body");1144 for (var instanceName in tinyMCE.instances) {1145 if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))1146 continue;1147 1148 var inst = tinyMCE.instances[instanceName];1149 1150 // Reset design mode if lost (on everything just in case)1151 inst.autoResetDesignMode();1152 1153 if (inst.getBody() == targetBody) {1154 tinyMCE.selectedInstance = inst;1155 tinyMCE.selectedElement = e.target;1156 tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");1157 tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");1158 break;1159 }1160 }1161 1162 if (tinyMCE.isSafari) {1163 tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.getBookmark();1164 tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;1165 1166 var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");1167 1168 // Patch the darned link1169 if (lnk && e.type == "mousedown") {1170 lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));1171 lnk.setAttribute("href", "javascript:void(0);");1172 }1173 1174 // Patch back1175 if (lnk && e.type == "click") {1176 window.setTimeout(function() {1177 lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));1178 lnk.removeAttribute("mce_real_href");1179 }, 10);1180 }1181 }1182 1183 // Reset selected node1184 if (e.type != "focus")1185 tinyMCE.selectedNode = null;1186 1187 tinyMCE.triggerNodeChange(false);1188 tinyMCE.execCommand("mceEndTyping");1189 1190 if (e.type == "mouseup")1191 tinyMCE.execCommand("mceAddUndoLevel");1192 1193 // Just in case1194 if (!tinyMCE.selectedInstance && e.target.editorId)1195 tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];1196 1197 // Run image/link fix on Gecko if diffrent document base1198 if (tinyMCE.isGecko && tinyMCE.settings['document_base_url'] != "" + document.location.href)1199 window.setTimeout('tinyMCE.getInstanceById("' + inst.editorId + '").fixBrokenURLs();', 10);1200 1201 return false;1202 break;1203 } // end switch1204 }; // end function1205 1206 TinyMCE.prototype.switchClass = function(element, class_name, lock_state) {1207 var lockChanged = false;1208 1209 if (typeof(lock_state) != "undefined" && element != null) {1210 element.classLock = lock_state;1211 lockChanged = true;1212 }1213 1214 if (element != null && (lockChanged || !element.classLock)) {1215 element.oldClassName = element.className;1216 element.className = class_name;1217 }1218 };1219 1220 TinyMCE.prototype.restoreAndSwitchClass = function(element, class_name) {1221 if (element != null && !element.classLock) {1222 this.restoreClass(element);1223 this.switchClass(element, class_name);1224 }1225 };1226 1227 TinyMCE.prototype.switchClassSticky = function(element_name, class_name, lock_state) {1228 var element, lockChanged = false;1229 1230 // Performance issue1231 if (!this.stickyClassesLookup[element_name])1232 this.stickyClassesLookup[element_name] = document.getElementById(element_name);1233 1234 // element = document.getElementById(element_name);1235 element = this.stickyClassesLookup[element_name];1236 1237 if (typeof(lock_state) != "undefined" && element != null) {1238 element.classLock = lock_state;1239 lockChanged = true;1240 }1241 1242 if (element != null && (lockChanged || !element.classLock)) {1243 element.className = class_name;1244 element.oldClassName = class_name;1245 1246 // Fix opacity in Opera1247 if (tinyMCE.isOpera) {1248 if (class_name == "mceButtonDisabled") {1249 var suffix = "";1250 1251 if (!element.mceOldSrc)1252 element.mceOldSrc = element.src;1253 1254 if (this.operaOpacityCounter > -1)1255 suffix = '?rnd=' + this.operaOpacityCounter++;1256 1257 element.src = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/images/opacity.png" + suffix;1258 element.style.backgroundImage = "url('" + element.mceOldSrc + "')";1259 } else {1260 if (element.mceOldSrc) {1261 element.src = element.mceOldSrc;1262 element.parentNode.style.backgroundImage = "";1263 element.mceOldSrc = null;1264 }1265 }1266 }1267 }1268 };1269 1270 TinyMCE.prototype.restoreClass = function(element) {1271 if (element != null && element.oldClassName && !element.classLock) {1272 element.className = element.oldClassName;1273 element.oldClassName = null;1274 }1275 };1276 1277 TinyMCE.prototype.setClassLock = function(element, lock_state) {1278 if (element != null)1279 element.classLock = lock_state;1280 };1281 1282 TinyMCE.prototype.addEvent = function(obj, name, handler) {1283 if (tinyMCE.isMSIE) {1284 obj.attachEvent("on" + name, handler);1285 } else1286 obj.addEventListener(name, handler, false);1287 };1288 1289 TinyMCE.prototype.submitPatch = function() {1290 tinyMCE.removeTinyMCEFormElements(this);1291 tinyMCE.triggerSave();1292 this.mceOldSubmit();1293 tinyMCE.isNotDirty = true;1294 };1295 1296 TinyMCE.prototype.onLoad = function() {1297 for (var c=0; c<tinyMCE.configs.length; c++) {1298 tinyMCE.settings = tinyMCE.configs[c];1299 1300 var selector = tinyMCE.getParam("editor_selector");1301 var deselector = tinyMCE.getParam("editor_deselector");1302 var elementRefAr = new Array();1303 1304 // Add submit triggers1305 if (document.forms && tinyMCE.settings['add_form_submit_trigger'] && !tinyMCE.submitTriggers) {1306 for (var i=0; i<document.forms.length; i++) {1307 var form = document.forms[i];1308 1309 tinyMCE.addEvent(form, "submit", TinyMCE.prototype.handleEvent);1310 tinyMCE.addEvent(form, "reset", TinyMCE.prototype.handleEvent);1311 tinyMCE.submitTriggers = true; // Do it only once1312 1313 // Patch the form.submit function1314 if (tinyMCE.settings['submit_patch']) {1315 try {1316 form.mceOldSubmit = form.submit;1317 form.submit = TinyMCE.prototype.submitPatch;1318 } catch (e) {1319 // Do nothing1320 }1321 }1322 }1323 }1324 1325 // Add editor instances based on mode1326 var mode = tinyMCE.settings['mode'];1327 switch (mode) {1328 case "exact":1329 var elements = tinyMCE.getParam('elements', '', true, ',');1330 1331 for (var i=0; i<elements.length; i++) {1332 var element = tinyMCE._getElementById(elements[i]);1333 var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";1334 1335 if (tinyMCE.getAttrib(element, "class").indexOf(deselector) != -1)1336 continue;1337 1338 if (trigger == "false")1339 continue;1340 1341 if (tinyMCE.settings['ask'] && element) {1342 elementRefAr[elementRefAr.length] = element;1343 continue;1344 }1345 1346 if (element)1347 tinyMCE.addMCEControl(element, elements[i]);1348 else if (tinyMCE.settings['debug'])1349 alert("Error: Could not find element by id or name: " + elements[i]);1350 }1351 break;1352 1353 case "specific_textareas":1354 case "textareas":1355 var nodeList = document.getElementsByTagName("textarea");1356 1357 for (var i=0; i<nodeList.length; i++) {1358 var elm = nodeList.item(i);1359 var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);1360 1361 if (selector != '' && tinyMCE.getAttrib(elm, "class").indexOf(selector) == -1)1362 continue;1363 1364 if (tinyMCE.getAttrib(elm, "class").indexOf(deselector) != -1)1365 continue;1366 1367 if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))1368 elementRefAr[elementRefAr.length] = elm;1369 }1370 break;1371 }1372 1373 for (var i=0; i<elementRefAr.length; i++) {1374 var element = elementRefAr[i];1375 var elementId = element.name ? element.name : element.id;1376 1377 if (tinyMCE.settings['ask']) {1378 // Focus breaks in Mozilla1379 if (tinyMCE.isGecko) {1380 var settings = tinyMCE.settings;1381 1382 tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE.prototype.confirmAdd(e, settings);}, 10);});1383 } else {1384 var settings = tinyMCE.settings;1385 1386 tinyMCE.addEvent(element, "focus", function () { TinyMCE.prototype.confirmAdd(null, settings); });1387 }1388 } else1389 tinyMCE.addMCEControl(element, elementId);1390 }1391 1392 // Handle auto focus1393 if (tinyMCE.settings['auto_focus']) {1394 window.setTimeout(function () {1395 var inst = tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']);1396 inst.selectNode(inst.getBody(), true, true);1397 inst.contentWindow.focus();1398 }, 10);1399 }1400 1401 tinyMCE.executeCallback('oninit', '_oninit', 0);1402 }1403 };1404 1405 TinyMCE.prototype.removeMCEControl = function(editor_id) {1406 var inst = tinyMCE.getInstanceById(editor_id);1407 1408 if (inst) {1409 inst.switchSettings();1410 1411 editor_id = inst.editorId;1412 var html = tinyMCE.getContent(editor_id);1413 1414 // Remove editor instance from instances array1415 var tmpInstances = new Array();1416 for (var instanceName in tinyMCE.instances) {1417 var instance = tinyMCE.instances[instanceName];1418 if (!tinyMCE.isInstance(instance))1419 continue;1420 1421 if (instanceName != editor_id)1422 tmpInstances[instanceName] = instance;1423 }1424 tinyMCE.instances = tmpInstances;1425 1426 tinyMCE.selectedElement = null;1427 tinyMCE.selectedInstance = null;1428 1429 // Remove element1430 var replaceElement = document.getElementById(editor_id + "_parent");1431 var oldTargetElement = inst.oldTargetElement;1432 var targetName = oldTargetElement.nodeName.toLowerCase();1433 1434 if (targetName == "textarea" || targetName == "input") {1435 // Just show the old text area1436 replaceElement.parentNode.removeChild(replaceElement);1437 oldTargetElement.style.display = "inline";1438 oldTargetElement.value = html;1439 } else {1440 oldTargetElement.innerHTML = html;1441 1442 replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);1443 replaceElement.parentNode.removeChild(replaceElement);1444 }1445 }1446 };1447 1448 TinyMCE.prototype._cleanupElementName = function(element_name, element) {1449 var name = "";1450 1451 element_name = element_name.toLowerCase();1452 1453 // Never include body1454 if (element_name == "body")1455 return null;1456 1457 // If verification mode1458 if (tinyMCE.cleanup_verify_html) {1459 // Check if invalid element1460 for (var i=0; i<tinyMCE.cleanup_invalidElements.length; i++) {1461 if (tinyMCE.cleanup_invalidElements[i] == element_name)1462 return null;1463 }1464 1465 // Check if valid element1466 var validElement = false;1467 var elementAttribs = null;1468 for (var i=0; i<tinyMCE.cleanup_validElements.length && !elementAttribs; i++) {1469 for (var x=0, n=tinyMCE.cleanup_validElements[i][0].length; x<n; x++) {1470 var elmMatch = tinyMCE.cleanup_validElements[i][0][x];1471 1472 if (elmMatch.charAt(0) == '+' || elmMatch.charAt(0) == '-')1473 elmMatch = elmMatch.substring(1);1474 1475 // Handle wildcard/regexp1476 if (elmMatch.match(new RegExp('\\*|\\?|\\+', 'g')) != null) {1477 elmMatch = elmMatch.replace(new RegExp('\\?', 'g'), '(\\S?)');1478 elmMatch = elmMatch.replace(new RegExp('\\+', 'g'), '(\\S+)');1479 elmMatch = elmMatch.replace(new RegExp('\\*', 'g'), '(\\S*)');1480 elmMatch = "^" + elmMatch + "$";1481 if (element_name.match(new RegExp(elmMatch, 'g'))) {1482 elementAttribs = tinyMCE.cleanup_validElements[i];1483 validElement = true;1484 break;1485 }1486 }1487 1488 // Handle non regexp1489 if (element_name == elmMatch) {1490 elementAttribs = tinyMCE.cleanup_validElements[i];1491 validElement = true;1492 element_name = elementAttribs[0][0];1493 break;1494 }1495 }1496 }1497 1498 if (!validElement)1499 return null;1500 }1501 1502 if (element_name.charAt(0) == '+' || element_name.charAt(0) == '-')1503 name = element_name.substring(1);1504 1505 // Special Mozilla stuff1506 if (!tinyMCE.isMSIE) {1507 // Fix for bug #9584981508 if (name == "strong" && !tinyMCE.cleanup_on_save)1509 element_name = "b";1510 else if (name == "em" && !tinyMCE.cleanup_on_save)1511 element_name = "i";1512 }1513 1514 var elmData = new Object();1515 1516 elmData.element_name = element_name;1517 elmData.valid_attribs = elementAttribs;1518 1519 return elmData;1520 };1521 1522 /**1523 * This function moves CSS styles to/from attributes.1524 */1525 TinyMCE.prototype._moveStyle = function(elm, style, attrib) {1526 if (tinyMCE.cleanup_inline_styles) {1527 var val = tinyMCE.getAttrib(elm, attrib);1528 1529 if (val != '') {1530 val = '' + val;1531 1532 switch (attrib) {1533 case "background":1534 val = "url('" + val + "');";1535 break;1536 1537 case "bordercolor":1538 if (elm.style.borderStyle == '' || elm.style.borderStyle == 'none')1539 elm.style.borderStyle = 'solid';1540 break;1541 1542 case "border":1543 case "width":1544 case "height":1545 if (attrib == "border" && elm.style.borderWidth > 0)1546 return;1547 1548 if (val.indexOf('%') == -1)1549 val += 'px';1550 break;1551 1552 case "vspace":1553 case "hspace":1554 elm.style.marginTop = val + "px";1555 elm.style.marginBottom = val + "px";1556 elm.removeAttribute(attrib);1557 return;1558 1559 case "align":1560 if (elm.nodeName == "IMG") {1561 if (tinyMCE.isMSIE)1562 elm.style.styleFloat = val;1563 else1564 elm.style.cssFloat = val;1565 } else1566 elm.style.textAlign = val;1567 1568 elm.removeAttribute(attrib);1569 return;1570 }1571 1572 if (val != '') {1573 eval('elm.style.' + style + ' = val;');1574 elm.removeAttribute(attrib);1575 }1576 }1577 } else {1578 if (style == '')1579 return;1580 1581 var val = eval('elm.style.' + style) == '' ? tinyMCE.getAttrib(elm, attrib) : eval('elm.style.' + style);1582 val = val == null ? '' : '' + val;1583 1584 switch (attrib) {1585 // Always move background to style1586 case "background":1587 if (val.indexOf('url') == -1 && val != '')1588 val = "url('" + val + "');";1589 1590 if (val != '') {1591 elm.style.backgroundImage = val;1592 elm.removeAttribute(attrib);1593 }1594 return;1595 1596 case "border":1597 case "width":1598 case "height":1599 val = val.replace('px', '');1600 break;1601 1602 case "align":1603 if (tinyMCE.getAttrib(elm, 'align') == '') {1604 if (elm.nodeName == "IMG") {1605 if (tinyMCE.isMSIE && elm.style.styleFloat != '') {1606 val = elm.style.styleFloat;1607 style = 'styleFloat';1608 } else if (tinyMCE.isGecko && elm.style.cssFloat != '') {1609 val = elm.style.cssFloat;1610 style = 'cssFloat';1611 }1612 }1613 }1614 break;1615 }1616 1617 if (val != '') {1618 elm.removeAttribute(attrib);1619 elm.setAttribute(attrib, val);1620 eval('elm.style.' + style + ' = "";');1621 }1622 }1623 };1624 1625 TinyMCE.prototype._cleanupAttribute = function(valid_attributes, element_name, attribute_node, element_node) {1626 var attribName = attribute_node.nodeName.toLowerCase();1627 var attribValue = attribute_node.nodeValue;1628 var attribMustBeValue = null;1629 var verified = false;1630 1631 // Mozilla attibute, remove them1632 if (attribName.indexOf('moz_') != -1)1633 return null;1634 1635 // Mozilla fix for drag-drop/copy/paste images1636 if (!tinyMCE.isMSIE && (attribName == "mce_real_href" || attribName == "mce_real_src")) {1637 if (!tinyMCE.cleanup_on_save) {1638 var attrib = new Object();1639 1640 attrib.name = attribName;1641 attrib.value = attribValue;1642 1643 return attrib;1644 } else1645 return null;1646 }1647 1648 // Verify attrib1649 if (tinyMCE.cleanup_verify_html && !verified) {1650 for (var i=1; i<valid_attributes.length; i++) {1651 var attribMatch = valid_attributes[i][0];1652 var re = null;1653 1654 // Build regexp from wildcard1655 if (attribMatch.match(new RegExp('\\*|\\?|\\+', 'g')) != null) {1656 attribMatch = attribMatch.replace(new RegExp('\\?', 'g'), '(\\S?)');1657 attribMatch = attribMatch.replace(new RegExp('\\+', 'g'), '(\\S+)');1658 attribMatch = attribMatch.replace(new RegExp('\\*', 'g'), '(\\S*)');1659 attribMatch = "^" + attribMatch + "$";1660 re = new RegExp(attribMatch, 'g');1661 }1662 1663 if ((re && attribName.match(re) != null) || attribName == attribMatch) {1664 verified = true;1665 attribMustBeValue = valid_attributes[i][3];1666 break;1667 }1668 }1669 1670 if (!verified)1671 return false;1672 } else1673 verified = true;1674 1675 // Treat some attribs diffrent1676 switch (attribName) {1677 case "size":1678 if (tinyMCE.isMSIE5 && element_name == "font")1679 attribValue = element_node.size;1680 break;1681 1682 case "width":1683 case "height":1684 case "border":1685 // Old MSIE needs this1686 if (tinyMCE.isMSIE5)1687 attribValue = eval("element_node." + attribName);1688 break;1689 1690 case "shape":1691 attribValue = attribValue.toLowerCase();1692 break;1693 1694 case "cellspacing":1695 if (tinyMCE.isMSIE5)1696 attribValue = element_node.cellSpacing;1697 break;1698 1699 case "cellpadding":1700 if (tinyMCE.isMSIE5)1701 attribValue = element_node.cellPadding;1702 break;1703 1704 case "color":1705 if (tinyMCE.isMSIE5 && element_name == "font")1706 attribValue = element_node.color;1707 break;1708 1709 case "class":1710 // Remove mceItem classes from anchors1711 if (tinyMCE.cleanup_on_save && attribValue.indexOf('mceItemAnchor') != -1)1712 attribValue = attribValue.replace(/mceItem[a-z0-9]+/gi, '');1713 1714 if (element_name == "table" || element_name == "td") {1715 // Handle visual aid1716 if (tinyMCE.cleanup_visual_table_class != "")1717 attribValue = tinyMCE.getVisualAidClass(attribValue, !tinyMCE.cleanup_on_save);1718 }1719 1720 if (!tinyMCE._verifyClass(element_node) || attribValue == "")1721 return null;1722 1723 break;1724 1725 case "onfocus":1726 case "onblur":1727 case "onclick":1728 case "ondblclick":1729 case "onmousedown":1730 case "onmouseup":1731 case "onmouseover":1732 case "onmousemove":1733 case "onmouseout":1734 case "onkeypress":1735 case "onkeydown":1736 case "onkeydown":1737 case "onkeyup":1738 attribValue = tinyMCE.cleanupEventStr("" + attribValue);1739 1740 if (attribValue.indexOf('return false;') == 0)1741 attribValue = attribValue.substring(14);1742 1743 break;1744 1745 case "style":1746 attribValue = tinyMCE.serializeStyle(tinyMCE.parseStyle(tinyMCE.getAttrib(element_node, "style")));1747 break;1748 1749 // Convert the URLs of these1750 case "href":1751 case "src":1752 // Gecko 1.8 issue1753 if (tinyMCE.isGecko18 && attribName == "src")1754 attribValue = element_node.src;1755 1756 // Fix for dragdrop/copy paste Mozilla issue1757 if (!tinyMCE.isMSIE && attribName == "href" && element_node.getAttribute("mce_real_href"))1758 attribValue = element_node.getAttribute("mce_real_href");1759 1760 // Fix for dragdrop/copy paste Mozilla issue1761 if (!tinyMCE.isMSIE && attribName == "src" && element_node.getAttribute("mce_real_src"))1762 attribValue = element_node.getAttribute("mce_real_src");1763 1764 // Force absolute URLs in Firefox1765 if (tinyMCE.isGecko && !tinyMCE.getParam('relative_urls'))1766 attribValue = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], attribValue);1767 1768 attribValue = eval(tinyMCE.cleanup_urlconverter_callback + "(attribValue, element_node, tinyMCE.cleanup_on_save);");1769 break;1770 1771 case "colspan":1772 case "rowspan":1773 // Not needed1774 if (attribValue == "1")1775 return null;1776 break;1777 1778 // Skip these1779 case "_moz-userdefined":1780 case "editorid":1781 case "mce_real_href":1782 case "mce_real_src":1783 return null;1784 }1785 1786 // Not the must be value1787 if (attribMustBeValue != null) {1788 var isCorrect = false;1789 for (var i=0; i<attribMustBeValue.length; i++) {1790 if (attribValue == attribMustBeValue[i]) {1791 isCorrect = true;1792 break;1793 }1794 }1795 1796 if (!isCorrect)1797 return null;1798 }1799 1800 var attrib = new Object();1801 1802 attrib.name = attribName;1803 attrib.value = attribValue;1804 1805 return attrib;1806 };1807 1808 TinyMCE.prototype.clearArray = function(ar) {1809 // Since stupid people tend to extend core objects like1810 // Array with their own crap I needed to make functions that clean away1811 // this junk so the arrays get clean and nice as they should be1812 for (var key in ar)1813 ar[key] = null;1814 };1815 1816 TinyMCE.prototype.isInstance = function(inst) {1817 return inst != null && typeof(inst) == "object" && inst.isTinyMCEControl;1818 };1819 1820 TinyMCE.prototype.parseStyle = function(str) {1821 var ar = new Array();1822 1823 if (str == null)1824 return ar;1825 1826 var st = str.split(';');1827 1828 tinyMCE.clearArray(ar);1829 1830 for (var i=0; i<st.length; i++) {1831 if (st[i] == '')1832 continue;1833 1834 var re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');1835 var pa = st[i].replace(re, '$1||$2').split('||');1836 //tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2'));1837 if (pa.length == 2)1838 ar[pa[0].toLowerCase()] = pa[1];1839 }1840 1841 return ar;1842 };1843 1844 TinyMCE.prototype.compressStyle = function(ar, pr, sf, res) {1845 var box = new Array();1846 1847 box[0] = ar[pr + '-top' + sf];1848 box[1] = ar[pr + '-left' + sf];1849 box[2] = ar[pr + '-right' + sf];1850 box[3] = ar[pr + '-bottom' + sf];1851 1852 for (var i=0; i<box.length; i++) {1853 if (box[i] == null)1854 return;1855 1856 for (var a=0; a<box.length; a++) {1857 if (box[a] != box[i])1858 return;1859 }1860 }1861 1862 // They are all the same1863 ar[res] = box[0];1864 ar[pr + '-top' + sf] = null;1865 ar[pr + '-left' + sf] = null;1866 ar[pr + '-right' + sf] = null;1867 ar[pr + '-bottom' + sf] = null;1868 };1869 1870 TinyMCE.prototype.serializeStyle = function(ar) {1871 var str = "";1872 1873 // Compress box1874 tinyMCE.compressStyle(ar, "border", "", "border");1875 tinyMCE.compressStyle(ar, "border", "-width", "border-width");1876 tinyMCE.compressStyle(ar, "border", "-color", "border-color");1877 1878 for (var key in ar) {1879 var val = ar[key];1880 if (typeof(val) == 'function')1881 continue;1882 1883 if (val != null && val != '') {1884 val = '' + val; // Force string1885 1886 // Fix style URL1887 val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')");1888 1889 // Force HEX colors1890 if (tinyMCE.getParam("force_hex_style_colors"))1891 val = tinyMCE.convertRGBToHex(val);1892 1893 if (val != "url('')")1894 str += key.toLowerCase() + ": " + val + "; ";1895 }1896 }1897 1898 if (new RegExp('; $').test(str))1899 str = str.substring(0, str.length - 2);1900 1901 return str;1902 };1903 1904 TinyMCE.prototype.convertRGBToHex = function(s) {1905 if (s.toLowerCase().indexOf('rgb') != -1) {1906 var re = new RegExp("rgb\\s*\\(\\s*([0-9]+).*,\\s*([0-9]+).*,\\s*([0-9]+).*\\)", "gi");1907 var rgb = s.replace(re, "$1,$2,$3").split(',');1908 if (rgb.length == 3) {1909 r = parseInt(rgb[0]).toString(16);1910 g = parseInt(rgb[1]).toString(16);1911 b = parseInt(rgb[2]).toString(16);1912 1913 r = r.length == 1 ? '0' + r : r;1914 g = g.length == 1 ? '0' + g : g;1915 b = b.length == 1 ? '0' + b : b;1916 1917 s = "#" + r + g + b;1918 }1919 }1920 1921 return s;1922 };1923 1924 TinyMCE.prototype._verifyClass = function(node) {1925 // Sometimes the class gets set to null, weird Gecko bug?1926 if (tinyMCE.isGecko) {1927 var className = node.getAttribute('class');1928 if (!className)1929 return false;1930 }1931 1932 // Trim CSS class1933 if (tinyMCE.isMSIE)1934 var className = node.getAttribute('className');1935 1936 if (tinyMCE.cleanup_verify_css_classes && tinyMCE.cleanup_on_save) {1937 var csses = tinyMCE.getCSSClasses();1938 nonDefinedCSS = true;1939 for (var c=0; c<csses.length; c++) {1940 if (csses[c] == className) {1941 nonDefinedCSS = false;1942 break;1943 }1944 }1945 1946 if (nonDefinedCSS && className.indexOf('mce_') != 0) {1947 node.removeAttribute('className');1948 node.removeAttribute('class');1949 return false;1950 }1951 }1952 1953 return true;1954 };1955 1956 TinyMCE.prototype.cleanupNode = function(node) {1957 var output = "";1958 1959 switch (node.nodeType) {1960 case 1: // Element1961 var elementData = tinyMCE._cleanupElementName(node.nodeName, node);1962 var elementName = elementData ? elementData.element_name : null;1963 var elementValidAttribs = elementData ? elementData.valid_attribs : null;1964 var elementAttribs = "";1965 var openTag = false, nonEmptyTag = false;1966 1967 if (elementName != null && elementName.charAt(0) == '+') {1968 elementName = elementName.substring(1);1969 openTag = true;1970 }1971 1972 if (elementName != null && elementName.charAt(0) == '-') {1973 elementName = elementName.substring(1);1974 nonEmptyTag = true;1975 }1976 1977 // Checking DOM tree for MSIE weirdness!!1978 if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {1979 var lookup = tinyMCE.cleanup_elementLookupTable;1980 1981 for (var i=0; i<lookup.length; i++) {1982 // Found element reference else were, hmm?1983 if (lookup[i] == node)1984 return output;1985 }1986 1987 // Add element to lookup table1988 lookup[lookup.length] = node;1989 }1990 1991 // Element not valid (only render children)1992 if (!elementName) {1993 if (node.hasChildNodes()) {1994 for (var i=0; i<node.childNodes.length; i++)1995 output += this.cleanupNode(node.childNodes[i]);1996 }1997 1998 return output;1999 }2000 2001 if (tinyMCE.cleanup_on_save) {2002 if (node.nodeName == "A" && node.className == "mceItemAnchor") {2003 if (node.hasChildNodes()) {2004 for (var i=0; i<node.childNodes.length; i++)2005 output += this.cleanupNode(node.childNodes[i]);2006 }2007 2008 return '<a name="' + this.convertStringToXML(node.getAttribute("name")) + '"></a>' + output;2009 }2010 }2011 2012 // Remove deprecated attributes2013 var re = new RegExp("^(TABLE|TD|TR)$");2014 if (re.test(node.nodeName)) {2015 // Move attrib to style2016 if ((node.nodeName != "TABLE" || tinyMCE.cleanup_inline_styles) && (width = tinyMCE.getAttrib(node, "width")) != '') {2017 node.style.width = width.indexOf('%') != -1 ? width : width.replace(/[^0-9]/gi, '') + "px";2018 node.removeAttribute("width");2019 }2020 2021 // Is table and not inline2022 if ((node.nodeName == "TABLE" && !tinyMCE.cleanup_inline_styles) && node.style.width != '') {2023 tinyMCE.setAttrib(node, "width", node.style.width.replace('px',''));2024 node.style.width = '';2025 }2026 2027 // Move attrib to style2028 if ((height = tinyMCE.getAttrib(node, "height")) != '') {2029 node.style.height = height.indexOf('%') != -1 ? height : height.replace(/[^0-9]/gi, '') + "px";2030 node.removeAttribute("height");2031 }2032 }2033 2034 // Handle inline/outline styles2035 if (tinyMCE.cleanup_inline_styles) {2036 var re = new RegExp("^(TABLE|TD|TR|IMG|HR)$");2037 if (re.test(node.nodeName)) {2038 tinyMCE._moveStyle(node, 'width', 'width');2039 tinyMCE._moveStyle(node, 'height', 'height');2040 tinyMCE._moveStyle(node, 'borderWidth', 'border');2041 tinyMCE._moveStyle(node, '', 'vspace');2042 tinyMCE._moveStyle(node, '', 'hspace');2043 tinyMCE._moveStyle(node, 'textAlign', 'align');2044 tinyMCE._moveStyle(node, 'backgroundColor', 'bgColor');2045 tinyMCE._moveStyle(node, 'borderColor', 'borderColor');2046 tinyMCE._moveStyle(node, 'backgroundImage', 'background');2047 2048 // Refresh element in old MSIE2049 if (tinyMCE.isMSIE5)2050 node.outerHTML = node.outerHTML;2051 } else if (tinyMCE.isBlockElement(node))2052 tinyMCE._moveStyle(node, 'textAlign', 'align');2053 2054 if (node.nodeName == "FONT")2055 tinyMCE._moveStyle(node, 'color', 'color');2056 }2057 2058 // Set attrib data2059 if (elementValidAttribs) {2060 for (var a=1; a<elementValidAttribs.length; a++) {2061 var attribName, attribDefaultValue, attribForceValue, attribValue;2062 2063 attribName = elementValidAttribs[a][0];2064 attribDefaultValue = elementValidAttribs[a][1];2065 attribForceValue = elementValidAttribs[a][2];2066 2067 if (attribDefaultValue != null || attribForceValue != null) {2068 var attribValue = node.getAttribute(attribName);2069 2070 if (node.getAttribute(attribName) == null || node.getAttribute(attribName) == "")2071 attribValue = attribDefaultValue;2072 2073 attribValue = attribForceValue ? attribForceValue : attribValue;2074 2075 // Is to generate id2076 if (attribValue == "{$uid}")2077 attribValue = "uid_" + (tinyMCE.cleanup_idCount++);2078 2079 // Add visual aid class2080 if (attribName == "class")2081 attribValue = tinyMCE.getVisualAidClass(attribValue, tinyMCE.cleanup_on_save);2082 2083 node.setAttribute(attribName, attribValue);2084 //alert(attribName + "=" + attribValue);2085 }2086 }2087 }2088 2089 if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && elementName == "style")2090 return "<style>" + node.innerHTML + "</style>";2091 2092 // Remove empty tables2093 if (elementName == "table" && !node.hasChildNodes())2094 return "";2095 2096 // Handle element attributes2097 if (node.attributes.length > 0) {2098 var lastAttrib = "";2099 2100 for (var i=0; i<node.attributes.length; i++) {2101 if (node.attributes[i].specified) {2102 // Is the attrib already processed (removed duplicate attributes in opera TD[align=left])2103 if (tinyMCE.isOpera) {2104 if (node.attributes[i].nodeName == lastAttrib)2105 continue;2106 2107 lastAttrib = node.attributes[i].nodeName;2108 }2109 2110 // tinyMCE.debug(node.nodeName, node.attributes[i].nodeName, node.attributes[i].nodeValue, node.innerHTML);2111 var attrib = tinyMCE._cleanupAttribute(elementValidAttribs, elementName, node.attributes[i], node);2112 if (attrib && attrib.value != "")2113 elementAttribs += " " + attrib.name + "=" + '"' + this.convertStringToXML("" + attrib.value) + '"';2114 }2115 }2116 }2117 2118 // MSIE table summary fix (MSIE 5.5)2119 if (tinyMCE.isMSIE && elementName == "table" && node.getAttribute("summary") != null && elementAttribs.indexOf('summary') == -1) {2120 var summary = tinyMCE.getAttrib(node, 'summary');2121 if (summary != '')2122 elementAttribs += " summary=" + '"' + this.convertStringToXML(summary) + '"';2123 }2124 2125 // Handle missing attributes in MSIE 5.52126 if (tinyMCE.isMSIE5 && /^(td|img|a)$/.test(elementName)) {2127 var ma = new Array("scope", "longdesc", "hreflang", "charset", "type");2128 2129 for (var u=0; u<ma.length; u++) {2130 if (node.getAttribute(ma[u]) != null) {2131 var s = tinyMCE.getAttrib(node, ma[u]);2132 2133 if (s != '')2134 elementAttribs += " " + ma[u] + "=" + '"' + this.convertStringToXML(s) + '"';2135 }2136 }2137 }2138 2139 // MSIE form element issue2140 if (tinyMCE.isMSIE && elementName == "input") {2141 if (node.type) {2142 if (!elementAttribs.match(/ type=/g))2143 elementAttribs += " type=" + '"' + node.type + '"';2144 }2145 2146 if (node.value) {2147 if (!elementAttribs.match(/ value=/g))2148 elementAttribs += " value=" + '"' + node.value + '"';2149 }2150 }2151 2152 // Add nbsp to some elements2153 if ((elementName == "p" || elementName == "td") && (node.innerHTML == "" || node.innerHTML == " "))2154 return "<" + elementName + elementAttribs + ">" + this.convertStringToXML(String.fromCharCode(160)) + "</" + elementName + ">";2155 2156 // Is MSIE script element2157 if (tinyMCE.isMSIE && elementName == "script")2158 return "<" + elementName + elementAttribs + ">" + node.text + "</" + elementName + ">";2159 2160 // Clean up children2161 if (node.hasChildNodes()) {2162 // If not empty span2163 if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) {2164 // Force BR2165 if (elementName == "p" && tinyMCE.cleanup_force_br_newlines)2166 output += "<div" + elementAttribs + ">";2167 else2168 output += "<" + elementName + elementAttribs + ">";2169 }2170 2171 for (var i=0; i<node.childNodes.length; i++)2172 output += this.cleanupNode(node.childNodes[i]);2173 2174 // If not empty span2175 if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) {2176 // Force BR2177 if (elementName == "p" && tinyMCE.cleanup_force_br_newlines)2178 output += "</div><br />";2179 else2180 output += "</" + elementName + ">";2181 }2182 } else {2183 if (!nonEmptyTag) {2184 if (openTag)2185 output += "<" + elementName + elementAttribs + "></" + elementName + ">";2186 else2187 output += "<" + elementName + elementAttribs + " />";2188 }2189 }2190 2191 return output;2192 2193 case 3: // Text2194 // Do not convert script elements2195 if (node.parentNode.nodeName == "SCRIPT" || node.parentNode.nodeName == "STYLE")2196 return node.nodeValue;2197 2198 return this.convertStringToXML(node.nodeValue);2199 2200 case 8: // Comment2201 return "<!--" + node.nodeValue + "-->";2202 2203 default: // Unknown2204 return "[UNKNOWN NODETYPE " + node.nodeType + "]";2205 }2206 };2207 2208 TinyMCE.prototype.convertStringToXML = function(html_data) {2209 var output = "";2210 2211 for (var i=0; i<html_data.length; i++) {2212 var chr = html_data.charCodeAt(i);2213 2214 // Numeric entities2215 if (tinyMCE.settings['entity_encoding'] == "numeric") {2216 if (chr > 127)2217 output += '&#' + chr + ";";2218 else2219 output += String.fromCharCode(chr);2220 2221 continue;2222 }2223 2224 // Raw entities2225 if (tinyMCE.settings['entity_encoding'] == "raw") {2226 output += String.fromCharCode(chr);2227 continue;2228 }2229 2230 // Named entities2231 if (typeof(tinyMCE.cleanup_entities["c" + chr]) != 'undefined' && tinyMCE.cleanup_entities["c" + chr] != '')2232 output += '&' + tinyMCE.cleanup_entities["c" + chr] + ';';2233 else2234 output += '' + String.fromCharCode(chr);2235 }2236 2237 return output;2238 };2239 2240 TinyMCE.prototype._getCleanupElementName = function(chunk) {2241 var pos;2242 2243 if (chunk.charAt(0) == '+')2244 chunk = chunk.substring(1);2245 2246 if (chunk.charAt(0) == '-')2247 chunk = chunk.substring(1);2248 2249 if ((pos = chunk.indexOf('/')) != -1)2250 chunk = chunk.substring(0, pos);2251 2252 if ((pos = chunk.indexOf('[')) != -1)2253 chunk = chunk.substring(0, pos);2254 2255 return chunk;2256 };2257 2258 TinyMCE.prototype._initCleanup = function() {2259 // Parse valid elements and attributes2260 var validElements = tinyMCE.settings["valid_elements"];2261 validElements = validElements.split(',');2262 2263 // Handle extended valid elements2264 var extendedValidElements = tinyMCE.settings["extended_valid_elements"];2265 extendedValidElements = extendedValidElements.split(',');2266 for (var i=0; i<extendedValidElements.length; i++) {2267 var elementName = this._getCleanupElementName(extendedValidElements[i]);2268 var skipAdd = false;2269 2270 // Check if it's defined before, if so override that one2271 for (var x=0; x<validElements.length; x++) {2272 if (this._getCleanupElementName(validElements[x]) == elementName) {2273 validElements[x] = extendedValidElements[i];2274 skipAdd = true;2275 break;2276 }2277 }2278 2279 if (!skipAdd)2280 validElements[validElements.length] = extendedValidElements[i];2281 }2282 2283 for (var i=0; i<validElements.length; i++) {2284 var item = validElements[i];2285 2286 item = item.replace('[','|');2287 item = item.replace(']','');2288 2289 // Split and convert2290 var attribs = item.split('|');2291 for (var x=0; x<attribs.length; x++)2292 attribs[x] = attribs[x].toLowerCase();2293 2294 // Handle change elements2295 attribs[0] = attribs[0].split('/');2296 2297 // Handle default attribute values2298 for (var x=1; x<attribs.length; x++) {2299 var attribName = attribs[x];2300 var attribDefault = null;2301 var attribForce = null;2302 var attribMustBe = null;2303 2304 // Default value2305 if ((pos = attribName.indexOf('=')) != -1) {2306 attribDefault = attribName.substring(pos+1);2307 attribName = attribName.substring(0, pos);2308 }2309 2310 // Force check2311 if ((pos = attribName.indexOf(':')) != -1) {2312 attribForce = attribName.substring(pos+1);2313 attribName = attribName.substring(0, pos);2314 }2315 2316 // Force check2317 if ((pos = attribName.indexOf('<')) != -1) {2318 attribMustBe = attribName.substring(pos+1).split('?');2319 attribName = attribName.substring(0, pos);2320 }2321 2322 attribs[x] = new Array(attribName, attribDefault, attribForce, attribMustBe);2323 }2324 2325 validElements[i] = attribs;2326 }2327 2328 var invalidElements = tinyMCE.settings['invalid_elements'].split(',');2329 for (var i=0; i<invalidElements.length; i++)2330 invalidElements[i] = invalidElements[i].toLowerCase();2331 2332 // Set these for performance2333 tinyMCE.settings['cleanup_validElements'] = validElements;2334 tinyMCE.settings['cleanup_invalidElements'] = invalidElements;2335 2336 // Setup entities2337 tinyMCE.settings['cleanup_entities'] = new Array();2338 var entities = tinyMCE.getParam('entities', '', true, ',');2339 for (var i=0; i<entities.length; i+=2)2340 tinyMCE.settings['cleanup_entities']['c' + entities[i]] = entities[i+1];2341 };2342 2343 TinyMCE.prototype._cleanupHTML = function(inst, doc, config, element, visual, on_save) {2344 if (!tinyMCE.settings['cleanup'])2345 return element.innerHTML;2346 2347 if (on_save && tinyMCE.getParam("convert_fonts_to_spans"))2348 tinyMCE.convertFontsToSpans(doc);2349 2350 // Call custom cleanup code2351 tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);2352 2353 // Set these for performance2354 tinyMCE.cleanup_validElements = tinyMCE.settings['cleanup_validElements'];2355 tinyMCE.cleanup_entities = tinyMCE.settings['cleanup_entities'];2356 tinyMCE.cleanup_invalidElements = tinyMCE.settings['cleanup_invalidElements'];2357 tinyMCE.cleanup_verify_html = tinyMCE.settings['verify_html'];2358 tinyMCE.cleanup_force_br_newlines = tinyMCE.settings['force_br_newlines'];2359 tinyMCE.cleanup_urlconverter_callback = tinyMCE.settings['urlconverter_callback'];2360 tinyMCE.cleanup_verify_css_classes = tinyMCE.settings['verify_css_classes'];2361 tinyMCE.cleanup_visual_table_class = tinyMCE.settings['visual_table_class'];2362 tinyMCE.cleanup_apply_source_formatting = tinyMCE.settings['apply_source_formatting'];2363 tinyMCE.cleanup_inline_styles = tinyMCE.settings['inline_styles'];2364 tinyMCE.cleanup_visual_aid = visual;2365 tinyMCE.cleanup_on_save = on_save;2366 tinyMCE.cleanup_idCount = 0;2367 tinyMCE.cleanup_elementLookupTable = new Array();2368 2369 var startTime = new Date().getTime();2370 2371 // Cleanup madness that breaks the editor in MSIE2372 if (tinyMCE.isMSIE) {2373 // Remove null ids from HR elements, results in runtime error2374 var nodes = element.getElementsByTagName("hr");2375 for (var i=0; i<nodes.length; i++) {2376 if (nodes[i].id == "null")2377 nodes[i].removeAttribute("id");2378 }2379 2380 tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '<p>[ \n\r]*<hr.*>[ \n\r]*</p>', '<hr />', 'gi'));2381 tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '<!([^-(DOCTYPE)]* )|<!/[^-]*>', '', 'gi'));2382 }2383 2384 var html = this.cleanupNode(element);2385 2386 if (tinyMCE.settings['debug'])2387 tinyMCE.debug("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms.");2388 2389 // Remove pesky HR paragraphs and other crap2390 html = tinyMCE.regexpReplace(html, '<p><hr /></p>', '<hr />');2391 html = tinyMCE.regexpReplace(html, '<p> </p><hr /><p> </p>', '<hr />');2392 html = tinyMCE.regexpReplace(html, '<td>\\s*<br />\\s*</td>', '<td> </td>');2393 html = tinyMCE.regexpReplace(html, '<p>\\s*<br />\\s*</p>', '<p> </p>');2394 html = tinyMCE.regexpReplace(html, '<p>\\s* \\s*<br />\\s* \\s*</p>', '<p> </p>');2395 html = tinyMCE.regexpReplace(html, '<p>\\s* \\s*<br />\\s*</p>', '<p> </p>');2396 html = tinyMCE.regexpReplace(html, '<p>\\s*<br />\\s* \\s*</p>', '<p> </p>');2397 2398 // Remove empty anchors2399 html = html.replace(new RegExp('<a>(.*?)</a>', 'gi'), '$1');2400 2401 // Remove some mozilla crap2402 if (!tinyMCE.isMSIE)2403 html = html.replace(new RegExp('<o:p _moz-userdefined="" />', 'g'), "");2404 2405 if (tinyMCE.settings['remove_linebreaks'])2406 html = html.replace(new RegExp('\r|\n', 'g'), ' ');2407 2408 if (tinyMCE.getParam('apply_source_formatting')) {2409 html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n");2410 html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n</$1$2>\n");2411 html = html.replace(new RegExp('<br />', 'g'), "<br />\n");2412 }2413 2414 if (tinyMCE.settings['force_br_newlines']) {2415 var re = new RegExp('<p> </p>', 'g');2416 html = html.replace(re, "<br />");2417 }2418 2419 if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) {2420 // Remove weridness!2421 var re = new RegExp('<>', 'g');2422 html = html.replace(re, "");2423 }2424 2425 // Call custom cleanup code2426 html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html);2427 2428 // Emtpy node, return empty2429 var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase();2430 if (chk == "<br/>" || chk == "<br>" || chk == "<p> </p>" || chk == "<p> </p>" || chk == "<p></p>")2431 html = "";2432 2433 if (tinyMCE.settings["preformatted"])2434 return "<pre>" + html + "</pre>";2435 2436 return html;2437 };2438 2439 TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) {2440 tinyMCE.execCommand('mceBeginUndoLevel');2441 2442 if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") {2443 var doc = this.selectedInstance.getDoc();2444 var linkElement = tinyMCE.getParentElement(this.selectedElement, "a");2445 var newLink = false;2446 2447 if (!linkElement) {2448 linkElement = doc.createElement("a");2449 newLink = true;2450 }2451 2452 href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");2453 tinyMCE.setAttrib(linkElement, 'href', href);2454 tinyMCE.setAttrib(linkElement, 'target', target);2455 tinyMCE.setAttrib(linkElement, 'title', title);2456 tinyMCE.setAttrib(linkElement, 'onclick', onclick);2457 tinyMCE.setAttrib(linkElement, 'class', style_class);2458 2459 if (newLink) {2460 linkElement.appendChild(this.selectedElement.cloneNode(true));2461 this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement);2462 }2463 2464 return;2465 }2466 2467 if (!this.linkElement && this.selectedInstance) {2468 if (tinyMCE.isSafari) {2469 tinyMCE.execCommand("mceInsertContent", false, '<a href="' + tinyMCE.uniqueURL + '">' + this.selectedInstance.getSelectedHTML() + '</a>');2470 } else2471 this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);2472 2473 tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);2474 2475 var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);2476 2477 for (var i=0; i<elementArray.length; i++) {2478 href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, elementArray[i]);");2479 tinyMCE.setAttrib(elementArray[i], 'href', href);2480 tinyMCE.setAttrib(elementArray[i], 'mce_real_href', href);2481 tinyMCE.setAttrib(elementArray[i], 'target', target);2482 tinyMCE.setAttrib(elementArray[i], 'title', title);2483 tinyMCE.setAttrib(elementArray[i], 'onclick', onclick);2484 tinyMCE.setAttrib(elementArray[i], 'class', style_class);2485 }2486 2487 tinyMCE.linkElement = elementArray[0];2488 }2489 2490 if (this.linkElement) {2491 href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, this.linkElement);");2492 tinyMCE.setAttrib(this.linkElement, 'href', href);2493 tinyMCE.setAttrib(this.linkElement, 'mce_real_href', href);2494 tinyMCE.setAttrib(this.linkElement, 'target', target);2495 tinyMCE.setAttrib(this.linkElement, 'title', title);2496 tinyMCE.setAttrib(this.linkElement, 'onclick', onclick);2497 tinyMCE.setAttrib(this.linkElement, 'class', style_class);2498 }2499 2500 tinyMCE.execCommand('mceEndUndoLevel');2501 };2502 2503 TinyMCE.prototype.insertImage = function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {2504 tinyMCE.execCommand('mceBeginUndoLevel');2505 2506 if (src == "")2507 return;2508 2509 if (!this.imgElement && tinyMCE.isSafari) {2510 var html = "";2511 2512 html += '<img src="' + src + '" alt="' + alt + '"';2513 html += ' border="' + border + '" hspace="' + hspace + '"';2514 html += ' vspace="' + vspace + '" width="' + width + '"';2515 html += ' height="' + height + '" align="' + align + '" title="' + title + '" onmouseover="' + onmouseover + '" onmouseout="' + onmouseout + '" />';2516 2517 tinyMCE.execCommand("mceInsertContent", false, html);2518 } else {2519 if (!this.imgElement && this.selectedInstance) {2520 if (tinyMCE.isSafari)2521 tinyMCE.execCommand("mceInsertContent", false, '<img src="' + tinyMCE.uniqueURL + '" />');2522 else2523 this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);2524 2525 tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);2526 }2527 }2528 2529 if (this.imgElement) {2530 var needsRepaint = false;2531 2532 src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");2533 2534 if (onmouseover && onmouseover != "")2535 onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";2536 2537 if (onmouseout && onmouseout != "")2538 onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";2539 2540 // Use alt as title if it's undefined2541 if (typeof(title) == "undefined")2542 title = alt;2543 2544 if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align"))2545 needsRepaint = true;2546 2547 tinyMCE.setAttrib(this.imgElement, 'src', src);2548 tinyMCE.setAttrib(this.imgElement, 'mce_real_src', src);2549 tinyMCE.setAttrib(this.imgElement, 'alt', alt);2550 tinyMCE.setAttrib(this.imgElement, 'title', title);2551 tinyMCE.setAttrib(this.imgElement, 'align', align);2552 tinyMCE.setAttrib(this.imgElement, 'border', border, true);2553 tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true);2554 tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true);2555 tinyMCE.setAttrib(this.imgElement, 'width', width, true);2556 tinyMCE.setAttrib(this.imgElement, 'height', height, true);2557 tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover);2558 tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout);2559 2560 // Fix for bug #989846 - Image resize bug2561 if (width && width != "")2562 this.imgElement.style.pixelWidth = width;2563 2564 if (height && height != "")2565 this.imgElement.style.pixelHeight = height;2566 2567 if (needsRepaint)2568 tinyMCE.selectedInstance.repaint();2569 }2570 2571 tinyMCE.execCommand('mceEndUndoLevel');2572 };2573 2574 TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) {2575 var elements = this.getElementsByAttributeValue(node, element_name, attrib, value);2576 if (elements.length == 0)2577 return null;2578 2579 return elements[0];2580 };2581 2582 TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) {2583 var elements = new Array();2584 2585 if (node && node.nodeName.toLowerCase() == element_name) {2586 if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1)2587 elements[elements.length] = node;2588 }2589 2590 if (node && node.hasChildNodes()) {2591 for (var x=0, n=node.childNodes.length; x<n; x++) {2592 var childElements = this.getElementsByAttributeValue(node.childNodes[x], element_name, attrib, value);2593 for (var i=0, m=childElements.length; i<m; i++)2594 elements[elements.length] = childElements[i];2595 }2596 }2597 2598 return elements;2599 };2600 2601 TinyMCE.prototype.isBlockElement = function(node) {2602 return node != null && node.nodeType == 1 && this.blockRegExp.test(node.nodeName);2603 };2604 2605 TinyMCE.prototype.getParentBlockElement = function(node) {2606 // Search up the tree for block element2607 while (node) {2608 if (this.blockRegExp.test(node.nodeName))2609 return node;2610 2611 node = node.parentNode;2612 }2613 2614 return null;2615 };2616 2617 TinyMCE.prototype.getNodeTree = function(node, node_array, type, node_name) {2618 if (typeof(type) == "undefined" || node.nodeType == type && (typeof(node_name) == "undefined" || node.nodeName == node_name))2619 node_array[node_array.length] = node;2620 2621 if (node.hasChildNodes()) {2622 for (var i=0; i<node.childNodes.length; i++)2623 tinyMCE.getNodeTree(node.childNodes[i], node_array, type, node_name);2624 }2625 2626 return node_array;2627 };2628 2629 TinyMCE.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {2630 if (typeof(names) == "undefined") {2631 if (node.nodeType == 1)2632 return node;2633 2634 // Find parent node that is a element2635 while ((node = node.parentNode) != null && node.nodeType != 1) ;2636 2637 return node;2638 }2639 2640 var namesAr = names.split(',');2641 2642 if (node == null)2643 return null;2644 2645 do {2646 for (var i=0; i<namesAr.length; i++) {2647 if (node.nodeName.toLowerCase() == namesAr[i].toLowerCase() || names == "*") {2648 if (typeof(attrib_name) == "undefined")2649 return node;2650 else if (node.getAttribute(attrib_name)) {2651 if (typeof(attrib_value) == "undefined") {2652 if (node.getAttribute(attrib_name) != "")2653 return node;2654 } else if (node.getAttribute(attrib_name) == attrib_value)2655 return node;2656 }2657 }2658 }2659 } while ((node = node.parentNode) != null);2660 2661 return null;2662 };2663 2664 TinyMCE.prototype.convertURL = function(url, node, on_save) {2665 var prot = document.location.protocol;2666 var host = document.location.hostname;2667 var port = document.location.port;2668 2669 var fileProto = (prot == "file:");2670 2671 // Something is wrong, remove weirdness2672 url = tinyMCE.regexpReplace(url, '(http|https):///', '/');2673 2674 // Mailto link or anchor (Pass through)2675 if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || tinyMCE.regexpReplace(url,'[ \t\r\n\+]|%20','').charAt(0) == "#")2676 return url;2677 2678 // Fix relative/Mozilla2679 if (!tinyMCE.isMSIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')2680 return tinyMCE.settings['base_href'] + url;2681 2682 // Handle absolute url anchors2683 if (!tinyMCE.getParam('relative_urls')) {2684 var urlParts = tinyMCE.parseURL(url);2685 var baseUrlParts = tinyMCE.parseURL(tinyMCE.settings['base_href']);2686 2687 // If anchor and path is the same page2688 if (urlParts['anchor'] && urlParts['path'] == baseUrlParts['path'])2689 return "#" + urlParts['anchor'];2690 }2691 2692 // Convert to relative urls2693 if (on_save && tinyMCE.getParam('relative_urls')) {2694 var urlParts = tinyMCE.parseURL(url);2695 2696 // If not absolute url, do nothing (Mozilla)2697 // WEIRD STUFF?!2698 /* if (!urlParts['protocol'] && !tinyMCE.isMSIE) {2699 var urlPrefix = "http://";2700 urlPrefix += host;2701 if (port != "")2702 urlPrefix += ":" + port;2703 2704 url = urlPrefix + url;2705 urlParts = tinyMCE.parseURL(url);2706 }*/2707 2708 var tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings['document_base_url']);2709 2710 // Link is within this site2711 if (urlParts['host'] == tmpUrlParts['host'] && (!urlParts['port'] || urlParts['port'] == tmpUrlParts['port']))2712 return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings['document_base_url'], url);2713 }2714 2715 // Remove current domain2716 if (!fileProto && tinyMCE.getParam('remove_script_host')) {2717 var start = "", portPart = "";2718 2719 if (port != "")2720 portPart = ":" + port;2721 2722 start = prot + "//" + host + portPart + "/";2723 2724 if (url.indexOf(start) == 0)2725 url = url.substring(start.length-1);2726 2727 // Add first slash if missing on a absolute URL2728 if (!tinyMCE.getParam('relative_urls') && url.indexOf('://') == -1 && url.charAt(0) != '/')2729 url = '/' + url;2730 }2731 2732 return url;2733 };2734 2735 /**2736 * Parses a URL in to its diffrent components.2737 */2738 TinyMCE.prototype.parseURL = function(url_str) {2739 var urlParts = new Array();2740 2741 if (url_str) {2742 var pos, lastPos;2743 2744 // Parse protocol part2745 pos = url_str.indexOf('://');2746 if (pos != -1) {2747 urlParts['protocol'] = url_str.substring(0, pos);2748 lastPos = pos + 3;2749 }2750 2751 // Find port or path start2752 for (var i=lastPos; i<url_str.length; i++) {2753 var chr = url_str.charAt(i);2754 2755 if (chr == ':')2756 break;2757 2758 if (chr == '/')2759 break;2760 }2761 pos = i;2762 2763 // Get host2764 urlParts['host'] = url_str.substring(lastPos, pos);2765 2766 // Get port2767 lastPos = pos;2768 if (url_str.charAt(pos) == ':') {2769 pos = url_str.indexOf('/', lastPos);2770 urlParts['port'] = url_str.substring(lastPos+1, pos);2771 }2772 2773 // Get path2774 lastPos = pos;2775 pos = url_str.indexOf('?', lastPos);2776 2777 if (pos == -1)2778 pos = url_str.indexOf('#', lastPos);2779 2780 if (pos == -1)2781 pos = url_str.length;2782 2783 urlParts['path'] = url_str.substring(lastPos, pos);2784 2785 // Get query2786 lastPos = pos;2787 if (url_str.charAt(pos) == '?') {2788 pos = url_str.indexOf('#');2789 pos = (pos == -1) ? url_str.length : pos;2790 urlParts['query'] = url_str.substring(lastPos+1, pos);2791 }2792 2793 // Get anchor2794 lastPos = pos;2795 if (url_str.charAt(pos) == '#') {2796 pos = url_str.length;2797 urlParts['anchor'] = url_str.substring(lastPos+1, pos);2798 }2799 }2800 2801 return urlParts;2802 };2803 2804 TinyMCE.prototype.serializeURL = function(up) {2805 var url = "";2806 2807 if (up['protocol'])2808 url += up['protocol'] + "://";2809 2810 if (up['host'])2811 url += up['host'];2812 2813 if (up['port'])2814 url += ":" + up['port'];2815 2816 if (up['path'])2817 url += up['path'];2818 2819 if (up['query'])2820 url += "?" + up['query'];2821 2822 if (up['anchor'])2823 url += "#" + up['anchor'];2824 2825 return url;2826 };2827 2828 /**2829 * Converts an absolute path to relative path.2830 */2831 TinyMCE.prototype.convertAbsoluteURLToRelativeURL = function(base_url, url_to_relative) {2832 var baseURL = this.parseURL(base_url);2833 var targetURL = this.parseURL(url_to_relative);2834 var strTok1;2835 var strTok2;2836 var breakPoint = 0;2837 var outPath = "";2838 var forceSlash = false;2839 2840 if (targetURL.path == "")2841 targetURL.path = "/";2842 else2843 forceSlash = true;2844 2845 // Crop away last path part2846 base_url = baseURL.path.substring(0, baseURL.path.lastIndexOf('/'));2847 strTok1 = base_url.split('/');2848 strTok2 = targetURL.path.split('/');2849 2850 if (strTok1.length >= strTok2.length) {2851 for (var i=0; i<strTok1.length; i++) {2852 if (i >= strTok2.length || strTok1[i] != strTok2[i]) {2853 breakPoint = i + 1;2854 break;2855 }2856 }2857 }2858 2859 if (strTok1.length < strTok2.length) {2860 for (var i=0; i<strTok2.length; i++) {2861 if (i >= strTok1.length || strTok1[i] != strTok2[i]) {2862 breakPoint = i + 1;2863 break;2864 }2865 }2866 }2867 2868 if (breakPoint == 1)2869 return targetURL.path;2870 2871 for (var i=0; i<(strTok1.length-(breakPoint-1)); i++)2872 outPath += "../";2873 2874 for (var i=breakPoint-1; i<strTok2.length; i++) {2875 if (i != (breakPoint-1))2876 outPath += "/" + strTok2[i];2877 else2878 outPath += strTok2[i];2879 }2880 2881 targetURL.protocol = null;2882 targetURL.host = null;2883 targetURL.port = null;2884 targetURL.path = outPath == "" && forceSlash ? "/" : outPath;2885 2886 return this.serializeURL(targetURL);2887 };2888 2889 TinyMCE.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) {2890 var baseURL = TinyMCE.prototype.parseURL(base_url);2891 var relURL = TinyMCE.prototype.parseURL(relative_url);2892 2893 if (relative_url == "" || relative_url.charAt(0) == '/' || relative_url.indexOf('://') != -1 || relative_url.indexOf('mailto:') != -1 || relative_url.indexOf('javascript:') != -1)2894 return relative_url;2895 2896 // Split parts2897 baseURLParts = baseURL['path'].split('/');2898 relURLParts = relURL['path'].split('/');2899 2900 // Remove empty chunks2901 var newBaseURLParts = new Array();2902 for (var i=baseURLParts.length-1; i>=0; i--) {2903 if (baseURLParts[i].length == 0)2904 continue;2905 2906 newBaseURLParts[newBaseURLParts.length] = baseURLParts[i];2907 }2908 baseURLParts = newBaseURLParts.reverse();2909 2910 // Merge relURLParts chunks2911 var newRelURLParts = new Array();2912 var numBack = 0;2913 for (var i=relURLParts.length-1; i>=0; i--) {2914 if (relURLParts[i].length == 0 || relURLParts[i] == ".")2915 continue;2916 2917 if (relURLParts[i] == '..') {2918 numBack++;2919 continue;2920 }2921 2922 if (numBack > 0) {2923 numBack--;2924 continue;2925 }2926 2927 newRelURLParts[newRelURLParts.length] = relURLParts[i];2928 }2929 2930 relURLParts = newRelURLParts.reverse();2931 2932 // Remove end from absolute path2933 var len = baseURLParts.length-numBack;2934 var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/');2935 var start = "", end = "";2936 2937 // Build output URL2938 relURL.protocol = baseURL.protocol;2939 relURL.host = baseURL.host;2940 relURL.port = baseURL.port;2941 2942 // Re-add trailing slash if it's removed2943 if (relURL.path.charAt(relURL.path.length-1) == "/")2944 absPath += "/";2945 2946 relURL.path = absPath;2947 2948 return TinyMCE.prototype.serializeURL(relURL);2949 };2950 2951 TinyMCE.prototype.getParam = function(name, default_value, strip_whitespace, split_chr) {2952 var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];2953 2954 // Fix bool values2955 if (value == "true" || value == "false")2956 return (value == "true");2957 2958 if (strip_whitespace)2959 value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "");2960 2961 if (typeof(split_chr) != "undefined" && split_chr != null) {2962 value = value.split(split_chr);2963 var outArray = new Array();2964 2965 for (var i=0; i<value.length; i++) {2966 if (value[i] && value[i] != "")2967 outArray[outArray.length] = value[i];2968 }2969 2970 value = outArray;2971 }2972 2973 return value;2974 };2975 2976 TinyMCE.prototype.getLang = function(name, default_value, parse_entities) {2977 var value = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name];2978 2979 if (parse_entities) {2980 var el = document.createElement("div");2981 el.innerHTML = value;2982 value = el.innerHTML;2983 }2984 2985 return value;2986 };2987 2988 TinyMCE.prototype.addToLang = function(prefix, ar) {2989 for (var key in ar) {2990 if (typeof(ar[key]) == 'function')2991 continue;2992 2993 tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key];2994 }2995 2996 // for (var key in ar)2997 // tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|";2998 };2999 3000 TinyMCE.prototype.replaceVar = function(replace_haystack, replace_var, replace_str) {3001 var re = new RegExp('{\\\$' + replace_var + '}', 'g');3002 return replace_haystack.replace(re, replace_str);3003 };3004 3005 TinyMCE.prototype.replaceVars = function(replace_haystack, replace_vars) {3006 for (var key in replace_vars) {3007 var value = replace_vars[key];3008 if (typeof(value) == 'function')3009 continue;3010 3011 replace_haystack = tinyMCE.replaceVar(replace_haystack, key, value);3012 }3013 3014 return replace_haystack;3015 };3016 3017 TinyMCE.prototype.triggerNodeChange = function(focus, setup_content) {3018 if (tinyMCE.settings['handleNodeChangeCallback']) {3019 if (tinyMCE.selectedInstance) {3020 var inst = tinyMCE.selectedInstance;3021 var editorId = inst.editorId;3022 var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();3023 var undoIndex = -1;3024 var undoLevels = -1;3025 var anySelection = false;3026 var selectedText = inst.getSelectedText();3027 3028 if (tinyMCE.settings["auto_resize"]) {3029 var doc = inst.getDoc();3030 3031 inst.iframeElement.style.width = doc.body.offsetWidth + "px";3032 inst.iframeElement.style.height = doc.body.offsetHeight + "px";3033 }3034 3035 if (tinyMCE.selectedElement)3036 anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);3037 3038 if (tinyMCE.settings['custom_undo_redo']) {3039 undoIndex = inst.undoIndex;3040 undoLevels = inst.undoLevels.length;3041 }3042 3043 tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);3044 }3045 }3046 3047 if (this.selectedInstance && (typeof(focus) == "undefined" || focus))3048 this.selectedInstance.contentWindow.focus();3049 };3050 3051 TinyMCE.prototype._customCleanup = function(inst, type, content) {3052 // Call custom cleanup3053 var customCleanup = tinyMCE.settings['cleanup_callback'];3054 if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")3055 content = eval(customCleanup + "(type, content, inst);");3056 3057 // Trigger plugin cleanups3058 var plugins = tinyMCE.getParam('plugins', '', true, ',');3059 for (var i=0; i<plugins.length; i++) {3060 if (eval("typeof(TinyMCE_" + plugins[i] + "_cleanup)") != "undefined")3061 content = eval("TinyMCE_" + plugins[i] + "_cleanup(type, content, inst);");3062 }3063 3064 return content;3065 };3066 3067 TinyMCE.prototype.getContent = function(editor_id) {3068 if (typeof(editor_id) != "undefined")3069 tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);3070 3071 if (tinyMCE.selectedInstance) {3072 var old = this.selectedInstance.getBody().innerHTML;3073 var html = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);3074 tinyMCE.setInnerHTML(this.selectedInstance.getBody(), old);3075 return html;3076 }3077 3078 return null;3079 };3080 3081 TinyMCE.prototype.setContent = function(html_content) {3082 if (tinyMCE.selectedInstance) {3083 tinyMCE.selectedInstance.execCommand('mceSetContent', false, html_content);3084 tinyMCE.selectedInstance.repaint();3085 }3086 };3087 3088 TinyMCE.prototype.importThemeLanguagePack = function(name) {3089 if (typeof(name) == "undefined")3090 name = tinyMCE.settings['theme'];3091 3092 tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js');3093 };3094 3095 TinyMCE.prototype.importPluginLanguagePack = function(name, valid_languages) {3096 var lang = "en";3097 3098 valid_languages = valid_languages.split(',');3099 for (var i=0; i<valid_languages.length; i++) {3100 if (tinyMCE.settings['language'] == valid_languages[i])3101 lang = tinyMCE.settings['language'];3102 }3103 3104 tinyMCE.loadScript(tinyMCE.baseURL + '/plugins/' + name + '/langs/' + lang + '.js');3105 };3106 3107 /**3108 * Adds themeurl, settings and lang to HTML code.3109 */3110 TinyMCE.prototype.applyTemplate = function(html, args) {3111 html = tinyMCE.replaceVar(html, "themeurl", tinyMCE.themeURL);3112 3113 if (typeof(args) != "undefined")3114 html = tinyMCE.replaceVars(html, args);3115 3116 html = tinyMCE.replaceVars(html, tinyMCE.settings);3117 html = tinyMCE.replaceVars(html, tinyMCELang);3118 3119 return html;3120 };3121 3122 TinyMCE.prototype.openWindow = function(template, args) {3123 var html, width, height, x, y, resizable, scrollbars, url;3124 3125 args['mce_template_file'] = template['file'];3126 args['mce_width'] = template['width'];3127 args['mce_height'] = template['height'];3128 tinyMCE.windowArgs = args;3129 3130 html = template['html'];3131 if (!(width = parseInt(template['width'])))3132 width = 320;3133 3134 if (!(height = parseInt(template['height'])))3135 height = 200;3136 3137 // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!3138 if (tinyMCE.isMSIE)3139 height += 40;3140 else3141 height += 20;3142 3143 x = parseInt(screen.width / 2.0) - (width / 2.0);3144 y = parseInt(screen.height / 2.0) - (height / 2.0);3145 3146 resizable = (args && args['resizable']) ? args['resizable'] : "no";3147 scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";3148 3149 if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)3150 url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];3151 else3152 url = template['file'];3153 3154 // Replace all args as variables in URL3155 for (var name in args) {3156 if (typeof(args[name]) == 'function')3157 continue;3158 3159 url = tinyMCE.replaceVar(url, name, escape(args[name]));3160 }3161 3162 if (html) {3163 html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']);3164 html = tinyMCE.applyTemplate(html, args);3165 3166 var win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable);3167 if (win == null) {3168 alert(tinyMCELang['lang_popup_blocked']);3169 return;3170 }3171 3172 win.document.write(html);3173 win.document.close();3174 win.resizeTo(width, height);3175 win.focus();3176 } else {3177 if (tinyMCE.isMSIE && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {3178 var features = "resizable:" + resizable3179 + ";scroll:"3180 + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:"3181 + width + "px;dialogHeight:" + height + "px;";3182 3183 window.showModalDialog(url, window, features);3184 } else {3185 var modal = (resizable == "yes") ? "no" : "yes";3186 3187 if (tinyMCE.isGecko && tinyMCE.isMac)3188 modal = "no";3189 3190 if (template['close_previous'] != "no")3191 try {tinyMCE.lastWindow.close();} catch (ex) {}3192 3193 var win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable);3194 if (win == null) {3195 alert(tinyMCELang['lang_popup_blocked']);3196 return;3197 }3198 3199 if (template['close_previous'] != "no")3200 tinyMCE.lastWindow = win;3201 3202 eval('try { win.resizeTo(width, height); } catch(e) { }');3203 3204 // Make it bigger if statusbar is forced3205 if (tinyMCE.isGecko) {3206 if (win.document.defaultView.statusbar.visible)3207 win.resizeBy(0, tinyMCE.isMac ? 10 : 24);3208 }3209 3210 win.focus();3211 }3212 }3213 };3214 3215 TinyMCE.prototype.closeWindow = function(win) {3216 win.close();3217 };3218 3219 TinyMCE.prototype.getVisualAidClass = function(class_name, state) {3220 var aidClass = tinyMCE.settings['visual_table_class'];3221 3222 if (typeof(state) == "undefined")3223 state = tinyMCE.settings['visual'];3224 3225 // Split3226 var classNames = new Array();3227 var ar = class_name.split(' ');3228 for (var i=0; i<ar.length; i++) {3229 if (ar[i] == aidClass)3230 ar[i] = "";3231 3232 if (ar[i] != "")3233 classNames[classNames.length] = ar[i];3234 }3235 3236 if (state)3237 classNames[classNames.length] = aidClass;3238 3239 // Glue3240 var className = "";3241 for (var i=0; i<classNames.length; i++) {3242 if (i > 0)3243 className += " ";3244 3245 className += classNames[i];3246 }3247 3248 return className;3249 };3250 3251 TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) {3252 if (!el)3253 return;3254 3255 var tableElement = null;3256 3257 switch (el.nodeName) {3258 case "TABLE":3259 var oldW = el.style.width;3260 var oldH = el.style.height;3261 var bo = tinyMCE.getAttrib(el, "border");3262 3263 bo = bo == "" || bo == "0" ? true : false;3264 3265 tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));3266 3267 el.style.width = oldW;3268 el.style.height = oldH;3269 3270 for (var y=0; y<el.rows.length; y++) {3271 for (var x=0; x<el.rows[y].cells.length; x++) {3272 var cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);3273 tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn);3274 }3275 }3276 3277 break;3278 3279 case "A":3280 var anchorName = tinyMCE.getAttrib(el, "name");3281 3282 if (anchorName != '' && state) {3283 el.title = anchorName;3284 el.className = 'mceItemAnchor';3285 } else if (anchorName != '' && !state)3286 el.className = '';3287 3288 break;3289 }3290 3291 if (deep && el.hasChildNodes()) {3292 for (var i=0; i<el.childNodes.length; i++)3293 tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst);3294 }3295 };3296 3297 TinyMCE.prototype.getAttrib = function(elm, name, default_value) {3298 if (typeof(default_value) == "undefined")3299 default_value = "";3300 3301 // Not a element3302 if (!elm || elm.nodeType != 1)3303 return default_value;3304 3305 var v = elm.getAttribute(name);3306 3307 // Try className for class attrib3308 if (name == "class" && !v)3309 v = elm.className;3310 3311 if (name == "style" && !tinyMCE.isOpera)3312 v = elm.style.cssText;3313 3314 return (v && v != "") ? v : default_value;3315 };3316 3317 TinyMCE.prototype.setAttrib = function(element, name, value, fix_value) {3318 if (typeof(value) == "number" && value != null)3319 value = "" + value;3320 3321 if (fix_value) {3322 if (value == null)3323 value = "";3324 3325 var re = new RegExp('[^0-9%]', 'g');3326 value = value.replace(re, '');3327 }3328 3329 if (name == "style")3330 element.style.cssText = value;3331 3332 if (name == "class")3333 element.className = value;3334 3335 if (value != null && value != "" && value != -1)3336 element.setAttribute(name, value);3337 else3338 element.removeAttribute(name);3339 };3340 3341 TinyMCE.prototype.setStyleAttrib = function(elm, name, value) {3342 eval('elm.style.' + name + '=value;');3343 3344 // Style attrib deleted3345 if (tinyMCE.isMSIE && value == null || value == '') {3346 var str = tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));3347 elm.style.cssText = str;3348 elm.setAttribute("style", str);3349 }3350 };3351 3352 TinyMCE.prototype.convertSpansToFonts = function(doc) {3353 var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');3354 3355 var h = doc.body.innerHTML;3356 h = h.replace(/<span/gi, '<font');3357 h = h.replace(/<\/span/gi, '</font');3358 doc.body.innerHTML = h;3359 3360 var s = doc.getElementsByTagName("font");3361 for (var i=0; i<s.length; i++) {3362 var size = tinyMCE.trim(s[i].style.fontSize).toLowerCase();3363 var fSize = 0;3364 3365 for (var x=0; x<sizes.length; x++) {3366 if (sizes[x] == size) {3367 fSize = x + 1;3368 break;3369 }3370 }3371 3372 if (fSize > 0) {3373 tinyMCE.setAttrib(s[i], 'size', fSize);3374 s[i].style.fontSize = '';3375 }3376 3377 var fFace = s[i].style.fontFamily;3378 if (fFace != null && fFace != "") {3379 tinyMCE.setAttrib(s[i], 'face', fFace);3380 s[i].style.fontFamily = '';3381 }3382 3383 var fColor = s[i].style.color;3384 if (fColor != null && fColor != "") {3385 tinyMCE.setAttrib(s[i], 'color', tinyMCE.convertRGBToHex(fColor));3386 s[i].style.color = '';3387 }3388 }3389 };3390 3391 TinyMCE.prototype.convertFontsToSpans = function(doc) {3392 var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');3393 3394 var h = doc.body.innerHTML;3395 h = h.replace(/<font/gi, '<span');3396 h = h.replace(/<\/font/gi, '</span');3397 doc.body.innerHTML = h;3398 3399 var fsClasses = tinyMCE.getParam('font_size_classes');3400 if (fsClasses != '')3401 fsClasses = fsClasses.replace(/\s+/, '').split(',');3402 else3403 fsClasses = null;3404 3405 var s = doc.getElementsByTagName("span");3406 for (var i=0; i<s.length; i++) {3407 var fSize, fFace, fColor;3408 3409 fSize = tinyMCE.getAttrib(s[i], 'size');3410 fFace = tinyMCE.getAttrib(s[i], 'face');3411 fColor = tinyMCE.getAttrib(s[i], 'color');3412 3413 if (fSize != "") {3414 fSize = parseInt(fSize);3415 3416 if (fSize > 0 && fSize < 8) {3417 if (fsClasses != null)3418 tinyMCE.setAttrib(s[i], 'class', fsClasses[fSize-1]);3419 else3420 s[i].style.fontSize = sizes[fSize-1];3421 }3422 3423 s[i].removeAttribute('size');3424 }3425 3426 if (fFace != "") {3427 s[i].style.fontFamily = fFace;3428 s[i].removeAttribute('face');3429 }3430 3431 if (fColor != "") {3432 s[i].style.color = fColor;3433 s[i].removeAttribute('color');3434 }3435 }3436 };3437 3438 /*3439 TinyMCE.prototype.applyClassesToFonts = function(doc, size) {3440 var f = doc.getElementsByTagName("font");3441 for (var i=0; i<f.length; i++) {3442 var s = tinyMCE.getAttrib(f[i], "size");3443 3444 if (s != "")3445 tinyMCE.setAttrib(f[i], 'class', "mceItemFont" + s);3446 }3447 3448 if (typeof(size) != "undefined") {3449 var css = "";3450 3451 for (var x=0; x<doc.styleSheets.length; x++) {3452 for (var i=0; i<doc.styleSheets[x].rules.length; i++) {3453 if (doc.styleSheets[x].rules[i].selectorText == '#mceSpanFonts .mceItemFont' + size) {3454 css = doc.styleSheets[x].rules[i].style.cssText;3455 break;3456 }3457 }3458 3459 if (css != "")3460 break;3461 }3462 3463 if (doc.styleSheets[0].rules[0].selectorText == "FONT")3464 doc.styleSheets[0].removeRule(0);3465 3466 doc.styleSheets[0].addRule("FONT", css, 0);3467 }3468 };3469 */3470 3471 TinyMCE.prototype.setInnerHTML = function(e, h) {3472 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {3473 e.innerHTML = '<div id="mceTMPElement" style="display: none">TMP</div>' + h;3474 e.firstChild.removeNode(true);3475 } else3476 e.innerHTML = h;3477 };3478 3479 TinyMCE.prototype.getOuterHTML = function(e) {3480 if (tinyMCE.isMSIE)3481 return e.outerHTML;3482 3483 var d = e.ownerDocument.createElement("body");3484 d.appendChild(e);3485 return d.innerHTML;3486 };3487 3488 TinyMCE.prototype.setOuterHTML = function(doc, e, h) {3489 if (tinyMCE.isMSIE) {3490 e.outerHTML = h;3491 return;3492 }3493 3494 var d = e.ownerDocument.createElement("body");3495 d.innerHTML = h;3496 e.parentNode.replaceChild(d.firstChild, e);3497 };3498 3499 TinyMCE.prototype.insertAfter = function(nc, rc){3500 if (rc.nextSibling)3501 rc.parentNode.insertBefore(nc, rc.nextSibling);3502 else3503 rc.parentNode.appendChild(nc);3504 };3505 3506 TinyMCE.prototype.cleanupAnchors = function(doc) {3507 var an = doc.getElementsByTagName("a");3508 3509 for (var i=0; i<an.length; i++) {3510 if (tinyMCE.getAttrib(an[i], "name") != "") {3511 var cn = an[i].childNodes;3512 for (var x=cn.length-1; x>=0; x--)3513 tinyMCE.insertAfter(cn[x], an[i]);3514 }3515 }3516 };3517 3518 TinyMCE.prototype._setHTML = function(doc, html_content) {3519 // Force closed anchors open3520 //html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');3521 3522 html_content = tinyMCE.cleanupHTMLCode(html_content);3523 3524 // Try innerHTML if it fails use pasteHTML in MSIE3525 try {3526 tinyMCE.setInnerHTML(doc.body, html_content);3527 } catch (e) {3528 if (this.isMSIE)3529 doc.body.createTextRange().pasteHTML(html_content);3530 }3531 3532 // Content duplication bug fix3533 if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {3534 // Remove P elements in P elements3535 var paras = doc.getElementsByTagName("P");3536 for (var i=0; i<paras.length; i++) {3537 var node = paras[i];3538 while ((node = node.parentNode) != null) {3539 if (node.nodeName.toLowerCase() == "p")3540 node.outerHTML = node.innerHTML;3541 }3542 }3543 3544 // Content duplication bug fix (Seems to be word crap)3545 var html = doc.body.innerHTML;3546 3547 if (html.indexOf('="mso') != -1) {3548 for (var i=0; i<doc.body.all.length; i++) {3549 var el = doc.body.all[i];3550 el.removeAttribute("className","",0);3551 el.removeAttribute("style","",0);3552 }3553 3554 html = doc.body.innerHTML;3555 html = tinyMCE.regexpReplace(html, "<o:p><\/o:p>", "<br />");3556 html = tinyMCE.regexpReplace(html, "<o:p> <\/o:p>", "");3557 html = tinyMCE.regexpReplace(html, "<st1:.*?>", "");3558 html = tinyMCE.regexpReplace(html, "<p><\/p>", "");3559 html = tinyMCE.regexpReplace(html, "<p><\/p>\r\n<p><\/p>", "");3560 html = tinyMCE.regexpReplace(html, "<p> <\/p>", "<br />");3561 html = tinyMCE.regexpReplace(html, "<p>\s*(<p>\s*)?", "<p>");3562 html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "</p>");3563 }3564 3565 // Always set the htmlText output3566 tinyMCE.setInnerHTML(doc.body, html);3567 }3568 3569 tinyMCE.cleanupAnchors(doc);3570 3571 if (tinyMCE.getParam("convert_fonts_to_spans"))3572 tinyMCE.convertSpansToFonts(doc);3573 };3574 3575 TinyMCE.prototype.getImageSrc = function(str) {3576 var pos = -1;3577 3578 if (!str)3579 return "";3580 3581 if ((pos = str.indexOf('this.src=')) != -1) {3582 var src = str.substring(pos + 10);3583 3584 src = src.substring(0, src.indexOf('\''));3585 3586 return src;3587 }3588 3589 return "";3590 };3591 3592 TinyMCE.prototype._getElementById = function(element_id) {3593 var elm = document.getElementById(element_id);3594 if (!elm) {3595 // Check for element in forms3596 for (var j=0; j<document.forms.length; j++) {3597 for (var k=0; k<document.forms[j].elements.length; k++) {3598 if (document.forms[j].elements[k].name == element_id) {3599 elm = document.forms[j].elements[k];3600 break;3601 }3602 }3603 }3604 }3605 3606 return elm;3607 };3608 3609 TinyMCE.prototype.getEditorId = function(form_element) {3610 var inst = this.getInstanceById(form_element);3611 if (!inst)3612 return null;3613 3614 return inst.editorId;3615 };3616 3617 TinyMCE.prototype.getInstanceById = function(editor_id) {3618 var inst = this.instances[editor_id];3619 if (!inst) {3620 for (var n in tinyMCE.instances) {3621 var instance = tinyMCE.instances[n];3622 if (!tinyMCE.isInstance(instance))3623 continue;3624 3625 if (instance.formTargetElementId == editor_id) {3626 inst = instance;3627 break;3628 }3629 }3630 }3631 3632 return inst;3633 };3634 3635 TinyMCE.prototype.queryInstanceCommandValue = function(editor_id, command) {3636 var inst = tinyMCE.getInstanceById(editor_id);3637 if (inst)3638 return inst.queryCommandValue(command);3639 3640 return false;3641 };3642 3643 TinyMCE.prototype.queryInstanceCommandState = function(editor_id, command) {3644 var inst = tinyMCE.getInstanceById(editor_id);3645 if (inst)3646 return inst.queryCommandState(command);3647 3648 return null;3649 };3650 3651 TinyMCE.prototype.setWindowArg = function(name, value) {3652 this.windowArgs[name] = value;3653 };3654 3655 TinyMCE.prototype.getWindowArg = function(name, default_value) {3656 return (typeof(this.windowArgs[name]) == "undefined") ? default_value : this.windowArgs[name];3657 };3658 3659 TinyMCE.prototype.getCSSClasses = function(editor_id, doc) {3660 var output = new Array();3661 3662 // Is cached, use that3663 if (typeof(tinyMCE.cssClasses) != "undefined")3664 return tinyMCE.cssClasses;3665 3666 if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {3667 var instance;3668 3669 for (var instanceName in tinyMCE.instances) {3670 instance = tinyMCE.instances[instanceName];3671 if (!tinyMCE.isInstance(instance))3672 continue;3673 3674 break;3675 }3676 3677 doc = instance.getDoc();3678 }3679 3680 if (typeof(doc) == "undefined") {3681 var instance = tinyMCE.getInstanceById(editor_id);3682 doc = instance.getDoc();3683 }3684 3685 if (doc) {3686 var styles = tinyMCE.isMSIE ? doc.styleSheets : doc.styleSheets;3687 3688 if (styles && styles.length > 0) {3689 for (var x=0; x<styles.length; x++) {3690 var csses = null;3691 3692 // Just ignore any errors3693 eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : doc.styleSheets[" + x + "].cssRules;} catch(e) {}");3694 if (!csses)3695 return new Array();3696 3697 for (var i=0; i<csses.length; i++) {3698 var selectorText = csses[i].selectorText;3699 3700 // Can be multiple rules per selector3701 if (selectorText) {3702 var rules = selectorText.split(',');3703 for (var c=0; c<rules.length; c++) {3704 // Invalid rule3705 if (rules[c].indexOf(' ') != -1 || rules[c].indexOf(':') != -1 || rules[c].indexOf('mceItem') != -1)3706 continue;3707 3708 if (rules[c] == "." + tinyMCE.settings['visual_table_class'])3709 continue;3710 3711 // Is class rule3712 if (rules[c].indexOf('.') != -1) {3713 //alert(rules[c].substring(rules[c].indexOf('.')));3714 output[output.length] = rules[c].substring(rules[c].indexOf('.')+1);3715 }3716 }3717 }3718 }3719 }3720 }3721 }3722 3723 // Cache em3724 if (output.length > 0)3725 tinyMCE.cssClasses = output;3726 3727 return output;3728 };3729 3730 TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) {3731 if (in_str == null)3732 return in_str;3733 3734 if (typeof(opts) == "undefined")3735 opts = 'g';3736 3737 var re = new RegExp(reg_exp, opts);3738 return in_str.replace(re, replace_str);3739 };3740 3741 TinyMCE.prototype.trim = function(str) {3742 return str.replace(/^\s*|\s*$/g, "");3743 };3744 3745 TinyMCE.prototype.cleanupEventStr = function(str) {3746 str = "" + str;3747 str = str.replace('function anonymous()\n{\n', '');3748 str = str.replace('\n}', '');3749 str = str.replace(/^return true;/gi, ''); // Remove event blocker3750 3751 return str;3752 };3753 3754 TinyMCE.prototype.getAbsPosition = function(node) {3755 var pos = new Object();3756 3757 pos.absLeft = pos.absTop = 0;3758 3759 var parentNode = node;3760 while (parentNode) {3761 pos.absLeft += parentNode.offsetLeft;3762 pos.absTop += parentNode.offsetTop;3763 3764 parentNode = parentNode.offsetParent;3765 }3766 3767 return pos;3768 };3769 3770 TinyMCE.prototype.getControlHTML = function(control_name) {3771 var themePlugins = tinyMCE.getParam('plugins', '', true, ',');3772 var templateFunction;3773 3774 // Is it defined in any plugins3775 for (var i=themePlugins.length; i>=0; i--) {3776 templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML";3777 if (eval("typeof(" + templateFunction + ")") != 'undefined') {3778 var html = eval(templateFunction + "('" + control_name + "');");3779 if (html != "")3780 return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]);3781 }3782 }3783 3784 return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');");3785 };3786 3787 TinyMCE.prototype._themeExecCommand = function(editor_id, element, command, user_interface, value) {3788 var themePlugins = tinyMCE.getParam('plugins', '', true, ',');3789 var templateFunction;3790 3791 // Is it defined in any plugins3792 for (var i=themePlugins.length; i>=0; i--) {3793 templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand";3794 if (eval("typeof(" + templateFunction + ")") != 'undefined') {3795 if (eval(templateFunction + "(editor_id, element, command, user_interface, value);"))3796 return true;3797 }3798 }3799 3800 // Theme funtion3801 templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand";3802 if (eval("typeof(" + templateFunction + ")") != 'undefined')3803 return eval(templateFunction + "(editor_id, element, command, user_interface, value);");3804 3805 // Pass to normal3806 return false;3807 };3808 3809 TinyMCE.prototype._getThemeFunction = function(suffix, skip_plugins) {3810 if (skip_plugins)3811 return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;3812 3813 var themePlugins = tinyMCE.getParam('plugins', '', true, ',');3814 var templateFunction;3815 3816 // Is it defined in any plugins3817 for (var i=themePlugins.length; i>=0; i--) {3818 templateFunction = 'TinyMCE_' + themePlugins[i] + suffix;3819 if (eval("typeof(" + templateFunction + ")") != 'undefined')3820 return templateFunction;3821 }3822 3823 return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;3824 };3825 3826 3827 TinyMCE.prototype.isFunc = function(func_name) {3828 if (func_name == null || func_name == "")3829 return false;3830 3831 return eval("typeof(" + func_name + ")") != "undefined";3832 };3833 3834 TinyMCE.prototype.exec = function(func_name, args) {3835 var str = func_name + '(';3836 3837 // Add all arguments3838 for (var i=3; i<args.length; i++) {3839 str += 'args[' + i + ']';3840 3841 if (i < args.length-1)3842 str += ',';3843 }3844 3845 str += ');';3846 3847 return eval(str);3848 };3849 3850 TinyMCE.prototype.executeCallback = function(param, suffix, mode) {3851 switch (mode) {3852 // No chain3853 case 0:3854 var state = false;3855 3856 // Execute each plugin callback3857 var plugins = tinyMCE.getParam('plugins', '', true, ',');3858 for (var i=0; i<plugins.length; i++) {3859 var func = "TinyMCE_" + plugins[i] + suffix;3860 if (tinyMCE.isFunc(func)) {3861 tinyMCE.exec(func, this.executeCallback.arguments);3862 state = true;3863 }3864 }3865 3866 // Execute theme callback3867 var func = 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;3868 if (tinyMCE.isFunc(func)) {3869 tinyMCE.exec(func, this.executeCallback.arguments);3870 state = true;3871 }3872 3873 // Execute settings callback3874 var func = tinyMCE.getParam(param, '');3875 if (tinyMCE.isFunc(func)) {3876 tinyMCE.exec(func, this.executeCallback.arguments);3877 state = true;3878 }3879 3880 return state;3881 3882 // Chain mode3883 case 1:3884 // Execute each plugin callback3885 var plugins = tinyMCE.getParam('plugins', '', true, ',');3886 for (var i=0; i<plugins.length; i++) {3887 var func = "TinyMCE_" + plugins[i] + suffix;3888 if (tinyMCE.isFunc(func)) {3889 if (tinyMCE.exec(func, this.executeCallback.arguments))3890 return true;3891 }3892 }3893 3894 // Execute theme callback3895 var func = 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;3896 if (tinyMCE.isFunc(func)) {3897 if (tinyMCE.exec(func, this.executeCallback.arguments))3898 return true;3899 }3900 3901 // Execute settings callback3902 var func = tinyMCE.getParam(param, '');3903 if (tinyMCE.isFunc(func)) {3904 if (tinyMCE.exec(func, this.executeCallback.arguments))3905 return true;3906 }3907 3908 return false;3909 }3910 };3911 3912 TinyMCE.prototype.debug = function() {3913 var msg = "";3914 3915 var elm = document.getElementById("tinymce_debug");3916 if (!elm) {3917 var debugDiv = document.createElement("div");3918 debugDiv.setAttribute("className", "debugger");3919 debugDiv.className = "debugger";3920 debugDiv.innerHTML = '\3921 Debug output:\3922 <textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap"></textarea>';3923 3924 document.body.appendChild(debugDiv);3925 elm = document.getElementById("tinymce_debug");3926 }3927 3928 var args = this.debug.arguments;3929 for (var i=0; i<args.length; i++) {3930 msg += args[i];3931 if (i<args.length-1)3932 msg += ', ';3933 }3934 3935 elm.value += msg + "\n";3936 };3937 3938 // TinyMCEControl3939 function TinyMCEControl(settings) {3940 // Undo levels3941 this.undoLevels = new Array();3942 this.undoIndex = 0;3943 this.typingUndoIndex = -1;3944 this.undoRedo = true;3945 this.isTinyMCEControl = true;3946 3947 // Default settings3948 this.settings = settings;3949 this.settings['theme'] = tinyMCE.getParam("theme", "default");3950 this.settings['width'] = tinyMCE.getParam("width", -1);3951 this.settings['height'] = tinyMCE.getParam("height", -1);3952 };3953 3954 TinyMCEControl.prototype.repaint = function() {3955 if (tinyMCE.isMSIE)3956 return;3957 3958 this.getBody().style.display = 'none';3959 this.getBody().style.display = 'block';3960 };3961 3962 TinyMCEControl.prototype.switchSettings = function() {3963 if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings['index']) {3964 tinyMCE.settings = this.settings;3965 tinyMCE.currentConfig = this.settings['index'];3966 }3967 };3968 3969 TinyMCEControl.prototype.fixBrokenURLs = function() {3970 var body = this.getBody();3971 3972 var elms = body.getElementsByTagName("img");3973 for (var i=0; i<elms.length; i++) {3974 var src = elms[i].getAttribute('mce_real_src');3975 if (src && src != "")3976 elms[i].setAttribute("src", src);3977 }3978 3979 var elms = body.getElementsByTagName("a");3980 for (var i=0; i<elms.length; i++) {3981 var href = elms[i].getAttribute('mce_real_href');3982 if (href && href != "")3983 elms[i].setAttribute("href", href);3984 }3985 };3986 3987 TinyMCEControl.prototype.convertAllRelativeURLs = function() {3988 var body = this.getBody();3989 3990 // Convert all image URL:s to absolute URL3991 var elms = body.getElementsByTagName("img");3992 for (var i=0; i<elms.length; i++) {3993 var src = elms[i].getAttribute('src');3994 if (src && src != "") {3995 src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);3996 elms[i].setAttribute("src", src);3997 elms[i].setAttribute("mce_real_src", src);3998 }3999 }4000 4001 // Convert all link URL:s to absolute URL4002 var elms = body.getElementsByTagName("a");4003 for (var i=0; i<elms.length; i++) {4004 var href = elms[i].getAttribute('href');4005 if (href && href != "") {4006 href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], href);4007 elms[i].setAttribute("href", href);4008 elms[i].setAttribute("mce_real_href", href);4009 }4010 }4011 };4012 4013 TinyMCEControl.prototype.getSelectedHTML = function() {4014 if (tinyMCE.isSafari) {4015 // Not realy perfect!!4016 4017 return this.getRng().toString();4018 }4019 4020 var elm = document.createElement("body");4021 4022 if (tinyMCE.isGecko)4023 elm.appendChild(this.getRng().cloneContents());4024 else4025 elm.innerHTML = this.getRng().htmlText;4026 4027 return tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, elm, this.visualAid);4028 };4029 4030 TinyMCEControl.prototype.getBookmark = function() {4031 var rng = this.getRng();4032 4033 if (tinyMCE.isSafari)4034 return rng;4035 4036 if (tinyMCE.isMSIE)4037 return rng;4038 4039 if (tinyMCE.isGecko)4040 return rng.cloneRange();4041 4042 return null;4043 };4044 4045 TinyMCEControl.prototype.moveToBookmark = function(bookmark) {4046 if (tinyMCE.isSafari) {4047 var sel = this.getSel().realSelection;4048 4049 sel.setBaseAndExtent(bookmark.startContainer, bookmark.startOffset, bookmark.endContainer, bookmark.endOffset);4050 4051 return true;4052 }4053 4054 if (tinyMCE.isMSIE)4055 return bookmark.select();4056 4057 if (tinyMCE.isGecko) {4058 var rng = this.getDoc().createRange();4059 var sel = this.getSel();4060 4061 rng.setStart(bookmark.startContainer, bookmark.startOffset);4062 rng.setEnd(bookmark.endContainer, bookmark.endOffset);4063 4064 sel.removeAllRanges();4065 sel.addRange(rng);4066 4067 return true;4068 }4069 4070 return false;4071 };4072 4073 TinyMCEControl.prototype.getSelectedText = function() {4074 if (tinyMCE.isMSIE) {4075 var doc = this.getDoc();4076 4077 if (doc.selection.type == "Text") {4078 var rng = doc.selection.createRange();4079 selectedText = rng.text;4080 } else4081 selectedText = '';4082 } else {4083 var sel = this.getSel();4084 4085 if (sel && sel.toString)4086 selectedText = sel.toString();4087 else4088 selectedText = '';4089 }4090 4091 return selectedText;4092 };4093 4094 TinyMCEControl.prototype.selectNode = function(node, collapse, select_text_node, to_start) {4095 if (!node)4096 return;4097 4098 if (typeof(collapse) == "undefined")4099 collapse = true;4100 4101 if (typeof(select_text_node) == "undefined")4102 select_text_node = false;4103 4104 if (typeof(to_start) == "undefined")4105 to_start = true;4106 4107 if (tinyMCE.isMSIE) {4108 var rng = this.getBody().createTextRange();4109 4110 try {4111 rng.moveToElementText(node);4112 4113 if (collapse)4114 rng.collapse(to_start);4115 4116 rng.select();4117 } catch (e) {4118 // Throws illigal agrument in MSIE some times4119 }4120 } else {4121 var sel = this.getSel();4122 4123 if (!sel)4124 return;4125 4126 if (tinyMCE.isSafari) {4127 sel.realSelection.setBaseAndExtent(node, 0, node, node.innerText.length);4128 4129 if (collapse) {4130 if (to_start)4131 sel.realSelection.collapseToStart();4132 else4133 sel.realSelection.collapseToEnd();4134 }4135 4136 this.scrollToNode(node);4137 4138 return;4139 }4140 4141 var rng = this.getDoc().createRange();4142 4143 if (select_text_node) {4144 // Find first textnode in tree4145 var nodes = tinyMCE.getNodeTree(node, new Array(), 3);4146 if (nodes.length > 0)4147 rng.selectNodeContents(nodes[0]);4148 else4149 rng.selectNodeContents(node);4150 } else4151 rng.selectNode(node);4152 4153 if (collapse) {4154 // Special treatment of textnode collapse4155 if (!to_start && node.nodeType == 3) {4156 rng.setStart(node, node.nodeValue.length);4157 rng.setEnd(node, node.nodeValue.length);4158 } else4159 rng.collapse(to_start);4160 }4161 4162 sel.removeAllRanges();4163 sel.addRange(rng);4164 }4165 4166 this.scrollToNode(node);4167 4168 // Set selected element4169 tinyMCE.selectedElement = null;4170 if (node.nodeType == 1)4171 tinyMCE.selectedElement = node;4172 };4173 4174 TinyMCEControl.prototype.scrollToNode = function(node) {4175 // Scroll to node position4176 var pos = tinyMCE.getAbsPosition(node);4177 var doc = this.getDoc();4178 var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;4179 var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;4180 var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : this.targetElement.clientHeight;4181 4182 // Only scroll if out of visible area4183 if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))4184 this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);4185 };4186 4187 TinyMCEControl.prototype.getBody = function() {4188 return this.getDoc().body;4189 };4190 4191 TinyMCEControl.prototype.getDoc = function() {4192 return this.contentWindow.document;4193 };4194 4195 TinyMCEControl.prototype.getWin = function() {4196 return this.contentWindow;4197 };4198 4199 TinyMCEControl.prototype.getSel = function() {4200 if (tinyMCE.isMSIE && !tinyMCE.isOpera)4201 return this.getDoc().selection;4202 4203 var sel = this.contentWindow.getSelection();4204 4205 // Fake getRangeAt4206 if (tinyMCE.isSafari && !sel.getRangeAt) {4207 var newSel = new Object();4208 var doc = this.getDoc();4209 4210 function getRangeAt(idx) {4211 var rng = new Object();4212 4213 rng.startContainer = this.focusNode;4214 rng.endContainer = this.anchorNode;4215 rng.commonAncestorContainer = this.focusNode;4216 rng.createContextualFragment = function (html) {4217 // Seems to be a tag4218 if (html.charAt(0) == '<') {4219 var elm = doc.createElement("div");4220 4221 elm.innerHTML = html;4222 4223 return elm.firstChild;4224 }4225 4226 return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!");4227 };4228 4229 rng.deleteContents = function () {4230 doc.execCommand("Delete", false, "");4231 };4232 4233 return rng;4234 }4235 4236 // Patch selection4237 4238 newSel.focusNode = sel.baseNode;4239 newSel.focusOffset = sel.baseOffset;4240 newSel.anchorNode = sel.extentNode;4241 newSel.anchorOffset = sel.extentOffset;4242 newSel.getRangeAt = getRangeAt;4243 newSel.text = "" + sel;4244 newSel.realSelection = sel;4245 4246 newSel.toString = function () {return this.text;};4247 4248 return newSel;4249 }4250 4251 return sel;4252 };4253 4254 TinyMCEControl.prototype.getRng = function() {4255 var sel = this.getSel();4256 if (sel == null)4257 return null;4258 4259 if (tinyMCE.isMSIE && !tinyMCE.isOpera)4260 return sel.createRange();4261 4262 if (tinyMCE.isSafari) {4263 var rng = this.getDoc().createRange();4264 var sel = this.getSel().realSelection;4265 4266 rng.setStart(sel.baseNode, sel.baseOffset);4267 rng.setEnd(sel.extentNode, sel.extentOffset);4268 4269 return rng;4270 }4271 4272 return this.getSel().getRangeAt(0);4273 };4274 4275 TinyMCEControl.prototype._insertPara = function(e) {4276 function isEmpty(para) {4277 function isEmptyHTML(html) {4278 return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";4279 }4280 4281 // Check for images4282 if (para.getElementsByTagName("img").length > 0)4283 return false;4284 4285 // Check for tables4286 if (para.getElementsByTagName("table").length > 0)4287 return false;4288 4289 // Check for HRs4290 if (para.getElementsByTagName("hr").length > 0)4291 return false;4292 4293 // Check all textnodes4294 var nodes = tinyMCE.getNodeTree(para, new Array(), 3);4295 for (var i=0; i<nodes.length; i++) {4296 if (!isEmptyHTML(nodes[i].nodeValue))4297 return false;4298 }4299 4300 // No images, no tables, no hrs, no text content then it's empty4301 return true;4302 }4303 4304 var doc = this.getDoc();4305 var sel = this.getSel();4306 var win = this.contentWindow;4307 var rng = sel.getRangeAt(0);4308 var body = doc.body;4309 var rootElm = doc.documentElement;4310 var self = this;4311 var blockName = "P";4312 4313 // tinyMCE.debug(body.innerHTML);4314 4315 // debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString());4316 4317 // Setup before range4318 var rngBefore = doc.createRange();4319 rngBefore.setStart(sel.anchorNode, sel.anchorOffset);4320 rngBefore.collapse(true);4321 4322 // Setup after range4323 var rngAfter = doc.createRange();4324 rngAfter.setStart(sel.focusNode, sel.focusOffset);4325 rngAfter.collapse(true);4326 4327 // Setup start/end points4328 var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;4329 var startNode = direct ? sel.anchorNode : sel.focusNode;4330 var startOffset = direct ? sel.anchorOffset : sel.focusOffset;4331 var endNode = direct ? sel.focusNode : sel.anchorNode;4332 var endOffset = direct ? sel.focusOffset : sel.anchorOffset;4333 4334 startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;4335 endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;4336 4337 // tinyMCE.debug(startNode, endNode);4338 4339 // Get block elements4340 var startBlock = tinyMCE.getParentBlockElement(startNode);4341 var endBlock = tinyMCE.getParentBlockElement(endNode);4342 4343 // Use current block name4344 if (startBlock != null) {4345 blockName = startBlock.nodeName;4346 4347 // Use P instead4348 if (blockName == "TD" || blockName == "TABLE" || (blockName == "DIV" && new RegExp('left|right', 'gi').test(startBlock.style.cssFloat)))4349 blockName = "P";4350 }4351 4352 // Within a list use normal behaviour4353 if (tinyMCE.getParentElement(startBlock, "OL,UL") != null)4354 return false;4355 4356 // Within a table create new paragraphs4357 if ((startBlock != null && startBlock.nodeName == "TABLE") || (endBlock != null && endBlock.nodeName == "TABLE"))4358 startBlock = endBlock = null;4359 4360 // Setup new paragraphs4361 var paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);4362 var paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);4363 4364 // Is header, then force paragraph under4365 if (/^(H[1-6])$/.test(blockName))4366 paraAfter = doc.createElement("p");4367 4368 // Setup chop nodes4369 var startChop = startNode;4370 var endChop = endNode;4371 4372 // Get startChop node4373 node = startChop;4374 do {4375 if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))4376 break;4377 4378 startChop = node;4379 } while ((node = node.previousSibling ? node.previousSibling : node.parentNode));4380 4381 // Get endChop node4382 node = endChop;4383 do {4384 if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))4385 break;4386 4387 endChop = node;4388 } while ((node = node.nextSibling ? node.nextSibling : node.parentNode));4389 4390 // Fix when only a image is within the TD4391 if (startChop.nodeName == "TD")4392 startChop = startChop.firstChild;4393 4394 if (endChop.nodeName == "TD")4395 endChop = endChop.lastChild;4396 4397 // If not in a block element4398 if (startBlock == null) {4399 // Delete selection4400 rng.deleteContents();4401 sel.removeAllRanges();4402 4403 if (startChop != rootElm && endChop != rootElm) {4404 // Insert paragraph before4405 rngBefore = rng.cloneRange();4406 4407 if (startChop == body)4408 rngBefore.setStart(startChop, 0);4409 else4410 rngBefore.setStartBefore(startChop);4411 4412 paraBefore.appendChild(rngBefore.cloneContents());4413 4414 // Insert paragraph after4415 if (endChop.parentNode.nodeName == blockName)4416 endChop = endChop.parentNode;4417 4418 // If not after image4419 //if (rng.startContainer.nodeName != "BODY" && rng.endContainer.nodeName != "BODY")4420 rng.setEndAfter(endChop);4421 4422 if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")4423 rngBefore.setEndAfter(endChop);4424 4425 var contents = rng.cloneContents();4426 if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))4427 paraAfter.innerHTML = contents.firstChild.innerHTML;4428 else4429 paraAfter.appendChild(contents);4430 4431 // Check if it's a empty paragraph4432 if (isEmpty(paraBefore))4433 paraBefore.innerHTML = " ";4434 4435 // Check if it's a empty paragraph4436 if (isEmpty(paraAfter))4437 paraAfter.innerHTML = " ";4438 4439 // Delete old contents4440 rng.deleteContents();4441 rngAfter.deleteContents();4442 rngBefore.deleteContents();4443 4444 // Insert new paragraphs4445 paraAfter.normalize();4446 rngBefore.insertNode(paraAfter);4447 paraBefore.normalize();4448 rngBefore.insertNode(paraBefore);4449 4450 // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);4451 } else {4452 body.innerHTML = "<" + blockName + "> </" + blockName + "><" + blockName + "> </" + blockName + ">";4453 paraAfter = body.childNodes[1];4454 }4455 4456 this.selectNode(paraAfter, true, true);4457 4458 return true;4459 }4460 4461 // Place first part within new paragraph4462 if (startChop.nodeName == blockName)4463 rngBefore.setStart(startChop, 0);4464 else4465 rngBefore.setStartBefore(startChop);4466 4467 rngBefore.setEnd(startNode, startOffset);4468 paraBefore.appendChild(rngBefore.cloneContents());4469 4470 // Place secound part within new paragraph4471 rngAfter.setEndAfter(endChop);4472 rngAfter.setStart(endNode, endOffset);4473 var contents = rngAfter.cloneContents();4474 4475 if (contents.firstChild && contents.firstChild.nodeName == blockName) {4476 /* var nodes = contents.firstChild.childNodes;4477 for (var i=0; i<nodes.length; i++) {4478 //tinyMCE.debug(nodes[i].nodeName);4479 if (nodes[i].nodeName != "BODY")4480 paraAfter.appendChild(nodes[i]);4481 }4482 */4483 paraAfter.innerHTML = contents.firstChild.innerHTML;4484 } else4485 paraAfter.appendChild(contents);4486 4487 // Check if it's a empty paragraph4488 if (isEmpty(paraBefore))4489 paraBefore.innerHTML = " ";4490 4491 // Check if it's a empty paragraph4492 if (isEmpty(paraAfter))4493 paraAfter.innerHTML = " ";4494 4495 // Create a range around everything4496 var rng = doc.createRange();4497 4498 if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {4499 rng.setStartBefore(startChop.parentNode);4500 } else {4501 if (rngBefore.startContainer.nodeName.toUpperCase() == blockName && rngBefore.startOffset == 0)4502 rng.setStartBefore(rngBefore.startContainer);4503 else4504 rng.setStart(rngBefore.startContainer, rngBefore.startOffset);4505 }4506 4507 if (!endChop.nextSibling && endChop.parentNode.nodeName.toUpperCase() == blockName)4508 rng.setEndAfter(endChop.parentNode);4509 else4510 rng.setEnd(rngAfter.endContainer, rngAfter.endOffset);4511 4512 // Delete all contents and insert new paragraphs4513 rng.deleteContents();4514 rng.insertNode(paraAfter);4515 rng.insertNode(paraBefore);4516 //tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);4517 4518 // Normalize4519 paraAfter.normalize();4520 paraBefore.normalize();4521 4522 this.selectNode(paraAfter, true, true);4523 4524 return true;4525 };4526 4527 TinyMCEControl.prototype._handleBackSpace = function(evt_type) {4528 var doc = this.getDoc();4529 var sel = this.getSel();4530 if (sel == null)4531 return false;4532 4533 var rng = sel.getRangeAt(0);4534 var node = rng.startContainer;4535 var elm = node.nodeType == 3 ? node.parentNode : node;4536 4537 if (node == null)4538 return;4539 4540 // Empty node, wrap contents in paragraph4541 if (elm && elm.nodeName == "") {4542 var para = doc.createElement("p");4543 4544 while (elm.firstChild)4545 para.appendChild(elm.firstChild);4546 4547 elm.parentNode.insertBefore(para, elm);4548 elm.parentNode.removeChild(elm);4549 4550 var rng = rng.cloneRange();4551 rng.setStartBefore(node.nextSibling);4552 rng.setEndAfter(node.nextSibling);4553 rng.extractContents();4554 4555 this.selectNode(node.nextSibling, true, true);4556 }4557 4558 // Remove empty paragraphs4559 var para = tinyMCE.getParentBlockElement(node);4560 if (para != null && para.nodeName.toLowerCase() == 'p' && evt_type == "keypress") {4561 var htm = para.innerHTML;4562 var block = tinyMCE.getParentBlockElement(node);4563 4564 // Empty node, we do the killing!!4565 if (htm == "" || htm == " " || block.nodeName.toLowerCase() == "li") {4566 var prevElm = para.previousSibling;4567 4568 while (prevElm != null && prevElm.nodeType != 1)4569 prevElm = prevElm.previousSibling;4570 4571 if (prevElm == null)4572 return false;4573 4574 // Get previous elements last text node4575 var nodes = tinyMCE.getNodeTree(prevElm, new Array(), 3);4576 var lastTextNode = nodes.length == 0 ? null : nodes[nodes.length-1];4577 4578 // Select the last text node and move curstor to end4579 if (lastTextNode != null)4580 this.selectNode(lastTextNode, true, false, false);4581 4582 // Remove the empty paragrapsh4583 para.parentNode.removeChild(para);4584 4585 //debug("within p element" + para.innerHTML);4586 //showHTML(this.getBody().innerHTML);4587 return true;4588 }4589 }4590 4591 // Remove BR elements4592 /* while (node != null && (node = node.nextSibling) != null) {4593 if (node.nodeName.toLowerCase() == 'br')4594 node.parentNode.removeChild(node);4595 else if (node.nodeType == 1) // Break at other element4596 break;4597 }*/4598 4599 //showHTML(this.getBody().innerHTML);4600 4601 return false;4602 };4603 4604 TinyMCEControl.prototype._insertSpace = function() {4605 return true;4606 };4607 4608 TinyMCEControl.prototype.autoResetDesignMode = function() {4609 // Add fix for tab/style.display none/block problems in Gecko4610 if (!tinyMCE.isMSIE && tinyMCE.settings['auto_reset_designmode']) {4611 var sel = this.getSel();4612 4613 // Weird, wheres that cursor selection?4614 if (!sel || !sel.rangeCount || sel.rangeCount == 0)4615 eval('try { this.getDoc().designMode = "On"; } catch(e) {}');4616 }4617 };4618 4619 TinyMCEControl.prototype.isDirty = function() {4620 // Is content modified and not in a submit procedure4621 return this.startContent != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;4622 };4623 4624 TinyMCEControl.prototype._mergeElements = function(scmd, pa, ch, override) {4625 if (scmd == "removeformat") {4626 pa.className = "";4627 pa.style.cssText = "";4628 ch.className = "";4629 ch.style.cssText = "";4630 return;4631 }4632 4633 var st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style"));4634 var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));4635 var className = tinyMCE.getAttrib(pa, "class");4636 4637 className += " " + tinyMCE.getAttrib(ch, "class");4638 4639 if (override) {4640 for (var n in st) {4641 if (typeof(st[n]) == 'function')4642 continue;4643 4644 stc[n] = st[n];4645 }4646 } else {4647 for (var n in stc) {4648 if (typeof(stc[n]) == 'function')4649 continue;4650 4651 st[n] = stc[n];4652 }4653 }4654 4655 tinyMCE.setAttrib(pa, "style", tinyMCE.serializeStyle(st));4656 tinyMCE.setAttrib(pa, "class", tinyMCE.trim(className));4657 ch.className = "";4658 ch.style.cssText = "";4659 ch.removeAttribute("class");4660 ch.removeAttribute("style");4661 };4662 4663 TinyMCEControl.prototype.setUseCSS = function(b) {4664 var doc = this.getDoc();4665 try {doc.execCommand("useCSS", false, !b);} catch (ex) {}4666 try {doc.execCommand("styleWithCSS", false, b);} catch (ex) {}4667 };4668 4669 TinyMCEControl.prototype.execCommand = function(command, user_interface, value) {4670 var doc = this.getDoc();4671 var win = this.getWin();4672 var focusElm = this.getFocusElement();4673 4674 if (this.lastSafariSelection && !new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) {4675 this.moveToBookmark(this.lastSafariSelection);4676 tinyMCE.selectedElement = this.lastSafariSelectedElement;4677 }4678 4679 // Mozilla issue4680 if (!tinyMCE.isMSIE && !this.useCSS) {4681 this.setUseCSS(false);4682 this.useCSS = true;4683 }4684 4685 //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value);4686 this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks4687 4688 // Call theme execcommand4689 if (tinyMCE._themeExecCommand(this.editorId, this.getBody(), command, user_interface, value))4690 return;4691 4692 // Fix align on images4693 if (focusElm && focusElm.nodeName == "IMG") {4694 var align = focusElm.getAttribute('align');4695 var img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm;4696 4697 switch (command) {4698 case "JustifyLeft":4699 if (align == 'left')4700 img.removeAttribute('align');4701 else4702 img.setAttribute('align', 'left');4703 4704 // Remove the div4705 var div = focusElm.parentNode;4706 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)4707 div.parentNode.replaceChild(img, div);4708 4709 this.selectNode(img);4710 this.repaint();4711 tinyMCE.triggerNodeChange();4712 return;4713 4714 case "JustifyCenter":4715 img.removeAttribute('align');4716 4717 // Is centered4718 var div = tinyMCE.getParentElement(focusElm, "div");4719 if (div && div.style.textAlign == "center") {4720 // Remove div4721 if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)4722 div.parentNode.replaceChild(img, div);4723 } else {4724 // Add div4725 var div = this.getDoc().createElement("div");4726 div.style.textAlign = 'center';4727 div.appendChild(img);4728 focusElm.parentNode.replaceChild(div, focusElm);4729 }4730 4731 this.selectNode(img);4732 this.repaint();4733 tinyMCE.triggerNodeChange();4734 return;4735 4736 case "JustifyRight":4737 if (align == 'right')4738 img.removeAttribute('align');4739 else4740 img.setAttribute('align', 'right');4741 4742 // Remove the div4743 var div = focusElm.parentNode;4744 if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)4745 div.parentNode.replaceChild(img, div);4746 4747 this.selectNode(img);4748 this.repaint();4749 tinyMCE.triggerNodeChange();4750 return;4751 }4752 }4753 4754 if (tinyMCE.settings['force_br_newlines']) {4755 var alignValue = "";4756 4757 if (doc.selection.type != "Control") {4758 switch (command) {4759 case "JustifyLeft":4760 alignValue = "left";4761 break;4762 4763 case "JustifyCenter":4764 alignValue = "center";4765 break;4766 4767 case "JustifyFull":4768 alignValue = "justify";4769 break;4770 4771 case "JustifyRight":4772 alignValue = "right";4773 break;4774 }4775 4776 if (alignValue != "") {4777 var rng = doc.selection.createRange();4778 4779 if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null)4780 divElm.setAttribute("align", alignValue);4781 else if (rng.pasteHTML && rng.htmlText.length > 0)4782 rng.pasteHTML('<div align="' + alignValue + '">' + rng.htmlText + "</div>");4783 4784 tinyMCE.triggerNodeChange();4785 return;4786 }4787 }4788 }4789 4790 switch (command) {4791 case "mceRepaint":4792 this.repaint();4793 return true;4794 4795 case "mceStoreSelection":4796 this.selectionBookmark = this.getBookmark();4797 return true;4798 4799 case "mceRestoreSelection":4800 this.moveToBookmark(this.selectionBookmark);4801 return true;4802 4803 case "InsertUnorderedList":4804 case "InsertOrderedList":4805 var tag = (command == "InsertUnorderedList") ? "ul" : "ol";4806 4807 if (tinyMCE.isSafari)4808 this.execCommand("mceInsertContent", false, "<" + tag + "><li> </li><" + tag + ">");4809 else4810 this.getDoc().execCommand(command, user_interface, value);4811 4812 tinyMCE.triggerNodeChange();4813 break;4814 4815 case "Strikethrough":4816 if (tinyMCE.isSafari)4817 this.execCommand("mceInsertContent", false, "<strike>" + this.getSelectedHTML() + "</strike>");4818 else4819 this.getDoc().execCommand(command, user_interface, value);4820 4821 tinyMCE.triggerNodeChange();4822 break;4823 4824 case "mceSelectNode":4825 this.selectNode(value);4826 tinyMCE.triggerNodeChange();4827 tinyMCE.selectedNode = value;4828 break;4829 4830 case "FormatBlock":4831 if (value == null || value == "") {4832 var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");4833 4834 if (elm)4835 this.execCommand("mceRemoveNode", false, elm);4836 } else4837 this.getDoc().execCommand("FormatBlock", false, value);4838 4839 tinyMCE.triggerNodeChange();4840 4841 break;4842 4843 case "mceRemoveNode":4844 if (!value)4845 value = tinyMCE.getParentElement(this.getFocusElement());4846 4847 if (tinyMCE.isMSIE) {4848 value.outerHTML = value.innerHTML;4849 } else {4850 var rng = value.ownerDocument.createRange();4851 rng.setStartBefore(value);4852 rng.setEndAfter(value);4853 rng.deleteContents();4854 rng.insertNode(rng.createContextualFragment(value.innerHTML));4855 }4856 4857 tinyMCE.triggerNodeChange();4858 4859 break;4860 4861 case "mceSelectNodeDepth":4862 var parentNode = this.getFocusElement();4863 for (var i=0; parentNode; i++) {4864 if (parentNode.nodeName.toLowerCase() == "body")4865 break;4866 4867 if (parentNode.nodeName.toLowerCase() == "#text") {4868 i--;4869 parentNode = parentNode.parentNode;4870 continue;4871 }4872 4873 if (i == value) {4874 this.selectNode(parentNode, false);4875 tinyMCE.triggerNodeChange();4876 tinyMCE.selectedNode = parentNode;4877 return;4878 }4879 4880 parentNode = parentNode.parentNode;4881 }4882 4883 break;4884 4885 case "SetStyleInfo":4886 var rng = this.getRng();4887 var sel = this.getSel();4888 var scmd = value['command'];4889 var sname = value['name'];4890 var svalue = value['value'] == null ? '' : value['value'];4891 //var svalue = value['value'] == null ? '' : value['value'];4892 var wrapper = value['wrapper'] ? value['wrapper'] : "span";4893 var parentElm = null;4894 var invalidRe = new RegExp("^BODY|HTML$", "g");4895 var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;4896 4897 // Whole element selected check4898 if (tinyMCE.isMSIE) {4899 // Control range4900 if (rng.item)4901 parentElm = rng.item(0);4902 else {4903 var pelm = rng.parentElement();4904 var prng = doc.selection.createRange();4905 prng.moveToElementText(pelm);4906 4907 if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {4908 if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))4909 parentElm = pelm;4910 }4911 }4912 } else {4913 var felm = this.getFocusElement();4914 if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode))4915 parentElm = felm;4916 }4917 4918 // Whole element selected4919 if (parentElm && !invalidRe.test(parentElm.nodeName)) {4920 if (scmd == "setstyle")4921 tinyMCE.setStyleAttrib(parentElm, sname, svalue);4922 4923 if (scmd == "setattrib")4924 tinyMCE.setAttrib(parentElm, sname, svalue);4925 4926 if (scmd == "removeformat") {4927 parentElm.style.cssText = '';4928 tinyMCE.setAttrib(parentElm, 'class', '');4929 }4930 4931 // Remove style/attribs from all children4932 var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);4933 for (var z=0; z<ch.length; z++) {4934 if (ch[z] == parentElm)4935 continue;4936 4937 if (scmd == "setstyle")4938 tinyMCE.setStyleAttrib(ch[z], sname, '');4939 4940 if (scmd == "setattrib")4941 tinyMCE.setAttrib(ch[z], sname, '');4942 4943 if (scmd == "removeformat") {4944 ch[z].style.cssText = '';4945 tinyMCE.setAttrib(ch[z], 'class', '');4946 }4947 }4948 } else {4949 doc.execCommand("fontname", false, "#mce_temp_font#");4950 var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#");4951 4952 // Change them all4953 for (var x=0; x<elementArray.length; x++) {4954 elm = elementArray[x];4955 if (elm) {4956 var spanElm = doc.createElement(wrapper);4957 4958 if (scmd == "setstyle")4959 tinyMCE.setStyleAttrib(spanElm, sname, svalue);4960 4961 if (scmd == "setattrib")4962 tinyMCE.setAttrib(spanElm, sname, svalue);4963 4964 if (scmd == "removeformat") {4965 spanElm.style.cssText = '';4966 tinyMCE.setAttrib(spanElm, 'class', '');4967 }4968 4969 if (elm.hasChildNodes()) {4970 for (var i=0; i<elm.childNodes.length; i++)4971 spanElm.appendChild(elm.childNodes[i].cloneNode(true));4972 }4973 4974 spanElm.setAttribute("mce_new", "true");4975 elm.parentNode.replaceChild(spanElm, elm);4976 4977 // Remove style/attribs from all children4978 var ch = tinyMCE.getNodeTree(spanElm, new Array(), 1);4979 for (var z=0; z<ch.length; z++) {4980 if (ch[z] == spanElm)4981 continue;4982 4983 if (scmd == "setstyle")4984 tinyMCE.setStyleAttrib(ch[z], sname, '');4985 4986 if (scmd == "setattrib")4987 tinyMCE.setAttrib(ch[z], sname, '');4988 4989 if (scmd == "removeformat") {4990 ch[z].style.cssText = '';4991 tinyMCE.setAttrib(ch[z], 'class', '');4992 }4993 }4994 }4995 }4996 }4997 4998 // Cleaup wrappers4999 var nodes = doc.getElementsByTagName(wrapper);5000 for (var i=nodes.length-1; i>=0; i--) {5001 var elm = nodes[i];5002 var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";5003 5004 elm.removeAttribute("mce_new");5005 5006 // Is only child a element5007 if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {5008 //tinyMCE.debug("merge1" + isNew);5009 this._mergeElements(scmd, elm, elm.childNodes[0], isNew);5010 continue;5011 }5012 5013 // Is I the only child5014 if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {5015 //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);5016 if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))5017 this._mergeElements(scmd, elm.parentNode, elm, false);5018 }5019 }5020 5021 // Remove empty wrappers5022 var nodes = doc.getElementsByTagName(wrapper);5023 for (var i=nodes.length-1; i>=0; i--) {5024 var elm = nodes[i];5025 var isEmpty = true;5026 5027 // Check if it has any attribs5028 var tmp = doc.createElement("body");5029 tmp.appendChild(elm.cloneNode(false));5030 5031 // Is empty span, remove it5032 tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');5033 //tinyMCE.debug(tmp.innerHTML);5034 if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) {5035 for (var x=0; x<elm.childNodes.length; x++) {5036 if (elm.parentNode != null)5037 elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm);5038 }5039 5040 elm.parentNode.removeChild(elm);5041 }5042 }5043 5044 // Re add the visual aids5045 if (scmd == "removeformat")5046 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);5047 5048 tinyMCE.triggerNodeChange();5049 5050 break;5051 5052 case "FontName":5053 this.getDoc().execCommand('FontName', false, value);5054 5055 if (tinyMCE.isGecko)5056 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);5057 5058 return;5059 5060 case "FontSize":5061 this.getDoc().execCommand('FontSize', false, value);5062 5063 if (tinyMCE.isGecko)5064 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);5065 5066 return;5067 5068 case "forecolor":5069 this.getDoc().execCommand('forecolor', false, value);5070 break;5071 5072 case "HiliteColor":5073 if (tinyMCE.isGecko) {5074 this.setUseCSS(true);5075 this.getDoc().execCommand('hilitecolor', false, value);5076 this.setUseCSS(false);5077 } else5078 this.getDoc().execCommand('BackColor', false, value);5079 break;5080 5081 case "Cut":5082 case "Copy":5083 case "Paste":5084 var cmdFailed = false;5085 5086 // Try executing command5087 eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');5088 5089 if (tinyMCE.isOpera && cmdFailed)5090 alert('Currently not supported by your browser, use keyboard shortcuts instead.');5091 5092 // Alert error in gecko if command failed5093 if (tinyMCE.isGecko && cmdFailed) {5094 // Confirm more info5095 if (confirm(tinyMCE.getLang('lang_clipboard_msg')))5096 window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');5097 5098 return;5099 } else5100 tinyMCE.triggerNodeChange();5101 break;5102 5103 case "mceSetContent":5104 if (!value)5105 value = "";5106 5107 // Call custom cleanup code5108 value = tinyMCE._customCleanup(this, "insert_to_editor", value);5109 tinyMCE._setHTML(doc, value);5110 tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body));5111 tinyMCE.handleVisualAid(doc.body, true, this.visualAid, this);5112 tinyMCE._setEventsEnabled(doc.body, false);5113 return true;5114 5115 case "mceLink":5116 var selectedText = "";5117 5118 if (tinyMCE.isMSIE) {5119 var rng = doc.selection.createRange();5120 selectedText = rng.text;5121 } else5122 selectedText = this.getSel().toString();5123 5124 if (!tinyMCE.linkElement) {5125 if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0))5126 return;5127 }5128 5129 var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";5130 5131 if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")5132 tinyMCE.linkElement = tinyMCE.selectedElement;5133 5134 // Is anchor not a link5135 if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")5136 tinyMCE.linkElement = null;5137 5138 if (tinyMCE.linkElement) {5139 href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');5140 target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');5141 title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');5142 onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');5143 style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');5144 5145 // Try old onclick to if copy/pasted content5146 if (onclick == "")5147 onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');5148 5149 onclick = tinyMCE.cleanupEventStr(onclick);5150 5151 // Fix for drag-drop/copy paste bug in Mozilla5152 mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_real_href');5153 if (mceRealHref != "")5154 href = mceRealHref;5155 5156 href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");5157 action = "update";5158 }5159 5160 if (this.settings['insertlink_callback']) {5161 var returnVal = eval(this.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);");5162 if (returnVal && returnVal['href'])5163 tinyMCE.insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']);5164 } else {5165 tinyMCE.openWindow(this.insertLinkTemplate, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class});5166 }5167 break;5168 5169 case "mceImage":5170 var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";5171 var title = "", onmouseover = "", onmouseout = "", action = "insert";5172 var img = tinyMCE.imgElement;5173 5174 if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {5175 img = tinyMCE.selectedElement;5176 tinyMCE.imgElement = img;5177 }5178 5179 if (img) {5180 // Is it a internal MCE visual aid image, then skip this one.5181 if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)5182 return;5183 5184 src = tinyMCE.getAttrib(img, 'src');5185 alt = tinyMCE.getAttrib(img, 'alt');5186 5187 // Try polling out the title5188 if (alt == "")5189 alt = tinyMCE.getAttrib(img, 'title');5190 5191 // Fix width/height attributes if the styles is specified5192 if (tinyMCE.isGecko) {5193 var w = img.style.width;5194 if (w != null && w != "")5195 img.setAttribute("width", w);5196 5197 var h = img.style.height;5198 if (h != null && h != "")5199 img.setAttribute("height", h);5200 }5201 5202 border = tinyMCE.getAttrib(img, 'border');5203 hspace = tinyMCE.getAttrib(img, 'hspace');5204 vspace = tinyMCE.getAttrib(img, 'vspace');5205 width = tinyMCE.getAttrib(img, 'width');5206 height = tinyMCE.getAttrib(img, 'height');5207 align = tinyMCE.getAttrib(img, 'align');5208 onmouseover = tinyMCE.getAttrib(img, 'onmouseover');5209 onmouseout = tinyMCE.getAttrib(img, 'onmouseout');5210 title = tinyMCE.getAttrib(img, 'title');5211 5212 // Is realy specified?5213 if (tinyMCE.isMSIE) {5214 width = img.attributes['width'].specified ? width : "";5215 height = img.attributes['height'].specified ? height : "";5216 }5217 5218 onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));5219 onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));5220 5221 // Fix for drag-drop/copy paste bug in Mozilla5222 mceRealSrc = tinyMCE.getAttrib(img, 'mce_real_src');5223 if (mceRealSrc != "")5224 src = mceRealSrc;5225 5226 src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");5227 5228 if (onmouseover != "")5229 onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);");5230 5231 if (onmouseout != "")5232 onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);");5233 5234 action = "update";5235 }5236 5237 if (this.settings['insertimage_callback']) {5238 var returnVal = eval(this.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");5239 if (returnVal && returnVal['src'])5240 tinyMCE.insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']);5241 } else5242 tinyMCE.openWindow(this.insertImageTemplate, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action});5243 break;5244 5245 case "mceCleanup":5246 tinyMCE._setHTML(this.contentDocument, this.getBody().innerHTML);5247 tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, this.getBody(), this.visualAid));5248 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);5249 tinyMCE._setEventsEnabled(this.getBody(), false);5250 this.repaint();5251 tinyMCE.triggerNodeChange();5252 break;5253 5254 case "mceReplaceContent":5255 this.getWin().focus();5256 5257 var selectedText = "";5258 5259 if (tinyMCE.isMSIE) {5260 var rng = doc.selection.createRange();5261 selectedText = rng.text;5262 } else5263 selectedText = this.getSel().toString();5264 5265 if (selectedText.length > 0) {5266 value = tinyMCE.replaceVar(value, "selection", selectedText);5267 tinyMCE.execCommand('mceInsertContent', false, value);5268 }5269 5270 tinyMCE.triggerNodeChange();5271 break;5272 5273 case "mceSetAttribute":5274 if (typeof(value) == 'object') {5275 var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];5276 var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);5277 5278 if (targetNode) {5279 targetNode.setAttribute(value['name'], value['value']);5280 tinyMCE.triggerNodeChange();5281 }5282 }5283 break;5284 5285 case "mceSetCSSClass":5286 this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value});5287 break;5288 5289 case "mceInsertRawHTML":5290 var key = 'tiny_mce_marker';5291 5292 this.execCommand('mceBeginUndoLevel');5293 5294 // Insert marker key5295 this.execCommand('mceInsertContent', false, key);5296 5297 // Store away scroll pos5298 var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;5299 var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;5300 5301 // Find marker and replace with RAW HTML5302 var html = this.getBody().innerHTML;5303 if ((pos = html.indexOf(key)) != -1)5304 tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));5305 5306 // Restore scoll pos5307 this.contentWindow.scrollTo(scrollX, scrollY);5308 5309 this.execCommand('mceEndUndoLevel');5310 5311 break;5312 5313 case "mceInsertContent":5314 var insertHTMLFailed = false;5315 this.getWin().focus();5316 5317 if (tinyMCE.isGecko || tinyMCE.isOpera) {5318 try {this.getDoc().execCommand('inserthtml', false, value);} catch (ex) {insertHTMLFailed = true;}5319 if (!insertHTMLFailed) {5320 tinyMCE.triggerNodeChange();5321 return;5322 }5323 }5324 5325 // Ugly hack in Opera due to non working "inserthtml"5326 if (tinyMCE.isOpera && insertHTMLFailed) {5327 this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);5328 var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);5329 ar[0].outerHTML = value;5330 return;5331 }5332 5333 if (!tinyMCE.isMSIE) {5334 var isHTML = value.indexOf('<') != -1;5335 var sel = this.getSel();5336 var rng = this.getRng();5337 5338 if (isHTML) {5339 if (tinyMCE.isSafari) {5340 var tmpRng = this.getDoc().createRange();5341 5342 tmpRng.setStart(this.getBody(), 0);5343 tmpRng.setEnd(this.getBody(), 0);5344 5345 value = tmpRng.createContextualFragment(value);5346 } else5347 value = rng.createContextualFragment(value);5348 } else {5349 // Setup text node5350 var el = document.createElement("div");5351 el.innerHTML = value;5352 value = el.firstChild.nodeValue;5353 value = doc.createTextNode(value);5354 }5355 5356 // Insert plain text in Safari5357 if (tinyMCE.isSafari && !isHTML) {5358 this.execCommand('InsertText', false, value.nodeValue);5359 tinyMCE.triggerNodeChange();5360 return true;5361 } else if (tinyMCE.isSafari && isHTML) {5362 rng.deleteContents();5363 rng.insertNode(value);5364 tinyMCE.triggerNodeChange();5365 return true;5366 }5367 5368 rng.deleteContents();5369 5370 // If target node is text do special treatment, (Mozilla 1.3 fix)5371 if (rng.startContainer.nodeType == 3) {5372 var node = rng.startContainer.splitText(rng.startOffset);5373 node.parentNode.insertBefore(value, node);5374 } else5375 rng.insertNode(value);5376 5377 if (!isHTML) {5378 // Removes weird selection trails5379 sel.selectAllChildren(doc.body);5380 sel.removeAllRanges();5381 5382 // Move cursor to end of content5383 var rng = doc.createRange();5384 5385 rng.selectNode(value);5386 rng.collapse(false);5387 5388 sel.addRange(rng);5389 } else5390 rng.collapse(false);5391 } else {5392 var rng = doc.selection.createRange();5393 5394 if (rng.item)5395 rng.item(0).outerHTML = value;5396 else5397 rng.pasteHTML(value);5398 }5399 5400 tinyMCE.triggerNodeChange();5401 break;5402 5403 case "mceStartTyping":5404 if (tinyMCE.settings['custom_undo_redo'] && this.typingUndoIndex == -1) {5405 this.typingUndoIndex = this.undoIndex;5406 this.execCommand('mceAddUndoLevel');5407 //tinyMCE.debug("mceStartTyping");5408 }5409 break;5410 5411 case "mceEndTyping":5412 if (tinyMCE.settings['custom_undo_redo'] && this.typingUndoIndex != -1) {5413 this.execCommand('mceAddUndoLevel');5414 this.typingUndoIndex = -1;5415 //tinyMCE.debug("mceEndTyping");5416 }5417 break;5418 5419 case "mceBeginUndoLevel":5420 this.undoRedo = false;5421 break;5422 5423 case "mceEndUndoLevel":5424 this.undoRedo = true;5425 this.execCommand('mceAddUndoLevel');5426 break;5427 5428 case "mceAddUndoLevel":5429 if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo) {5430 // tinyMCE.debug("add level");5431 5432 if (this.typingUndoIndex != -1) {5433 this.undoIndex = this.typingUndoIndex;5434 // tinyMCE.debug("Override: " + this.undoIndex);5435 }5436 5437 var newHTML = tinyMCE.trim(this.getBody().innerHTML);5438 if (newHTML != this.undoLevels[this.undoIndex]) {5439 // tinyMCE.debug("[" + newHTML + "," + this.undoLevels[this.undoIndex] + "]");5440 5441 tinyMCE.executeCallback('onchange_callback', '_onchange', 0, this);5442 5443 // Time to compress5444 var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];5445 if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {5446 for (var i=0; i<this.undoLevels.length-1; i++) {5447 //tinyMCE.debug(this.undoLevels[i] + "=" + this.undoLevels[i+1]);5448 this.undoLevels[i] = this.undoLevels[i+1];5449 }5450 5451 this.undoLevels.length--;5452 this.undoIndex--;5453 }5454 5455 this.undoIndex++;5456 this.undoLevels[this.undoIndex] = newHTML;5457 this.undoLevels.length = this.undoIndex + 1;5458 5459 // tinyMCE.debug("level added" + this.undoIndex);5460 tinyMCE.triggerNodeChange(false);5461 5462 // tinyMCE.debug(this.undoIndex + "," + (this.undoLevels.length-1));5463 }5464 }5465 break;5466 5467 case "Undo":5468 if (tinyMCE.settings['custom_undo_redo']) {5469 tinyMCE.execCommand("mceEndTyping");5470 5471 // Do undo5472 if (this.undoIndex > 0) {5473 this.undoIndex--;5474 tinyMCE.setInnerHTML(this.getBody(), this.undoLevels[this.undoIndex]);5475 this.repaint();5476 }5477 5478 // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);5479 tinyMCE.triggerNodeChange();5480 } else5481 this.getDoc().execCommand(command, user_interface, value);5482 break;5483 5484 case "Redo":5485 if (tinyMCE.settings['custom_undo_redo']) {5486 tinyMCE.execCommand("mceEndTyping");5487 5488 if (this.undoIndex < (this.undoLevels.length-1)) {5489 this.undoIndex++;5490 tinyMCE.setInnerHTML(this.getBody(), this.undoLevels[this.undoIndex]);5491 this.repaint();5492 // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);5493 }5494 5495 tinyMCE.triggerNodeChange();5496 } else5497 this.getDoc().execCommand(command, user_interface, value);5498 break;5499 5500 case "mceToggleVisualAid":5501 this.visualAid = !this.visualAid;5502 tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);5503 tinyMCE.triggerNodeChange();5504 break;5505 5506 case "Indent":5507 this.getDoc().execCommand(command, user_interface, value);5508 tinyMCE.triggerNodeChange();5509 if (tinyMCE.isMSIE) {5510 var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");5511 do {5512 if (n && n.nodeName == "BLOCKQUOTE") {5513 n.removeAttribute("dir");5514 n.removeAttribute("style");5515 }5516 } while (n != null && (n = n.parentNode) != null);5517 }5518 break;5519 5520 case "removeformat":5521 var text = this.getSelectedText();5522 5523 if (tinyMCE.isOpera) {5524 this.getDoc().execCommand("RemoveFormat", false, null);5525 return;5526 }5527 5528 if (tinyMCE.isMSIE) {5529 try {5530 var rng = doc.selection.createRange();5531 rng.execCommand("RemoveFormat", false, null);5532 } catch (e) {5533 // Do nothing5534 }5535 5536 this.execCommand("SetStyleInfo", false, {command : "removeformat"});5537 } else {5538 this.getDoc().execCommand(command, user_interface, value);5539 5540 this.execCommand("SetStyleInfo", false, {command : "removeformat"});5541 }5542 5543 // Remove class5544 if (text.length == 0)5545 this.execCommand("mceSetCSSClass", false, "");5546 5547 tinyMCE.triggerNodeChange();5548 break;5549 5550 default:5551 this.getDoc().execCommand(command, user_interface, value);5552 5553 if (tinyMCE.isGecko)5554 window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);5555 else5556 tinyMCE.triggerNodeChange();5557 }5558 5559 // Add undo level after modification5560 if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceStartTyping" && command != "mceEndTyping")5561 tinyMCE.execCommand("mceAddUndoLevel");5562 };5563 5564 TinyMCEControl.prototype.queryCommandValue = function(command) {5565 return this.getDoc().queryCommandValue(command);5566 };5567 5568 TinyMCEControl.prototype.queryCommandState = function(command) {5569 return this.getDoc().queryCommandState(command);5570 };5571 5572 TinyMCEControl.prototype.onAdd = function(replace_element, form_element_name, target_document) {5573 var targetDoc = target_document ? target_document : document;5574 5575 this.targetDoc = targetDoc;5576 5577 tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings['theme'];5578 this.settings['themeurl'] = tinyMCE.themeURL;5579 5580 if (!replace_element) {5581 alert("Error: Could not find the target element.");5582 return false;5583 }5584 5585 var templateFunction = tinyMCE._getThemeFunction('_getInsertLinkTemplate');5586 if (eval("typeof(" + templateFunction + ")") != 'undefined')5587 this.insertLinkTemplate = eval(templateFunction + '(this.settings);');5588 5589 var templateFunction = tinyMCE._getThemeFunction('_getInsertImageTemplate');5590 if (eval("typeof(" + templateFunction + ")") != 'undefined')5591 this.insertImageTemplate = eval(templateFunction + '(this.settings);');5592 5593 var templateFunction = tinyMCE._getThemeFunction('_getEditorTemplate');5594 if (eval("typeof(" + templateFunction + ")") == 'undefined') {5595 alert("Error: Could not find the template function: " + templateFunction);5596 return false;5597 }5598 5599 var editorTemplate = eval(templateFunction + '(this.settings, this.editorId);');5600 5601 var deltaWidth = editorTemplate['delta_width'] ? editorTemplate['delta_width'] : 0;5602 var deltaHeight = editorTemplate['delta_height'] ? editorTemplate['delta_height'] : 0;5603 var html = '<span id="' + this.editorId + '_parent">' + editorTemplate['html'];5604 5605 var templateFunction = tinyMCE._getThemeFunction('_handleNodeChange', true);5606 if (eval("typeof(" + templateFunction + ")") != 'undefined')5607 this.settings['handleNodeChangeCallback'] = templateFunction;5608 5609 html = tinyMCE.replaceVar(html, "editor_id", this.editorId);5610 this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm";5611 5612 this.settings['old_width'] = this.settings['width'];5613 this.settings['old_height'] = this.settings['height'];5614 5615 // Set default width, height5616 if (this.settings['width'] == -1)5617 this.settings['width'] = replace_element.offsetWidth;5618 5619 if (this.settings['height'] == -1)5620 this.settings['height'] = replace_element.offsetHeight;5621 5622 // Try the style width5623 if (this.settings['width'] == 0)5624 this.settings['width'] = replace_element.style.width;5625 5626 // Try the style height5627 if (this.settings['height'] == 0)5628 this.settings['height'] = replace_element.style.height;5629 5630 // If no width/height then default to 320x240, better than nothing5631 if (this.settings['width'] == 0)5632 this.settings['width'] = 320;5633 5634 if (this.settings['height'] == 0)5635 this.settings['height'] = 240;5636 5637 this.settings['area_width'] = parseInt(this.settings['width']);5638 this.settings['area_height'] = parseInt(this.settings['height']);5639 this.settings['area_width'] += deltaWidth;5640 this.settings['area_height'] += deltaHeight;5641 5642 // Special % handling5643 if (("" + this.settings['width']).indexOf('%') != -1)5644 this.settings['area_width'] = "100%";5645 5646 if (("" + this.settings['height']).indexOf('%') != -1)5647 this.settings['area_height'] = "100%";5648 5649 if (("" + replace_element.style.width).indexOf('%') != -1) {5650 this.settings['width'] = replace_element.style.width;5651 this.settings['area_width'] = "100%";5652 }5653 5654 if (("" + replace_element.style.height).indexOf('%') != -1) {5655 this.settings['height'] = replace_element.style.height;5656 this.settings['area_height'] = "100%";5657 }5658 5659 html = tinyMCE.applyTemplate(html);5660 5661 this.settings['width'] = this.settings['old_width'];5662 this.settings['height'] = this.settings['old_height'];5663 5664 this.visualAid = this.settings['visual'];5665 this.formTargetElementId = form_element_name;5666 5667 // Get replace_element contents5668 if (replace_element.nodeName == "TEXTAREA" || replace_element.nodeName == "INPUT")5669 this.startContent = replace_element.value;5670 else5671 this.startContent = replace_element.innerHTML;5672 5673 // If not text area5674 if (replace_element.nodeName.toLowerCase() != "textarea") {5675 this.oldTargetElement = replace_element.cloneNode(true);5676 5677 // Debug mode5678 if (tinyMCE.settings['debug'])5679 html += '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';5680 else5681 html += '<input type="hidden" type="text" id="' + form_element_name + '" name="' + form_element_name + '" />';5682 5683 html += '</span>';5684 5685 // Output HTML and set editable5686 if (!tinyMCE.isMSIE) {5687 var rng = replace_element.ownerDocument.createRange();5688 rng.setStartBefore(replace_element);5689 5690 var fragment = rng.createContextualFragment(html);5691 replace_element.parentNode.replaceChild(fragment, replace_element);5692 } else5693 replace_element.outerHTML = html;5694 } else {5695 html += '</span>';5696 5697 // Just hide the textarea element5698 this.oldTargetElement = replace_element;5699 5700 if (!tinyMCE.settings['debug'])5701 this.oldTargetElement.style.display = "none";5702 5703 // Output HTML and set editable5704 if (!tinyMCE.isMSIE) {5705 var rng = replace_element.ownerDocument.createRange();5706 rng.setStartBefore(replace_element);5707 5708 var fragment = rng.createContextualFragment(html);5709 replace_element.parentNode.insertBefore(fragment, replace_element);5710 } else5711 replace_element.insertAdjacentHTML("beforeBegin", html);5712 }5713 5714 // Setup iframe5715 var dynamicIFrame = false;5716 var tElm = targetDoc.getElementById(this.editorId);5717 5718 if (!tinyMCE.isMSIE) {5719 if (tElm && tElm.nodeName.toLowerCase() == "span") {5720 tElm = tinyMCE._createIFrame(tElm);5721 dynamicIFrame = true;5722 }5723 5724 this.targetElement = tElm;5725 this.iframeElement = tElm;5726 this.contentDocument = tElm.contentDocument;5727 this.contentWindow = tElm.contentWindow;5728 5729 //this.getDoc().designMode = "on";5730 } else {5731 if (tElm && tElm.nodeName.toLowerCase() == "span")5732 tElm = tinyMCE._createIFrame(tElm);5733 else5734 tElm = targetDoc.frames[this.editorId];5735 5736 this.targetElement = tElm;5737 this.iframeElement = targetDoc.getElementById(this.editorId);5738 5739 if (tinyMCE.isOpera) {5740 this.contentDocument = this.iframeElement.contentDocument;5741 this.contentWindow = this.iframeElement.contentWindow;5742 dynamicIFrame = true;5743 } else {5744 this.contentDocument = tElm.window.document;5745 this.contentWindow = tElm.window;5746 }5747 5748 this.getDoc().designMode = "on";5749 }5750 5751 // Setup base HTML5752 var doc = this.contentDocument;5753 if (dynamicIFrame) {5754 var html = tinyMCE.getParam('doctype') + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + tinyMCE.settings['base_href'] + '" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';5755 5756 try {5757 this.getDoc().designMode = "on";5758 doc.open();5759 doc.write(html);5760 doc.close();5761 } catch (e) {5762 // Failed Mozilla 1.35763 this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm";5764 }5765 }5766 5767 // This timeout is needed in MSIE 5.5 for some odd reason5768 // it seems that the document.frames isn't initialized yet?5769 if (tinyMCE.isMSIE)5770 window.setTimeout("TinyMCE.prototype.addEventHandlers('" + this.editorId + "');", 1);5771 5772 tinyMCE.setupContent(this.editorId, true);5773 5774 return true;5775 };5776 5777 TinyMCEControl.prototype.getFocusElement = function() {5778 if (tinyMCE.isMSIE && !tinyMCE.isOpera) {5779 var doc = this.getDoc();5780 var rng = doc.selection.createRange();5781 5782 // if (rng.collapse)5783 // rng.collapse(true);5784 5785 var elm = rng.item ? rng.item(0) : rng.parentElement();5786 } else {5787 var sel = this.getSel();5788 var rng = this.getRng();5789 5790 var elm = rng.commonAncestorContainer;5791 //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;5792 5793 // Handle selection a image or other control like element such as anchors5794 if (!rng.collapsed) {5795 // Is selection small5796 if (rng.startContainer == rng.endContainer) {5797 if (rng.startOffset - rng.endOffset < 2) {5798 if (rng.startContainer.hasChildNodes())5799 elm = rng.startContainer.childNodes[rng.startOffset];5800 }5801 }5802 }5803 5804 // Get the element parent of the node5805 elm = tinyMCE.getParentElement(elm);5806 5807 //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")5808 // elm = tinyMCE.selectedElement;5809 }5810 5811 return elm;5812 };5813 5814 // Global instances5815 var tinyMCE = new TinyMCE();5816 var tinyMCELang = new Array();
Note: See TracChangeset
for help on using the changeset viewer.