WordPress/wp-admin/js/post.min.js
desrosj 968d57a6b3 Build/Test Tools: Support NodeJS 14.x in the 4.5 branch.
This updates the 4.5 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 also replaces the `npm-shrinkwrap.json` with a `package-lock.json` file. Lock files were not supported in earlier versions of NPM, but can now be used.

In addition to backporting the package updates that happened after branching 4.5, dependencies that were removed in future releases have also been updated to their latest versions.

Props desrosj, dd32, netweb, jorbin.
Merges [37185,37212,37612,38111,38688,39110,39113-39119,39478,42460-42461,42463,42887,43320,43323,43977,44219,44233,44728,45321,45765,46404,46408-46409,47404,47867-47869,47872-47873,48705,49636,49933,49937,49939,50017,50126,50176,50185,50192] to the 4.5 branch.
See #52341.
Built from https://develop.svn.wordpress.org/branches/4.5@50208


git-svn-id: http://core.svn.wordpress.org/branches/4.5@49880 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 04:20:44 +00:00

1 line
17 KiB
JavaScript

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