mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-04 12:29:22 +00:00
This updates the 4.1 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 4.1, dependencies that were removed in future releases have also been updated to their latest versions. Props desrosj, dd32, netweb, jorbin. Merges [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 4.1 branch. See #52341. Built from https://develop.svn.wordpress.org/branches/4.1@50216 git-svn-id: http://core.svn.wordpress.org/branches/4.1@49884 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 line
9.0 KiB
JavaScript
1 line
9.0 KiB
JavaScript
var wpLink;!function(a){var n,t,e,i,l={},r={},s="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",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.url=a("#url-field"),l.nonce=a("#_ajax_linking_nonce"),l.title=a("#link-title-field"),l.openInNewTab=a("#link-target-checkbox"),l.search=a("#search-field"),r.search=new e(a("#search-results")),r.recent=new e(a("#most-recent-results")),r.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(e){e.preventDefault(),wpLink.update()}),l.close.add(l.backdrop).add("#wp-link-cancel a").click(function(e){e.preventDefault(),wpLink.close()}),a("#wp-link-search-toggle").on("click",wpLink.toggleInternalLinking),r.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(t),t=window.setTimeout(function(){wpLink.searchInternalLinks.call(e)},500)})},open:function(e){a(document.body).addClass("modal-open"),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()),l.wrap.show(),l.backdrop.show(),wpLink.refresh(),a(document).trigger("wplink-open",l.wrap))},isMCE:function(){return n&&!n.isHidden()},refresh:function(){r.search.refresh(),r.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh():wpLink.setDefaultValues(),s?l.url.focus().blur():l.url.focus()[0].select(),r.recent.ul.children().length||r.recent.ajax()},mceRefresh:function(){var e;(e=n.dom.getParent(n.selection.getNode(),"A"))?(l.url.val(n.dom.getAttrib(e,"href")),l.title.val(n.dom.getAttrib(e,"title")),l.openInNewTab.prop("checked","_blank"===n.dom.getAttrib(e,"target")),l.submit.val(wpLinkL10n.update)):wpLink.setDefaultValues()},close:function(){a(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(),a(document).trigger("wplink-close",l.wrap)},getAttrs:function(){return{href:l.url.val(),title:l.title.val(),target:l.openInNewTab.prop("checked")?"_blank":""}},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var e,t,i,n,l=wpLink.textarea;l&&(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?(l.focus(),wpLink.range.text=e+wpLink.range.text+"</a>",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):void 0!==l.selectionStart&&(t=l.selectionStart,n=l.selectionEnd,i=t+(e=e+l.value.substring(t,n)+"</a>").length,t==n&&(i-="</a>".length),l.value=l.value.substring(0,t)+e+l.value.substring(n,l.value.length),l.selectionStart=l.selectionEnd=i),wpLink.close(),l.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){l.url.val(t.children(".item-permalink").val()),l.title.val(t.hasClass("no-title")?"":t.children(".item-title").text())},setDefaultValues:function(){var e=n&&n.selection.getContent();e&&/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i.test(e)?l.url.val("mailto:"+e):e&&/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,4}[^ "]*$/i.test(e)?l.url.val(e.replace(/&|�?38;/gi,"&")):l.url.val("http://"),l.title.val(""),l.submit.val(wpLinkL10n.save)},searchInternalLinks:function(){var e,t=a(this),i=t.val();2<i.length?(r.recent.hide(),r.search.show(),wpLink.lastSearch!=i&&(wpLink.lastSearch=i,e=t.parent().find(".spinner").show(),r.search.change(i),r.search.ajax(function(){e.hide()}))):(r.search.hide(),r.recent.show())},next:function(){r.search.next(),r.recent.next()},prev:function(){r.search.prev(),r.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&&(l.submit.focus(),e.preventDefault()):(l.close.focus(),e.preventDefault())),e.keyCode!==i.UP&&e.keyCode!==i.DOWN||document.activeElement&&("link-title-field"===document.activeElement.id||"url-field"===document.activeElement.id)||(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,l,a;return t?(setTimeout(function(){return n?e.apply(a,l):void(i=!0)},t),function(){if(i)return e.apply(this,arguments);l=arguments,a=this,n=!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()}},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,l,a;e.hasClass("unselectable")||e==this.selected||(this.deselect(),this.selected=e.addClass("selected"),i=e.outerHeight(),n=this.element.height(),l=e.position().top,a=this.element.scrollTop(),l<0?this.element.scrollTop(a+l):n<l+i&&this.element.scrollTop(a+l-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="",l=!0,t=1==t.page;e?a.each(e,function(){i=l?"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>",l=!l}):t&&(n+='<li class="unselectable no-matches-found"><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:l.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); |