WordPress.org

Plugin Directory

Changeset 1146169


Ignore:
Timestamp:
04/26/15 13:49:07 (3 years ago)
Author:
ffsantos92
Message:

v1.1.2

Location:
rel-nofollow-checkbox
Files:
7 added
4 edited

Legend:

Unmodified
Added
Removed
  • rel-nofollow-checkbox/trunk/readme.txt

    r1146137 r1146169  
    44Requires at least: 3.2 
    55Tested up to: 4.2 
    6 Stable tag: 1.1.1 
     6Stable tag: 1.1.2 
    77License: GPLv2 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    3434== Changelog == 
    3535 
     36= 1.1.2 = 
     37* Add an option for the link title attribute  
     38 
    3639= 1.1.1 = 
    3740* Minor bugs fixed 
  • rel-nofollow-checkbox/trunk/rel-nofollow-checkbox.php

    r1146137 r1146169  
    44 * Plugin URI:  https://github.com/ffsantos92/rel-nofollow-checkbox 
    55 * Description: This plugin adds a simple checkbox in the insert/edit link popup for including nofollow attribute. 
    6  * Version:     1.1.1 
     6 * Version:     1.1.2 
    77 * Author:      Fabio Santos 
    88 * Author URI:  http://www.fabiosantos.me. 
  • rel-nofollow-checkbox/trunk/wplink.js

    r1146137 r1146169  
    1 /* rel-nofollow-checkbox v1.1.1 | GPLv2 License | by fabiosantos.me */ 
     1/* rel-nofollow-checkbox v1.1.2 | GPLv2 License | by fabiosantos.me */ 
    22/* global ajaxurl, tinymce, wpLinkL10n, setUserSetting, wpActiveEditor */ 
    33var wpLink; 
     
    2828                .css('min-height', '310px'); 
    2929 
     30            var fsTitleHtml = '<div><label><span>Link Title</span><input id="fs-title" type="text"></label></div>'; 
     31            $(fsTitleHtml) 
     32                .insertAfter('wp-link-text-field'); 
     33 
    3034            inputs.wrap = $('#wp-link-wrap'); 
    3135            inputs.dialog = $('#wp-link'); 
     
    3943            inputs.nonce = $('#_ajax_linking_nonce'); 
    4044            inputs.fsRelNofollow = $('#rel-nofollow-checkbox'); 
     45            inputs.fsTitle = $('#fs-title'); 
    4146            inputs.openInNewTab = $('#wp-link-target'); 
    4247            inputs.search = $('#wp-link-search'); 
     
    246251                inputs.openInNewTab.prop('checked', '_blank' === editor.dom.getAttrib(linkNode, 'target')); 
    247252                inputs.fsRelNofollow.prop('checked', 'nofollow' === editor.dom.getAttrib(linkNode, 'rel')); 
     253                inputs.fsTitle.val(editor.dom.getAttrib(linkNode, 'title')); 
    248254                inputs.submit.val(wpLinkL10n.update); 
    249255            } else { 
     
    291297                href: $.trim(inputs.url.val()), 
    292298                target: inputs.openInNewTab.prop('checked') ? '_blank' : '', 
    293                 rel: inputs.fsRelNofollow.prop('checked') ? 'nofollow' : '' 
     299                rel: inputs.fsRelNofollow.prop('checked') ? 'nofollow' : '', 
     300                title: inputs.fsTitle.val(), 
    294301            }; 
    295302        }, 
  • rel-nofollow-checkbox/trunk/wplink.min.js

    r1146137 r1146169  
    1 /* rel-nofollow-checkbox v1.1.1 | GPLv2 License | by fabiosantos.me */ 
     1/* rel-nofollow-checkbox v1.1.2 | GPLv2 License | by fabiosantos.me */ 
    22/* global ajaxurl, tinymce, wpLinkL10n, setUserSetting, wpActiveEditor */ 
    3 var wpLink;!function(e){function t(){return n.dom.getParent(n.selection.getNode(),"a")}var n,i,s,a,r,l={},o={},c="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){function t(){var t=e.trim(l.url.val());t&&r!==t&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(t)&&(l.url.val("http://"+t),r=t)}var n='<div><label><span> </span><input type="checkbox" id="rel-nofollow-checkbox" /><strong> rel="nofollow"</strong></label></div>';e(n).insertAfter("#wp-link .link-target"),e("#wp-link-wrap").css("min-height","310px"),l.wrap=e("#wp-link-wrap"),l.dialog=e("#wp-link"),l.backdrop=e("#wp-link-backdrop"),l.submit=e("#wp-link-submit"),l.close=e("#wp-link-close"),l.text=e("#wp-link-text"),l.url=e("#wp-link-url"),l.nonce=e("#_ajax_linking_nonce"),l.fsRelNofollow=e("#rel-nofollow-checkbox"),l.openInNewTab=e("#wp-link-target"),l.search=e("#wp-link-search"),o.search=new s(e("#search-results")),o.recent=new s(e("#most-recent-results")),o.elements=l.dialog.find(".query-results"),l.queryNotice=e("#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()}),e("#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(i),i=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)}),l.url.on("paste",function(){setTimeout(t,0)}),l.url.on("blur",t)},open:function(t){var i;e(document.body).addClass("modal-open"),wpLink.range=null,t&&(window.wpActiveEditor=t),window.wpActiveEditor&&(this.textarea=e("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(i=tinymce.get(wpActiveEditor),n=i&&!i.isHidden()?i:null,n&&tinymce.isIE&&(n.windowManager.bookmark=n.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),l.wrap.show(),l.backdrop.show(),wpLink.refresh(),e(document).trigger("wplink-open",l.wrap))},isMCE:function(){return n&&!n.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||"":"undefined"!=typeof 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=n.selection.getContent();if(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1===t.indexOf("href=")))return!1;if(e){var i,s=e.childNodes;if(0===s.length)return!1;for(i=s.length-1;i>=0;i--)if(3!=s[i].nodeType)return!1}return!0},mceRefresh:function(){var e,t=n.selection.getNode(),i=n.dom.getParent(t,"a[href]"),s=this.hasSelectedText(i);i?(e=i.innerText||i.textContent,l.url.val(n.dom.getAttrib(i,"href")),l.openInNewTab.prop("checked","_blank"===n.dom.getAttrib(i,"target")),l.fsRelNofollow.prop("checked","nofollow"===n.dom.getAttrib(i,"rel")),l.submit.val(wpLinkL10n.update)):(e=n.selection.getContent({format:"text"}),this.setDefaultValues()),s?(l.text.val(e||""),l.wrap.addClass("has-text-field")):(l.text.val(""),l.wrap.removeClass("has-text-field"))},close:function(){e(document.body).removeClass("modal-open"),wpLink.isMCE()?n.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),l.backdrop.hide(),l.wrap.hide(),r=!1,e(document).trigger("wplink-close",l.wrap)},getAttrs:function(){return{href:e.trim(l.url.val()),target:l.openInNewTab.prop("checked")?"_blank":"",rel:l.fsRelNofollow.prop("checked")?"nofollow":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,n,i,s,a,r,o=wpLink.textarea;o&&(e=wpLink.getAttrs(),t=l.text.val(),e.href&&(n='<a href="'+e.href+'"',e.target&&(n+=' target="'+e.target+'"'),e.rel&&(n+=' rel="nofollow"'),n+=">",document.selection&&wpLink.range?(o.focus(),wpLink.range.text=n+(t||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof o.selectionStart&&(i=o.selectionStart,s=o.selectionEnd,r=t||o.value.substring(i,s),n=n+r+"</a>",a=i+n.length,i!==s||r||(a-=4),o.value=o.value.substring(0,i)+n+o.value.substring(s,o.value.length),o.selectionStart=o.selectionEnd=a),wpLink.close(),o.focus()))},mceUpdate:function(){var e,i,s=wpLink.getAttrs();return wpLink.close(),n.focus(),tinymce.isIE&&n.selection.moveToBookmark(n.windowManager.bookmark),s.href?(e=t(),i=l.text.val(),void(e?(i&&("innerText"in e?e.innerText=i:e.textContent=i),n.dom.setAttribs(e,s)):i?n.selection.setNode(n.dom.create("a",s,i)):n.execCommand("mceInsertLink",!1,s))):void n.execCommand("unlink")},updateFields:function(e,t){l.url.val(t.children(".item-permalink").val())},setDefaultValues:function(){var e,t=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,i=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?e=n.selection.getContent():document.selection&&wpLink.range?e=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(e=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),l.url.val(e&&t.test(e)?"mailto:"+e:e&&i.test(e)?e.replace(/&amp;|&#0?38;/gi,"&"):""),l.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var t,n=e(this),i=n.val();if(i.length>2){if(o.recent.hide(),o.search.show(),wpLink.lastSearch==i)return;wpLink.lastSearch=i,t=n.parent().find(".spinner").addClass("is-active"),o.search.change(i),o.search.ajax(function(){t.removeClass("is-active")})}else o.search.hide(),o.recent.show()},next:function(){o.search.next(),o.recent.next()},prev:function(){o.search.prev(),o.recent.prev()},keydown:function(t){var n,i,s=e.ui.keyCode;s.ESCAPE===t.keyCode?(wpLink.close(),t.stopImmediatePropagation()):s.TAB===t.keyCode&&(i=t.target.id,"wp-link-submit"!==i||t.shiftKey?"wp-link-close"===i&&t.shiftKey&&(l.submit.focus(),t.preventDefault()):(l.close.focus(),t.preventDefault())),(t.keyCode===s.UP||t.keyCode===s.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(n=t.keyCode===s.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[n](),wpLink.keyInterval=setInterval(wpLink[n],wpLink.keySensitivity),t.preventDefault())},keyup:function(t){var n=e.ui.keyCode;(t.which===n.UP||t.which===n.DOWN)&&(clearInterval(wpLink.keyInterval),t.preventDefault())},delayedCallback:function(e,t){var n,i,s,a;return t?(setTimeout(function(){return i?e.apply(a,s):void(n=!0)},t),function(){return n?e.apply(this,arguments):(s=arguments,a=this,void(i=!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()}},s=function(t,n){var i=this;this.element=t,this.ul=t.children("ul"),this.contentHeight=t.children("#link-selector-height"),this.waiting=t.find(".river-waiting"),this.change(n),this.refresh(),e("#wp-link .query-results, #wp-link #link-selector").scroll(function(){i.maybeLoad()}),t.on("click","li",function(t){i.select(e(this),t)})},e.extend(s.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,s,a;e.hasClass("unselectable")||e==this.selected||(this.deselect(),this.selected=e.addClass("selected"),n=e.outerHeight(),i=this.element.height(),s=e.position().top,a=this.element.scrollTop(),0>s?this.element.scrollTop(a+s):s+n>i&&this.element.scrollTop(a+s-i+n),this.element.trigger("river-select",[e,t,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var e;this.selected&&(e=this.selected.prev("li"),e.length&&this.select(e))}},next:function(){if(this.visible){var t=this.selected?this.selected.next("li"):e("li:not(.unselectable):first",this.element);t.length&&this.select(t)}},ajax:function(e){var t=this,n=1==this.query.page?0:wpLink.minRiverAJAXDuration,i=wpLink.delayedCallback(function(n,i){t.process(n,i),e&&e(n,i)},n);this.query.ajax(i)},change:function(e){this.query&&this._search==e||(this._search=e,this.query=new a(e),this.element.scrollTop(0))},process:function(t,n){var i="",s=!0,a="",r=1==n.page;t?e.each(t,function(){a=s?"alternate":"",a+=this.title?"":" no-title",i+=a?'<li class="'+a+'">':"<li>",i+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',i+='<span class="item-title">',i+=this.title?this.title:wpLinkL10n.noTitle,i+='</span><span class="item-info">'+this.info+"</span></li>",s=!s}):r&&(i+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[r?"html":"append"](i)},maybeLoad:function(){var e=this,t=this.element,n=t.scrollTop()+t.height();!this.query.ready()||n<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var n=t.scrollTop(),i=n+t.height();!e.query.ready()||i<e.contentHeight.height()-wpLink.riverBottomThreshold||(e.waiting.addClass("is-active"),t.scrollTop(n+e.waiting.outerHeight()),e.ajax(function(){e.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),a=function(e){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=e},e.extend(a.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:l.nonce.val()};this.search&&(i.search=this.search),this.querying=!0,e.post(ajaxurl,i,function(e){n.page++,n.querying=!1,n.allLoaded=!e,t(e,i)},"json")}}),e(document).ready(wpLink.init)}(jQuery); 
     3var wpLink;!function(e){function t(){return i.dom.getParent(i.selection.getNode(),"a")}var i,n,s,a,l,r={},o={},c="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){function t(){var t=e.trim(r.url.val());t&&l!==t&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(t)&&(r.url.val("http://"+t),l=t)}var i='<div><label><span> </span><input type="checkbox" id="rel-nofollow-checkbox" /><strong> rel="nofollow"</strong></label></div>';e(i).insertAfter("#wp-link .link-target"),e("#wp-link-wrap").css("min-height","310px");var a='<div><label><span>Link Title</span><input id="fs-title" type="text"></label></div>';e(a).insertAfter("wp-link-text-field"),r.wrap=e("#wp-link-wrap"),r.dialog=e("#wp-link"),r.backdrop=e("#wp-link-backdrop"),r.submit=e("#wp-link-submit"),r.close=e("#wp-link-close"),r.text=e("#wp-link-text"),r.url=e("#wp-link-url"),r.nonce=e("#_ajax_linking_nonce"),r.fsRelNofollow=e("#rel-nofollow-checkbox"),r.fsTitle=e("#fs-title"),r.openInNewTab=e("#wp-link-target"),r.search=e("#wp-link-search"),o.search=new s(e("#search-results")),o.recent=new s(e("#most-recent-results")),o.elements=r.dialog.find(".query-results"),r.queryNotice=e("#query-notice-message"),r.queryNoticeTextDefault=r.queryNotice.find(".query-notice-default"),r.queryNoticeTextHint=r.queryNotice.find(".query-notice-hint"),r.dialog.keydown(wpLink.keydown),r.dialog.keyup(wpLink.keyup),r.submit.click(function(e){e.preventDefault(),wpLink.update()}),r.close.add(r.backdrop).add("#wp-link-cancel a").click(function(e){e.preventDefault(),wpLink.close()}),e("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),o.elements.on("river-select",wpLink.updateFields),r.search.on("focus.wplink",function(){r.queryNoticeTextDefault.hide(),r.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){r.queryNoticeTextDefault.show(),r.queryNoticeTextHint.addClass("screen-reader-text").hide()}),r.search.keyup(function(){var e=this;window.clearTimeout(n),n=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)}),r.url.on("paste",function(){setTimeout(t,0)}),r.url.on("blur",t)},open:function(t){var n;e(document.body).addClass("modal-open"),wpLink.range=null,t&&(window.wpActiveEditor=t),window.wpActiveEditor&&(this.textarea=e("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(n=tinymce.get(wpActiveEditor),i=n&&!n.isHidden()?n:null,i&&tinymce.isIE&&(i.windowManager.bookmark=i.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),r.wrap.show(),r.backdrop.show(),wpLink.refresh(),e(document).trigger("wplink-open",r.wrap))},isMCE:function(){return i&&!i.isHidden()},refresh:function(){var e="";o.search.refresh(),o.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():(r.wrap.hasClass("has-text-field")||r.wrap.addClass("has-text-field"),document.selection?e=document.selection.createRange().text||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(e=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||""),r.text.val(e),wpLink.setDefaultValues()),c?r.url.focus().blur():r.url.focus()[0].select(),o.recent.ul.children().length||o.recent.ajax(),l=r.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(e){var t=i.selection.getContent();if(/</.test(t)&&(!/^<a [^>]+>[^<]+<\/a>$/.test(t)||-1===t.indexOf("href=")))return!1;if(e){var n,s=e.childNodes;if(0===s.length)return!1;for(n=s.length-1;n>=0;n--)if(3!=s[n].nodeType)return!1}return!0},mceRefresh:function(){var e,t=i.selection.getNode(),n=i.dom.getParent(t,"a[href]"),s=this.hasSelectedText(n);n?(e=n.innerText||n.textContent,r.url.val(i.dom.getAttrib(n,"href")),r.openInNewTab.prop("checked","_blank"===i.dom.getAttrib(n,"target")),r.fsRelNofollow.prop("checked","nofollow"===i.dom.getAttrib(n,"rel")),r.fsTitle.val(i.dom.getAttrib(n,"title")),r.submit.val(wpLinkL10n.update)):(e=i.selection.getContent({format:"text"}),this.setDefaultValues()),s?(r.text.val(e||""),r.wrap.addClass("has-text-field")):(r.text.val(""),r.wrap.removeClass("has-text-field"))},close:function(){e(document.body).removeClass("modal-open"),wpLink.isMCE()?i.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),r.backdrop.hide(),r.wrap.hide(),l=!1,e(document).trigger("wplink-close",r.wrap)},getAttrs:function(){return{href:e.trim(r.url.val()),target:r.openInNewTab.prop("checked")?"_blank":"",rel:r.fsRelNofollow.prop("checked")?"nofollow":"",title:r.fsTitle.val()}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,s,a,l,o=wpLink.textarea;o&&(e=wpLink.getAttrs(),t=r.text.val(),e.href&&(i='<a href="'+e.href+'"',e.target&&(i+=' target="'+e.target+'"'),e.rel&&(i+=' rel="nofollow"'),i+=">",document.selection&&wpLink.range?(o.focus(),wpLink.range.text=i+(t||wpLink.range.text)+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof o.selectionStart&&(n=o.selectionStart,s=o.selectionEnd,l=t||o.value.substring(n,s),i=i+l+"</a>",a=n+i.length,n!==s||l||(a-=4),o.value=o.value.substring(0,n)+i+o.value.substring(s,o.value.length),o.selectionStart=o.selectionEnd=a),wpLink.close(),o.focus()))},mceUpdate:function(){var e,n,s=wpLink.getAttrs();return wpLink.close(),i.focus(),tinymce.isIE&&i.selection.moveToBookmark(i.windowManager.bookmark),s.href?(e=t(),n=r.text.val(),void(e?(n&&("innerText"in e?e.innerText=n:e.textContent=n),i.dom.setAttribs(e,s)):n?i.selection.setNode(i.dom.create("a",s,n)):i.execCommand("mceInsertLink",!1,s))):void i.execCommand("unlink")},updateFields:function(e,t){r.url.val(t.children(".item-permalink").val())},setDefaultValues:function(){var e,t=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i,n=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i;this.isMCE()?e=i.selection.getContent():document.selection&&wpLink.range?e=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(e=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)),r.url.val(e&&t.test(e)?"mailto:"+e:e&&n.test(e)?e.replace(/&amp;|&#0?38;/gi,"&"):""),r.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var t,i=e(this),n=i.val();if(n.length>2){if(o.recent.hide(),o.search.show(),wpLink.lastSearch==n)return;wpLink.lastSearch=n,t=i.parent().find(".spinner").addClass("is-active"),o.search.change(n),o.search.ajax(function(){t.removeClass("is-active")})}else o.search.hide(),o.recent.show()},next:function(){o.search.next(),o.recent.next()},prev:function(){o.search.prev(),o.recent.prev()},keydown:function(t){var i,n,s=e.ui.keyCode;s.ESCAPE===t.keyCode?(wpLink.close(),t.stopImmediatePropagation()):s.TAB===t.keyCode&&(n=t.target.id,"wp-link-submit"!==n||t.shiftKey?"wp-link-close"===n&&t.shiftKey&&(r.submit.focus(),t.preventDefault()):(r.close.focus(),t.preventDefault())),(t.keyCode===s.UP||t.keyCode===s.DOWN)&&(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(i=t.keyCode===s.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[i](),wpLink.keyInterval=setInterval(wpLink[i],wpLink.keySensitivity),t.preventDefault())},keyup:function(t){var i=e.ui.keyCode;(t.which===i.UP||t.which===i.DOWN)&&(clearInterval(wpLink.keyInterval),t.preventDefault())},delayedCallback:function(e,t){var i,n,s,a;return t?(setTimeout(function(){return n?e.apply(a,s):void(i=!0)},t),function(){return i?e.apply(this,arguments):(s=arguments,a=this,void(n=!0))}):e},toggleInternalLinking:function(e){var t=r.wrap.hasClass("search-panel-visible");r.wrap.toggleClass("search-panel-visible",!t),setUserSetting("wplink",t?"0":"1"),r[t?"url":"search"].focus(),e.preventDefault()}},s=function(t,i){var n=this;this.element=t,this.ul=t.children("ul"),this.contentHeight=t.children("#link-selector-height"),this.waiting=t.find(".river-waiting"),this.change(i),this.refresh(),e("#wp-link .query-results, #wp-link #link-selector").scroll(function(){n.maybeLoad()}),t.on("click","li",function(t){n.select(e(this),t)})},e.extend(s.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,s,a;e.hasClass("unselectable")||e==this.selected||(this.deselect(),this.selected=e.addClass("selected"),i=e.outerHeight(),n=this.element.height(),s=e.position().top,a=this.element.scrollTop(),0>s?this.element.scrollTop(a+s):s+i>n&&this.element.scrollTop(a+s-n+i),this.element.trigger("river-select",[e,t,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var e;this.selected&&(e=this.selected.prev("li"),e.length&&this.select(e))}},next:function(){if(this.visible){var t=this.selected?this.selected.next("li"):e("li:not(.unselectable):first",this.element);t.length&&this.select(t)}},ajax:function(e){var t=this,i=1==this.query.page?0:wpLink.minRiverAJAXDuration,n=wpLink.delayedCallback(function(i,n){t.process(i,n),e&&e(i,n)},i);this.query.ajax(n)},change:function(e){this.query&&this._search==e||(this._search=e,this.query=new a(e),this.element.scrollTop(0))},process:function(t,i){var n="",s=!0,a="",l=1==i.page;t?e.each(t,function(){a=s?"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:wpLinkL10n.noTitle,n+='</span><span class="item-info">'+this.info+"</span></li>",s=!s}):l&&(n+='<li class="unselectable no-matches-found"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[l?"html":"append"](n)},maybeLoad:function(){var e=this,t=this.element,i=t.scrollTop()+t.height();!this.query.ready()||i<this.contentHeight.height()-wpLink.riverBottomThreshold||setTimeout(function(){var i=t.scrollTop(),n=i+t.height();!e.query.ready()||n<e.contentHeight.height()-wpLink.riverBottomThreshold||(e.waiting.addClass("is-active"),t.scrollTop(i+e.waiting.outerHeight()),e.ajax(function(){e.waiting.removeClass("is-active")}))},wpLink.timeToTriggerRiver)}}),a=function(e){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=e},e.extend(a.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:r.nonce.val()};this.search&&(n.search=this.search),this.querying=!0,e.post(ajaxurl,n,function(e){i.page++,i.querying=!1,i.allLoaded=!e,t(e,n)},"json")}}),e(document).ready(wpLink.init)}(jQuery); 
Note: See TracChangeset for help on using the changeset viewer.