[pLog-svn] r7061 - plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Fri Oct 8 17:56:07 EDT 2010


Author: jondaley
Date: 2010-10-08 17:56:07 -0400 (Fri, 08 Oct 2010)
New Revision: 7061

Added:
   plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js
Log:
compressed

Added: plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js
===================================================================
--- plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js	                        (rev 0)
+++ plog/branches/lifetype-1.2/js/tinymce/plugins/insertresource/editor_plugin.js	2010-10-08 21:56:07 UTC (rev 7061)
@@ -0,0 +1,22 @@
+
+(function(){tinymce.PluginManager.requireLangPack('insertresource');tinymce.create('tinymce.plugins.InsertResourcePlugin',{init:function(ed,url){var t=this;ed.onBeforeSetContent.add(function(ed,o){o.content=t.edit2html(t,o.content);});ed.onPostProcess.add(function(ed,o){if(o.set){o.content=t.edit2html(t,o.content);}
+if(o.get){o.content=t.html2edit(t,o.content);}});ed.addCommand('mceInsertResource',function(){ed.windowManager.open({file:url+'../../../../../admin.php?op=resourceList&mode=1',width:500+parseInt(ed.getLang('InsertResource.delta_width',0)),height:450+parseInt(ed.getLang('InsertResource.delta_height',0)),inline:1},{plugin_url:url,});});ed.addButton('insertresource',{title:'insertresource.desc',cmd:'mceInsertResource',image:url+'/img/insertresource.gif'});ed.onInit.add(function(){if(ed.settings.content_css!==false)
+ed.dom.loadCSS(url+"/css/content.css");});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('insertresource',n.nodeName=='IMG');});},getInfo:function(){return{longname:'InsertResource plugin',author:'LifeType',authorurl:'http://lifetype.net',infourl:'',version:"2.0"};},edit2html:function(t,content){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=t._parseAttributes(objectTag);var cssClass="";if(!attribs||attribs["value"]==undefined||attribs["class"]!="ltPlayer"){startPos++;continue;}
+var regexp=/.*file=([a-zA-Z0-9\-\/:._%]*)/i;result=regexp.exec(attribs["value"]);var fileUrl="";if(result){fileUrl=result[1];}
+if(attribs["height"]==undefined)
+attribs["height"]=20;if(attribs["width"]==undefined)
+attribs["width"]=320;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="'+fileUrl+'"';content+=' alt="'+fileUrl+'" class="ltFlashPlayer" />'+content.substring(endPos);content+=contentAfter;index++;startPos++;}
+return content;},html2edit:function(t,content){var startPos=-1;while((startPos=content.indexOf('<img',startPos+1))!=-1){var endPos=content.indexOf('/>',startPos);var attribs=t._parseAttributes(content.substring(startPos+4,endPos));if(!attribs||attribs['class']!="ltFlashPlayer")
+continue;endPos+=2;var embedHTML='';if(attribs["height"]==undefined)
+attribs["height"]=20;if(attribs["width"]==undefined)
+attribs["width"]=320;embedHTML=getFlashPlayerHTML(attribs["alt"],attribs["height"],attribs["width"]);chunkBefore=content.substring(0,startPos);chunkAfter=content.substring(endPos);content=chunkBefore+embedHTML+chunkAfter;}
+return content;},_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=='"')&&!withInValue)
+withInValue=true;else if((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.PluginManager.add('insertresource',tinymce.plugins.InsertResourcePlugin);})();
\ No newline at end of file



More information about the pLog-svn mailing list