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

Props desrosj, dd32, netweb, jorbin.
Merges [35859,35862,36860-36865,36935,36978-36979,37017,37019-37020,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.4 branch.
See #52341.
Built from https://develop.svn.wordpress.org/branches/4.4@50210


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

1 line
14 KiB
JavaScript

var setCommentsList,theList,theExtraList,commentReply;!function(C){var s,o,i=document.title,w=C("#dashboard_right_now").length,r=function(t){t=parseInt(t.html().replace(/[^0-9]+/g,""),10);return isNaN(t)?0:t},l=function(t,e){var n="";if(!isNaN(e)){if(3<(e=e<1?"0":e.toString()).length){for(;3<e.length;)n=thousandsSeparator+e.substr(e.length-3)+n,e=e.substr(0,e.length-3);e+=n}t.html(e)}},x=function(n,t){var e=".post-com-count-"+t,a="comment-count-no-comments",s="comment-count-approved";b("span.approved-count",n),t&&(t=C("span."+s,e),e=C("span."+a,e),t.each(function(){var t=C(this),e=r(t)+n;0===(e=e<1?0:e)?t.removeClass(s).addClass(a):t.addClass(s).removeClass(a),l(t,e)}),e.each(function(){var t=C(this);0<n?t.removeClass(a).addClass(s):t.addClass(a).removeClass(s),l(t,n)}))},b=function(t,n){C(t).each(function(){var t=C(this),e=r(t)+n;l(t,e=e<1?0:e)})},k=function(t){var e;w&&t&&t.i18n_comments_text&&(e=C("#dashboard_right_now"),C(".comment-count a",e).text(t.i18n_comments_text),C(".comment-mod-count a",e).text(t.i18n_moderation_text).parent()[0<t.in_moderation?"removeClass":"addClass"]("hidden"))},m=function(t){var e,n,a;o=o||new RegExp(adminCommentsL10n.docTitleCommentsCount.replace("%s","\\([0-9"+thousandsSeparator+"]+\\)")+"?"),s=s||C("<div />"),e=i,1<=(t=(a=o.exec(document.title))?(a=a[0],s.html(a),r(s)+t):(s.html(0),t))?(l(s,t),(n=o.exec(document.title))&&(e=document.title.replace(n[0],adminCommentsL10n.docTitleCommentsCount.replace("%s",s.text())+" "))):(n=o.exec(e))&&(e=e.replace(n[0],adminCommentsL10n.docTitleComments)),document.title=e},L=function(n,t){var e=".post-com-count-"+t,a="comment-count-no-pending",s="post-com-count-no-pending",o="comment-count-pending";w||m(n),C("span.pending-count").each(function(){var t=C(this),e=r(t)+n;e<1&&(e=0),t.closest(".awaiting-mod")[0===e?"addClass":"removeClass"]("count-0"),l(t,e)}),t&&(t=C("span."+o,e),e=C("span."+a,e),t.each(function(){var t=C(this),e=r(t)+n;0===(e=e<1?0:e)?(t.parent().addClass(s),t.removeClass(o).addClass(a)):(t.parent().removeClass(s),t.addClass(o).removeClass(a)),l(t,e)}),e.each(function(){var t=C(this);0<n?(t.parent().removeClass(s),t.removeClass(a).addClass(o)):(t.parent().addClass(s),t.addClass(a).removeClass(o)),l(t,n)}))};setCommentsList=function(){var i,f=0,g=C('input[name="_total"]',"#comments-form"),l=C('input[name="_per_page"]',"#comments-form"),m=C('input[name="_page"]',"#comments-form"),y=function(t,e,n){e<f||(n&&(f=e),g.val(t.toString()))},t=function(t,e){var n,a,s,o=C("#"+e.element);!0!==e.parsed&&(s=e.parsed.responses[0]),a=C("#replyrow"),n=C("#comment_ID",a).val(),a=C("#replybtn",a),o.is(".unapproved")?(e.data.id==n&&a.text(adminCommentsL10n.replyApprove),o.find("div.comment_status").html("0")):(e.data.id==n&&a.text(adminCommentsL10n.reply),o.find("div.comment_status").html("1")),i=C("#"+e.element).is("."+e.dimClass)?1:-1,s?(k(s.supplemental),L(i,s.supplemental.postId),x(-1*i,s.supplemental.postId)):(L(i),x(-1*i))},e=function(t,e){var n,a,s,o,i=!1,r=C(t.target).attr("data-wp-lists");return t.data._total=g.val()||0,t.data._per_page=l.val()||0,t.data._page=m.val()||0,t.data._url=document.location.href,t.data.comment_status=C('input[name="comment_status"]',"#comments-form").val(),-1!=r.indexOf(":trash=1")?i="trash":-1!=r.indexOf(":spam=1")&&(i="spam"),i&&(n=r.replace(/.*?comment-([0-9]+).*/,"$1"),a=C("#comment-"+n),s=C("#"+i+"-undo-holder").html(),a.find(".check-column :checkbox").prop("checked",!1),a.siblings("#replyrow").length&&commentReply.cid==n&&commentReply.close(),s=a.is("tr")?(r=a.children(":visible").length,o=C(".author strong",a).text(),C('<tr id="undo-'+n+'" class="undo un'+i+'" style="display:none;"><td colspan="'+r+'">'+s+"</td></tr>")):(o=C(".comment-author",a).text(),C('<div id="undo-'+n+'" style="display:none;" class="undo un'+i+'">'+s+"</div>")),a.before(s),C("strong","#undo-"+n).text(o),(o=C(".undo a","#undo-"+n)).attr("href","comment.php?action=un"+i+"comment&c="+n+"&_wpnonce="+t.data._ajax_nonce),o.attr("data-wp-lists","delete:the-comment-list:comment-"+n+"::un"+i+"=1"),o.attr("class","vim-z vim-destructive"),C(".avatar",a).first().clone().prependTo("#undo-"+n+" ."+i+"-undo-inside"),o.click(function(t){t.preventDefault(),e.wpList.del(this),C("#undo-"+n).css({backgroundColor:"#ceb"}).fadeOut(350,function(){C(this).remove(),C("#comment-"+n).css("backgroundColor","").fadeIn(300,function(){C(this).show()})})})),t},n=function(t,e){var n,a,s,o,i,r=!0===e.parsed?{}:e.parsed.responses[0],l=!0===e.parsed?"":r.supplemental.status,m=!0===e.parsed?"":r.supplemental.postId,p=!0===e.parsed?"":r.supplemental,c=C(e.target).parent(),d=C("#"+e.element),u=d.hasClass("approved"),h=d.hasClass("unapproved"),v=d.hasClass("spam"),d=d.hasClass("trash");k(p),c.is("span.undo")?c.hasClass("unspam")?(a=-1,"trash"===l?s=1:"1"===l?i=1:"0"===l&&(o=1)):c.hasClass("untrash")&&(s=-1,"spam"===l?a=1:"1"===l?i=1:"0"===l&&(o=1)):c.is("span.spam")?(u?i=-1:h?o=-1:d&&(s=-1),a=1):c.is("span.unspam")?(u?o=1:h?i=1:(d||v)&&(c.hasClass("approve")?i=1:c.hasClass("unapprove")&&(o=1)),a=-1):c.is("span.trash")?(u?i=-1:h?o=-1:v&&(a=-1),s=1):c.is("span.untrash")?(u?o=1:h?i=1:d&&(c.hasClass("approve")?i=1:c.hasClass("unapprove")&&(o=1)),s=-1):c.is("span.approve:not(.unspam):not(.untrash)")?o=-(i=1):c.is("span.unapprove:not(.unspam):not(.untrash)")?(i=-1,o=1):c.is("span.delete")&&(v?a=-1:d&&(s=-1)),o&&(L(o,m),b("span.all-count",o)),i&&(x(i,m),b("span.all-count",i)),a&&b("span.spam-count",a),s&&b("span.trash-count",s),w||(n=g.val()?parseInt(g.val(),10):0,C(e.target).parent().is("span.undo")?n++:n--,n<0&&(n=0),"object"==typeof t?r.supplemental.total_items_i18n&&f<r.supplemental.time?((e=r.supplemental.total_items_i18n||"")&&(C(".displaying-num").text(e),C(".total-pages").text(r.supplemental.total_pages_i18n),C(".tablenav-pages").find(".next-page, .last-page").toggleClass("disabled",r.supplemental.total_pages==C(".current-page").val())),y(n,r.supplemental.time,!0)):r.supplemental.time&&y(n,r.supplemental.time,!1):y(n,t,!1)),theExtraList&&0!==theExtraList.size()&&0!==theExtraList.children().size()&&(theList.get(0).wpList.add(theExtraList.children(":eq(0):not(.no-items)").remove().clone()),_(),n=function(){C("#the-comment-list tr:visible").length||theList.get(0).wpList.add(theExtraList.find(".no-items").clone())},(t=C(":animated","#the-comment-list")).length?t.promise().done(n):n())},_=function(t){var e=C.query.get(),n=C(".total-pages").text(),a=C('input[name="_per_page"]',"#comments-form").val();e.paged||(e.paged=1),e.paged>n||(t?(theExtraList.empty(),e.number=Math.min(8,a)):(e.number=1,e.offset=Math.min(8,a)-1),e.no_placeholder=!0,e.paged++,!0===e.comment_type&&(e.comment_type=""),e=C.extend(e,{action:"fetch-list",list_args:list_args,_ajax_fetch_list_nonce:C("#_ajax_fetch_list_nonce").val()}),C.ajax({url:ajaxurl,global:!1,dataType:"json",data:e,success:function(t){theExtraList.get(0).wpList.add(t.rows)}}))};theExtraList=C("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"}),theList=C("#the-comment-list").wpList({alt:"",delBefore:e,dimAfter:t,delAfter:n,addColor:"none"}).bind("wpListDelEnd",function(t,e){var n=C(e.target).attr("data-wp-lists"),e=e.element.replace(/[^0-9]+/g,"");-1==n.indexOf(":trash=1")&&-1==n.indexOf(":spam=1")||C("#undo-"+e).fadeIn(300,function(){C(this).show()})})},commentReply={cid:"",act:"",init:function(){var t=C("#replyrow");C("a.cancel",t).click(function(){return commentReply.revert()}),C("a.save",t).click(function(){return commentReply.send()}),C("input#author-name, input#author-email, input#author-url",t).keypress(function(t){if(13==t.which)return commentReply.send(),t.preventDefault(),!1}),C("#the-comment-list .column-comment > p").dblclick(function(){commentReply.toggle(C(this).parent())}),C("#doaction, #doaction2, #post-query-submit").click(function(){0<C("#the-comment-list #replyrow").length&&commentReply.close()}),this.comments_listing=C('#comments-form > input[name="comment_status"]').val()||""},addEvents:function(t){t.each(function(){C(this).find(".column-comment > p").dblclick(function(){commentReply.toggle(C(this).parent())})})},toggle:function(t){"none"!==C(t).css("display")&&(C("#replyrow").parent().is("#com-reply")||window.confirm(adminCommentsL10n.warnQuickEdit))&&C(t).find("a.vim-q").click()},revert:function(){return C("#the-comment-list #replyrow").length<1||C("#replyrow").fadeOut("fast",function(){commentReply.close()}),!1},close:function(){var t,e=C("#replyrow");e.parent().is("#com-reply")||(this.cid&&"edit-comment"==this.act&&(t=C("#comment-"+this.cid)).fadeIn(300,function(){t.show()}).css("backgroundColor",""),"undefined"!=typeof QTags&&QTags.closeAllTags("replycontent"),C("#add-new-comment").css("display",""),e.hide(),C("#com-reply").append(e),C("#replycontent").css("height","").val(""),C("#edithead input").val(""),C(".error",e).empty().hide(),C(".spinner",e).removeClass("is-active"),this.cid="")},open:function(t,e,n){var a,s,o,i,r=C("#comment-"+t),l=r.height();return this.close(),this.cid=t,a=C("#replyrow"),s=C("#inline-"+t),o="edit"==(n=n||"replyto")?"edit":"replyto",o=this.act=o+"-comment",i=C("> th:visible, > td:visible",r).length,a.hasClass("inline-edit-row")&&0!==i&&C("td",a).attr("colspan",i),C("#action",a).val(o),C("#comment_post_ID",a).val(e),C("#comment_ID",a).val(t),"edit"==n?(C("#author-name",a).val(C("div.author",s).text()),C("#author-email",a).val(C("div.author-email",s).text()),C("#author-url",a).val(C("div.author-url",s).text()),C("#status",a).val(C("div.comment_status",s).text()),C("#replycontent",a).val(C("textarea.comment",s).val()),C("#edithead, #editlegend, #savebtn",a).show(),C("#replyhead, #replybtn, #addhead, #addbtn",a).hide(),120<l&&(l=500<l?500:l,C("#replycontent",a).css("height",l+"px")),r.after(a).fadeOut("fast",function(){C("#replyrow").fadeIn(300,function(){C(this).show()})})):"add"==n?(C("#addhead, #addbtn",a).show(),C("#replyhead, #replybtn, #edithead, #editlegend, #savebtn",a).hide(),C("#the-comment-list").prepend(a),C("#replyrow").fadeIn(300)):(n=C("#replybtn",a),C("#edithead, #editlegend, #savebtn, #addhead, #addbtn",a).hide(),C("#replyhead, #replybtn",a).show(),r.after(a),r.hasClass("unapproved")?n.text(adminCommentsL10n.replyApprove):n.text(adminCommentsL10n.reply),C("#replyrow").fadeIn(300,function(){C(this).show()})),setTimeout(function(){var t=C("#replyrow").offset().top,e=t+C("#replyrow").height(),n=window.pageYOffset||document.documentElement.scrollTop,a=document.documentElement.clientHeight||window.innerHeight||0;n+a-20<e?window.scroll(0,e-a+35):t-20<n&&window.scroll(0,t-35),C("#replycontent").focus().keyup(function(t){27==t.which&&commentReply.revert()})},600),!1},send:function(){var e={};return C("#replysubmit .error").hide(),C("#replysubmit .spinner").addClass("is-active"),C("#replyrow input").not(":button").each(function(){var t=C(this);e[t.attr("name")]=t.val()}),e.content=C("#replycontent").val(),e.id=e.comment_post_ID,e.comments_listing=this.comments_listing,e.p=C('[name="p"]').val(),C("#comment-"+C("#comment_ID").val()).hasClass("unapproved")&&(e.approve_parent=1),C.ajax({type:"POST",url:ajaxurl,data:e,success:function(t){commentReply.show(t)},error:function(t){commentReply.error(t)}}),!1},show:function(t){var e,n,a,s=this;return"string"==typeof t?(s.error({responseText:t}),!1):(e=wpAjax.parseAjaxResponse(t)).errors?(s.error({responseText:wpAjax.broken}),!1):(s.revert(),t="#comment-"+(e=e.responses[0]).id,"edit-comment"==s.act&&C(t).remove(),void(e.supplemental.parent_approved&&(a=C("#comment-"+e.supplemental.parent_approved),L(-1,e.supplemental.parent_post_id),"moderated"==this.comments_listing)?a.animate({backgroundColor:"#CCEEBB"},400,function(){a.fadeOut()}):(e.supplemental.i18n_comments_text&&(w?k(e.supplemental):(x(1,e.supplemental.parent_post_id),b("span.all-count",1))),e=C.trim(e.data),C(e).hide(),C("#replyrow").after(e),t=C(t),s.addEvents(t),n=t.hasClass("unapproved")?"#FFFFE0":t.closest(".widefat, .postbox").css("backgroundColor"),t.animate({backgroundColor:"#CCEEBB"},300).animate({backgroundColor:n},300,function(){a&&a.length&&a.animate({backgroundColor:"#CCEEBB"},300).animate({backgroundColor:n},300).removeClass("unapproved").addClass("approved").find("div.comment_status").html("1")}))))},error:function(t){var e=t.statusText;C("#replysubmit .spinner").removeClass("is-active"),(e=t.responseText?t.responseText.replace(/<.[^<>]*?>/g,""):e)&&C("#replysubmit .error").html(e).show()},addcomment:function(t){var e=this;C("#add-new-comment").fadeOut(200,function(){e.open(0,t,"add"),C("table.comments-box").css("display",""),C("#no-comments").remove()})}},C(document).ready(function(){var t,e,n,a;setCommentsList(),commentReply.init(),C(document).on("click","span.delete a.delete",function(t){t.preventDefault()}),void 0!==C.table_hotkeys&&(t=function(n){return function(){var t="next"==n?"first":"last",e=C(".tablenav-pages ."+n+"-page:not(.disabled)");e.length&&(window.location=e[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g,"")+"&hotkeys_highlight_"+t+"=1")}},e=function(t,e){window.location=C("span.edit a",e).attr("href")},n=function(){C("#cb-select-all-1").data("wp-toggle",1).trigger("click").removeData("wp-toggle")},a=function(e){return function(){var t=C('select[name="action"]');C('option[value="'+e+'"]',t).prop("selected",!0),C("#doaction").click()}},C.table_hotkeys(C("table.widefat"),["a","u","s","d","r","q","z",["e",e],["shift+x",n],["shift+a",a("approve")],["shift+s",a("spam")],["shift+d",a("delete")],["shift+t",a("trash")],["shift+z",a("untrash")],["shift+u",a("unapprove")]],{highlight_first:adminCommentsL10n.hotkeys_highlight_first,highlight_last:adminCommentsL10n.hotkeys_highlight_last,prev_page_link_cb:t("prev"),next_page_link_cb:t("next"),hotkeys_opts:{disableInInput:!0,type:"keypress",noDisable:'.check-column input[type="checkbox"]'},cycle_expr:"#the-comment-list tr",start_row_index:0})),C("#the-comment-list").on("click",".comment-inline",function(t){t.preventDefault();var e=C(this),t="replyto";void 0!==e.data("action")&&(t=e.data("action")),commentReply.open(e.data("commentId"),e.data("postId"),t)})})}(jQuery);