WordPress/wp-admin/js/post.min.js
desrosj c6169ea341 Build/Test Tools: Support NodeJS 14.x in the 4.1 branch.
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
2021-02-05 04:30:35 +00:00

1 line
19 KiB
JavaScript

var tagBox,commentsBox,WPSetThumbnailHTML,WPSetThumbnailID,WPRemoveThumbnail,wptitlehint,makeSlugeditClickable,editPermalink;function array_unique_noempty(t){var i=[];return jQuery.each(t,function(t,e){(e=jQuery.trim(e))&&-1==jQuery.inArray(e,i)&&i.push(e)}),i}makeSlugeditClickable=editPermalink=function(){},window.wp=window.wp||{},function(c){var t=!1;tagBox={clean:function(t){var e=postL10n.comma;return t=(t=","!==e?t.replace(new RegExp(e,"g"),","):t).replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,""),t=","!==e?t.replace(/,/g,e):t},parseTags:function(t){var e=t.id.split("-check-num-")[1],i=c(t).closest(".tagsdiv"),s=i.find(".the-tags"),a=postL10n.comma,t=s.val().split(a),n=[];return delete t[e],c.each(t,function(t,e){(e=c.trim(e))&&n.push(e)}),s.val(this.clean(n.join(a))),this.quickClicks(i),!1},quickClicks:function(t){var i,e=c(".the-tags",t),s=c(".tagchecklist",t),a=c(t).attr("id");e.length&&(i=e.prop("disabled"),e=e.val().split(postL10n.comma),s.empty(),c.each(e,function(t,e){(e=c.trim(e))&&(e=c("<span />").text(e),i||((t=c('<a id="'+a+"-check-num-"+t+'" class="ntdelbutton">X</a>')).click(function(){tagBox.parseTags(this)}),e.prepend("&nbsp;").prepend(t)),s.append(e))}))},flushTags:function(t,e,i){var s,a=c(".the-tags",t),n=c("input.newtag",t),o=postL10n.comma,l=(e=e||!1)?c(e).text():n.val(),l=(s=a.val())?s+o+l:l;return l=array_unique_noempty((l=this.clean(l)).split(o)).join(o),a.val(l),this.quickClicks(t),e||n.val(""),void 0===i&&n.focus(),!1},get:function(i){var s=i.substr(i.indexOf("-")+1);c.post(ajaxurl,{action:"get-tagcloud",tax:s},function(t,e){0!==t&&"success"==e||(t=wpAjax.broken),t=c('<p id="tagcloud-'+s+'" class="the-tagcloud">'+t+"</p>"),c("a",t).click(function(){return tagBox.flushTags(c(this).closest(".inside").children(".tagsdiv"),this),!1}),c("#"+i).after(t)})},init:function(){var t=this,e=c("div.ajaxtag");c(".tagsdiv").each(function(){tagBox.quickClicks(this)}),c("input.tagadd",e).click(function(){t.flushTags(c(this).closest(".tagsdiv"))}),c("div.taghint",e).click(function(){c(this).css("visibility","hidden").parent().siblings(".newtag").focus()}),c("input.newtag",e).blur(function(){""===this.value&&c(this).parent().siblings(".taghint").css("visibility","")}).focus(function(){c(this).parent().siblings(".taghint").css("visibility","hidden")}).keyup(function(t){if(13==t.which)return tagBox.flushTags(c(this).closest(".tagsdiv")),!1}).keypress(function(t){if(13==t.which)return t.preventDefault(),!1}).each(function(){var t=c(this).closest("div.tagsdiv").attr("id");c(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+t,{delay:500,minchars:2,multiple:!0,multipleSep:postL10n.comma+" "})}),c("#post").submit(function(){c("div.tagsdiv").each(function(){tagBox.flushTags(this,!1,1)})}),c("a.tagcloud-link").click(function(){return tagBox.get(c(this).attr("id")),c(this).unbind().click(function(){return c(this).siblings(".the-tagcloud").toggle(),!1}),!1})}},commentsBox={st:0,get:function(t,e){var i=this.st;return e=e||20,this.st+=e,this.total=t,c("#commentsdiv .spinner").show(),e={action:"get-comments",mode:"single",_ajax_nonce:c("#add_comment_nonce").val(),p:c("#post_ID").val(),start:i,number:e},c.post(ajaxurl,e,function(t){return t=wpAjax.parseAjaxResponse(t),c("#commentsdiv .widefat").show(),c("#commentsdiv .spinner").hide(),"object"==typeof t&&t.responses[0]?(c("#the-comment-list").append(t.responses[0].data),theList=theExtraList=null,c("a[className*=':']").unbind(),void(commentsBox.st>commentsBox.total?c("#show-comments").hide():c("#show-comments").show().children("a").html(postL10n.showcomm))):void(1!=t?c("#the-comment-list").append('<tr><td colspan="2">'+wpAjax.broken+"</td></tr>"):c("#show-comments").html(postL10n.endcomm))}),!1}},WPSetThumbnailHTML=function(t){c(".inside","#postimagediv").html(t)},WPSetThumbnailID=function(t){var e=c('input[value="_thumbnail_id"]',"#list-table");0<e.size()&&c("#meta\\["+e.attr("id").match(/[0-9]+/)+"\\]\\[value\\]").text(t)},WPRemoveThumbnail=function(t){c.post(ajaxurl,{action:"set-post-thumbnail",post_id:c("#post_ID").val(),thumbnail_id:-1,_ajax_nonce:t,cookie:encodeURIComponent(document.cookie)},function(t){"0"==t?alert(setPostThumbnailL10n.error):WPSetThumbnailHTML(t)})},c(document).on("heartbeat-send.refresh-lock",function(t,e){var i=c("#active_post_lock").val(),s=c("#post_ID").val(),a={};s&&c("#post-lock-dialog").length&&(a.post_id=s,i&&(a.lock=i),e["wp-refresh-post-lock"]=a)}).on("heartbeat-tick.refresh-lock",function(t,e){var i,s;e["wp-refresh-post-lock"]&&((i=e["wp-refresh-post-lock"]).lock_error?(s=c("#post-lock-dialog")).length&&!s.is(":visible")&&(wp.autosave&&(c(document).one("heartbeat-tick",function(){wp.autosave.server.suspend(),s.removeClass("saving").addClass("saved"),c(window).off("beforeunload.edit-post")}),s.addClass("saving"),wp.autosave.server.triggerSave()),i.lock_error.avatar_src&&(e=c('<img class="avatar avatar-64 photo" width="64" height="64" />').attr("src",i.lock_error.avatar_src.replace(/&amp;/g,"&")),s.find("div.post-locked-avatar").empty().append(e)),s.show().find(".currently-editing").text(i.lock_error.text),s.find(".wp-tab-first").focus()):i.new_lock&&c("#active_post_lock").val(i.new_lock))}).on("before-autosave.update-post-slug",function(){t=document.activeElement&&"title"===document.activeElement.id}).on("after-autosave.update-post-slug",function(){c("#edit-slug-box > *").length||t||c.post(ajaxurl,{action:"sample-permalink",post_id:c("#post_ID").val(),new_title:c("#title").val(),samplepermalinknonce:c("#samplepermalinknonce").val()},function(t){"-1"!=t&&c("#edit-slug-box").html(t)})})}(jQuery),function(a){var n,t;function i(){n=!1,window.clearTimeout(t),t=window.setTimeout(function(){n=!0},3e5)}a(document).on("heartbeat-send.wp-refresh-nonces",function(t,e){var i,s;n&&(s=a("#post_ID").val())&&(i=a("#_wpnonce").val())&&(e["wp-refresh-post-nonces"]={post_id:s,post_nonce:i})}).on("heartbeat-tick.wp-refresh-nonces",function(t,e){e=e["wp-refresh-post-nonces"];e&&(i(),e.replace&&a.each(e.replace,function(t,e){a("#"+t).val(e)}),e.heartbeatNonce&&(window.heartbeatSettings.nonce=e.heartbeatNonce))}).ready(function(){i()})}(jQuery),jQuery(document).ready(function(d){var u,e,i,t,s,a,n,o,l,c,r="",p=0,h=d("#content"),v=d(document),f=d("#edit-slug-box"),m=d("#post_ID").val()||0,g=d("#submitpost"),b=!0,w=d("#post-visibility-select"),k=d("#timestampdiv"),_=d("#post-status-select");function y(t){c.hasClass("wp-editor-expand")||(o?a.theme.resizeTo(null,n+t.pageY):l.height(Math.max(50,n+t.pageY)),t.preventDefault())}function x(){var t;c.hasClass("wp-editor-expand")||(t=o?(a.focus(),((t=parseInt(d("#wp-content-editor-container .mce-toolbar-grp").height(),10))<10||200<t)&&(t=30),parseInt(d("#content_ifr").css("height"),10)+t-28):(l.focus(),parseInt(l.css("height"),10)),v.off(".wp-editor-resize"),t&&50<t&&t<5e3&&setUserSetting("ed_size",t))}postboxes.add_postbox_toggles(pagenow),window.name="",d("#post-lock-dialog .notification-dialog").on("keydown",function(t){var e;9==t.which&&((e=d(t.target)).hasClass("wp-tab-first")&&t.shiftKey?(d(this).find(".wp-tab-last").focus(),t.preventDefault()):e.hasClass("wp-tab-last")&&!t.shiftKey&&(d(this).find(".wp-tab-first").focus(),t.preventDefault()))}).filter(":visible").find(".wp-tab-first").focus(),wp.heartbeat&&d("#post-lock-dialog").length&&wp.heartbeat.interval(15),i=g.find(":submit, a.submitdelete, #post-preview").on("click.edit-post",function(t){var e=d(this);e.hasClass("disabled")?t.preventDefault():e.hasClass("submitdelete")||e.is("#post-preview")||d("form#post").off("submit.edit-post").on("submit.edit-post",function(t){t.isDefaultPrevented()||(wp.autosave&&wp.autosave.server.suspend(),b=!1,d(window).off("beforeunload.edit-post"),i.addClass("disabled"),("publish"===e.attr("id")?g.find("#major-publishing-actions .spinner"):g.find("#minor-publishing .spinner")).show())})}),d("#post-preview").on("click.post-preview",function(t){var e=d(this),i=d("form#post"),s=d("input#wp-preview"),a=e.attr("target")||"wp-preview",n=navigator.userAgent.toLowerCase();t.preventDefault(),e.hasClass("disabled")||(wp.autosave&&wp.autosave.server.tempBlockSave(),s.val("dopreview"),i.attr("target",a).submit().attr("target",""),-1!==n.indexOf("safari")&&-1===n.indexOf("chrome")&&i.attr("action",function(t,e){return e+"?t="+(new Date).getTime()}),s.val(""))}),d("#title").on("keydown.editor-focus",function(t){var e,i;if(9===t.keyCode&&!t.ctrlKey&&!t.altKey&&!t.shiftKey){if(e="undefined"!=typeof tinymce&&tinymce.get("content"),i=d("#content"),e&&!e.isHidden())e.focus();else{if(!i.length)return;i.focus()}t.preventDefault()}}),d("#auto_draft").val()&&d("#title").blur(function(){var t;this.value&&!d("#edit-slug-box > *").length&&(d("form#post").one("submit",function(){t=!0}),window.setTimeout(function(){!t&&wp.autosave&&wp.autosave.server.triggerSave()},200))}),v.on("autosave-disable-buttons.edit-post",function(){i.addClass("disabled")}).on("autosave-enable-buttons.edit-post",function(){wp.heartbeat&&wp.heartbeat.hasConnectionError()||i.removeClass("disabled")}).on("before-autosave.edit-post",function(){d(".autosave-message").text(postL10n.savingText)}).on("after-autosave.edit-post",function(t,e){d(".autosave-message").text(e.message)}),d(window).on("beforeunload.edit-post",function(){var t="undefined"!=typeof tinymce&&tinymce.get("content");if(t&&!t.isHidden()&&t.isDirty()||wp.autosave&&wp.autosave.server.postChanged())return postL10n.saveAlert}).on("unload.edit-post",function(t){b&&(t.target&&"#document"!=t.target.nodeName||d.ajax({type:"POST",url:ajaxurl,async:!1,data:{action:"wp-remove-post-lock",_wpnonce:d("#_wpnonce").val(),post_ID:d("#post_ID").val(),active_post_lock:d("#active_post_lock").val()}}))}),d("#tagsdiv-post_tag").length?tagBox.init():d("#side-sortables, #normal-sortables, #advanced-sortables").children("div.postbox").each(function(){if(0===this.id.indexOf("tagsdiv-"))return tagBox.init(),!1}),d(".categorydiv").each(function(){var t,a,e,i=d(this).attr("id").split("-");i.shift(),a=i.join("-"),e="category"==a?"cats":a+"_tab",d("a","#"+a+"-tabs").click(function(){var t=d(this).attr("href");return d(this).parent().addClass("tabs").siblings("li").removeClass("tabs"),d("#"+a+"-tabs").siblings(".tabs-panel").hide(),d(t).show(),"#"+a+"-all"==t?deleteUserSetting(e):setUserSetting(e,"pop"),!1}),getUserSetting(e)&&d('a[href="#'+a+'-pop"]',"#"+a+"-tabs").click(),d("#new"+a).one("focus",function(){d(this).val("").removeClass("form-input-tip")}),d("#new"+a).keypress(function(t){13===t.keyCode&&(t.preventDefault(),d("#"+a+"-add-submit").click())}),d("#"+a+"-add-submit").click(function(){d("#new"+a).focus()}),t=function(t){return!!d("#new"+a).val()&&(t.data+="&"+d(":checked","#"+a+"checklist").serialize(),d("#"+a+"-add-submit").prop("disabled",!0),t)},i=function(t,e){var i,s=d("#new"+a+"_parent");d("#"+a+"-add-submit").prop("disabled",!1),"undefined"!=e.parsed.responses[0]&&(i=e.parsed.responses[0].supplemental.newcat_parent)&&(s.before(i),s.remove())},d("#"+a+"checklist").wpList({alt:"",response:a+"-ajax-response",addBefore:t,addAfter:i}),d("#"+a+"-add-toggle").click(function(){return d("#"+a+"-adder").toggleClass("wp-hidden-children"),d('a[href="#'+a+'-all"]',"#"+a+"-tabs").click(),d("#new"+a).focus(),!1}),d("#"+a+"checklist, #"+a+"checklist-pop").on("click",'li.popular-category > label input[type="checkbox"]',function(){var t=d(this),e=t.is(":checked"),i=t.val();i&&t.parents("#taxonomy-"+a).length&&d("#in-"+a+"-"+i+", #in-popular-"+a+"-"+i).prop("checked",e)})}),d("#postcustom").length&&d("#the-list").wpList({addAfter:function(){d("table#list-table").show()},addBefore:function(t){return t.data+="&post_id="+d("#post_ID").val(),t}}),d("#submitdiv").length&&(u=d("#timestamp").html(),e=d("#post-visibility-display").html(),t=function(){"public"!=w.find("input:radio:checked").val()?(d("#sticky").prop("checked",!1),d("#sticky-span").hide()):d("#sticky-span").show(),"password"!=w.find("input:radio:checked").val()?d("#password-span").hide():d("#password-span").show()},s=function(){if(!k.length)return!0;var t,e=d("#post_status"),i=d('option[value="publish"]',e),s=d("#aa").val(),a=d("#mm").val(),n=d("#jj").val(),o=d("#hh").val(),l=d("#mn").val(),c=new Date(s,a-1,n,o,l),r=new Date(d("#hidden_aa").val(),d("#hidden_mm").val()-1,d("#hidden_jj").val(),d("#hidden_hh").val(),d("#hidden_mn").val()),p=new Date(d("#cur_aa").val(),d("#cur_mm").val()-1,d("#cur_jj").val(),d("#cur_hh").val(),d("#cur_mn").val());return c.getFullYear()!=s||1+c.getMonth()!=a||c.getDate()!=n||c.getMinutes()!=l?(k.find(".timestamp-wrap").addClass("form-invalid"),!1):(k.find(".timestamp-wrap").removeClass("form-invalid"),p<c&&"future"!=d("#original_post_status").val()?(t=postL10n.publishOnFuture,d("#publish").val(postL10n.schedule)):c<=p&&"publish"!=d("#original_post_status").val()?(t=postL10n.publishOn,d("#publish").val(postL10n.publish)):(t=postL10n.publishOnPast,d("#publish").val(postL10n.update)),r.toUTCString()==c.toUTCString()?d("#timestamp").html(u):d("#timestamp").html(t+" <b>"+postL10n.dateFormat.replace("%1$s",d('option[value="'+d("#mm").val()+'"]',"#mm").text()).replace("%2$s",n).replace("%3$s",s).replace("%4$s",o).replace("%5$s",l)+"</b> "),"private"==w.find("input:radio:checked").val()?(d("#publish").val(postL10n.update),0===i.length?e.append('<option value="publish">'+postL10n.privatelyPublished+"</option>"):i.html(postL10n.privatelyPublished),d('option[value="publish"]',e).prop("selected",!0),d("#misc-publishing-actions .edit-post-status").hide()):("future"==d("#original_post_status").val()||"draft"==d("#original_post_status").val()?i.length&&(i.remove(),e.val(d("#hidden_post_status").val())):i.html(postL10n.published),e.is(":hidden")&&d("#misc-publishing-actions .edit-post-status").show()),d("#post-status-display").html(d("option:selected",e).text()),"private"==d("option:selected",e).val()||"publish"==d("option:selected",e).val()?d("#save-post").hide():(d("#save-post").show(),"pending"==d("option:selected",e).val()?d("#save-post").show().val(postL10n.savePending):d("#save-post").show().val(postL10n.saveDraft)),!0)},d("#visibility .edit-visibility").click(function(){return w.is(":hidden")&&(t(),w.slideDown("fast").find('input[type="radio"]').first().focus(),d(this).hide()),!1}),w.find(".cancel-post-visibility").click(function(t){w.slideUp("fast"),d("#visibility-radio-"+d("#hidden-post-visibility").val()).prop("checked",!0),d("#post_password").val(d("#hidden-post-password").val()),d("#sticky").prop("checked",d("#hidden-post-sticky").prop("checked")),d("#post-visibility-display").html(e),d("#visibility .edit-visibility").show().focus(),s(),t.preventDefault()}),w.find(".save-post-visibility").click(function(t){w.slideUp("fast"),d("#visibility .edit-visibility").show(),s(),"public"!=w.find("input:radio:checked").val()&&d("#sticky").prop("checked",!1),r=d("#sticky").prop("checked")?"Sticky":"",d("#post-visibility-display").html(postL10n[w.find("input:radio:checked").val()+r]),t.preventDefault()}),w.find("input:radio").change(function(){t()}),k.siblings("a.edit-timestamp").click(function(t){k.is(":hidden")&&(k.slideDown("fast"),d("#mm").focus(),d(this).hide()),t.preventDefault()}),k.find(".cancel-timestamp").click(function(t){k.slideUp("fast").siblings("a.edit-timestamp").show().focus(),d("#mm").val(d("#hidden_mm").val()),d("#jj").val(d("#hidden_jj").val()),d("#aa").val(d("#hidden_aa").val()),d("#hh").val(d("#hidden_hh").val()),d("#mn").val(d("#hidden_mn").val()),s(),t.preventDefault()}),k.find(".save-timestamp").click(function(t){s()&&(k.slideUp("fast"),k.siblings("a.edit-timestamp").show()),t.preventDefault()}),d("#post").on("submit",function(t){s()||(t.preventDefault(),k.show(),wp.autosave&&wp.autosave.enableButtons(),d("#publishing-action .spinner").hide())}),_.siblings("a.edit-post-status").click(function(t){_.is(":hidden")&&(_.slideDown("fast").find("select").focus(),d(this).hide()),t.preventDefault()}),_.find(".save-post-status").click(function(t){_.slideUp("fast").siblings("a.edit-post-status").show(),s(),t.preventDefault()}),_.find(".cancel-post-status").click(function(t){d("#post-status-select").slideUp("fast").siblings("a.edit-post-status").show().focus(),d("#post_status").val(d("#hidden_post_status").val()),s(),t.preventDefault()})),f.length&&f.on("click",function(t){t=d(t.target);(t.is("#editable-post-name")||t.hasClass("edit-slug"))&&function(){var t,e,i=0,s=d("#editable-post-name"),a=s.html(),n=d("#post_name"),o=n.val(),l=d("#edit-slug-buttons"),c=l.html(),r=d("#editable-post-name-full").html();for(d("#view-post-btn").hide(),l.html('<a href="#" class="save button button-small">'+postL10n.ok+'</a> <a class="cancel" href="#">'+postL10n.cancel+"</a>"),l.children(".save").click(function(){var i=s.children("input").val();return i==d("#editable-post-name-full").text()?l.children(".cancel").click():d.post(ajaxurl,{action:"sample-permalink",post_id:m,new_slug:i,new_title:d("#title").val(),samplepermalinknonce:d("#samplepermalinknonce").val()},function(t){var e=d("#edit-slug-box");e.html(t),e.hasClass("hidden")&&e.fadeIn("fast",function(){e.removeClass("hidden")}),l.html(c),n.val(i),d("#view-post-btn").show()}),!1}),l.children(".cancel").click(function(){return d("#view-post-btn").show(),s.html(a),l.html(c),n.val(o),!1}),t=0;t<r.length;++t)"%"==r.charAt(t)&&i++;e=i>r.length/4?"":r,s.html('<input type="text" id="new-post-slug" value="'+e+'" />').children("input").keypress(function(t){t=t.keyCode||0;return 13==t?(l.children(".save").click(),!1):27==t?(l.children(".cancel").click(),!1):void 0}).keyup(function(){n.val(this.value)}).focus()}()}),"undefined"!=typeof wpWordCount&&(v.triggerHandler("wpcountwords",[h.val()]),h.keyup(function(t){t=t.keyCode||t.charCode;return t==p||(13!=t&&8!=p&&46!=p||v.triggerHandler("wpcountwords",[h.val()]),p=t),!0})),(wptitlehint=function(t){var e=d("#"+(t=t||"title")),i=d("#"+t+"-prompt-text");""===e.val()&&i.removeClass("screen-reader-text"),i.click(function(){d(this).addClass("screen-reader-text"),e.focus()}),e.blur(function(){""===this.value&&i.removeClass("screen-reader-text")}).focus(function(){i.addClass("screen-reader-text")}).keydown(function(t){i.addClass("screen-reader-text"),d(this).unbind(t)})})(),l=d("textarea#content"),f=d("#post-status-info"),c=d("#postdivrich"),!l.length||"ontouchstart"in window?d("#content-resize-handle").hide():f.on("mousedown.wp-editor-resize",function(t){(a="undefined"!=typeof tinymce?tinymce.get("content"):a)&&!a.isHidden()?(o=!0,n=d("#content_ifr").height()-t.pageY):(o=!1,n=l.height()-t.pageY,l.blur()),v.on("mousemove.wp-editor-resize",y).on("mouseup.wp-editor-resize mouseleave.wp-editor-resize",x),t.preventDefault()}).on("mouseup.wp-editor-resize",x),"undefined"!=typeof tinymce&&d("#post-formats-select input.post-format").on("change.set-editor-class",function(){var t,e,i=this.id;i&&d(this).prop("checked")&&(t=tinymce.get("content"))&&((e=t.getBody()).className=e.className.replace(/\bpost-format-[^ ]+/,""),t.dom.addClass(e,"post-format-0"==i?"post-format-standard":i),d(document).trigger("editor-classchange"))})});