Tidy up sanity checks in theme.dev.js. props DH-Shredder, fixes #19815.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
22863bd9c3
commit
e0fa1f427c
|
@ -105,8 +105,6 @@ jQuery( document ).ready( function($) {
|
||||||
var ThemeScroller;
|
var ThemeScroller;
|
||||||
(function($){
|
(function($){
|
||||||
ThemeScroller = {
|
ThemeScroller = {
|
||||||
nonce: '',
|
|
||||||
nextPage: 2, // By default, assume we're on the first page.
|
|
||||||
querying: false,
|
querying: false,
|
||||||
scrollPollingDelay: 500,
|
scrollPollingDelay: 500,
|
||||||
failedRetryDelay: 4000,
|
failedRetryDelay: 4000,
|
||||||
|
@ -119,8 +117,7 @@ var ThemeScroller;
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
init: function() {
|
init: function() {
|
||||||
var self = this,
|
var self = this;
|
||||||
startPage;
|
|
||||||
|
|
||||||
// Get out early if we don't have the required arguments.
|
// Get out early if we don't have the required arguments.
|
||||||
if ( typeof ajaxurl === 'undefined' ||
|
if ( typeof ajaxurl === 'undefined' ||
|
||||||
|
@ -132,10 +129,7 @@ var ThemeScroller;
|
||||||
|
|
||||||
// Handle inputs
|
// Handle inputs
|
||||||
this.nonce = $('#_ajax_fetch_list_nonce').val();
|
this.nonce = $('#_ajax_fetch_list_nonce').val();
|
||||||
|
this.nextPage = ( theme_list_args.paged + 1 );
|
||||||
startPage = theme_list_args.paged;
|
|
||||||
if ( startPage !== undefined )
|
|
||||||
this.nextPage = ( startPage + 1 );
|
|
||||||
|
|
||||||
// Cache jQuery selectors
|
// Cache jQuery selectors
|
||||||
this.$outList = $('#availablethemes');
|
this.$outList = $('#availablethemes');
|
||||||
|
@ -147,8 +141,7 @@ var ThemeScroller;
|
||||||
* If there are more pages to query, then start polling to track
|
* If there are more pages to query, then start polling to track
|
||||||
* when user hits the bottom of the current page
|
* when user hits the bottom of the current page
|
||||||
*/
|
*/
|
||||||
if ( theme_list_args.total_pages !== undefined &&
|
if ( theme_list_args.total_pages >= this.nextPage )
|
||||||
theme_list_args.total_pages >= this.nextPage )
|
|
||||||
this.pollInterval =
|
this.pollInterval =
|
||||||
setInterval( function() {
|
setInterval( function() {
|
||||||
return self.poll();
|
return self.poll();
|
||||||
|
@ -181,9 +174,7 @@ var ThemeScroller;
|
||||||
* @param results Array with results from this.ajax() query.
|
* @param results Array with results from this.ajax() query.
|
||||||
*/
|
*/
|
||||||
process: function( results ) {
|
process: function( results ) {
|
||||||
if ( ( results === undefined ) ||
|
if ( results === undefined ) {
|
||||||
( results.rows === undefined ) ||
|
|
||||||
( results.rows.indexOf( 'no-items' ) != -1 ) ) {
|
|
||||||
clearInterval( this.pollInterval );
|
clearInterval( this.pollInterval );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue