forked from jessegreathouse/TinyEditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
packed.js
1 lines (1 loc) · 7.6 KB
/
packed.js
1
function T$(e){return document.getElementById(e)}function T$$$(){return document.all?1:0}TINY={},TINY.editor=function(){function e(e,i){this.n=e,window[e]=this,this.t=T$(i.id),this.obj=i,this.xhtml=i.xhtml;var s=document.createElement("div"),o=document.createElement("div"),r=document.createElement("div"),a=i.controls.length,l=0;for(this.i=document.createElement("iframe"),this.i.frameBorder=0,this.i.width=i.width||"500",this.i.height=i.height||"250",this.ie=T$$$(),r.className=i.rowclass||"teheader",s.className=i.cssclass||"te",s.style.maxWidth=this.i.width+"px",s.appendChild(r),l;a>l;l++){var c=i.controls[l];if("n"==c)r=document.createElement("div"),r.className=i.rowclass||"teheader",s.appendChild(r);else if("|"==c){var h=document.createElement("div");h.className=i.dividerclass||"tedivider",r.appendChild(h)}else if("font"==c){var d=document.createElement("select"),p=i.fonts||["Verdana","Arial","Georgia"],u=p.length,m=0;for(d.className="tefont",d.onchange=new Function(this.n+'.ddaction(this,"fontname")'),d.options[0]=new Option("Font",""),m;u>m;m++){var g=p[m];d.options[m+1]=new Option(g,g)}r.appendChild(d)}else if("size"==c){var d=document.createElement("select"),f=i.sizes||[1,2,3,4,5,6,7],y=f.length,m=0;for(d.className="tesize",d.onchange=new Function(this.n+'.ddaction(this,"fontsize")'),m;y>m;m++){var v=f[m];d.options[m]=new Option(v,v)}r.appendChild(d)}else if("style"==c){var d=document.createElement("select"),b=i.styles||[["Style",""],["Paragraph","<p>"],["Header 1","<h1>"],["Header 2","<h2>"],["Header 3","<h3>"],["Header 4","<h4>"],["Header 5","<h5>"],["Header 6","<h6>"]],y=b.length,m=0;for(d.className="testyle",d.onchange=new Function(this.n+'.ddaction(this,"formatblock")'),m;y>m;m++){var w=b[m];d.options[m]=new Option(w[0],w[1])}r.appendChild(d)}else if(t[c]){var $,x=document.createElement("div"),m=t[c],E=m[2],C=m[0]*n;x.className=i.controlclass,x.style.backgroundPosition="0px "+C+"px",x.title=m[1],$="a"==E?'.action("'+m[3]+'",0,'+(m[4]||0)+")":'.insert("'+m[4]+'","'+m[5]+'","'+m[3]+'")',x.onclick=new Function(this.n+("print"==c?".print()":$)),x.onmouseover=new Function(this.n+".hover(this,"+C+",1)"),x.onmouseout=new Function(this.n+".hover(this,"+C+",0)"),r.appendChild(x),this.ie&&(x.unselectable="on")}}if(this.t.parentNode.insertBefore(s,this.t),this.t.style.width=this.i.width+"px",o.appendChild(this.t),o.appendChild(this.i),s.appendChild(o),this.t.style.display="none",i.footer){var k=document.createElement("div");if(k.className=i.footerclass||"tefooter",i.toggle){var T=i.toggle,I=document.createElement("div");I.className=T.cssclass||"toggle",I.innerHTML=T.text||"source",I.onclick=new Function(this.n+".toggle(0,this);return false"),k.appendChild(I)}if(i.resize){var N=i.resize,z=document.createElement("div");z.className=N.cssclass||"resize",z.onmousedown=new Function("event",this.n+".resize(event);return false"),z.onselectstart=function(){return!1},k.appendChild(z)}s.appendChild(k)}this.e=this.i.contentWindow.document,this.e.open();var H="<html><head>",L=i.bodyid?' id="'+i.bodyid+'"':"";if(i.cssfile&&(H+='<link rel="stylesheet" href="'+i.cssfile+'" />'),i.css&&(H+='<style type="text/css">'+i.css+"</style>"),H+="</head><body"+L+">"+(i.content||this.t.value),H+="</body></html>",this.e.write(H),this.e.close(),this.e.designMode="on",this.d=1,this.xhtml)try{this.e.execCommand("styleWithCSS",0,0)}catch(F){try{this.e.execCommand("useCSS",0,1)}catch(F){}}}var t=[],n=-30;return t.cut=[1,"Cut","a","cut",1],t.copy=[2,"Copy","a","copy",1],t.paste=[3,"Paste","a","paste",1],t.bold=[4,"Bold","a","bold"],t.italic=[5,"Italic","a","italic"],t.underline=[6,"Underline","a","underline"],t.strikethrough=[7,"Strikethrough","a","strikethrough"],t.subscript=[8,"Subscript","a","subscript"],t.superscript=[9,"Superscript","a","superscript"],t.orderedlist=[10,"Insert Ordered List","a","insertorderedlist"],t.unorderedlist=[11,"Insert Unordered List","a","insertunorderedlist"],t.outdent=[12,"Outdent","a","outdent"],t.indent=[13,"Indent","a","indent"],t.leftalign=[14,"Left Align","a","justifyleft"],t.centeralign=[15,"Center Align","a","justifycenter"],t.rightalign=[16,"Right Align","a","justifyright"],t.blockjustify=[17,"Block Justify","a","justifyfull"],t.undo=[18,"Undo","a","undo"],t.redo=[19,"Redo","a","redo"],t.image=[20,"Insert Image","i","insertimage","Enter Image URL:","http://"],t.hr=[21,"Insert Horizontal Rule","a","inserthorizontalrule"],t.link=[22,"Insert Hyperlink","i","createlink","Enter URL:","http://"],t.unlink=[23,"Remove Hyperlink","a","unlink"],t.unformat=[24,"Remove Formatting","a","removeformat"],t.print=[25,"Print","a","print"],e.prototype.print=function(){this.i.contentWindow.print()},e.prototype.hover=function(e,t,n){e.style.backgroundPosition=(n?"34px ":"0px ")+t+"px"},e.prototype.ddaction=function(e,t){var n=e.selectedIndex,i=e.options[n].value;this.action(t,i)},e.prototype.action=function(e,t,n){n&&!this.ie?alert("Your browser does not support this function."):this.e.execCommand(e,0,t||null)},e.prototype.insert=function(e,t,n){var i=prompt(e,t);null!=i&&""!=i&&this.e.execCommand(n,0,i)},e.prototype.setfont=function(){execCommand("formatblock",0,hType)},e.prototype.resize=function(e){this.mv&&this.freeze(),this.i.bcs=TINY.cursor.top(e),this.mv=new Function("event",this.n+".move(event)"),this.sr=new Function(this.n+".freeze()"),this.ie?(document.attachEvent("onmousemove",this.mv),document.attachEvent("onmouseup",this.sr)):(document.addEventListener("mousemove",this.mv,1),document.addEventListener("mouseup",this.sr,1))},e.prototype.move=function(e){var t=TINY.cursor.top(e);this.i.height=parseInt(this.i.height)+t-this.i.bcs,this.i.bcs=t},e.prototype.freeze=function(){this.ie?(document.detachEvent("onmousemove",this.mv),document.detachEvent("onmouseup",this.sr)):(document.removeEventListener("mousemove",this.mv,1),document.removeEventListener("mouseup",this.sr,1))},e.prototype.toggle=function(e,t){if(this.d){var n=this.e.body.innerHTML;this.xhtml&&(n=n.replace(/<span class="apple-style-span">(.*)<\/span>/gi,"$1"),n=n.replace(/ class="apple-style-span"/gi,""),n=n.replace(/<span style="">/gi,""),n=n.replace(/<br>/gi,"<br />"),n=n.replace(/<br ?\/?>$/gi,""),n=n.replace(/^<br ?\/?>/gi,""),n=n.replace(/(<img [^>]+[^\/])>/gi,"$1 />"),n=n.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>"),n=n.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>"),n=n.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>'),n=n.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,"$2"),n=n.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>'),n=n.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,"$1"),n=n.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,"<strong>$1</strong>"),n=n.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,"<em>$1</em>"),n=n.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>")),t&&(t.innerHTML=this.obj.toggle.activetext||"wysiwyg"),this.t.value=n,e||(this.t.style.height=this.i.height+"px",this.i.style.display="none",this.t.style.display="block",this.d=0)}else{var n=this.t.value;t&&(t.innerHTML=this.obj.toggle.text||"source"),this.xhtml&&!this.ie&&(n=n.replace(/<strong>(.*)<\/strong>/gi,'<span style="font-weight: bold;">$1</span>'),n=n.replace(/<em>(.*)<\/em>/gi,'<span style="font-weight: italic;">$1</span>')),this.e.body.innerHTML=n,this.t.style.display="none",this.i.style.display="block",this.d=1}},e.prototype.post=function(){this.d&&this.toggle(1)},{edit:e}}(),TINY.cursor=function(){return{top:function(e){return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:e.clientY+window.scrollY}}}();