mailr/public/tiny_mce/plugins/flash/editor_plugin.js

2 lines
5.9 KiB
JavaScript
Raw Normal View History

/* Import plugin specific language pack */
tinyMCE.importPluginLanguagePack('flash','en,de,sv,zh_cn,cs,fa,fr_ca,fr,pl,pt_br');function TinyMCE_flash_initInstance(inst){if(!tinyMCE.settings['flash_skip_plugin_css'])tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/flash/flash.css");}function TinyMCE_flash_getControlHTML(control_name){switch(control_name){case "flash":return '<img id="{$editor_id}_flash" src="{$pluginurl}/images/flash.gif" title="{$lang_insert_flash}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceFlash\');" />';}return "";}function TinyMCE_flash_parseAttributes(attribute_string){var attributeName="";var attributeValue="";var withInName;var withInValue;var attributes=new Array();var whiteSpaceRegExp=new RegExp('^[ \n\r\t]+','g');if(attribute_string==null||attribute_string.length<2)return null;withInName=withInValue=false;for(var i=0;i<attribute_string.length;i++){var chr=attribute_string.charAt(i);if((chr=='"'||chr=="'")&&!withInValue)withInValue=true;else if((chr=='"'||chr=="'")&&withInValue){withInValue=false;var pos=attributeName.lastIndexOf(' ');if(pos!=-1)attributeName=attributeName.substring(pos+1);attributes[attributeName.toLowerCase()]=attributeValue.substring(1).toLowerCase();attributeName="";attributeValue="";}else if(!whiteSpaceRegExp.test(chr)&&!withInName&&!withInValue)withInName=true;if(chr=='='&&withInName)withInName=false;if(withInName)attributeName+=chr;if(withInValue)attributeValue+=chr;}return attributes;}function TinyMCE_flash_execCommand(editor_id,element,command,user_interface,value){function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";}switch(command){case "mceFlash":var name="",swffile="",swfwidth="",swfheight="",action="insert";var template=new Array();var inst=tinyMCE.getInstanceById(editor_id);var focusElm=inst.getFocusElement();template['file']='../../plugins/flash/flash.htm';template['width']=400;template['height']=195;if(focusElm!=null&&focusElm.nodeName.toLowerCase()=="img"){name=getAttrib(focusElm,'name');if(name!='mce_plugin_flash')return true;swffile=getAttrib(focusElm,'alt');swffile=eval(tinyMCE.settings['urlconverter_callback']+"(swffile, null, true);");swfwidth=getAttrib(focusElm,'width');swfheight=getAttrib(focusElm,'height');action="update";}tinyMCE.openWindow(template,{editor_id:editor_id,swffile:swffile,swfwidth:swfwidth,swfheight:swfheight,action:action});return true;}return false;}function TinyMCE_flash_cleanup(type,content){switch(type){case "insert_to_editor_dom":var imgs=content.getElementsByTagName("img");for(var i=0;i<imgs.length;i++){if(tinyMCE.getAttrib(imgs[i],"name")=="mce_plugin_flash"){var src=tinyMCE.getAttrib(imgs[i],"alt");src=tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'],src);imgs[i].setAttribute('alt',src);}}break;case "get_from_editor_dom":var imgs=content.getElementsByTagName("img");for(var i=0;i<imgs.length;i++){if(tinyMCE.getAttrib(imgs[i],"name")=="mce_plugin_flash"){var src=tinyMCE.getAttrib(imgs[i],"alt");src=eval(tinyMCE.settings['urlconverter_callback']+"(src, null, true);");imgs[i].setAttribute('alt',src);}}break;case "insert_to_editor":var startPos=0;var embedList=new Array();content=content.replace(new RegExp('<[ ]*embed','gi'),'<embed');content=content.replace(new RegExp('<[ ]*/embed[ ]*>','gi'),'</embed>');content=content.replace(new RegExp('<[ ]*object','gi'),'<object');content=content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');while((startPos=content.indexOf('<embed',startPos+1))!=-1){var endPos=content.indexOf('>',startPos);var attribs=TinyMCE_flash_parseAttributes(content.substring(startPos+6,endPos));embedList[embedList.length]=attribs;}var index=0;while((startPos=content.indexOf('<object',startPos))!=-1){if(index>=embedList.length)break;var attribs=embedList[index];endPos=content.indexOf('</object>',startPos);endPos+=9;var contentAfter=content.substring(endPos);content=content.subs