]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/quicktags.min.js
Wordpress 3.7
[autoinstalls/wordpress.git] / wp-includes / js / quicktags.min.js
1 function quicktags(a){return new QTags(a)}function edInsertContent(a,b){return QTags.insertContent(b)}function edButton(a,b,c,d,e){return QTags.addButton(a,b,c,d,e,"",-1)}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(){var a,b=function(a){var c,d,e;"undefined"!=typeof jQuery?jQuery(document).ready(a):(c=b,c.funcs=[],c.ready=function(){if(!c.isReady)for(c.isReady=!0,d=0;d<c.funcs.length;d++)c.funcs[d]()},c.isReady?a():c.funcs.push(a),c.eventAttached||(document.addEventListener?(e=function(){document.removeEventListener("DOMContentLoaded",e,!1),c.ready()},document.addEventListener("DOMContentLoaded",e,!1),window.addEventListener("load",c.ready,!1)):document.attachEvent&&(e=function(){"complete"===document.readyState&&(document.detachEvent("onreadystatechange",e),c.ready())},document.attachEvent("onreadystatechange",e),window.attachEvent("onload",c.ready),function(){try{document.documentElement.doScroll("left")}catch(a){return setTimeout(arguments.callee,50),void 0}c.ready()}()),c.eventAttached=!0))},c=function(){var a,b=new Date;return a=function(a){var b=a.toString();return b.length<2&&(b="0"+b),b},b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"T"+a(b.getUTCHours())+":"+a(b.getUTCMinutes())+":"+a(b.getUTCSeconds())+"+00:00"}();a=QTags=function(c){if("string"==typeof c)c={id:c};else if("object"!=typeof c)return!1;var d,e,f,g=this,h=c.id,i=document.getElementById(h),j="qt_"+h;return h&&i?(g.name=j,g.id=h,g.canvas=i,g.settings=c,"content"!=h||"string"!=typeof adminpage||"post-new-php"!=adminpage&&"post-php"!=adminpage?f=j+"_toolbar":(edCanvas=i,f="ed_toolbar"),d=document.createElement("div"),d.id=f,d.className="quicktags-toolbar",i.parentNode.insertBefore(d,i),g.toolbar=d,e=function(a){a=a||window.event;var b,c=a.target||a.srcElement,d=c.clientWidth||c.offsetWidth;d&&/ ed_button /.test(" "+c.className+" ")&&(g.canvas=i=document.getElementById(h),b=c.id.replace(j+"_",""),g.theButtons[b]&&g.theButtons[b].callback.call(g.theButtons[b],c,i,g))},d.addEventListener?d.addEventListener("click",e,!1):d.attachEvent&&d.attachEvent("onclick",e),g.getButton=function(a){return g.theButtons[a]},g.getButtonElement=function(a){return document.getElementById(j+"_"+a)},a.instances[h]=g,a.instances[0]||(a.instances[0]=a.instances[h],b(function(){a._buttonsInit()})),void 0):!1},a.instances={},a.getInstance=function(b){return a.instances[b]},a._buttonsInit=function(){var b,c,d,e,f,g,h,i,j,k,l=this,m=",strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,";for(g in l.instances)if(0!=g){h=l.instances[g],b=h.canvas,c=h.name,d=h.settings,f="",e={},k="",d.buttons&&(k=","+d.buttons+",");for(j in edButtons)edButtons[j]&&(i=edButtons[j].id,k&&-1!=m.indexOf(","+i+",")&&-1==k.indexOf(","+i+",")||edButtons[j].instance&&edButtons[j].instance!=g||(e[i]=edButtons[j],edButtons[j].html&&(f+=edButtons[j].html(c+"_"))));k&&-1!=k.indexOf(",fullscreen,")&&(e.fullscreen=new a.FullscreenButton,f+=e.fullscreen.html(c+"_")),"rtl"==document.getElementsByTagName("html")[0].dir&&(e.textdirection=new a.TextDirectionButton,f+=e.textdirection.html(c+"_")),h.toolbar.innerHTML=f,h.theButtons=e}l.buttonsInitDone=!0},a.addButton=function(b,c,d,e,f,g,h,i){var j;if(b&&c){if(h=h||0,e=e||"","function"==typeof d)j=new a.Button(b,c,f,g,i),j.callback=d;else{if("string"!=typeof d)return;j=new a.TagButton(b,c,d,e,f,g,i)}if(-1==h)return j;if(h>0){for(;"undefined"!=typeof edButtons[h];)h++;edButtons[h]=j}else edButtons[edButtons.length]=j;this.buttonsInitDone&&this._buttonsInit()}},a.insertContent=function(a){var b,c,d,e,f,g=document.getElementById(wpActiveEditor);return g?(document.selection?(g.focus(),b=document.selection.createRange(),b.text=a,g.focus()):g.selectionStart||"0"==g.selectionStart?(f=g.value,c=g.selectionStart,d=g.selectionEnd,e=g.scrollTop,g.value=f.substring(0,c)+a+f.substring(d,f.length),g.focus(),g.selectionStart=c+a.length,g.selectionEnd=c+a.length,g.scrollTop=e):(g.value+=a,g.focus()),!0):!1},a.Button=function(a,b,c,d,e){var f=this;f.id=a,f.display=b,f.access=c,f.title=d||"",f.instance=e||""},a.Button.prototype.html=function(a){var b=this.access?' accesskey="'+this.access+'"':"";return'<input type="button" id="'+a+this.id+'"'+b+' class="ed_button" title="'+this.title+'" value="'+this.display+'" />'},a.Button.prototype.callback=function(){},a.TagButton=function(b,c,d,e,f,g,h){var i=this;a.Button.call(i,b,c,f,g,h),i.tagStart=d,i.tagEnd=e},a.TagButton.prototype=new a.Button,a.TagButton.prototype.openTag=function(a,b){var c=this;b.openTags||(b.openTags=[]),c.tagEnd&&(b.openTags.push(c.id),a.value="/"+a.value)},a.TagButton.prototype.closeTag=function(a,b){var c=this,d=c.isOpen(b);d!==!1&&b.openTags.splice(d,1),a.value=c.display},a.TagButton.prototype.isOpen=function(a){var b=this,c=0,d=!1;if(a.openTags)for(;d===!1&&c<a.openTags.length;)d=a.openTags[c]==b.id?c:!1,c++;else d=!1;return d},a.TagButton.prototype.callback=function(a,b,c){var d,e,f,g,h,i,j,k,l=this,m=b.value,n=m?l.tagEnd:"";document.selection?(b.focus(),k=document.selection.createRange(),k.text.length>0?k.text=l.tagEnd?l.tagStart+k.text+n:k.text+l.tagStart:l.tagEnd?l.isOpen(c)===!1?(k.text=l.tagStart,l.openTag(a,c)):(k.text=n,l.closeTag(a,c)):k.text=l.tagStart,b.focus()):b.selectionStart||"0"==b.selectionStart?(d=b.selectionStart,e=b.selectionEnd,f=e,g=b.scrollTop,h=m.substring(0,d),i=m.substring(e,m.length),j=m.substring(d,e),d!=e?l.tagEnd?(b.value=h+l.tagStart+j+n+i,f+=l.tagStart.length+n.length):(b.value=h+j+l.tagStart+i,f+=l.tagStart.length):l.tagEnd?l.isOpen(c)===!1?(b.value=h+l.tagStart+i,l.openTag(a,c),f=d+l.tagStart.length):(b.value=h+n+i,f=d+n.length,l.closeTag(a,c)):(b.value=h+l.tagStart+i,f=d+l.tagStart.length),b.focus(),b.selectionStart=f,b.selectionEnd=f,b.scrollTop=g):(n?l.isOpen(c)!==!1?(b.value+=l.tagStart,l.openTag(a,c)):(b.value+=n,l.closeTag(a,c)):b.value+=l.tagStart,b.focus())},a.SpellButton=function(){},a.CloseButton=function(){a.Button.call(this,"close",quicktagsL10n.closeTags,"",quicktagsL10n.closeAllOpenTags)},a.CloseButton.prototype=new a.Button,a._close=function(a,b,c){var d,e,f=c.openTags;if(f)for(;f.length>0;)d=c.getButton(f[f.length-1]),e=document.getElementById(c.name+"_"+d.id),a?d.callback.call(d,e,b,c):d.closeTag(e,c)},a.CloseButton.prototype.callback=a._close,a.closeAllTags=function(b){var c=this.getInstance(b);a._close("",c.canvas,c)},a.LinkButton=function(){a.TagButton.call(this,"link","link","","</a>","a")},a.LinkButton.prototype=new a.TagButton,a.LinkButton.prototype.callback=function(b,c,d,e){var f,g=this;return"undefined"!=typeof wpLink?(wpLink.open(),void 0):(e||(e="http://"),g.isOpen(d)===!1?(f=prompt(quicktagsL10n.enterURL,e),f&&(g.tagStart='<a href="'+f+'">',a.TagButton.prototype.callback.call(g,b,c,d))):a.TagButton.prototype.callback.call(g,b,c,d),void 0)},a.ImgButton=function(){a.TagButton.call(this,"img","img","","","m")},a.ImgButton.prototype=new a.TagButton,a.ImgButton.prototype.callback=function(b,c,d,e){e||(e="http://");var f,g=prompt(quicktagsL10n.enterImageURL,e);g&&(f=prompt(quicktagsL10n.enterImageDescription,""),this.tagStart='<img src="'+g+'" alt="'+f+'" />',a.TagButton.prototype.callback.call(this,b,c,d))},a.FullscreenButton=function(){a.Button.call(this,"fullscreen",quicktagsL10n.fullscreen,"f",quicktagsL10n.toggleFullscreen)},a.FullscreenButton.prototype=new a.Button,a.FullscreenButton.prototype.callback=function(a,b){b.id&&"undefined"!=typeof fullscreen&&fullscreen.on()},a.TextDirectionButton=function(){a.Button.call(this,"textdirection",quicktagsL10n.textdirection,"",quicktagsL10n.toggleTextdirection)},a.TextDirectionButton.prototype=new a.Button,a.TextDirectionButton.prototype.callback=function(a,b){var c="rtl"==document.getElementsByTagName("html")[0].dir,d=b.style.direction;d||(d=c?"rtl":"ltr"),b.style.direction="rtl"==d?"ltr":"rtl",b.focus()},edButtons[10]=new a.TagButton("strong","b","<strong>","</strong>","b"),edButtons[20]=new a.TagButton("em","i","<em>","</em>","i"),edButtons[30]=new a.LinkButton,edButtons[40]=new a.TagButton("block","b-quote","\n\n<blockquote>","</blockquote>\n\n","q"),edButtons[50]=new a.TagButton("del","del",'<del datetime="'+c+'">',"</del>","d"),edButtons[60]=new a.TagButton("ins","ins",'<ins datetime="'+c+'">',"</ins>","s"),edButtons[70]=new a.ImgButton,edButtons[80]=new a.TagButton("ul","ul","<ul>\n","</ul>\n\n","u"),edButtons[90]=new a.TagButton("ol","ol","<ol>\n","</ol>\n\n","o"),edButtons[100]=new a.TagButton("li","li","     <li>","</li>\n","l"),edButtons[110]=new a.TagButton("code","code","<code>","</code>","c"),edButtons[120]=new a.TagButton("more","more","<!--more-->","","t"),edButtons[140]=new a.CloseButton}();