WordPress/wp-admin/js/edit-comments.js

1 line
13 KiB
JavaScript
Raw Normal View History

var theList,theExtraList,toggleWithKeyboard=false,getCount,updateCount,updatePending,dashboardTotals;(function($){setCommentsList=function(){var totalInput,perPageInput,pageInput,lastConfidentTime=0,dimAfter,delBefore,updateTotalCount,delAfter,refillTheExtraList;totalInput=$('input[name="_total"]',"#comments-form");perPageInput=$('input[name="_per_page"]',"#comments-form");pageInput=$('input[name="_page"]',"#comments-form");dimAfter=function(r,settings){var c=$("#"+settings.element),editRow,replyID,replyButton;editRow=$("#replyrow");replyID=$("#comment_ID",editRow).val();replyButton=$("#replybtn",editRow);if(c.is(".unapproved")){if(settings.data.id==replyID){replyButton.text(adminCommentsL10n.replyApprove)}c.find("div.comment_status").html("0")}else{if(settings.data.id==replyID){replyButton.text(adminCommentsL10n.reply)}c.find("div.comment_status").html("1")}$("span.pending-count").each(function(){var a=$(this),n,dif;n=a.html().replace(/[^0-9]+/g,"");n=parseInt(n,10);if(isNaN(n)){return}dif=$("#"+settings.element).is("."+settings.dimClass)?1:-1;n=n+dif;if(n<0){n=0}a.closest(".awaiting-mod")[0==n?"addClass":"removeClass"]("count-0");updateCount(a,n);dashboardTotals()})};delBefore=function(settings,list){var cl=$(settings.target).attr("class"),id,el,n,h,a,author,action=false;settings.data._total=totalInput.val()||0;settings.data._per_page=perPageInput.val()||0;settings.data._page=pageInput.val()||0;settings.data._url=document.location.href;settings.data.comment_status=$('input[name="comment_status"]',"#comments-form").val();if(cl.indexOf(":trash=1")!=-1){action="trash"}else{if(cl.indexOf(":spam=1")!=-1){action="spam"}}if(action){id=cl.replace(/.*?comment-([0-9]+).*/,"$1");el=$("#comment-"+id);note=$("#"+action+"-undo-holder").html();el.find(".check-column :checkbox").prop("checked",false);if(el.siblings("#replyrow").length&&commentReply.cid==id){commentReply.close()}if(el.is("tr")){n=el.children(":visible").length;author=$(".author strong",el).text();h=$('<tr id="undo-'+id+'" class="undo un'+action+'" style="display:none;"><td colspan="'+n+'">'+note+"</td></tr>")}else{author=$(".comment-author",el).text();h=$('<div id="undo-'+id+'" style="display:none;" class="undo un'+action+'">'+note+"</div>")}el.before(h);$("strong","#undo-"+id).text(author+" ");a=$(".undo a","#undo-"+id);a.attr("href","comment.php?action=un"+action+"comment&c="+id+"&_wpnonce="+settings.data._ajax_nonce);a.attr("class","delete:the-comment-list:comment-"+id+"::un"+action+"=1 vim-z vim-destructive");$(".avatar",el).clone().prependTo("#undo-"+id+" ."+action+"-undo-inside");a.click(function(){list.wpList.del(this);$("#undo-"+id).css({backgroundColor:"#ceb"}).fadeOut(350,function(){$(this).remove();$("#comment-"+id).css("backgroundColor","").fadeIn(300,function(){$(this).show()})});return false})}return settings};updateTotalCount=function(total,time,setConfidentTime){if(time<lastConfidentTime){return}if(setConfidentTime){lastConfidentTime=time}totalInput.val(total.toString())};dashboardTotals=function(n){var dash=$("#dashboard_right_now"),total,appr,totalN,apprN;n=n||0;if(isNaN(n)||!dash.length){return}total=$("span.total-count",dash);appr=$("span.approved-count",dash);totalN=getCount(total);totalN=totalN+n;apprN=totalN-getCount($("span.pending-count",dash))-getCount($("span.spam-count",dash));updateCount(total,totalN);updateCount(appr,apprN)};getCount=function(el){var n=parseInt(el.html().replace(/[^0-9]+/g,""),10);if(isNaN(n)){return 0}return n};updateCount=function(el,n){var n1="";if(isNaN(n)){return}n=n<1?"0":n.toString();if(n.length>3){while(n.length>3){n1=thousandsSeparator+n.substr(n.length-3)+n1;n=n.substr(0,n.length-3)}n=n+n1}el.html(n)};updatePending=function(n){$("span.pending-count").each(function(){var a=$(this);if(n<0){n=0}a.closest(".awaiting-mod")[0==n?"addClass":"removeClass"]("count-0");updateCount(a,n);dashboardTotals()})};delAfter=function(r,settings){var total,N,spam,trash,pending,untrash=$(settings.target).parent().is("span.untrash"),unspam=$(settings.target).parent().is("span.unspam"),unapproved=$("#"+settings.element).is(".unapproved