Make WordPress Core


Ignore:
Timestamp:
03/04/2008 05:07:47 PM (18 years ago)
Author:
ryan
Message:

Comment bubble count fixes from mdawaffe. fixes #6090

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/edit-comments.js

    r7082 r7153  
    88        a.html( n.toString() );
    99    });
    10     // we need to do the opposite for this guy, TODO: update title
    1110    $('.post-com-count span.comment-count').each( function() {
    1211        var a = $(this);
    13         var n = parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? -1 : 1 );
     12        var n = parseInt(a.html(),10);
     13        var t = parseInt(a.parent().attr('title'), 10);
     14        if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment
     15            n = n - 1;
     16            t = t + 1;
     17        } else { // we approved a formerly unapproved comment
     18            n = n + 1;
     19            t = t - 1;
     20        }
     21        if ( t >= 0 ) { a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); }
     22        if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
    1423        a.html( n.toString() );
    1524    });
     
    1726
    1827var delAfter = function( r, settings ) {
    19     $('span.comment-count').each( function() {
     28    $('li span.comment-count').each( function() {
    2029        var a = $(this);
    21         if ( a.parent('.current').size() || $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) {
     30        if ( parseInt(a.html(),10) < 1 ) { return; }
     31        // on ?edit-comments.php?comment_status=moderated tab
     32        // or the comment is unapproved
     33        if ( a.parent('.current').size() || $('#' + settings.element).is('.unapproved') ) {
    2234            var n = parseInt(a.html(),10) - 1;
    2335            a.html( n.toString() );
    2436        }
     37    });
     38    $('.post-com-count span.comment-count').each( function() {
     39        var a = $(this);
     40        if ( $('#' + settings.element).is('.unapproved') ) { // we deleted an unapproved comment, decrement pending title
     41            var t = parseInt(a.parent().attr('title'), 10);
     42            if ( t < 1 ) { return; }
     43            t = t - 1;
     44            a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) );
     45            if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); }
     46            return;
     47        }
     48        var n = parseInt(a.html(),10) - 1;
     49        a.html( n.toString() );
    2550    });
    2651
Note: See TracChangeset for help on using the changeset viewer.