]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/wplink.min.js
WordPress 3.9
[autoinstalls/wordpress.git] / wp-includes / js / wplink.min.js
index 5e0f06dd223bd8dabeec89c104ac5eaf4dfb128f..5aaeeef1965260f181cc7f13047eab60f941f058 100644 (file)
@@ -1 +1 @@
-var wpLink;!function(a){var b,c,d,e={},f={};wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){e.dialog=a("#wp-link"),e.submit=a("#wp-link-submit"),e.url=a("#url-field"),e.nonce=a("#_ajax_linking_nonce"),e.title=a("#link-title-field"),e.openInNewTab=a("#link-target-checkbox"),e.search=a("#search-field"),f.search=new c(a("#search-results")),f.recent=new c(a("#most-recent-results")),f.elements=a(".query-results",e.dialog),e.dialog.keydown(wpLink.keydown),e.dialog.keyup(wpLink.keyup),e.submit.click(function(a){a.preventDefault(),wpLink.update()}),a("#wp-link-cancel").click(function(a){a.preventDefault(),wpLink.close()}),a("#internal-toggle").click(wpLink.toggleInternalLinking),f.elements.bind("river-select",wpLink.updateFields),e.search.keyup(wpLink.searchInternalLinks),e.dialog.bind("wpdialogrefresh",wpLink.refresh),e.dialog.bind("wpdialogbeforeopen",wpLink.beforeOpen),e.dialog.bind("wpdialogclose",wpLink.onClose)},beforeOpen:function(){wpLink.range=null,!wpLink.isMCE()&&document.selection&&(wpLink.textarea.focus(),wpLink.range=document.selection.createRange())},open:function(){wpActiveEditor&&(this.textarea=a("#"+wpActiveEditor).get(0),e.dialog.data("wpdialog")||e.dialog.wpdialog({title:wpLinkL10n.title,width:480,height:"auto",modal:!0,dialogClass:"wp-dialog"}),e.dialog.wpdialog("open"))},isMCE:function(){return tinyMCEPopup&&(b=tinyMCEPopup.editor)&&!b.isHidden()},refresh:function(){f.search.refresh(),f.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),e.url.focus()[0].select(),f.recent.ul.children().length||f.recent.ajax()},mceRefresh:function(){var a;b=tinyMCEPopup.editor,tinyMCEPopup.restoreSelection(),(a=b.dom.getParent(b.selection.getNode(),"A"))?(e.url.val(b.dom.getAttrib(a,"href")),e.title.val(b.dom.getAttrib(a,"title")),e.openInNewTab.prop("checked","_blank"==b.dom.getAttrib(a,"target")),e.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){wpLink.isMCE()?tinyMCEPopup.close():e.dialog.wpdialog("close")},onClose:function(){wpLink.isMCE()||(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))},getAttrs:function(){return{href:e.url.val(),title:e.title.val(),target:e.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g=wpLink.textarea;g&&(a=wpLink.getAttrs(),a.href&&"http://"!=a.href&&(b='<a href="'+a.href+'"',a.title&&(b+=' title="'+a.title+'"'),a.target&&(b+=' target="'+a.target+'"'),b+=">",document.selection&&wpLink.range?(g.focus(),wpLink.range.text=b+wpLink.range.text+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof g.selectionStart&&(c=g.selectionStart,d=g.selectionEnd,f=g.value.substring(c,d),b=b+f+"</a>",e=c+b.length,c==d&&(e-="</a>".length),g.value=g.value.substring(0,c)+b+g.value.substring(d,g.value.length),g.selectionStart=g.selectionEnd=e),wpLink.close(),g.focus()))},mceUpdate:function(){var b,c,d=tinyMCEPopup.editor,e=wpLink.getAttrs();return tinyMCEPopup.restoreSelection(),b=d.dom.getParent(d.selection.getNode(),"A"),e.href&&"http://"!=e.href?(null==b?(d.getDoc().execCommand("unlink",!1,null),tinyMCEPopup.execCommand("mceInsertLink",!1,"#mce_temp_url#",{skip_undo:1}),tinymce.each(d.dom.select("a"),function(a){"#mce_temp_url#"==d.dom.getAttrib(a,"href")&&(b=a,d.dom.setAttribs(b,e))}),tinymce.isWebKit&&"#mce_temp_url#"==a(b).text()&&(d.dom.remove(b),b=null)):d.dom.setAttribs(b,e),!b||1==b.childNodes.length&&"IMG"==b.firstChild.nodeName||(d.selection.select(b),d.selection.collapse(0),tinyMCEPopup.storeSelection()),d.execCommand("mceEndUndoLevel"),wpLink.close(),d.focus(),void 0):(b&&(c=d.selection.getBookmark(),d.dom.remove(b,1),d.selection.moveToBookmark(c),tinyMCEPopup.execCommand("mceEndUndoLevel"),wpLink.close()),void 0)},updateFields:function(a,b,c){e.url.val(b.children(".item-permalink").val()),e.title.val(b.hasClass("no-title")?"":b.children(".item-title").text()),c&&"click"==c.type&&e.url.focus()},setDefaultValues:function(){e.url.val("http://"),e.title.val(""),e.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>2){if(f.recent.hide(),f.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").show(),f.search.change(d),f.search.ajax(function(){b.hide()})}else f.search.hide(),f.recent.show()},next:function(){f.search.next(),f.recent.next()},prev:function(){f.search.prev(),f.recent.prev()},keydown:function(b){var c,d=a.ui.keyCode;(b.which===d.UP||b.which===d.DOWN)&&(c=b.which===d.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;return b.which===c.ESCAPE?(b.stopImmediatePropagation(),a(document).triggerHandler("wp_CloseOnEscape",[{event:b,what:"wplink",cb:wpLink.close}])||wpLink.close(),!1):((b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.preventDefault()),void 0)},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):(c=!0,void 0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,d=!0,void 0)}):a},toggleInternalLinking:function(b){var c=a("#search-panel"),d=e.dialog.wpdialog("widget"),f=!c.is(":visible"),g=a(window);a(this).toggleClass("toggle-arrow-active",f),e.dialog.height("auto"),c.slideToggle(300,function(){setUserSetting("wplink",f?"1":"0"),e[f?"search":"url"].focus();var a=g.scrollTop(),b=d.offset().top,c=b+d.outerHeight(),h=c-g.height();h>a&&d.animate({top:b>h?b-h:a},200)}),b.preventDefault()}},c=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),b.scroll(function(){d.maybeLoad()}),b.delegate("li","click",function(b){d.select(a(this),b)})},a.extend(c.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(),0>e?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 d(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c<this.ul.height()-wpLink.riverBottomThreshold||setTimeout(function(){var c=b.scrollTop(),d=c+b.height();!a.query.ready()||d<a.ul.height()-wpLink.riverBottomThreshold||(a.waiting.show(),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.hide()}))},wpLink.timeToTriggerRiver)}}),d=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(d.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:e.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
\ No newline at end of file
+var wpLink;!function(a){var b,c,d,e,f={},g={};wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){f.wrap=a("#wp-link-wrap"),f.dialog=a("#wp-link"),f.backdrop=a("#wp-link-backdrop"),f.submit=a("#wp-link-submit"),f.close=a("#wp-link-close"),f.url=a("#url-field"),f.nonce=a("#_ajax_linking_nonce"),f.title=a("#link-title-field"),f.openInNewTab=a("#link-target-checkbox"),f.search=a("#search-field"),g.search=new d(a("#search-results")),g.recent=new d(a("#most-recent-results")),g.elements=f.dialog.find(".query-results"),f.dialog.keydown(wpLink.keydown),f.dialog.keyup(wpLink.keyup),f.submit.click(function(a){a.preventDefault(),wpLink.update()}),f.close.add(f.backdrop).add("#wp-link-cancel a").click(function(a){a.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").click(wpLink.toggleInternalLinking),g.elements.on("river-select",wpLink.updateFields),f.search.keyup(function(){var a=this;window.clearTimeout(c),c=window.setTimeout(function(){wpLink.searchInternalLinks.call(a)},500)})},open:function(c){var d;wpLink.range=null,c&&(window.wpActiveEditor=c),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(d=tinymce.get(wpActiveEditor),b=d&&!d.isHidden()?d:null,b&&tinymce.isIE&&(b.windowManager.bookmark=b.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),f.wrap.show(),f.backdrop.show(),wpLink.refresh())},isMCE:function(){return b&&!b.isHidden()},refresh:function(){g.search.refresh(),g.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),f.url.focus()[0].select(),g.recent.ul.children().length||g.recent.ajax()},mceRefresh:function(){var a;(a=b.dom.getParent(b.selection.getNode(),"A"))?(f.url.val(b.dom.getAttrib(a,"href")),f.title.val(b.dom.getAttrib(a,"title")),f.openInNewTab.prop("checked","_blank"===b.dom.getAttrib(a,"target")),f.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){wpLink.isMCE()?b.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),f.backdrop.hide(),f.wrap.hide()},getAttrs:function(){return{href:f.url.val(),title:f.title.val(),target:f.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var a,b,c,d,e,f,g,h=wpLink.textarea;h&&(a=wpLink.getAttrs(),a.href&&"http://"!=a.href&&(b='<a href="'+a.href+'"',a.title&&(f=a.title.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),b+=' title="'+f+'"'),a.target&&(b+=' target="'+a.target+'"'),b+=">",document.selection&&wpLink.range?(h.focus(),wpLink.range.text=b+wpLink.range.text+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof h.selectionStart&&(c=h.selectionStart,d=h.selectionEnd,g=h.value.substring(c,d),b=b+g+"</a>",e=c+b.length,c==d&&(e-="</a>".length),h.value=h.value.substring(0,c)+b+h.value.substring(d,h.value.length),h.selectionStart=h.selectionEnd=e),wpLink.close(),h.focus()))},mceUpdate:function(){var a,c=wpLink.getAttrs();return wpLink.close(),b.focus(),tinymce.isIE&&b.selection.moveToBookmark(b.windowManager.bookmark),a=b.dom.getParent(b.selection.getNode(),"a[href]"),c.href&&"http://"!=c.href?(a?b.dom.setAttribs(a,c):b.execCommand("mceInsertLink",!1,c),void b.selection.collapse()):void b.execCommand("unlink")},updateFields:function(a,b,c){f.url.val(b.children(".item-permalink").val()),f.title.val(b.hasClass("no-title")?"":b.children(".item-title").text()),c&&"click"==c.type&&f.url.focus()},setDefaultValues:function(){f.url.val("http://"),f.title.val(""),f.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var b,c=a(this),d=c.val();if(d.length>2){if(g.recent.hide(),g.search.show(),wpLink.lastSearch==d)return;wpLink.lastSearch=d,b=c.parent().find(".spinner").show(),g.search.change(d),g.search.ajax(function(){b.hide()})}else g.search.hide(),g.recent.show()},next:function(){g.search.next(),g.recent.next()},prev:function(){g.search.prev(),g.recent.prev()},keydown:function(b){var c,d,e=a.ui.keyCode;e.ESCAPE===b.keyCode?(wpLink.close(),b.stopImmediatePropagation()):e.TAB===b.keyCode&&(d=b.target.id,"wp-link-submit"!==d||b.shiftKey?"wp-link-close"===d&&b.shiftKey&&(f.submit.focus(),b.preventDefault()):(f.close.focus(),b.preventDefault())),(b.keyCode===e.UP||b.keyCode===e.DOWN)&&(c=b.keyCode===e.UP?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[c](),wpLink.keyInterval=setInterval(wpLink[c],wpLink.keySensitivity),b.preventDefault())},keyup:function(b){var c=a.ui.keyCode;(b.which===c.UP||b.which===c.DOWN)&&(clearInterval(wpLink.keyInterval),b.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},toggleInternalLinking:function(){var a=f.wrap.hasClass("search-panel-visible");f.wrap.toggleClass("search-panel-visible",!a),setUserSetting("wplink",a?"0":"1"),f[a?"url":"search"].focus()}},d=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(d.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(),0>e?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 e(a),this.element.scrollTop(0))},process:function(b,c){var d="",e=!0,f="",g=1==c.page;b?a.each(b,function(){f=e?"alternate":"",f+=this.title?"":" no-title",d+=f?'<li class="'+f+'">':"<li>",d+='<input type="hidden" class="item-permalink" value="'+this.permalink+'" />',d+='<span class="item-title">',d+=this.title?this.title:wpLinkL10n.noTitle,d+='</span><span class="item-info">'+this.info+"</span></li>",e=!e}):g&&(d+='<li class="unselectable"><span class="item-title"><em>'+wpLinkL10n.noMatchesFound+"</em></span></li>"),this.ul[g?"html":"append"](d)},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.show(),b.scrollTop(c+a.waiting.outerHeight()),a.ajax(function(){a.waiting.hide()}))},wpLink.timeToTriggerRiver)}}),e=function(a){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=a},a.extend(e.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:f.nonce.val()};this.search&&(d.search=this.search),this.querying=!0,a.post(ajaxurl,d,function(a){c.page++,c.querying=!1,c.allLoaded=!a,b(a,d)},"json")}}),a(document).ready(wpLink.init)}(jQuery);
\ No newline at end of file