From af95d56dc9c75508efe7b203b1a9de1589493dbf Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 4 Mar 2008 17:07:47 +0000 Subject: [PATCH] Comment bubble count fixes from mdawaffe. fixes #6090 git-svn-id: http://svn.automattic.com/wordpress/trunk@7153 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/schema.php | 1 + wp-admin/js/edit-comments.js | 33 +++++++++++++++++++++++++++++---- wp-includes/script-loader.php | 5 ++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/schema.php b/wp-admin/includes/schema.php index e94c39d0a5..d49196a5f9 100644 --- a/wp-admin/includes/schema.php +++ b/wp-admin/includes/schema.php @@ -250,6 +250,7 @@ function populate_options() { add_option('medium_size_w', 300); add_option('medium_size_h', 300); add_option('autosave_interval', 60); + add_option('autosave_interval', 60); // Delete unused options $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing'); diff --git a/wp-admin/js/edit-comments.js b/wp-admin/js/edit-comments.js index adcfe472c0..d911eff2b7 100644 --- a/wp-admin/js/edit-comments.js +++ b/wp-admin/js/edit-comments.js @@ -7,22 +7,47 @@ var dimAfter = function( r, settings ) { var n = parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 ); a.html( n.toString() ); }); - // we need to do the opposite for this guy, TODO: update title $('.post-com-count 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); + var t = parseInt(a.parent().attr('title'), 10); + if ( $('#' + settings.element).is('.unapproved') ) { // we unapproved a formerly approved comment + n = n - 1; + t = t + 1; + } else { // we approved a formerly unapproved comment + n = n + 1; + t = t - 1; + } + 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() ); }); } var delAfter = function( r, settings ) { - $('span.comment-count').each( function() { + $('li span.comment-count').each( function() { var a = $(this); - if ( a.parent('.current').size() || $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) { + 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() ); } }); + $('.post-com-count span.comment-count').each( function() { + var a = $(this); + if ( $('#' + settings.element).is('.unapproved') ) { // we deleted an unapproved comment, decrement pending title + var t = parseInt(a.parent().attr('title'), 10); + if ( t < 1 ) { return; } + t = t - 1; + a.parent().attr('title', adminCommentsL10n.pending.replace( /%i%/, t.toString() ) ); + if ( 0 === t ) { a.parents('strong:first').replaceWith( a.parents('strong:first').html() ); } + return; + } + var n = parseInt(a.html(),10) - 1; + a.html( n.toString() ); + }); if ( theExtraList.size() == 0 || theExtraList.children().size() == 0 ) { return; diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index 1d7040d908..5aef5e35e7 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -130,7 +130,10 @@ class WP_Scripts { 'good' => __('Good'), 'strong' => __('Strong') ) ); - $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080228' ); + $this->add( 'admin-comments', '/wp-admin/js/edit-comments.js', array('wp-lists'), '20080304' ); + $this->localize( 'admin-comments', 'adminCommentsL10n', array( + 'pending' => __('%i% pending') // must look like: "# blah blah" + ) ); $this->add( 'admin-users', '/wp-admin/js/users.js', array('wp-lists'), '20070823' ); $this->add( 'admin-forms', '/wp-admin/js/forms.js', false, '20080108' ); $this->add( 'xfn', '/wp-admin/js/xfn.js', false, '3517' );