Make WordPress Core

Changeset 27759


Ignore:
Timestamp:
03/26/2014 11:13:43 PM (12 years ago)
Author:
wonderboymusic
Message:

Fix double avatars and JS errors when spamming/trashing comments.

Props avryl, SergeyBiryukov.
Fixes #27329.

Location:
trunk/src
Files:
2 edited

Legend:

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

    r27131 r27759  
    33
    44(function($) {
    5 var getCount, updateCount, updatePending, dashboardTotals;
     5var getCount, updateCount, updatePending;
    66
    77setCommentsList = function() {
     
    8080                        a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1');
    8181                        a.attr('class', 'vim-z vim-destructive');
    82                         $('.avatar', el).clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
     82                        $('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside');
    8383
    8484                        a.click(function(){
     
    104104
    105105                totalInput.val( total.toString() );
    106         };
    107 
    108         dashboardTotals = function(n) {
    109                 var total, appr, totalN, apprN,
    110                         dash = $('#dashboard_right_now');
    111 
    112                 n = n || 0;
    113                 if ( isNaN(n) || !dash.length )
    114                         return;
    115 
    116                 total = $('span.total-count', dash);
    117                 appr = $('span.approved-count', dash);
    118                 totalN = getCount(total);
    119 
    120                 totalN = totalN + n;
    121                 apprN = totalN - getCount( $('span.pending-count', dash) ) - getCount( $('span.spam-count', dash) );
    122                 updateCount(total, totalN);
    123                 updateCount(appr, apprN);
    124106        };
    125107
     
    154136                        updateCount( a, n );
    155137                });
    156 
    157                 dashboardTotals();
    158138        };
    159139
    160140        // In admin-ajax.php, we send back the unix time stamp instead of 1 on success
    161141        delAfter = function( r, settings ) {
    162                 var total_items_i18n, total, N, spam, trash, pending,
     142                var total_items_i18n, total, spam, trash, pending,
    163143                        untrash = $(settings.target).parent().is('span.untrash'),
    164144                        unspam = $(settings.target).parent().is('span.unspam'),
     
    206186                });
    207187
    208                 if ( $('#dashboard_right_now').length ) {
    209                         N = trash ? -1 * trash : 0;
    210                         dashboardTotals(N);
    211                 } else {
     188                if ( ! $('#dashboard_right_now').length ) {
    212189                        total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0;
    213190                        if ( $(settings.target).parent().is('span.undo') )
  • trunk/src/wp-includes/js/wp-lists.js

    r26195 r27759  
    310310
    311311        add: function( e, s ) {
    312                 e = $( $.trim(e) ); // Trim leading whitespaces
     312                if ( 'string' == typeof e ) {
     313                        e = $( $.trim( e ) ); // Trim leading whitespaces
     314                } else {
     315                        e = $( e );
     316                }
    313317
    314318                var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
Note: See TracChangeset for help on using the changeset viewer.