mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-14 06:36:47 +01:00
0ae050a6c6
This updates the 3.9 branch to support the latest LTS version of NodeJS (currently 14.x), allowing the same version to be used across all WordPress branches that receive security updates as a courtesy. Because older branches use (really) old versions of NodeJS, the local Docker environment cannot be backported since the needed dependencies will not run on these older versions (see #48301). This also blocks the ability to move automated testing over to GitHub Actions (see #50401). This change also introduces a `packager-lock.json` file to the branch. In addition to backporting the package updates that happened after branching 3.9, dependencies that were removed in future releases have also been updated to their latest versions. Props desrosj, dd32, netweb, jorbin. Merges [28695,28796,28821,29270,29505,29858-30059,30061-30063,30066-30067,31425,31504,31557,31648-31650,32356-32357,32988,33726,35363,35513,35521,35538-35541,35859,36861-36865,37017,37019,37020,37212,37612,38111,39110,39113,39115-39117,39478,41835,42460-42461,42463,42887,43320,43323,43977,44219,44233,45321,45765,46404,46408-46409,47404,47867,47872-47873,48705,49636,49933,49937,49939,50126,50176,50185] to the 3.9 branch. See #52341. Built from https://develop.svn.wordpress.org/branches/3.9@50220 git-svn-id: http://core.svn.wordpress.org/branches/3.9@49886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
8.1 KiB
JavaScript
1 line
8.1 KiB
JavaScript
var wpLink;!function(a){var n,t,e,i,s={},l={};wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",init:function(){s.wrap=a("#wp-link-wrap"),s.dialog=a("#wp-link"),s.backdrop=a("#wp-link-backdrop"),s.submit=a("#wp-link-submit"),s.close=a("#wp-link-close"),s.url=a("#url-field"),s.nonce=a("#_ajax_linking_nonce"),s.title=a("#link-title-field"),s.openInNewTab=a("#link-target-checkbox"),s.search=a("#search-field"),l.search=new e(a("#search-results")),l.recent=new e(a("#most-recent-results")),l.elements=s.dialog.find(".query-results"),s.dialog.keydown(wpLink.keydown),s.dialog.keyup(wpLink.keyup),s.submit.click(function(e){e.preventDefault(),wpLink.update()}),s.close.add(s.backdrop).add("#wp-link-cancel a").click(function(e){e.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").click(wpLink.toggleInternalLinking),l.elements.on("river-select",wpLink.updateFields),s.search.keyup(function(){var e=this;window.clearTimeout(t),t=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)})},open:function(e){wpLink.range=null,e&&(window.wpActiveEditor=e),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof tinymce&&(e=tinymce.get(wpActiveEditor),(n=e&&!e.isHidden()?e:null)&&tinymce.isIE&&(n.windowManager.bookmark=n.selection.getBookmark())),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),s.wrap.show(),s.backdrop.show(),wpLink.refresh())},isMCE:function(){return n&&!n.isHidden()},refresh:function(){l.search.refresh(),l.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),s.url.focus()[0].select(),l.recent.ul.children().length||l.recent.ajax()},mceRefresh:function(){var e;(e=n.dom.getParent(n.selection.getNode(),"A"))?(s.url.val(n.dom.getAttrib(e,"href")),s.title.val(n.dom.getAttrib(e,"title")),s.openInNewTab.prop("checked","_blank"===n.dom.getAttrib(e,"target")),s.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){wpLink.isMCE()?n.focus():(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select())),s.backdrop.hide(),s.wrap.hide()},getAttrs:function(){return{href:s.url.val(),title:s.title.val(),target:s.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,s=wpLink.textarea;s&&(i=wpLink.getAttrs(),(n=document.createElement("a")).href=i.href,"javascript:"!==n.protocol&&"data:"!==n.protocol||(i.href=""),i.href&&"http://"!=i.href&&(e='<a href="'+i.href+'"',i.title&&(e+=' title="'+i.title.replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")+'"'),i.target&&(e+=' rel="noopener" target="'+i.target+'"'),e+=">",document.selection&&wpLink.range?(s.focus(),wpLink.range.text=e+wpLink.range.text+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):void 0!==s.selectionStart&&(t=s.selectionStart,n=s.selectionEnd,i=t+(e=e+s.value.substring(t,n)+"</a>").length,t==n&&(i-="</a>".length),s.value=s.value.substring(0,t)+e+s.value.substring(n,s.value.length),s.selectionStart=s.selectionEnd=i),wpLink.close(),s.focus()))},mceUpdate:function(){var e,t=wpLink.getAttrs();wpLink.close(),n.focus(),tinymce.isIE&&n.selection.moveToBookmark(n.windowManager.bookmark),e=n.dom.getParent(n.selection.getNode(),"a[href]");var i=document.createElement("a");i.href=t.href,"javascript:"!==i.protocol&&"data:"!==i.protocol||(t.href=""),t.href&&"http://"!=t.href?(e?n.dom.setAttribs(e,t):n.execCommand("mceInsertLink",!1,t),n.selection.collapse()):n.execCommand("unlink")},updateFields:function(e,t,i){s.url.val(t.children(".item-permalink").val()),s.title.val(t.hasClass("no-title")?"":t.children(".item-title").text()),i&&"click"==i.type&&s.url.focus()},setDefaultValues:function(){s.url.val("http://"),s.title.val(""),s.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var e,t=a(this),i=t.val();2<i.length?(l.recent.hide(),l.search.show(),wpLink.lastSearch!=i&&(wpLink.lastSearch=i,e=t.parent().find(".spinner").show(),l.search.change(i),l.search.ajax(function(){e.hide()}))):(l.search.hide(),l.recent.show())},next:function(){l.search.next(),l.recent.next()},prev:function(){l.search.prev(),l.recent.prev()},keydown:function(e){var t,i=a.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&&(s.submit.focus(),e.preventDefault()):(s.close.focus(),e.preventDefault())),e.keyCode!==i.UP&&e.keyCode!==i.DOWN||(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=a.ui.keyCode;e.which!==t.UP&&e.which!==t.DOWN||(clearInterval(wpLink.keyInterval),e.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(){if(i)return e.apply(this,arguments);s=arguments,a=this,n=!0}):e},toggleInternalLinking:function(){var e=s.wrap.hasClass("search-panel-visible");s.wrap.toggleClass("search-panel-visible",!e),setUserSetting("wplink",e?"0":"1"),s[e?"url":"search"].focus()}},e=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(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){i.maybeLoad()}),e.on("click","li",function(e){i.select(a(this),e)})},a.extend(e.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(),s<0?this.element.scrollTop(a+s):n<s+i&&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(){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"):a("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 i(e),this.element.scrollTop(0))},process:function(e,t){var i,n="",s=!0,t=1==t.page;e?a.each(e,function(){i=s?"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>",s=!s}):t&&(n+='<li class="unselectable"><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.show(),n.scrollTop(e+i.waiting.outerHeight()),i.ajax(function(){i.waiting.hide()}))},wpLink.timeToTriggerRiver)}}),i=function(e){this.page=1,this.allLoaded=!1,this.querying=!1,this.search=e},a.extend(i.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:s.nonce.val()};this.search&&(n.search=this.search),this.querying=!0,a.post(ajaxurl,n,function(e){i.page++,i.querying=!1,i.allLoaded=!e,t(e,n)},"json")}}),a(document).ready(wpLink.init)}(jQuery); |