]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/quicktags.min.js
WordPress 4.4
[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,edCanvas,edButtons=[],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(){function a(a){return a=a||"",a=a.replace(/&([^#])(?![a-z1-4]{1,8};)/gi,"&#038;$1"),a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var b,c=function(a){var b,d,e,f;"undefined"!=typeof jQuery?jQuery(document).ready(a):(b=c,b.funcs=[],b.ready=function(){if(!b.isReady)for(b.isReady=!0,d=0;d<b.funcs.length;d++)b.funcs[d]()},b.isReady?a():b.funcs.push(a),b.eventAttached||(document.addEventListener?(e=function(){document.removeEventListener("DOMContentLoaded",e,!1),b.ready()},document.addEventListener("DOMContentLoaded",e,!1),window.addEventListener("load",b.ready,!1)):document.attachEvent&&(e=function(){"complete"===document.readyState&&(document.detachEvent("onreadystatechange",e),b.ready())},document.attachEvent("onreadystatechange",e),window.attachEvent("onload",b.ready),(f=function(){try{document.documentElement.doScroll("left")}catch(a){return void setTimeout(f,50)}b.ready()})()),b.eventAttached=!0))},d=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"}();b=QTags=function(a){if("string"==typeof a)a={id:a};else if("object"!=typeof a)return!1;var d,e,f,g,h,i=this,j=a.id,k=document.getElementById(j),l="qt_"+j;return j&&k?(i.name=l,i.id=j,i.canvas=k,i.settings=a,"content"!==j||"string"!=typeof adminpage||"post-new-php"!==adminpage&&"post-php"!==adminpage?f=l+"_toolbar":(edCanvas=k,f="ed_toolbar"),d=document.getElementById(f),d||(d=document.createElement("div"),d.id=f,d.className="quicktags-toolbar"),k.parentNode.insertBefore(d,k),i.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+" ")&&(i.canvas=k=document.getElementById(j),b=c.id.replace(l+"_",""),i.theButtons[b]&&i.theButtons[b].callback.call(i.theButtons[b],c,k,i))},h=function(){window.wpActiveEditor=j},g=document.getElementById("wp-"+j+"-wrap"),d.addEventListener?(d.addEventListener("click",e,!1),g&&g.addEventListener("click",h,!1)):d.attachEvent&&(d.attachEvent("onclick",e),g&&g.attachEvent("onclick",h)),i.getButton=function(a){return i.theButtons[a]},i.getButtonElement=function(a){return document.getElementById(l+"_"+a)},b.instances[j]=i,void(b.instances[0]||(b.instances[0]=b.instances[j],c(function(){b._buttonsInit()})))):!1},b.instances={},b.getInstance=function(a){return b.instances[a]},b._buttonsInit=function(){var a,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],a=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(",dfw,")&&(e.dfw=new b.DFWButton,f+=e.dfw.html(c+"_")),"rtl"===document.getElementsByTagName("html")[0].dir&&(e.textdirection=new b.TextDirectionButton,f+=e.textdirection.html(c+"_")),h.toolbar.innerHTML=f,h.theButtons=e,"undefined"!=typeof jQuery&&jQuery(document).triggerHandler("quicktags-init",[h])}l.buttonsInitDone=!0},b.addButton=function(a,c,d,e,f,g,h,i,j){var k;if(a&&c){if(h=h||0,e=e||"",j=j||{},"function"==typeof d)k=new b.Button(a,c,f,g,i,j),k.callback=d;else{if("string"!=typeof d)return;k=new b.TagButton(a,c,d,e,f,g,i,j)}if(-1===h)return k;if(h>0){for(;"undefined"!=typeof edButtons[h];)h++;edButtons[h]=k}else edButtons[edButtons.length]=k;this.buttonsInitDone&&this._buttonsInit()}},b.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.selectionStart=c+a.length,g.selectionEnd=c+a.length,g.scrollTop=e,g.focus()):(g.value+=a,g.focus()),!0):!1},b.Button=function(a,b,c,d,e,f){this.id=a,this.display=b,this.access="",this.title=d||"",this.instance=e||"",this.attr=f||{}},b.Button.prototype.html=function(b){var c,d,e,f=this.title?' title="'+a(this.title)+'"':"",g=this.attr&&this.attr.ariaLabel?' aria-label="'+a(this.attr.ariaLabel)+'"':"",h=this.display?' value="'+a(this.display)+'"':"",i=this.id?' id="'+a(b+this.id)+'"':"",j=(e=window.wp)&&e.editor&&e.editor.dfw;return"fullscreen"===this.id?'<button type="button"'+i+' class="ed_button qt-dfw qt-fullscreen"'+f+g+"></button>":"dfw"===this.id?(c=j&&j.isActive()?"":' disabled="disabled"',d=j&&j.isOn()?" active":"",'<button type="button"'+i+' class="ed_button qt-dfw'+d+'"'+f+g+c+"></button>"):'<input type="button"'+i+' class="ed_button button button-small"'+f+g+h+" />"},b.Button.prototype.callback=function(){},b.TagButton=function(a,c,d,e,f,g,h,i){var j=this;b.Button.call(j,a,c,f,g,h,i),j.tagStart=d,j.tagEnd=e},b.TagButton.prototype=new b.Button,b.TagButton.prototype.openTag=function(a,b){b.openTags||(b.openTags=[]),this.tagEnd&&(b.openTags.push(this.id),a.value="/"+a.value,this.attr.ariaLabelClose&&a.setAttribute("aria-label",this.attr.ariaLabelClose))},b.TagButton.prototype.closeTag=function(a,b){var c=this.isOpen(b);c!==!1&&b.openTags.splice(c,1),a.value=this.display,this.attr.ariaLabel&&a.setAttribute("aria-label",this.attr.ariaLabel)},b.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},b.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?l.tagEnd?k.text=l.tagStart+k.text+n:k.text=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.selectionStart=f,b.selectionEnd=f,b.scrollTop=g,b.focus()):(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())},b.SpellButton=function(){},b.CloseButton=function(){b.Button.call(this,"close",quicktagsL10n.closeTags,"",quicktagsL10n.closeAllOpenTags)},b.CloseButton.prototype=new b.Button,b._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)},b.CloseButton.prototype.callback=b._close,b.closeAllTags=function(a){var c=this.getInstance(a);b._close("",c.canvas,c)},b.LinkButton=function(){var a={ariaLabel:quicktagsL10n.link};b.TagButton.call(this,"link","link","","</a>","","","",a)},b.LinkButton.prototype=new b.TagButton,b.LinkButton.prototype.callback=function(a,c,d,e){var f,g=this;return"undefined"!=typeof wpLink?void wpLink.open(d.id):(e||(e="http://"),void(g.isOpen(d)===!1?(f=prompt(quicktagsL10n.enterURL,e),f&&(g.tagStart='<a href="'+f+'">',b.TagButton.prototype.callback.call(g,a,c,d))):b.TagButton.prototype.callback.call(g,a,c,d)))},b.ImgButton=function(){var a={ariaLabel:quicktagsL10n.image};b.TagButton.call(this,"img","img","","","","","",a)},b.ImgButton.prototype=new b.TagButton,b.ImgButton.prototype.callback=function(a,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+'" />',b.TagButton.prototype.callback.call(this,a,c,d))},b.DFWButton=function(){b.Button.call(this,"dfw","","f",quicktagsL10n.dfw)},b.DFWButton.prototype=new b.Button,b.DFWButton.prototype.callback=function(){var a;(a=window.wp)&&a.editor&&a.editor.dfw&&window.wp.editor.dfw.toggle()},b.TextDirectionButton=function(){b.Button.call(this,"textdirection",quicktagsL10n.textdirection,"",quicktagsL10n.toggleTextdirection)},b.TextDirectionButton.prototype=new b.Button,b.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 b.TagButton("strong","b","<strong>","</strong>","","","",{ariaLabel:quicktagsL10n.strong,ariaLabelClose:quicktagsL10n.strongClose}),edButtons[20]=new b.TagButton("em","i","<em>","</em>","","","",{ariaLabel:quicktagsL10n.em,ariaLabelClose:quicktagsL10n.emClose}),edButtons[30]=new b.LinkButton,edButtons[40]=new b.TagButton("block","b-quote","\n\n<blockquote>","</blockquote>\n\n","","","",{ariaLabel:quicktagsL10n.blockquote,ariaLabelClose:quicktagsL10n.blockquoteClose}),edButtons[50]=new b.TagButton("del","del",'<del datetime="'+d+'">',"</del>","","","",{ariaLabel:quicktagsL10n.del,ariaLabelClose:quicktagsL10n.delClose}),edButtons[60]=new b.TagButton("ins","ins",'<ins datetime="'+d+'">',"</ins>","","","",{ariaLabel:quicktagsL10n.ins,ariaLabelClose:quicktagsL10n.insClose}),edButtons[70]=new b.ImgButton,edButtons[80]=new b.TagButton("ul","ul","<ul>\n","</ul>\n\n","","","",{ariaLabel:quicktagsL10n.ul,ariaLabelClose:quicktagsL10n.ulClose}),edButtons[90]=new b.TagButton("ol","ol","<ol>\n","</ol>\n\n","","","",{ariaLabel:quicktagsL10n.ol,ariaLabelClose:quicktagsL10n.olClose}),edButtons[100]=new b.TagButton("li","li","     <li>","</li>\n","","","",{ariaLabel:quicktagsL10n.li,ariaLabelClose:quicktagsL10n.liClose}),edButtons[110]=new b.TagButton("code","code","<code>","</code>","","","",{ariaLabel:quicktagsL10n.code,ariaLabelClose:quicktagsL10n.codeClose}),edButtons[120]=new b.TagButton("more","more","<!--more-->\n\n","","","","",{ariaLabel:quicktagsL10n.more}),edButtons[140]=new b.CloseButton}();