-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmylib-editor-min.js
1 lines (1 loc) · 6.21 KB
/
mylib-editor-min.js
1
var API,global=this;if(API&&API.attachDocumentReadyListener){API.attachDocumentReadyListener(function(){var u,I,T,W,l,t,C,n,M,d,j;var F=API;var h=F.isHostMethod,R=F.isEventSupported;var K=F.attachListener,V=F.attachDocumentListener,O=F.attachWindowListener;var a=F.getBodyElement,A=F.getHtmlElement;var b=F.createElement;var e=F.showElement;var L=F.getElementParentElement;var Z=F.getIFrameDocument,p=F.getDocumentWindow;var q=F.getElementSize,G=F.sizeElementOuter;var J=F.getHostRange;var D=function(i){return i.contentDocument||(i.contentWindow&&i.contentWindow.document)};var P=function(i){var AA=i.contentWindow;if(!AA&&p){var z=i.contentDocument;if(z){AA=p(z)}}return AA};T=a();if(b&&L&&Z&&T&&h(T,"appendChild")){u=b("iframe");u.style.visibility="hidden";u.style.position="absolute";u.style.top=u.style.left=u.style.width=u.style.height="0";T.appendChild(u);I=D(u);T.removeChild(u);u=b("div");if(u&&I&&(typeof I.designMode=="string"||typeof u.contentEditable=="string")){F.getEditorDocument=D;F.getEditorWindow=P;W=API.editorNewPage=function(z,i){var AA=D(z);AA.open();AA.write('<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title></title></head><body>'+i+"</body></html>");AA.close()};if(F.getElementHtml){var N=F.getElementHtml;M=F.getEditorHtml=function(i){return N(a(D(i)))}}else{M=F.getEditorHtml=function(i){return a(D(i)).innerHTML}}if(J){j=function(AA){var i=J(AA.document);if(AA.selectionBookmark){try{i.moveToBookmark(AA.selectionBookmark);i.select()}catch(z){}AA.selectionBookmark=null}}}var Y=function(i){var AA=P(i);var z=AA.textarea;d(i,z.value)};var S=F.editorViewSource=function(AB,i,z){var AA=AB.contentWindow.textarea;if(typeof i=="undefined"){i=true}if(i){AA.style.visibility="hidden"}AA.style.height=AA.style.width=i?"":"0";AA.style.position=i?"":"absolute";AA.style.top=AA.style.left=i?"":"-10000px";AA.tabIndex=i?0:-1;if(i){if(e){e(AA,true,z)}else{AA.style.visibility="visible"}}AA.readOnly=!i};F.enhanceEditor=function(AB,AN){var AG,AI,AJ,AF;var AA=b("iframe");var AD=L(AB);var AL=AB.value;if(!AN){AN={}}if(AA&&AD){if(AN.id){AA.id=AN.id}if(q&&AN.autoSize){AG=q(AB)}AD.insertBefore(AA,AB);AI=P(AA);AJ=D(AA);AF=A();if(AI&&AJ&&AF&&R(AF,"keyup")){if(AG){G(AA,AG[0],AG[1])}AJ.designMode="on";AB.value="<p>"+AL+"</p>";W(AA,AB.value);AI.textarea=AB;if(K){K(AB,"change",function(){Y(AA)})}S(AA,false);AB.readOnly=true;var AM=["keyup","mouseup"];if(AN.updateInterfaceOnKeyDown){AM.push("keydown")}var z=AN.onupdateinterface,AC=AN.autoUpdate;AI.autoUpdate=AC;var AH=function(){if(z){z.call(AN.callbackContext,AA)}if(AC){AB.value=M(AA)}};var AK=function(){if(J){var i=API.getHostRange(D(AA));if(h(i,"getBookmark")){P(AA).selectionBookmark=i.getBookmark()}}if(AC){AB.value=M(AA)}};if(V){AJ=D(AA);for(var AE=AM.length;AE--;){V(AM[AE],AH,AJ)}}if(K){if(R("beforedeactivate",AA)){K(AA,"beforedeactivate",AK)}else{O("blur",AK,AI)}if(j&&R("activate",AA)){K(AA,"activate",function(){j(P(this))})}}}else{AD.removeChild(AA)}}AI=AD=AF=null;return AA};var X={"Normal":"P","Heading 1":"H1","Heading 2":"H2","Heading 3":"H3","Heading 4":"H4","Heading 5":"H5","Heading 6":"H6","Formatted":"PRE","Bulleted List":"UL","Numbered List":"OL"};var Q={"10px":"1","13px":"2","16px":"3","18px":"4","24px":"5","32px":"6"};var w=function(AA,AI){var AE,AD,AK=AI.rows,AB=AI.columns,AC=AI.border;var AH=AI.padding,AG=AI.spacing,AJ=AI.height,z=AI.width;var AF="<table";if(AJ){AF+=' height="'+AJ+'"'}if(z){AF+=' width="'+z+'"'}if(AC){AF+=' border="'+AC+'"'}if(AH){AF+=' padding="'+AH+'"'}if(AG){AF+=' spacing="'+AG+'"'}AF+="><tbody>";for(AE=AK;AE--;){AF+="<tr>";for(AD=AB;AD--;){AF+="<td></td>"}AF+="</tr>"}AF+="</tbody></table>";l(AA,"inserthtml",false,AF)};l=API.editorExecCommand=function(i,z,AE,AF){var AG;if(z=="inserttable"&&!AE){w(i,AF)}if(z=="formatblock"&&AF.charAt(0)!="<"){AF="<"+AF+">"}try{D(i).execCommand(z,AE,AF);AG=true}catch(AC){if(/^(cut|copy|paste)$/.test(z)){window.alert("Your security settings do not allow clipboard access.")}else{if(z=="inserthtml"&&J){var AA=J(D(i));if(h(AA,"pasteHTML")){try{AA.pasteHTML(AF);AG=true}catch(AD){}}}}}if(AG){var AB=P(i);if(AB.textarea&&AB.autoUpdate){AB.textarea.value=M(i)}}return AG};C=F.getEditorCommandState=function(i,z){return D(i).queryCommandState(z)};var U=/^'|'$/g;var s=new RegExp("rgb[a]*\\((\\d*),[\\s]*(\\d*),[\\s]*(\\d*)[),]","i");var H=new RegExp("^rgba\\(\\d+,\\s*\\d+,\\s*\\d,\\s*0\\)$","i");var g=function(i){return("0"+i.toString(16)).slice(-2)};var x=function(i){return[g(i[0]),g(i[1]),g(i[2])].join("").toUpperCase()};n=F.getEditorCommandValue=function(z,AB){var AA=D(z).queryCommandValue(AB);if(typeof AA=="string"){AA=AA.replace(U,"")}if(AA){if(AB=="formatblock"){AA=(X[AA]||AA).toUpperCase()}else{if(AB=="fontsize"){AA=Q[AA]||AA}else{if(/color/.test(AB)){if(typeof AA=="number"){AA="#"+x([AA%256,Math.floor(AA%65536/256),Math.floor(AA/65536)])}else{if(H.test(AA)){AA=""}else{var i=s.exec(AA);if(i){AA=["#",g(parseInt(i[1],10)),g(parseInt(i[2],10)),g(parseInt(i[3],10))].join("").toUpperCase()}}}}}}}return AA};t=F.getEditorCommandEnabled=function(i,AA){if(AA=="inserttable"){AA="inserthtml"}try{return D(i).queryCommandEnabled(AA)}catch(z){if(AA=="inserthtml"&&J){return true}}};d=F.setEditorHtml=function(z,i){a(D(z)).innerHTML=i};F.focusEditor=function(i){if(i.contentWindow){i.contentWindow.focus();if(j){j(i.contentWindow)}}else{var z=D(i);if(z&&z.focus){z.focus()}}};var B={orderedlist:"insertorderedlist",unorderedlist:"insertunorderedlist",left:"justifyleft",center:"justifycenter",right:"justifyright",justify:"justifyfull"};var v,E,o,f=["bold","italic","strikethrough","underline","cut","copy","paste","undo","redo","delete","selectall","left","center","right","justify","orderedlist","unorderedlist","subscript","superscript","indent","outdent","insertparagraph","inserthorizontalrule","removeformat","unlink","formatblock","fontname","fontsize","forecolor","backcolor","createlink","insertimage","inserthtml","inserttable"];var c=function(i){return function(z,AB,AA){l(z,i,AB,AA)}};var y=function(i){return function(z){return t(z,i)}};var k=function(i){return function(z){return C(z,i)}};var m=function(i){return function(z){return n(z,i)}};for(var r=f.length;r--;){v=f[r];E=B[v]||v;o=v.charAt(0).toUpperCase()+v.slice(1);F["editor"+o]=c(E);F["editor"+o+"Enabled"]=y(E);F["editor"+o+"State"]=k(E);F["editor"+o+"Value"]=m(E)}}u=I=null}T=F=null})}