From f14702fb65380d6fcd783c5e664f37014e4c718d Mon Sep 17 00:00:00 2001 From: westi Date: Tue, 11 Mar 2008 08:55:57 +0000 Subject: [PATCH] Bring the bubble back when we have moderated a comment. Fixes #6010 props mdawaffe. git-svn-id: http://svn.automattic.com/wordpress/trunk@7236 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/edit-comments.js | 20 +++++++++++--------- wp-includes/script-loader.php | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index ba016fb6f2..003f879d02 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -4,8 +4,11 @@ jQuery(function($) { var dimAfter = function( r, settings ) { $('li span.comment-count').each( function() { var a = $(this); - var n = parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); + var n = parseInt(a.html(),10); + n = n + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); + if ( n < 0 ) { n = 0; } a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); }); $('.post-com-count span.comment-count').each( function() { var a = $(this); @@ -18,6 +21,8 @@ var dimAfter = function( r, settings ) { n = n + 1; t = t - 1; } + if ( n < 0 ) { n = 0; } + if ( t < 0 ) { t = 0; } if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); } if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } a.html( n.toString() ); @@ -27,14 +32,11 @@ var dimAfter = function( r, settings ) { var delAfter = function( r, settings ) { $('li span.comment-count').each( function() { var a = $(this); - if ( parseInt(a.html(),10) < 1 ) { return; } - // on ?edit-comments.php?comment_status=moderated tab - // or the comment is unapproved - if ( a.parent('.current').size() || $('#' + settings.element).is('.unapproved') ) { - var n = parseInt(a.html(),10) - 1; - a.html( n.toString() ); - ( 0 < n ) ? $('#awaiting-mod').each(function() { $(this).show(); $(this).removeClass('count-0') }) : $('#awaiting-mod').hide(); - } + var n = parseInt(a.html(),10); + n = n + ( $('#' + settings.element).is('.unapproved') ? -1 : 1 ); + if ( n < 0 ) { n = 0; } + a.html( n.toString() ); + $('#awaiting-mod')[ 0 == n ? 'addClass' : 'removeClass' ]('count-0'); }); $('.post-com-count span.comment-count').each( function() { var a = $(this); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 2146988ef4..338b5b9fd7 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -122,7 +122,7 @@ class WP_Scripts { 'good' => __('Good'), 'strong' => __('Strong') ) ); - $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080304' ); + $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080311' ); $this->localize( 'admin-comments', 'adminCommentsL10n', array( 'pending' => __('%i% pending') // must look like: "# blah blah" ) );