WordPress/wp-admin/js/edit-comments.min.js
Andrew Nacin 47559f45bf Avoid jshint errors in edit-comment.js.
props adamsilverstein.
fixes #25979.

Built from https://develop.svn.wordpress.org/trunk@26156


git-svn-id: http://core.svn.wordpress.org/trunk@26067 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-14 05:10:10 +00:00

1 line
11 KiB
JavaScript

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