wp/wp-includes/js/wplink.min.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
--- a/wp/wp-includes/js/wplink.min.js	Tue Oct 22 16:11:46 2019 +0200
+++ b/wp/wp-includes/js/wplink.min.js	Tue Dec 15 13:49:49 2020 +0100
@@ -1,1 +1,2 @@
-!function(a,b,c){function d(){return e?e.$('a[data-wplink-edit="true"]'):null}var e,f,g,h,i,j=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i,k=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,63}[^ "]*$/i,l={},m={},n="ontouchend"in document;window.wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",modalOpen:!1,init:function(){l.wrap=a("#wp-link-wrap"),l.dialog=a("#wp-link"),l.backdrop=a("#wp-link-backdrop"),l.submit=a("#wp-link-submit"),l.close=a("#wp-link-close"),l.text=a("#wp-link-text"),l.url=a("#wp-link-url"),l.nonce=a("#_ajax_linking_nonce"),l.openInNewTab=a("#wp-link-target"),l.search=a("#wp-link-search"),m.search=new g(a("#search-results")),m.recent=new g(a("#most-recent-results")),m.elements=l.dialog.find(".query-results"),l.queryNotice=a("#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(a){a.preventDefault(),wpLink.update()}),l.close.add(l.backdrop).add("#wp-link-cancel button").click(function(a){a.preventDefault(),wpLink.close()}),m.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.on("keyup input",function(){window.clearTimeout(f),f=window.setTimeout(function(){wpLink.searchInternalLinks()},500)}),l.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),l.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(l.url.val());b&&i!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(l.url.val("http://"+b),i=b)},open:function(b,c,d){var f,g=a(document.body);g.addClass("modal-open"),wpLink.modalOpen=!0,wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof window.tinymce&&(g.append(l.backdrop,l.wrap),f=window.tinymce.get(window.wpActiveEditor),e=f&&!f.isHidden()?f:null),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),l.wrap.show(),l.backdrop.show(),wpLink.refresh(c,d),a(document).trigger("wplink-open",l.wrap))},isMCE:function(){return e&&!e.isHidden()},refresh:function(a,b){var c="";m.search.refresh(),m.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh(a,b):(l.wrap.hasClass("has-text-field")||l.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),l.text.val(b),wpLink.setDefaultValues()),n?l.url.focus().blur():window.setTimeout(function(){l.url[0].select(),l.url.focus()}),m.recent.ul.children().length||m.recent.ajax(),i=l.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,c,d,f=e.selection.getContent();if(/</.test(f)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(f)||f.indexOf("href=")===-1))return!1;if(a.length){if(c=a[0].childNodes,!c||!c.length)return!1;for(d=c.length-1;d>=0;d--)if(b=c[d],3!=b.nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(c,f){var g,h,i=d(),m=this.hasSelectedText(i);i.length?(g=i.text(),h=i.attr("href"),a.trim(g)||(g=f||""),c&&(k.test(c)||j.test(c))&&(h=c),"_wp_link_placeholder"!==h?(l.url.val(h),l.openInNewTab.prop("checked","_blank"===i.attr("target")),l.submit.val(b.update)):this.setDefaultValues(g),c&&c!==h?l.search.val(c):l.search.val(""),window.setTimeout(function(){wpLink.searchInternalLinks()})):(g=e.selection.getContent({format:"text"})||f||"",this.setDefaultValues(g)),m?(l.text.val(g),l.wrap.addClass("has-text-field")):(l.text.val(""),l.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),wpLink.modalOpen=!1,"noReset"!==b&&(wpLink.isMCE()?(e.plugins.wplink&&e.plugins.wplink.close(),e.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),l.backdrop.hide(),l.wrap.hide(),i=!1,a(document).trigger("wplink-close",l.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(l.url.val()),target:l.openInNewTab.prop("checked")?"_blank":null}},buildHtml:function(a){var b='<a href="'+a.href+'"';return a.target&&(b+=' rel="noopener" target="'+a.target+'"'),b+">"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var d,e,f,g,h,i,j,k=wpLink.textarea;if(k){d=wpLink.getAttrs(),e=l.text.val();var m=document.createElement("a");m.href=d.href,"javascript:"!==m.protocol&&"data:"!==m.protocol||(d.href=""),d.href&&(f=wpLink.buildHtml(d),document.selection&&wpLink.range?(k.focus(),wpLink.range.text=f+(e||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof k.selectionStart&&(g=k.selectionStart,h=k.selectionEnd,j=e||k.value.substring(g,h),f=f+j+"</a>",i=g+f.length,g!==h||j||(i-=4),k.value=k.value.substring(0,g)+f+k.value.substring(h,k.value.length),k.selectionStart=k.selectionEnd=i),wpLink.close(),k.focus(),a(k).trigger("change"),c.a11y.speak(b.linkInserted))}},mceUpdate:function(){var f,g,h,i=wpLink.getAttrs(),j=document.createElement("a");return j.href=i.href,"javascript:"!==j.protocol&&"data:"!==j.protocol||(i.href=""),i.href?(f=d(),e.undoManager.transact(function(){f.length||(e.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder","data-wp-temp-link":1}),f=e.$('a[data-wp-temp-link="1"]').removeAttr("data-wp-temp-link"),h=a.trim(f.text())),f.length?(l.wrap.hasClass("has-text-field")&&(g=l.text.val(),g?f.text(g):h||f.text(i.href)),i["data-wplink-edit"]=null,i["data-mce-href"]=i.href,f.attr(i)):e.execCommand("unlink")}),wpLink.close("noReset"),e.focus(),f.length&&(e.selection.select(f[0]),e.plugins.wplink&&e.plugins.wplink.checkLink(f[0])),e.nodeChanged(),void c.a11y.speak(b.linkInserted)):(e.execCommand("unlink"),void wpLink.close())},updateFields:function(a,b){l.url.val(b.children(".item-permalink").val()),l.wrap.hasClass("has-text-field")&&!l.text.val()&&l.text.val(b.children(".item-title").text())},getUrlFromSelection:function(b){return b||(this.isMCE()?b=e.selection.getContent({format:"text"}):document.selection&&wpLink.range?b=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),b=a.trim(b),b&&j.test(b)?"mailto:"+b:b&&k.test(b)?b.replace(/&amp;|&#0?38;/gi,"&"):""},setDefaultValues:function(a){l.url.val(this.getUrlFromSelection(a)),l.search.val(""),wpLink.searchInternalLinks(),l.submit.val(b.save)},searchInternalLinks:function(){var a,b=l.search.val()||"";if(b.length>2){if(m.recent.hide(),m.search.show(),wpLink.lastSearch==b)return;wpLink.lastSearch=b,a=l.search.parent().find(".spinner").addClass("is-active"),m.search.change(b),m.search.ajax(function(){a.removeClass("is-active")})}else m.search.hide(),m.recent.show()},next:function(){m.search.next(),m.recent.next()},prev:function(){m.search.prev(),m.recent.prev()},keydown:function(a){var b,c;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(c=a.target.id,"wp-link-submit"!==c||a.shiftKey?"wp-link-close"===c&&a.shiftKey&&(l.submit.focus(),a.preventDefault()):(l.close.focus(),a.preventDefault())),a.shiftKey||38!==a.keyCode&&40!==a.keyCode||(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(b=38===a.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[b](),wpLink.keyInterval=setInterval(wpLink[b],wpLink.keySensitivity),a.preventDefault())},keyup:function(a){38!==a.keyCode&&40!==a.keyCode||(clearInterval(wpLink.keyInterval),a.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a}},g=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(g.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(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),e<0?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new h(a),this.element.scrollTop(0))},process:function(c,d){var e="",f=!0,g="",h=1==d.page;c?a.each(c,function(){g=f?"alternate":"",g+=this.title?"":" no-title",e+=g?'<li class="'+g+'">':"<li>",e+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',e+='<span class="item-title">',e+=this.title?this.title:b.noTitle,e+='</span><span class="item-info">'+this.info+"</span></li>",f=!f}):h&&(e+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+b.noMatchesFound+"</em></span></li>"),this.ul[h?"html":"append"](e)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.contentHeight.height()-wpLink.riverBottomThreshold||(a.waiting.addClass("is-active"),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),h=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(h.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(b){var c=this,d={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:l.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(window.ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery,window.wpLinkL10n,window.wp);
\ No newline at end of file
+/*! This file is auto-generated */
+!function(c,h,u){var r,e,t,n,i,l=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i,o=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,63}[^ "]*$/i,p={},a={},s="ontouchend"in document;function d(){return r?r.$('a[data-wplink-edit="true"]'):null}window.wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",modalOpen:!1,init:function(){p.wrap=c("#wp-link-wrap"),p.dialog=c("#wp-link"),p.backdrop=c("#wp-link-backdrop"),p.submit=c("#wp-link-submit"),p.close=c("#wp-link-close"),p.text=c("#wp-link-text"),p.url=c("#wp-link-url"),p.nonce=c("#_ajax_linking_nonce"),p.openInNewTab=c("#wp-link-target"),p.search=c("#wp-link-search"),a.search=new t(c("#search-results")),a.recent=new t(c("#most-recent-results")),a.elements=p.dialog.find(".query-results"),p.queryNotice=c("#query-notice-message"),p.queryNoticeTextDefault=p.queryNotice.find(".query-notice-default"),p.queryNoticeTextHint=p.queryNotice.find(".query-notice-hint"),p.dialog.keydown(wpLink.keydown),p.dialog.keyup(wpLink.keyup),p.submit.click(function(e){e.preventDefault(),wpLink.update()}),p.close.add(p.backdrop).add("#wp-link-cancel button").click(function(e){e.preventDefault(),wpLink.close()}),a.elements.on("river-select",wpLink.updateFields),p.search.on("focus.wplink",function(){p.queryNoticeTextDefault.hide(),p.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){p.queryNoticeTextDefault.show(),p.queryNoticeTextHint.addClass("screen-reader-text").hide()}),p.search.on("keyup input",function(){window.clearTimeout(e),e=window.setTimeout(function(){wpLink.searchInternalLinks()},500)}),p.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),p.url.on("blur",wpLink.correctURL)},correctURL:function(){var e=c.trim(p.url.val());e&&i!==e&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(e)&&(p.url.val("http://"+e),i=e)},open:function(e,t,n){var i,a=c(document.body);a.addClass("modal-open"),wpLink.modalOpen=!0,wpLink.range=null,e&&(window.wpActiveEditor=e),window.wpActiveEditor&&(this.textarea=c("#"+window.wpActiveEditor).get(0),void 0!==window.tinymce&&(a.append(p.backdrop,p.wrap),i=window.tinymce.get(window.wpActiveEditor),r=i&&!i.isHidden()?i:null),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),p.wrap.show(),p.backdrop.show(),wpLink.refresh(t,n),c(document).trigger("wplink-open",p.wrap))},isMCE:function(){return r&&!r.isHidden()},refresh:function(e,t){a.search.refresh(),a.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh(e,t):(p.wrap.hasClass("has-text-field")||p.wrap.addClass("has-text-field"),document.selection?document.selection.createRange().text:void 0!==this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(t=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||t||""),p.text.val(t),wpLink.setDefaultValues()),s?p.url.focus().blur():window.setTimeout(function(){p.url[0].select(),p.url.focus()}),a.recent.ul.children().length||a.recent.ajax(),i=p.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(e){var t,n,i,a=r.selection.getContent();if(/</.test(a)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(a)||-1===a.indexOf("href=")))return!1;if(e.length){if(!(n=e[0].childNodes)||!n.length)return!1;for(i=n.length-1;0<=i;i--)if(3!=(t=n[i]).nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(t))return!1}return!0},mceRefresh:function(e,t){var n,i,a=d(),s=this.hasSelectedText(a);a.length?(n=a.text(),i=a.attr("href"),c.trim(n)||(n=t||""),e&&(o.test(e)||l.test(e))&&(i=e),"_wp_link_placeholder"!==i?(p.url.val(i),p.openInNewTab.prop("checked","_blank"===a.attr("target")),p.submit.val(h.update)):this.setDefaultValues(n),e&&e!==i?p.search.val(e):p.search.val(""),window.setTimeout(function(){wpLink.searchInternalLinks()})):(n=r.selection.getContent({format:"text"})||t||"",this.setDefaultValues(n)),s?(p.text.val(n),p.wrap.addClass("has-text-field")):(p.text.val(""),p.wrap.removeClass("has-text-field"))},close:function(e){c(document.body).removeClass("modal-open"),wpLink.modalOpen=!1,"noReset"!==e&&(wpLink.isMCE()?(r.plugins.wplink&&r.plugins.wplink.close(),r.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),p.backdrop.hide(),p.wrap.hide(),i=!1,c(document).trigger("wplink-close",p.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:c.trim(p.url.val()),target:p.openInNewTab.prop("checked")?"_blank":null}},buildHtml:function(e){var t='<a href="'+e.href+'"';return e.target&&(t+=' rel="noopener" target="'+e.target+'"'),t+">"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,n,i,a,s,r,l=wpLink.textarea;if(l){e=wpLink.getAttrs(),t=p.text.val();var o=document.createElement("a");o.href=e.href,"javascript:"!==o.protocol&&"data:"!==o.protocol||(e.href=""),e.href&&(n=wpLink.buildHtml(e),document.selection&&wpLink.range?(l.focus(),wpLink.range.text=n+(t||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):void 0!==l.selectionStart&&(i=l.selectionStart,a=l.selectionEnd,s=i+(n=n+(r=t||l.value.substring(i,a))+"</a>").length,i!==a||r||(s-=4),l.value=l.value.substring(0,i)+n+l.value.substring(a,l.value.length),l.selectionStart=l.selectionEnd=s),wpLink.close(),l.focus(),c(l).trigger("change"),u.a11y.speak(h.linkInserted))}},mceUpdate:function(){var e,t,n,i=wpLink.getAttrs(),a=document.createElement("a");if(a.href=i.href,"javascript:"!==a.protocol&&"data:"!==a.protocol||(i.href=""),!i.href)return r.execCommand("unlink"),void wpLink.close();e=d(),r.undoManager.transact(function(){e.length||(r.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder","data-wp-temp-link":1}),e=r.$('a[data-wp-temp-link="1"]').removeAttr("data-wp-temp-link"),n=c.trim(e.text())),e.length?(p.wrap.hasClass("has-text-field")&&((t=p.text.val())?e.text(t):n||e.text(i.href)),i["data-wplink-edit"]=null,i["data-mce-href"]=i.href,e.attr(i)):r.execCommand("unlink")}),wpLink.close("noReset"),r.focus(),e.length&&(r.selection.select(e[0]),r.plugins.wplink&&r.plugins.wplink.checkLink(e[0])),r.nodeChanged(),u.a11y.speak(h.linkInserted)},updateFields:function(e,t){p.url.val(t.children(".item-permalink").val()),p.wrap.hasClass("has-text-field")&&!p.text.val()&&p.text.val(t.children(".item-title").text())},getUrlFromSelection:function(e){return e||(this.isMCE()?e=r.selection.getContent({format:"text"}):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=c.trim(e))&&l.test(e)?"mailto:"+e:e&&o.test(e)?e.replace(/&amp;|&#0?38;/gi,"&"):""},setDefaultValues:function(e){p.url.val(this.getUrlFromSelection(e)),p.search.val(""),wpLink.searchInternalLinks(),p.submit.val(h.save)},searchInternalLinks:function(){var e,t=p.search.val()||"",n=parseInt(h.minInputLength,10)||3;if(t.length>=n){if(a.recent.hide(),a.search.show(),wpLink.lastSearch==t)return;wpLink.lastSearch=t,e=p.search.parent().find(".spinner").addClass("is-active"),a.search.change(t),a.search.ajax(function(){e.removeClass("is-active")})}else a.search.hide(),a.recent.show()},next:function(){a.search.next(),a.recent.next()},prev:function(){a.search.prev(),a.recent.prev()},keydown:function(e){var t,n;27===e.keyCode?(wpLink.close(),e.stopImmediatePropagation()):9===e.keyCode&&("wp-link-submit"!==(n=e.target.id)||e.shiftKey?"wp-link-close"===n&&e.shiftKey&&(p.submit.focus(),e.preventDefault()):(p.close.focus(),e.preventDefault())),e.shiftKey||38!==e.keyCode&&40!==e.keyCode||document.activeElement&&("link-title-field"===document.activeElement.id||"url-field"===document.activeElement.id)||(t=38===e.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[t](),wpLink.keyInterval=setInterval(wpLink[t],wpLink.keySensitivity),e.preventDefault())},keyup:function(e){38!==e.keyCode&&40!==e.keyCode||(clearInterval(wpLink.keyInterval),e.preventDefault())},delayedCallback:function(e,t){var n,i,a,s;return t?(setTimeout(function(){if(i)return e.apply(s,a);n=!0},t),function(){if(n)return e.apply(this,arguments);a=arguments,s=this,i=!0}):e}},t=function(e,t){var n=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(),c("#wp-link .query-results, #wp-link #link-selector").scroll(function(){n.maybeLoad()}),e.on("click","li",function(e){n.select(c(this),e)})},c.extend(t.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 n,i,a,s;e.hasClass("unselectable")||e==this.selected||(this.deselect(),this.selected=e.addClass("selected"),n=e.outerHeight(),i=this.element.height(),a=e.position().top,s=this.element.scrollTop(),a<0?this.element.scrollTop(s+a):i<a+n&&this.element.scrollTop(s+a-i+n),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(){if(this.visible){var e=this.selected?this.selected.next("li"):c("li:not(.unselectable):first",this.element);e.length&&this.select(e)}},ajax:function(n){var i=this,e=1==this.query.page?0:wpLink.minRiverAJAXDuration,t=wpLink.delayedCallback(function(e,t){i.process(e,t),n&&n(e,t)},e);this.query.ajax(t)},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 n="",i=!0,a="",s=1==t.page;e?c.each(e,function(){a=i?"alternate":"",a+=this.title?"":" no-title",n+=a?'<li class="'+a+'">':"<li>",n+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',n+='<span class="item-title">',n+=this.title?this.title:h.noTitle,n+='</span><span class="item-info">'+this.info+"</span></li>",i=!i}):s&&(n+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+h.noMatchesFound+"</em></span></li>"),this.ul[s?"html":"append"](n)},maybeLoad:function(){var n=this,i=this.element,e=i.scrollTop()+i.height();!this.query.ready()||e<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var e=i.scrollTop(),t=e+i.height();!n.query.ready()||t<n.contentHeight.height()-wpLink.riverBottomThreshold||(n.waiting.addClass("is-active"),i.scrollTop(e+n.waiting.outerHeight()),n.ajax(function(){n.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),n=function(e){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=e},c.extend(n.prototype,{ready:function(){return!(this.querying||this.allLoaded)},ajax:function(t){var n=this,i={action:"wp-link-ajax",page:this.page,_ajax_linking_nonce:p.nonce.val()};this.search&&(i.search=this.search),this.querying=!0,c.post(window.ajaxurl,i,function(e){n.page++,n.querying=!1,n.allLoaded=!e,t(e,i)},"json")}}),c(document).ready(wpLink.init)}(jQuery,window.wpLinkL10n,window.wp);
\ No newline at end of file