Make WordPress Core

Changeset 19893


Ignore:
Timestamp:
02/09/2012 09:40:46 PM (12 years ago)
Author:
ryan
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/theme.dev.js

    r19887 r19893  
    6767       
    6868        init : function() {
    69             $( '.pagination-links' ).hide();
     69            $('.pagination-links').hide();
    7070
    7171            inputs.nonce = $('#_ajax_fetch_list_nonce').val();
     
    7878            inputs.search = inputs.queryArray['s'];
    7979            inputs.features = inputs.queryArray['features'];
    80             inputs.startPage = parseInt( inputs.queryArray['paged'] );
     80            inputs.startPage = parseInt( inputs.queryArray['paged'] ); 
    8181            inputs.tab = inputs.queryArray['tab'];
    8282            inputs.type = inputs.queryArray['type'];
     
    8787                inputs.startPage++;
    8888
    89             // FIXME: Debug Features Array
    90             // console.log("Features:" + inputs.features);
    91 
    92             // Link to output and start polling
     89            // Cache jQuery objects
    9390            inputs.outList = $('#availablethemes');
     91            inputs.waiting = $('div.tablenav.bottom').children( 'img.ajax-loading' );
     92            inputs.window = $(window);
    9493
    9594            // Generate Query
     
    9796
    9897            // Start Polling
    99             $(window).scroll( function(){ wpThemes.maybeLoad(); });
     98            inputs.window.scroll( function(){ wpThemes.maybeLoad(); } );
    10099        },
    101100        delayedCallback : function( func, delay ) {
     
    138137                this.noMoreResults = true;
    139138            } else {
    140                 inputs.outList.append(results.rows);
     139                inputs.outList.append( results.rows );
    141140            }
    142141        },
     
    144143            var self = this,
    145144                el = $(document),
    146                 bottom = el.scrollTop() + $(window).innerHeight();
    147 
    148             /* // FIXME: Debug scroll trigger.
    149             console.log('scrollTop:'+ el.scrollTop() +
    150                 '; scrollBottom:' + bottom +
    151                 '; height:' + el.height() +
    152                 '; checkVal:' + (el.height() - wpThemes.outListBottomThreshold));
    153             */
    154 
     145                bottom = el.scrollTop() + inputs.window.innerHeight();
     146               
    155147            if ( this.noMoreResults ||
    156148                 !this.query.ready() ||
     
    160152            setTimeout( function() {
    161153                var newTop = el.scrollTop(),
    162                     newBottom = newTop + $(window).innerHeight();
     154                    newBottom = newTop + inputs.window.innerHeight();
    163155
    164156                if ( !self.query.ready() ||
     
    166158                    return;
    167159
    168                 /* FIXME: Create/Add Spinner.
    169                 self.waiting.show(); // Show Spinner
    170                 el.scrollTop( newTop + self.waiting.outerHeight() ); // Scroll down?
    171                 self.ajax( function() { self.waiting.hide(); }); // Hide Spinner
    172                 */
    173                 self.ajax();
     160                inputs.waiting.css( 'visibility', 'visible' ); // Show Spinner
     161                self.ajax( function() { inputs.waiting.css( 'visibility', 'hidden' ) } ); // Hide Spinner
     162               
    174163            }, wpThemes.timeToTriggerQuery );
    175164        },
     
    214203            query = {
    215204                action: 'fetch-list',
     205                tab: inputs.tab,
    216206                paged: this.page,
    217207                s: inputs.search,
     208                type: inputs.type,
     209                _ajax_fetch_list_nonce: inputs.nonce,
    218210                'features[]': inputs.features,
    219                 'list_args': list_args,
    220                 'tab': inputs.tab,
    221                 'type': inputs.type,
    222                 '_ajax_fetch_list_nonce': inputs.nonce
     211                'list_args': list_args
    223212            };
    224213
Note: See TracChangeset for help on using the changeset viewer.