Infinite scroll for themes.php and theme-install.php. Bump per page limit for themes.php to 999. Props helenyhou, DH-Shredder. see #19815

git-svn-id: http://svn.automattic.com/wordpress/trunk@19893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2012-02-09 21:40:46 +00:00
parent b0eb479cc2
commit 5cb35a7dfb
1 changed files with 17 additions and 28 deletions

View File

@ -66,7 +66,7 @@ var wpThemes;
noMoreResults: false, noMoreResults: false,
init : function() { init : function() {
$( '.pagination-links' ).hide(); $('.pagination-links').hide();
inputs.nonce = $('#_ajax_fetch_list_nonce').val(); inputs.nonce = $('#_ajax_fetch_list_nonce').val();
@ -86,17 +86,16 @@ var wpThemes;
else else
inputs.startPage++; inputs.startPage++;
// FIXME: Debug Features Array // Cache jQuery objects
// console.log("Features:" + inputs.features);
// Link to output and start polling
inputs.outList = $('#availablethemes'); inputs.outList = $('#availablethemes');
inputs.waiting = $('div.tablenav.bottom').children( 'img.ajax-loading' );
inputs.window = $(window);
// Generate Query // Generate Query
wpThemes.query = new Query(); wpThemes.query = new Query();
// Start Polling // Start Polling
$(window).scroll( function(){ wpThemes.maybeLoad(); }); inputs.window.scroll( function(){ wpThemes.maybeLoad(); } );
}, },
delayedCallback : function( func, delay ) { delayedCallback : function( func, delay ) {
var timeoutTriggered, funcTriggered, funcArgs, funcContext; var timeoutTriggered, funcTriggered, funcArgs, funcContext;
@ -137,20 +136,13 @@ var wpThemes;
( results.rows.indexOf( "no-items" ) != -1 ) ) { ( results.rows.indexOf( "no-items" ) != -1 ) ) {
this.noMoreResults = true; this.noMoreResults = true;
} else { } else {
inputs.outList.append(results.rows); inputs.outList.append( results.rows );
} }
}, },
maybeLoad: function() { maybeLoad: function() {
var self = this, var self = this,
el = $(document), el = $(document),
bottom = el.scrollTop() + $(window).innerHeight(); bottom = el.scrollTop() + inputs.window.innerHeight();
/* // FIXME: Debug scroll trigger.
console.log('scrollTop:'+ el.scrollTop() +
'; scrollBottom:' + bottom +
'; height:' + el.height() +
'; checkVal:' + (el.height() - wpThemes.outListBottomThreshold));
*/
if ( this.noMoreResults || if ( this.noMoreResults ||
!this.query.ready() || !this.query.ready() ||
@ -159,18 +151,15 @@ var wpThemes;
setTimeout( function() { setTimeout( function() {
var newTop = el.scrollTop(), var newTop = el.scrollTop(),
newBottom = newTop + $(window).innerHeight(); newBottom = newTop + inputs.window.innerHeight();
if ( !self.query.ready() || if ( !self.query.ready() ||
( newBottom < inputs.outList.height() - wpThemes.outListBottomThreshold ) ) ( newBottom < inputs.outList.height() - wpThemes.outListBottomThreshold ) )
return; return;
/* FIXME: Create/Add Spinner. inputs.waiting.css( 'visibility', 'visible' ); // Show Spinner
self.waiting.show(); // Show Spinner self.ajax( function() { inputs.waiting.css( 'visibility', 'hidden' ) } ); // Hide Spinner
el.scrollTop( newTop + self.waiting.outerHeight() ); // Scroll down?
self.ajax( function() { self.waiting.hide(); }); // Hide Spinner
*/
self.ajax();
}, wpThemes.timeToTriggerQuery ); }, wpThemes.timeToTriggerQuery );
}, },
parseQuery: function( query ) { parseQuery: function( query ) {
@ -213,13 +202,13 @@ var wpThemes;
var self = this, var self = this,
query = { query = {
action: 'fetch-list', action: 'fetch-list',
tab: inputs.tab,
paged: this.page, paged: this.page,
s: inputs.search, s: inputs.search,
type: inputs.type,
_ajax_fetch_list_nonce: inputs.nonce,
'features[]': inputs.features, 'features[]': inputs.features,
'list_args': list_args, 'list_args': list_args
'tab': inputs.tab,
'type': inputs.type,
'_ajax_fetch_list_nonce': inputs.nonce
}; };
this.querying = true; this.querying = true;