- md5
- c64811e4345d84d0cc32a2ba23b344f6
- sha1
- 502f7ddb6ac629cf9c6959e94b1dda028dd1fcc5
- sha256
- 0df3e47720ac337c8091afdfc60ea1b707ea7e08f3fef7e52033513be5ce5b37
var wpLink;!function(s){var a,t,i,n,r,l={},o={},c="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){function e(){var e=s.trim(l.url.val());e&&r!==e&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(e)&&(l.url.val("http://"+e),r=e)}l.wrap=s("#wp-link-wrap"),l.dialog=s("#wp-link"),l.backdrop=s("#wp-link-backdrop"),l.submit=s("#wp-link-submit"),l.close=s("#wp-link-close"),l.text=s("#wp-link-text"),l.url=s("#wp-link-url"),l.nonce=s("#_ajax_linking_nonce"),l.openInNewTab=s("#wp-link-target"),l.search=s("#wp-link-search"),o.search=new i(s("#search-results")),o.recent=new i(s("#most-recent-results")),o.elements=l.dialog.find(".query-results"),l.queryNotice=s("#query-notice-message"),l.queryNoticeTextDefault=l.queryNotice.find(".query-notice-default"),l.queryNoticeTextHint=l.queryNotice.find(".query-notice-hint"),l.dialog.keydown(wpLink.keydown),l.dialog.keyup(wpLink.keyup),l.submit.click(function(e){e.preventDefault(),wpLink.update()}),l.close.add(l.backdrop).add("#wp-link-cancel a").click(function(e){e.preventDefault(),wpLink.close()}),s("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),o.elements.on("river-select",wpLink.updateFields),l.search.on("focus.wplink",function(){l.queryNoticeTextDefault.hide(),l.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){l.queryNoticeTextDefault.show(),l.queryNoticeTextHint.addClass("screen-reader-text").hide()}),l.search.keyup(function(){var e=this;window.clearTimeout(t),t=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)}),l.url.on("paste",function(){setTimeout(e,0)}),l.url.on("blur",e)},open:function(e){s(document.body).addClass("modal-open"),wpLink.range=null,e&&(window.wpActiveEditor=e),window.wpActiveEditor&&(this.textarea=s("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e=tinymce.get(wpActiveEditor),(a=e&&!e.isHidden()?e:null)&&tinymce.isIE&&(a.windowManager.bookmark=a.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),l.wrap.show(),l.backdrop.show(),wpLink.refresh(),s(document).trigger("wplink-open",l.wrap))},isMCE:function(){return a&&!a.isHidden()},refresh:function(){var e="";o.search.refresh(),o.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(l.wrap.hasClass("has-text-field")||l.wrap.addClass("has-text-field"),document.selection?e=document.selection.createRange().text||"":void 0!==this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(e=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),l.text.val(e),wpLink.setDefaultValues()),c?l.url.focus().blur():l.url.focus()[0].select(),o.recent.ul.children().length||o.recent.ajax(),r=l.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(e){var t=a.selection.getContent();if(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1===t.indexOf("href=")))return!1;if(e){var i,n=e.childNodes;if(0===n.length)return!1;for(i=n.length-1;0<=i;i--)if(3!=n[i].nodeType)return!1}return!0},mceRefresh:function(){var e,t=a.selection.getNode(),i=a.dom.getParent(t,"a[href]"),t=this.hasSelectedText(i);i?(e=i.innerText||i.textContent,l.url.val(a.dom.getAttrib(i,"href")),l.openInNewTab.prop("checked","_blank"===a.dom.getAttrib(i,"target")),l.submit.val(wpLinkL10n.update)):(e=a.selection.getContent({format:"text"}),this.setDefaultValues()),t?(l.text.val(e||""),l.wrap.addClass("has-text-field")):(l.text.val(""),l.wrap.removeClass("has-text-field"))},close:function(){s(document.body).removeClass("modal-open"),wpLink.isMCE()?a.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),l.backdrop.hide(),l.wrap.hide(),r=!1,s(document).trigger("wplink-close",l.wrap)},getAttrs:function(){return{href:s.trim(l.url.val()),target:l.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,a,s=wpLink.textarea;s&&(n=wpLink.getAttrs(),i=l.text.val(),(a=document.createElement("a")).href=n.href,"javascript:"!==a.protocol&&"data:"!==a.protocol||(n.href=""),n.href?(e='<a href="'+n.href+'"',n.target&&(e+=' rel="noopener" target="'+n.target+'"'),e+=">",document.selection&&wpLink.range?(s.focus(),wpLink.range.text=e+(i||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):void 0!==s.selectionStart&&(t=s.selectionStart,a=s.selectionEnd,i=t+(e=e+(n=i||s.value.substring(t,a))+"</a>").length,t!==a||n||(i-=4),s.value=s.value.substring(0,t)+e+s.value.substring(a,s.value.length),s.selectionStart=s.selectionEnd=i),wpLink.close(),s.focus()):wpLink.close())},mceUpdate:function(){var e,t=wpLink.getAttrs();wpLink.close(),a.focus(),tinymce.isIE&&a.selection.moveToBookmark(a.windowManager.bookmark);var i=document.createElement("a");i.href=t.href,"javascript:"!==i.protocol&&"data:"!==i.protocol||(t.href=""),t.href?(e=a.dom.getParent(a.selection.getNode(),"a"),i=l.text.val(),e?(i&&("innerText"in e?e.innerText=i:e.textContent=i),a.dom.setAttribs(e,t)):i?a.selection.setNode(a.dom.create("a",t,i)):a.execCommand("mceInsertLink",!1,t)):a.execCommand("unlink")},updateFields:function(e,t){l.url.val(t.children(".item-permalink").val())},setDefaultValues:function(){var e;this.isMCE()?e=a.selection.getContent():document.selection&&wpLink.range?e=wpLink.range.text:void 0!==this.textarea.selectionStart&&(e=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),e&&/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(e)?l.url.val("mailto:"+e):e&&/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i.test(e)?l.url.val(e.replace(/&|�?38;/gi,"&")):l.url.val(""),l.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var e,t=s(this),i=t.val();2<i.length?(o.recent.hide(),o.search.show(),wpLink.lastSearch!=i&&(wpLink.lastSearch=i,e=t.parent().find(".spinner").addClass("is-active"),o.search.change(i),o.search.ajax(function(){e.removeClass("is-active")}))):(o.search.hide(),o.recent.show())},next:function(){o.search.next(),o.recent.next()},prev:function(){o.search.prev(),o.recent.prev()},keydown:function(e){var t,i=s.ui.keyCode;i.ESCAPE===e.keyCode?(wpLink.close(),e.stopImmediatePropagation()):i.TAB===e.keyCode&&("wp-link-submit"!==(t=e.target.id)||e.shiftKey?"wp-link-close"===t&&e.shiftKey&&(l.submit.focus(),e.preventDefault()):(l.close.focus(),e.preventDefault())),e.keyCode!==i.UP&&e.keyCode!==i.DOWN||document.activeElement&&("link-title-field"===document.activeElement.id||"url-field"===document.activeElement.id)||(i=e.keyCode===i.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[i](),wpLink.keyInterval=setInterval(wpLink[i],wpLink.keySensitivity),e.preventDefault())},keyup:function(e){var t=s.ui.keyCode;e.which!==t.UP&&e.which!==t.DOWN||(clearInterval(wpLink.keyInterval),e.preventDefault())},delayedCallback:function(e,t){var i,n,a,s;return t?(setTimeout(function(){return n?e.apply(s,a):void(i=!0)},t),function(){if(i)return e.apply(this,arguments);a=arguments,s=this,n=!0}):e},toggleInternalLinking:function(e){var t=l.wrap.hasClass("search-panel-visible");l.wrap.toggleClass("search-panel-visible",!t),setUserSetting("wplink",t?"0":"1"),l[t?"url":"search"].focus(),e.preventDefault()}},i=function(e,t){var i=this;this.element=e,this.ul=e.children("ul"),this.contentHeight=e.children("#link-selector-height"),this.waiting=e.find(".river-waiting"),this.change(t),this.refresh(),s("#wp-link .query-results, #wp-link #link-selector").scroll(function(){i.maybeLoad()}),e.on("click","li",function(e){i.select(s(this),e)})},s.extend(i.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(e,t){var i,n,a,s;e.hasClass("unselectable")||e==this.selected||(this.deselect(),this.selected=e.addClass("selected"),i=e.outerHeight(),n=this.element.height(),a=e.position().top,s=this.element.scrollTop(),a<0?this.element.scrollTop(s+a):n<a+i&&this.element.scrollTop(s+a-n+i),this.element.trigger("river-select",[e,t,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){var e;this.visible&&this.selected&&(e=this.selected.prev("li")).length&&this.select(e)},next:function(){var e;!this.visible||(e=this.selected?this.selected.next("li"):s("li:not(.unselectable):first",this.element)).length&&this.select(e)},ajax:function(i){var n=this,e=1==this.query.page?0:wpLink.minRiverAJAXDuration,e=wpLink.delayedCallback(function(e,t){n.process(e,t),i&&i(e,t)},e);this.query.ajax(e)},change:function(e){this.query&&this._search==e||(this._search=e,this.query=new n(e),this.element.scrollTop(0))},process:function(e,t){var i,n="",a=!0,t=1==t.page;e?s.each(e,function(){i=a?"alternate":"",i+=this.title?"":" no-title",n+=i?'<li class="'+i+'">':"<li>",n+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',n+='<span class="item-title">',n+=this.title||wpLinkL10n.noTitle,n+='</span><span class="item-info">'+this.info+"</span></li>",a=!a}):t&&(n+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[t?"html":"append"](n)},maybeLoad:function(){var i=this,n=this.element,e=n.scrollTop()+n.height();!this.query.ready()||e<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var e=n.scrollTop(),t=e+n.height();!i.query.ready()||t<i.contentHeight.height()-wpLink.riverBottomThreshold||(i.waiting.addClass("is-active"),n.scrollTop(e+i.waiting.outerHeight()),i.ajax(function(){i.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),n=function(e){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=e},s.extend(n.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(t){var i=this,n={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:l.nonce.val()};this.search&&(n.search=this.search),this.querying=!0,s.post(ajaxurl,n,function(e){i.page++,i.querying=!1,i.allLoaded=!e,t(e,n)},"json")}}),s(document).ready(wpLink.init)}(jQuery);
The same content is in 10 releases, WordPress 4.2.30 to 4.2.39. See them all, or every version of this file.