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