My first contribute with community
Posted: Mon Oct 01, 2007 12:35 am
/*
@ N.C. - Portugal
PLUGIN FLASH with compatibility HTML e XHTML 1.0 and valid (x)html
Added SWFObject - http://blog.deconcept.com/swfobject/
TinyMCE with flash plugin
//////////////////////////////////////////////////
download
1. http://blog.deconcept.com/swfobject/swfobject.zip
2. In template put
{literal}
{/literal}
Modified File
plugins/flash/editor_plugin_src.js
+- line 146 - 184
I WHAIT FOR YOUR FEEDBACK
*/
tinyMCE.importPluginLanguagePack('flash');
var TinyMCE_FlashPlugin={getInfo:function()
{
return{longname:'Flash',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/flash',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion}
},
initInstance:function(inst){
if(!tinyMCE.settings['flash_skip_plugin_css'])
tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/flash/css/content.css")
},getControlHTML:function(cn){switch(cn){
case"flash":return tinyMCE.getButtonHTML(cn,'lang_flash_desc','{$pluginurl}/images/flash.gif','mceFlash')
}return""
},execCommand:function(editor_id,element,command,user_interface,value){
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']=430;
template['height']=175;
template['width']+=tinyMCE.getLang('lang_flash_delta_width',0);
template['height']+=tinyMCE.getLang('lang_flash_delta_height',0);
if(focusElm!=null&&focusElm.nodeName.toLowerCase()=="img"){
name=tinyMCE.getAttrib(focusElm,'class');
if(name.indexOf('mceItemFlash')==-1)return true;
swffile=tinyMCE.getAttrib(focusElm,'alt');
if(tinyMCE.getParam('convert_urls'))swffile=eval(tinyMCE.settings['urlconverter_callback']+"(swffile, null, true);");
swfwidth=tinyMCE.getAttrib(focusElm,'width');
swfheight=tinyMCE.getAttrib(focusElm,'height');
action="update"}tinyMCE.openWindow(template,{
editor_id:editor_id,inline:"yes",swffile:swffile,swfwidth:swfwidth,swfheight:swfheight,action:action});
return true
}
return false
},cleanup:function(type,content){
switch(type)
{
case"insert_to_editor_dom":
if(tinyMCE.getParam('convert_urls')){
var imgs=content.getElementsByTagName("img");
for(var i=0;i','gi'),'');
content=content.replace(new RegExp('','gi'),'');
while((startPos=content.indexOf('',startPos);
var attribs=TinyMCE_FlashPlugin._parseAttributes(content.substring(startPos+6,endPos));
embedList[embedList.length]=attribs}
var index=0;
while((startPos=content.indexOf('=embedList.length)
break;
var attribs=embedList[index];
endPos=content.indexOf('',startPos);endPos+=9;
var contentAfter=content.substring(endPos);
content=content.substring(0,startPos);
content+=''+content.substring(endPos);content+=contentAfter;index++;startPos++}
var index=0;
while((startPos=content.indexOf('=embedList.length)break;
var attribs=embedList[index];
endPos=content.indexOf('>',startPos);endPos+=9;
var contentAfter=content.substring(endPos);
content=content.substring(0,startPos);
content+=''+content.substring(endPos);
content+=contentAfter;index++;startPos++}
break;
case"get_from_editor":var startPos=-1;
while((startPos=content.indexOf('',startPos);
var attribs=TinyMCE_FlashPlugin._parseAttributes(content.substring(startPos+4,endPos));if(attribs['class']!="mceItemFlash")
continue;
endPos+=2;
var embedHTML='';
var wmode=tinyMCE.getParam("flash_wmode","transparent");
var quality=tinyMCE.getParam("flash_quality","high");
var menu=tinyMCE.getParam("flash_menu","false");
/*--------------
beta // 11 agosto 2007 - 15h54 // by N.C. - Portugal
SWFObject - http://blog.deconcept.com/swfobject/
I WHAIT FOR YOUR FEEDBACK
---------------*/
/*TODO*/
/*news param*/
var scale=tinyMCE.getParam("flash_exactfit","exactfit");
/*news param*/
embedHTML+='';
embedHTML+='';
embedHTML+=' var so = new SWFObject("'+attribs["title"]+'", "my_CW_FlashID", "'+attribs["width"]+'", "'+attribs["height"]+'", "8", "#ffffff");';
embedHTML+=' so.addParam("quality", "'+quality+'");';
embedHTML+=' so.addParam("wmode", "'+wmode+'");';
embedHTML+=' so.addParam("scale", "'+scale+'");';
embedHTML+=' so.write("flashcontent");';
embedHTML+='';
/*TODO*/
/*--------------fim beta /--------------*/
chunkBefore=content.substring(0,startPos);
chunkAfter=content.substring(endPos);
content=chunkBefore+embedHTML+chunkAfter}
break
}
return content},handleNodeChange:function(editor_id,node,undo_index,undo_levels,visual_aid,any_selection){
if(node==null)return;
do{
if(node.nodeName=="IMG"&&tinyMCE.getAttrib(node,'class').indexOf('mceItemFlash')==0){tinyMCE.switchClass(editor_id+'_flash','mceButtonSelected');
return true}
}
while((node=node.parentNode));
tinyMCE.switchClass(editor_id+'_flash','mceButtonNormal');
return true},_parseAttributes:function(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);
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}
};
tinyMCE.addPlugin("flash",TinyMCE_FlashPlugin);