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

1 line
11 KiB
JavaScript
Raw Normal View History

var theList,theExtraList,toggleWithKeyboard=false;(function($){setCommentsList=function(){var totalInput,perPageInput,pageInput,lastConfidentTime=0,dimAfter,delBefore,updateTotalCount,delAfter;totalInput=$('.tablenav input[name="_total"]',"#comments-form");perPageInput=$('.tablenav input[name="_per_page"]',"#comments-form");pageInput=$('.tablenav input[name="_page"]',"#comments-form");dimAfter=function(r,settings){var c=$("#"+settings.element);if(c.is(".unapproved")){c.find("div.comment_status").html("0")}else{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("className"),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;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").attr("checked","");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("className","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());$("span.total-type-count").each(function(){updateCount($(this),total)})};function dashboardTotals(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)}function getCount(el){var n=parseInt(el.html().replace(/[^0-9]+/g,""),10);if(isNaN(n)){return 0}return n}function updateCount(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)}delAfter=function(r,settings){var total,pageLinks,N,untrash=$(settings.target).parent().is("span.untrash"),unspam=$(settings.target).parent().is("span.unspam"),spam,trash;function getUpdate(s){if($(settings.target).parent().is("span."+s)){return 1}else{if($("#"+settings.element).is("."+s)){return -1}}return 0}spam=getUpdate("spam");trash=getUpdate("trash");if(untrash){trash=-1}if(unspam){spam=-1}$("span.pending-count").each(function(){var a=$(this),n=getCount(a),unapproved=$("#"+settings.element).is(".unapproved");if($(settings.target).parent().is("span.unapprove")||((untrash||unspam)&&unapproved)){n=n+1}else{if(unapproved){n=n-1}}if(n<0){n=0}a.closest("#awaiting-mod")[0==n?"addClass":"removeClass"]("count-0");updateCount(a,n);dashboard