WordPress/wp-includes/js/quicktags.js

1 line
9.2 KiB
JavaScript
Raw Normal View History

var QTags,edButtons=[],edCanvas,edAddTag=function(){},edCheckOpenTags=function(){},edCloseAllTags=function(){},edInsertImage=function(){},edInsertLink=function(){},edInsertTag=function(){},edLink=function(){},edQuickLink=function(){},edRemoveTag=function(){},edShowButton=function(){},edShowLinks=function(){},edSpell=function(){},edToolbar=function(){};function quicktags(a){return new QTags(a)}function edInsertContent(b,a){return QTags.insertContent(a)}function edButton(f,e,c,b,a,d){return QTags.addButton(f,e,c,b,a,"",-1)}(function(){var c=function(h){var g,f,e;if(typeof jQuery!="undefined"){jQuery(document).ready(h)}else{g=c;g.funcs=[];g.ready=function(){if(!g.isReady){g.isReady=true;for(f=0;f<g.funcs.length;f++){g.funcs[f]()}}};if(g.isReady){h()}else{g.funcs.push(h)}if(!g.eventAttached){if(document.addEventListener){e=function(){document.removeEventListener("DOMContentLoaded",e,false);g.ready()};document.addEventListener("DOMContentLoaded",e,false);window.addEventListener("load",g.ready,false)}else{if(document.attachEvent){e=function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",e);g.ready()}};document.attachEvent("onreadystatechange",e);window.attachEvent("onload",g.ready);(function(){try{document.documentElement.doScroll("left")}catch(i){setTimeout(arguments.callee,50);return}g.ready()})()}}g.eventAttached=true}}},a=(function(){var e=new Date(),f;f=function(g){var h=g.toString();if(h.length<2){h="0"+h}return h};return e.getUTCFullYear()+"-"+f(e.getUTCMonth()+1)+"-"+f(e.getUTCDate())+"T"+f(e.getUTCHours())+":"+f(e.getUTCMinutes())+":"+f(e.getUTCSeconds())+"+00:00"})(),b={},d;d=QTags=function(k){if(typeof(k)=="string"){k={id:k}}else{if(typeof(k)!="object"){return false}}var j=this,l=k.id,i=document.getElementById(l),h="qt_"+l,e,g,f;if(!l||!i){return false}j.name=h;j.id=l;j.canvas=i;j.settings=k;if(l=="content"&&typeof(adminpage)=="string"&&(adminpage=="post-new-php"||adminpage=="post-php")){edCanvas=i;f="ed_toolbar"}else{f=h+"_toolbar"}e=document.createElement("div");e.id=f;e.className="quicktags-toolbar";i.parentNode.insertBefore(e,i);j.toolbar=e;g=function(o){o=o||window.event;var n=o.target||o.srcElement,m;if(/\s+ed_button\s+/.test(" "+n.className+" ")){j.canvas=i=document.getElementById(l);m=n.id.replace(h+"_","");if(j.theButtons[m]){j.theButtons[m].callback.call(j.theButtons[m],n,i,j)}}};if(e.addEventListener){e.addEventListener("click",g,false)}else{if(e.attachEvent){e.attachEvent("onclick",g)}}j.getButton=function(m){return j.theButtons[m]};j.getButtonElement=function(m){return document.getElementById(h+"_"+m)};d.instances[l]=j;if(!d.instances[0]){d.instances[0]=d.instances[l];c(function(){d._buttonsInit()})}};d.instances={};d.registerButton=function(f,e){b[f]=e};d.getInstance=function(e){return d.instances[e]};d._buttonsInit=function(){var q=this,p,h,e,j,o,n,m,f,l,k,g;for(f in q.instances){if(f==0){continue}p=q.instances[f];h=p.canvas;e=p.name;j=p.settings;m="";o={};n={};for(l in edButtons){if(!edButtons[l]){continue}o[edButtons[l].id]=edButtons[l]}if(f=="content"&&typeof(adminpage)=="string"&&(adminpage=="post-new-php"||adminpage=="post-php")){o.fullscreen=new d.FullscreenButton()}for(l in q._customButtons){if(!o[l]){o[l]=new q._customButtons[l]()}}if(j.buttons){k=j.buttons.split(",");for(l in k){g=k[l];if(o[g]){n[g]=o[g]}}}else{n=o}if(j.disabled_buttons){k=j.disabled_buttons.split(",");for(l in k){g=k[l];if(n[g]){delete (n[g])}}}for(l in n){if(!n[l]||!n[l].html){continue}m+=n[l].html(e+"_")}p.toolbar.innerHTML=m;p.theButtons=n}q.buttonsInitDone=true};d.addButton=function(l,j,f,e,i,k,h){var g;if(!l||!j){return}h=h||0;e=e||"";if(typeof(f)==="function"){g=new d.Button(l,j,i,k);g.callback=f}else{if(typeof(f)==="string"){g=new d.TagButton(l,j,f,e,i,k)}else{return}}if(h==-1){return g}if(h>0){while(typeof(edButtons[h])!="undefined"){h++}edButtons[h]=g}else{edButtons[edButtons.length]=g}if(this.buttonsInitDone){this._buttonsInit()}};d.insertContent=function(h){var i,g,f,j,k,e=document.getElementById(wpActiveEditor);if(!e){return false}if(document.selection){e.focus();i=document.sele