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

1 line
9.4 KiB
JavaScript
Raw Normal View History

var theList,theExtraList,toggleWithKeyboard=false;(function(a){setCommentsList=function(){var c,e,h,l=0,g,i,d,k;c=a('.tablenav input[name="_total"]',"#comments-form");e=a('.tablenav input[name="_per_page"]',"#comments-form");h=a('.tablenav input[name="_page"]',"#comments-form");g=function(n,m){var o=a("#"+m.element);if(o.is(".unapproved")){o.find("div.comment_status").html("0")}else{o.find("div.comment_status").html("1")}a("span.pending-count").each(function(){var p=a(this),r,q;r=p.html().replace(/[^0-9]+/g,"");r=parseInt(r,10);if(isNaN(r)){return}q=a("#"+m.element).is("."+m.dimClass)?1:-1;r=r+q;if(r<0){r=0}p.closest("#awaiting-mod")[0==r?"addClass":"removeClass"]("count-0");f(p,r);j()})};i=function(q,t){var w=a(q.target).attr("className"),m,o,p,s,u,v,r;q.data._total=c.val()||0;q.data._per_page=e.val()||0;q.data._page=h.val()||0;q.data._url=document.location.href;if(w.indexOf(":trash=1")!=-1){m=w.replace(/.*?comment-([0-9]+).*/,"$1");o=a("#comment-"+m);note=a("#undo-holder").html();if(o.siblings("#replyrow").length&&commentReply.cid==m){commentReply.close()}if(o.is("tr")){p=o.children(":visible").length;r=a(".author strong",o).html();s=a('<tr id="trashundo-'+m+'" style="display:none;"><td class="trash-undo" colspan="'+p+'">'+note+"</td></tr>")}else{r=a(".comment-author",o).html();s=a('<div id="trashundo-'+m+'" style="display:none;" class="trash-undo">'+note+"</div>")}o.before(s);a("strong","#trashundo-"+m).html(r+" ");u=a("a.undo-trash","#trashundo-"+m);u.attr("href","comment.php?action=untrashcomment&c="+m+"&_ajax_nonce="+q.data._ajax_nonce);u.attr("className","delete:the-comment-list:comment-"+m+"::untrash=1 vim-z vim-destructive");u.click(function(){t.wpList.del(this);a("#trashundo-"+m).fadeOut(300,function(){a(this).remove();a("#comment-"+m).css("backgroundColor","").fadeIn(300,function(){a(this).show()})});return false});if(v){window.clearTimeout(v)}v=window.setTimeout(function(){a("#trashundo-"+m).fadeOut("slow",function(){a(this).remove()})},7000)}return q};d=function(m,n,o){if(n<l){return}if(o){l=n}c.val(m.toString());a("span.total-type-count").each(function(){f(a(this),m)})};function j(s){var r=a("#dashboard_right_now"),o,q,p,m;s=s||0;if(isNaN(s)||!r.length){return}o=a("span.total-count",r);q=a("span.approved-count",r);p=b(o);m=b(q);if(p){p=p+s;m=p-b(a("span.pending-count",r));f(o,p);f(q,m)}}function b(m){var o=parseInt(m.html().replace(/[^0-9]+/g,""),10);if(isNaN(o)){return 0}return o}function f(o,p){var m="";if(isNaN(p)){return}p=p<1?"0":p.toString();if(p.length>3){while(p.length>3){m=thousandsSeparator+p.substr(p.length-3)+m;p=p.substr(0,p.length-3)}p=p+m}o.html(p)}k=function(m,n){var q,o,p,u=a(n.target).parent().is("span.untrash"),t,s;function v(r){if(a(n.target).parent().is("span."+r)){return 1}else{if(a("#"+n.element).is("."+r)){return -1}}return 0}t=v("spam");s=v("trash");if(u){s=-1}a("span.pending-count").each(function(){var r=a(this),x=b(r),w=a("#"+n.element).is(".unapproved");if(a(n.target).parent().is("span.unapprove")||(u&&w)){x=x+1}else{if(w){x=x-1}}if(x<0){x=0}r.closest("#awaiting-mod")[0==x?"addClass":"removeClass"]("count-0");f(r,x);j()});a("span.spam-count").each(function(){var r=a(this),w=b(r)+t;f(r,w)});a("span.trash-count").each(function(){var r=a(this),w=b(r)+s;f(r,w)});if(a("#dashboard_right_now").length){p=t||s||0;if(p>0){j(-1)}else{if(p<0){j(1)}}}else{if(("object"==typeof m)&&l<n.parsed.responses[0].supplemental.time){o=n.parsed.responses[0].supplemental.pageLinks||"";if(a.trim(o)){a(".tablenav-pages").find(".page-numbers").remove().end().append(a(o))}else{a(".tablenav-pages").find(".page-numbers").remove()}}q=c.val()?parseInt(c.val(),10):0;q=q-t-s;if(q<0){q=0}d(q,m,false)}if(theExtraList.size()==0||theExtraList.children().size()==0||u){return}theList.get(0).wpList.add(theExtraList.children(":eq(0)").remove().clone());a("#get-extra-comments").submit()};theExtraList=a("#the-extra-comment-list").wpList({alt:"",delColor:"none",addColor:"none"});theList=a("#the-comment-list").wpList({alt:"",delBefore:i,dimAfter:g,delAfter:k,addColor:"none"}).bind("wpListDelEnd",function(n,m){var o=m.element.