WordPress/wp-admin/js/press-this.min.js
desrosj e3353e0860 Build/Test Tools: Support NodeJS 14.x in the 4.2 branch.
This updates the 4.2 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.2, dependencies that were removed in future releases have also been updated to their latest versions.

Props desrosj, dd32, netweb, jorbin.
Merges [32356-32357,32988,33726,34888,35335,35363,35513,35521,35538-35541,35859,36861-36865,36935,36979,37017,37019-37020,37212,37612,38111,39110,39113,39115-39119,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.2 branch.
See #52341.
Built from https://develop.svn.wordpress.org/branches/4.2@50214


git-svn-id: http://core.svn.wordpress.org/branches/4.2@49883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 04:28:43 +00:00

1 line
9.0 KiB
JavaScript

!function(S,q){q.wp=q.wp||{},q.wp.pressThis=new function(){var o,d,l,e,r=!1,n=!1,s=document.createElement("textarea"),c=!1,i=q.wpPressThisConfig||{},p=q.wpPressThisData||{},t=128,u=!1,f=[],h="is-off-screen",m="is-hidden",g=h+" "+m,v=void 0!==(e=document.documentElement.style).transition?"transitionend":void 0!==e.WebkitTransition&&"webkitTransitionEnd";function C(e){return e&&q.pressThisL10n?q.pressThisL10n[e]||e:e||""}function a(e){return(e=e||"").replace(/<!--[\s\S]*?(-->|$)/g,"").replace(/<(script|style)[^>]*>[\s\S]*?(<\/\1>|$)/gi,"").replace(/<\/?[a-z][\s\S]*?(>|$)/gi,"")}function b(e){return e=S.trim(e||""),/^(?:https?:)?\/\//.test(e)?(e=a(e)).replace(/["\\]+/g,""):""}function x(){var e=S("#title-container");return e.find("img.emoji").each(function(){var e=S(this);e.replaceWith(S("<span>").text(e.attr("alt")))}),function(e){var t=a(e);try{s.innerHTML=t,t=a(s.value)}catch(e){}return t}(e.text())}function y(){var s=S("#pressthis-form"),a=S('<input type="hidden" name="post_category[]" value="">');o&&o.save(),S("#post_title").val(x()),q.tagBox&&S("div.tagsdiv").each(function(){q.tagBox.flushTags(this,!1,1)}),S(".categories-select .category").each(function(e,t){t=S(t);t.hasClass("selected")&&s.append(a.clone().val(t.attr("data-term-id")||""))})}function w(e){var a=S(document.activeElement).hasClass("draft-button");r=!1,S(".spinner").addClass("is-active"),S(".post-actions button").attr("disabled","disabled"),"publish"===e&&S("#post_status").val("publish"),y(),e=S("#pressthis-form").serialize(),S.ajax({type:"post",url:q.ajaxurl,data:e}).always(function(){S(".spinner").removeClass("is-active"),S(".post-actions button").removeAttr("disabled"),S("div.alerts").empty()}).done(function(e){var t,s;if(e.success)if(e.data.redirect)if(q.opener&&i.redirInParent){try{q.opener.location.href=e.data.redirect}catch(e){}q.self.close()}else q.location.href=e.data.redirect;else e.data.postSaved&&(t=S(".edit-post-link"),s=S(".draft-button"),n=!0,s.fadeOut(200,function(){s.removeClass("is-saving"),t.fadeIn(200,function(){var e=document.activeElement;a&&(e===s[0]||S(e).hasClass("post-actions")||"BODY"===e.nodeName)&&t.focus()})}));else D(e.data.errorMessage)}).fail(function(){D(C("serverError"))})}function k(){n&&(n=!1,S(".edit-post-link").fadeOut(200,function(){S(".draft-button").removeClass("is-saving").fadeIn(200)}))}function T(){var e=S("#new-category").val();e&&(e={action:"press-this-add-category",post_id:S("#post_ID").val()||0,name:e,new_cat_nonce:S("#_ajax_nonce-add-category").val()||"",parent:S("#new-category-parent").val()||0},S.post(q.ajaxurl,e,function(e){var a,n,i;e.success?(i=S("ul.categories-select"),S.each(e.data,function(e,t){var s=S("<li>").append(S('<div class="category selected" tabindex="0" role="checkbox" aria-checked="true">').attr("data-term-id",t.term_id).text(t.name));t.parent?(n&&n.length||(a=i.find('div[data-term-id="'+t.parent+'"]').parent(),(n=a.find("ul.children:first")).length||(n=S('<ul class="children">').appendTo(a))),n.prepend(s)):i.prepend(s),s.focus()}),B()):D(e.data.errorMessage)}))}function _(e,t){t=t?"is-error":"is-notice";S(".editor-wrapper div.alerts").append(S('<p class="alert '+t+'">').text(e))}function D(e){_(e,!0)}function O(){var c=0;d=S("ul.media-list"),l=S('<li class="suggested-media-thumbnail" tabindex="0"><span class="screen-reader-text"></span></li>'),p._embeds&&S.each(p._embeds,function(e,t){var s="",a=l.clone().addClass("is-embed");-1<(t=b(t)).indexOf("youtube.com/")?s="https://i.ytimg.com/vi/"+t.replace(/.+v=([^&]+).*/,"$1")+"/hqdefault.jpg":-1<t.indexOf("youtu.be/")?s="https://i.ytimg.com/vi/"+t.replace(/\/([^\/])$/,"$1")+"/hqdefault.jpg":-1<t.indexOf("dailymotion.com")?s=t.replace("/video/","/thumbnail/video/"):-1<t.indexOf("soundcloud.com")||t.indexOf("twitter.com"),a.attr("data-wp-src",t).find("span").text(C("suggestedEmbedAlt").replace("%d",e+1)),s&&a.css("background-image","url("+s+")"),d.append(a),c++}),p._images&&S.each(p._images,function(n,i){var o,r=new Image;i=b(i),o=i.replace(/^(http[^\?]+)(\?.*)?$/,"$1"),o=-1<i.indexOf("files.wordpress.com/")?o.replace(/\?.*$/,"")+"?w="+t:-1<i.indexOf("gravatar.com/")?o.replace(/\?.*$/,"")+"?s="+t:i,r.onload=function(){var e,t,s,a;r.width&&r.width<256||r.height&&r.height<128||(e=i,t=o,s=n,(a=l.clone().addClass("is-image")).attr("data-wp-src",e).css("background-image","url("+t+")").find("span").text(C("suggestedImgAlt").replace("%d",s+1)),d.append(a))},r.src=i,c++}),c&&S(".media-list-container").addClass("has-media")}function E(){c=!1,S(".options").removeClass("open").addClass("closed"),S(".options-panel-back").addClass(m),S(".press-this-actions, #scanbar").removeClass(m),S(".options-panel").addClass(h).one(v,function(){S(this).addClass(m),S(".post-options").removeClass(g),S(".setting-modal").addClass(g)})}function $(){S(".categories-select").on("click.press-this keydown.press-this",function(e){var t=S(e.target);t.is("div.category")&&("keydown"===e.type&&32!==e.keyCode||((t=t).hasClass("selected")?t.removeClass("selected").attr("aria-checked","false"):t.addClass("selected").attr("aria-checked","true"),e.preventDefault()))})}function j(){p.hasData&&S("#scanbar").hide(),O(),p.errors&&S.each(p.errors,function(e,t){D(t)}),q.tagBox&&q.tagBox.init()}function I(){var s,a,t,e,n,i;return S(document).on("tinymce-editor-init",function(e,t){(o=t).on("nodechange",function(){u=!0,k()})}).on("click.press-this keypress.press-this",".suggested-media-thumbnail",function(e){var t,s,a;"click"!==e.type&&13!==e.keyCode||(t=S(this),a="",o&&(s=b(t.attr("data-wp-src")||""),e=b(p.u),a=t.hasClass("is-image")?'<a href="'+(e=e||s)+'"><img class="alignnone size-full" src="'+s+'" /></a>':"[embed]"+s+"[/embed]",u?o.execCommand("mceInsertContent",!1,a):o.setContent("<p>"+a+"</p>"+o.getContent())))}),S(".post-actions").on("click.press-this",function(e){var t=S(e.target),e=t.closest("button");e.length?e.hasClass("draft-button")?(e.addClass("is-saving"),w("draft")):e.hasClass("publish-button")?w("publish"):e.hasClass("preview-button")&&(y(),q.opener&&q.opener.focus(),S("#wp-preview").val("dopreview"),S("#pressthis-form").attr("target","_blank").submit().attr("target",""),S("#wp-preview").val("")):t.hasClass("edit-post-link")&&q.opener&&(q.opener.focus(),q.self.close())}),s=S(".post-options"),a=S(".post-option"),t=S(".setting-modal"),e=S(".modal-close"),a.on("click",function(){var e=S(this).index(),e=t.eq(e);s.addClass(h).one(v,function(){S(this).addClass(m)}),e.removeClass(g).one(v,function(){S(this).find(".modal-close").focus()})}),e.on("click",function(){var e=S(this).parent(),t=e.index();s.removeClass(g),e.addClass(h),v?e.one(v,function(){S(this).addClass(m),a.eq(t-1).focus()}):setTimeout(function(){e.addClass(m),a.eq(t-1).focus()},350)}),n=S("#title-container"),i=S(".post-title-placeholder"),n.on("focus",function(){i.addClass("is-hidden"),k()}).on("blur",function(){n.text()||n.html()||i.removeClass("is-hidden")}).on("keyup",function(){r=!0}).on("paste",function(e){var t,s,a=e.originalEvent.clipboardData||q.clipboardData;if(a){try{(t=a.getData("Text")||a.getData("text/plain"))&&(t=S.trim(t.replace(/\s+/g," ")),q.getSelection?(s=q.getSelection().getRangeAt(0))&&(s.collapsed||s.deleteContents(),s.insertNode(document.createTextNode(t))):document.selection&&(s=document.selection.createRange())&&(s.text=t))}catch(e){}e.preventDefault()}r=!0,setTimeout(function(){n.text(x())},50)}),(n.text()||n.html())&&i.addClass("is-hidden"),$(),S(".options").on("click.press-this",function(){S(this).hasClass("open")?E():(c=!0,S(".options").removeClass("closed").addClass("open"),S(".press-this-actions, #scanbar").addClass(m),S(".options-panel-back").removeClass(m),S(".options-panel").removeClass(g).one(v,function(){S(".post-option:first").focus()}))}),S(".options-panel, .options-panel-back").on("focusout.press-this",function(){setTimeout(function(){var e=document.activeElement,t=S(e);!c||!e||t.hasClass("options-panel-back")||"BODY"!==e.nodeName&&(t.closest(".options-panel").length||t.closest(".options").length)||E()},50)}),S("#post-formats-select input").on("change",function(){var e=S(this);e.is(":checked")&&S("#post-option-post-format").text(S('label[for="'+e.attr("id")+'"]').text()||"")}),S(q).on("beforeunload.press-this",function(){if(r||o&&o.isDirty())return C("saveAlert")}),S("button.add-cat-toggle").on("click.press-this",function(){var e=S(this);e.toggleClass("is-toggled"),e.attr("aria-expanded","false"===e.attr("aria-expanded")?"true":"false"),S(".setting-modal .add-category, .categories-search-wrapper").toggleClass("is-hidden")}),S("button.add-cat-submit").on("click.press-this",T),S(".categories-search").on("keyup.press-this",function(){var s=S(this).val().toLowerCase()||"";/[\x20-\xFF]+/.test(s)&&s.length<2||(S.each(f,function(e,t){t.node.removeClass("is-hidden searched-parent")}),s&&S.each(f,function(e,t){-1===t.text.indexOf(s)?t.node.addClass("is-hidden"):t.parents.addClass("searched-parent")}))}),1}function B(){S(".categories-select").find("li").each(function(){var e=S(this);f.push({node:e,parents:e.parents("li"),text:e.children(".category").text().toLowerCase()})})}return S(document).ready(function(){j(),I(),B()}),{renderNotice:_,renderError:D}}}(jQuery,window);