Changeset 7153

Show
Ignore:
Timestamp:
03/04/08 17:07:47 (9 months ago)
Author:
ryan
Message:

Comment bubble count fixes from mdawaffe. fixes #6090

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-admin/includes/schema.php

    r7149 r7153  
    251251    add_option('medium_size_h', 300); 
    252252    add_option('autosave_interval', 60); 
     253    add_option('autosave_interval', 60); 
    253254 
    254255    // Delete unused options 
  • 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 
  • trunk/wp-includes/script-loader.php

    r7148 r7153  
    131131                'strong' => __('Strong') 
    132132            ) ); 
    133             $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080228' ); 
     133            $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080304' ); 
     134            $this->localize( 'admin-comments', 'adminCommentsL10n', array( 
     135                'pending' => __('%i% pending') // must look like: "# blah blah" 
     136            ) ); 
    134137            $this->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' ); 
    135138            $this->add( 'admin-forms', '/wp-admin/js/forms.js', false, '20080108' );