[pLog-svn] r7065 - plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Fri Oct 8 18:00:19 EDT 2010


Author: jondaley
Date: 2010-10-08 18:00:19 -0400 (Fri, 08 Oct 2010)
New Revision: 7065

Added:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/editor_plugin.js
Log:
forgot to add this (not working yet anyway...)

Added: plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/editor_plugin.js	                        (rev 0)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertvideo/editor_plugin.js	2010-10-08 22:00:19 UTC (rev 7065)
@@ -0,0 +1,38 @@
+
+tinyMCE.importPluginLanguagePack('insertvideo','en,fr');var TinyMCE_insertvideoPlugin={getInfo:function(){return{longname:'insertvideo plugin',author:'The LifeType Project',authorurl:'http://www.lifetype.net',infourl:'http://www.lifetype.net',version:"1.1"};},initInstance:function(inst){tinyMCE.importCSS(inst.getDoc(),tinyMCE.baseURL+"/plugins/insertvideo/css/content.css");},getControlHTML:function(cn){switch(cn){case"insertvideo":return tinyMCE.getButtonHTML(cn,'lang_insertvideo_desc','{$pluginurl}/images/youtube.png','mceinsertvideo',true);}
+return"";},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mceinsertvideo":if(user_interface){var insertvideo=new Array();insertvideo['file']='../../plugins/insertvideo/videoinput.html';insertvideo['width']=500;insertvideo['height']=290;tinyMCE.openWindow(insertvideo,{editor_id:editor_id,resizable:"no",scrollbars:"no",inline:"yes"});}
+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<imgs.length;i++){if(tinyMCE.getAttrib(imgs[i],"class").substr(0,6)=="ltVideo"){var src=tinyMCE.getAttrib(imgs[i],"alt");if(tinyMCE.getParam('convert_urls'))
+src=eval(tinyMCE.settings['urlconverter_callback']+"(src, null, true);");imgs[i].setAttribute('alt',src);imgs[i].setAttribute('title',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],"class").substr(0,6)=="ltVideo"){var src=tinyMCE.getAttrib(imgs[i],"alt");if(tinyMCE.getParam('convert_urls'))
+src=eval(tinyMCE.settings['urlconverter_callback']+"(src, null, true);");imgs[i].setAttribute('alt',src);imgs[i].setAttribute('title',src);}}
+break;case"insert_to_editor":var startPos=0;var embedList=new Array();content=content.replace(new RegExp('<[ ]*object','gi'),'<object');content=content.replace(new RegExp('<[ ]*/object[ ]*>','gi'),'</object>');var index=0;while((startPos=content.indexOf('<object',startPos))!=-1){endPos=content.indexOf('</object>',startPos);endPos+=9;objectTag=content.substring(startPos,endPos);attribs=TinyMCE_insertvideoPlugin._parseAttributes(objectTag);var cssClass="";if(!attribs||attribs["data"]==undefined){startPos++;continue;}
+else{var videoType=getVideoType(attribs["data"]);if(videoType==1){cssClass="ltVideoGoogleVideo";}
+else if(videoType==2){cssClass="ltVideoYouTube";}
+else if(videoType==3){cssClass="ltVideoMetacafe";}
+else if(videoType==4){cssClass="ltVideoIfilm";}
+else if(videoType==5){cssClass="ltVideoGoear";}
+else if(videoType==6){cssClass="ltVideoGrouper";}
+else if(videoType==7){cssClass="ltVideoDailymot";}
+else if(videoType==8){cssClass="ltVideoVimeo";}
+else{startPos++;continue;}}
+var contentAfter=content.substring(endPos);content=content.substring(0,startPos);content+='<img width="'+attribs["width"]+'" height="'+attribs["height"]+'"';content+=' src="'+(tinyMCE.getParam("theme_href")+'/images/spacer.gif')+'" title="'+attribs["data"]+'"';content+=' alt="'+attribs["data"]+'" class="'+cssClass+'" />'+content.substring(endPos);content+=contentAfter;index++;startPos++;}
+break;case"get_from_editor":var startPos=-1;while((startPos=content.indexOf('<img',startPos+1))!=-1){var endPos=content.indexOf('/>',startPos);var attribs=TinyMCE_insertvideoPlugin._parseAttributes(content.substring(startPos+4,endPos));if(!attribs||attribs['class']!="ltVideoYouTube"&&attribs['class']!="ltVideoGoogleVideo"&&attribs['class']!="ltVideoMetacafe"&&attribs['class']!="ltVideoIfilm"&&attribs['class']!="ltVideoGoear"&&attribs['class']!="ltVideoGrouper"&&attribs['class']!="ltVideoDailymot"&&attribs['class']!="ltVideoVimeo")
+continue;type=attribs['class'];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");embedHTML=getVideoFlashHTML(attribs["title"],attribs["width"],attribs["height"],type);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('ltVideo')==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;}};function getVideoFlashHTML(url,width,height,type)
+{html="<object type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\" data=\""+url+"\" id=\""+type+"\">"+"<param name=\"movie\" value=\""+url+"\" />"+"<param name=\"wmode\" value=\"transparent\" />"+"<param name=\"allowScriptAccess\" value=\"sameDomain\" />"+"<param name=\"quality\" value=\"best\" />"+"<param name=\"bgcolor\" value=\"#ffffff\" />";if(type=='ltVideoGoear'){html=html+"<param name=\"FlashVars\" value=\""+url.substring(43,url.length)+"\" />";}else{html=html+"<param name=\"FlashVars\" value=\"playerMode=embedded\" />";}
+html=html+"</object>";return(html);}
+function getVideoType(url)
+{var sites={1:/^http:\/\/video\.google\.com\//,2:/^http:\/\/.{2,3}\.youtube\.com\//,3:/^http:\/\/www\.metacafe\.com\//,4:/^http:\/\/www\.ifilm\.com\//,5:/^http:\/\/www\.goear.com\//,6:/^http:\/\/www\.grouper\.com\//,7:/^http:\/\/www\.dailymotion\.com\//,8:/^http:\/\/vimeo\.com\//};var found=false;var siteId=0;for(var id in sites){if(url.match(sites[id])){found=true;siteId=id;break;}}
+return(siteId);}
+tinyMCE.addPlugin("insertvideo",TinyMCE_insertvideoPlugin);
\ No newline at end of file



More information about the pLog-svn mailing list