1 line
1.3 KiB
JavaScript
1 line
1.3 KiB
JavaScript
tinymce.create("tinymce.plugins.Subscribe2Plugin",{init:function(e,n){var t,c=0,i='<p><img src="'+n+'/../include/spacer.gif" class="mceSubscribe2 mceItemNoResize" /></p>',o="mceSubscribe2",s=[],r=new RegExp(/(\[|<!--)subscribe2.*?(\]|-->)/g),u=function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e=s[c]),e};e.addCommand("mceSubscribe2",function(){e.execCommand("mceInsertContent",0,i)}),e.addButton("subscribe2",{title:"Insert Subscribe2 Token",image:n+"/../include/s2-button.png",cmd:o}),e.on("init",function(){e.dom.loadCSS(n+"/css/content.css"),e.theme.onResolveName&&e.theme.onResolveName.add(function(n,t){"IMG"===t.node.nodeName&&e.dom.hasClass(t.node,o)&&(t.name="subscribe2")})}),e.on("BeforeSetContent",function(e){s=e.content.match(r),e.content=e.content.replace(r,i)}),e.on("PostProcess",function(e){if(e.get){if(null!==s)for(t=s.length,c=0;c<t;c++)e.content=e.content.replace(/<img[^>]+>/,u);e.content=e.content.replace(/<img[^>]+>/g,function(e){return-1!==e.indexOf('class="mceSubscribe2')&&(e="[subscribe2]"),e})}})},getInfo:function(){return{longname:"Insert Subscribe2 Token",author:"Matthew Robinson",authorurl:"http://subscribe2.wordpress.com",infourl:"http://subscribe2.wordpress.com",version:tinymce.majorVersion+"."+tinymce.minorVersion}}}),tinymce.PluginManager.add("subscribe2",tinymce.plugins.Subscribe2Plugin); |