Fix the comments "river." issue 9. props garyc40. see #16262

git-svn-id: https://develop.svn.wordpress.org/trunk@17344 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Mark Jaquith 2011-01-21 21:17:12 +00:00
parent 19b385450e
commit 4bca42b961
5 changed files with 35 additions and 18 deletions

View File

@ -32,6 +32,7 @@ class WP_Comments_List_Table extends WP_List_Table {
parent::WP_List_Table( array(
'plural' => 'comments',
'singular' => 'comment',
'ajax' => true,
) );
}
@ -267,7 +268,7 @@ class WP_Comments_List_Table extends WP_List_Table {
function display() {
extract( $this->_args );
// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
$this->display_tablenav( 'top' );
@ -538,7 +539,7 @@ class WP_Post_Comments_List_Table extends WP_Comments_List_Table {
function display( $output_empty = false ) {
extract( $this->_args );
// wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' );
?>
<table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0" style="display:none;">
<tbody id="the-comment-list"<?php if ( $singular ) echo " class='list:$singular'"; ?>>

View File

@ -81,7 +81,7 @@ class WP_List_Table {
$args = wp_parse_args( $args, array(
'plural' => '',
'singular' => '',
'ajax' => true
'ajax' => false
) );
$screen = get_current_screen();
@ -93,10 +93,10 @@ class WP_List_Table {
$this->_args = $args;
// if ( $args['ajax'] ) {
if ( $args['ajax'] ) {
// wp_enqueue_script( 'list-table' );
// add_action( 'admin_footer', array( &$this, '_js_vars' ) );
// }
add_action( 'admin_footer', array( &$this, '_js_vars' ) );
}
}
/**

View File

@ -211,11 +211,15 @@ setCommentsList = function() {
theList.get(0).wpList.add( theExtraList.children(':eq(0)').remove().clone() );
// refillTheExtraList();
refillTheExtraList();
};
/* var refillTheExtraList = function(ev) {
var args = $.query.get(), total_pages = listTable.get_total_pages(), per_page = $('input[name=_per_page]', '#comments-form').val();
var refillTheExtraList = function(ev) {
// var args = $.query.get(), total_pages = listTable.get_total_pages(), per_page = $('input[name=_per_page]', '#comments-form').val(), r;
var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name=_per_page]', '#comments-form').val(), r;
if (! args.paged)
args.paged = 1;
if (args.paged > total_pages) {
return;
@ -226,17 +230,29 @@ setCommentsList = function() {
args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php
} else {
args.number = 1;
args.offset = per_page - 1; // fetch only the last item of the next page
args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list
}
args.no_placeholder = true;
args.paged ++;
listTable.fetch_list(args, function(response) {
theExtraList.get(0).wpList.add( response.rows );
args = $.extend(args, {
'action': 'fetch-list',
'list_args': list_args,
'_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val()
});
}; */
$.ajax({
url: ajaxurl,
global: false,
dataType: 'json',
data: args,
success: function(response) {
theExtraList.get(0).wpList.add( response.rows );
}
});
};
theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } );
theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } )

File diff suppressed because one or more lines are too long

View File

@ -299,7 +299,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'admin-custom-fields', "/wp-admin/js/custom-fields$suffix.js", array('wp-lists'), '20090106' );
$scripts->add_data( 'admin-custom-fields', 'group', 1 );
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags'), '20110121' );
$scripts->add( 'admin-comments', "/wp-admin/js/edit-comments$suffix.js", array('wp-lists', 'jquery-ui-resizable', 'quicktags', 'jquery-query'), '20110121b' );
$scripts->add_data( 'admin-comments', 'group', 1 );
$scripts->localize( 'admin-comments', 'adminCommentsL10n', array(
'hotkeys_highlight_first' => isset($_GET['hotkeys_highlight_first']),