<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[20094] trunk/wp-admin: Output themes and theme-install infinite scrolling args in JS, rather than parsing query strings.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/20094">20094</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-03-02 22:09:26 +0000 (Fri, 02 Mar 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Output themes and theme-install infinite scrolling args in JS, rather than parsing query strings. props DH-Shredder, helenyhou. Make WP_Theme_Install_List_Table extend WP_Themes_List_Table. Doesn't help much yet, but we should be able to dry things up further. see <a href="http://core.trac.wordpress.org/ticket/19815">#19815</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasswplisttablephp">trunk/wp-admin/includes/class-wp-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpthemeinstalllisttablephp">trunk/wp-admin/includes/class-wp-theme-install-list-table.php</a></li>
<li><a href="#trunkwpadminincludesclasswpthemeslisttablephp">trunk/wp-admin/includes/class-wp-themes-list-table.php</a></li>
<li><a href="#trunkwpadminincludeslisttablephp">trunk/wp-admin/includes/list-table.php</a></li>
<li><a href="#trunkwpadminjsthemedevjs">trunk/wp-admin/js/theme.dev.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasswplisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-list-table.php (20093 => 20094)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-list-table.php        2012-03-02 22:03:15 UTC (rev 20093)
+++ trunk/wp-admin/includes/class-wp-list-table.php        2012-03-02 22:09:26 UTC (rev 20094)
</span><span class="lines">@@ -484,7 +484,7 @@
</span><span class="cx">                 if ( empty( $this-&gt;_pagination_args ) )
</span><span class="cx">                         return;
</span><span class="cx"> 
</span><del>-                extract( $this-&gt;_pagination_args );
</del><ins>+                extract( $this-&gt;_pagination_args, EXTR_SKIP );
</ins><span class="cx"> 
</span><span class="cx">                 $output = '&lt;span class=&quot;displaying-num&quot;&gt;' . sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '&lt;/span&gt;';
</span><span class="cx"> 
</span><span class="lines">@@ -543,7 +543,10 @@
</span><span class="cx">                         '&amp;raquo;'
</span><span class="cx">                 );
</span><span class="cx"> 
</span><del>-                $output .= &quot;\n&lt;span class='pagination-links'&gt;&quot; . join( &quot;\n&quot;, $page_links ) . '&lt;/span&gt;';
</del><ins>+                $pagination_links_class = 'pagination-links';
+                if ( ! empty( $infinite_scroll ) )
+                        $pagination_links_class = ' hide-if-js';
+                $output .= &quot;\n&lt;span class='$pagination_links_class'&gt;&quot; . join( &quot;\n&quot;, $page_links ) . '&lt;/span&gt;';
</ins><span class="cx"> 
</span><span class="cx">                 if ( $total_pages )
</span><span class="cx">                         $page_class = $total_pages &lt; 2 ? ' one-page' : '';
</span><span class="lines">@@ -872,7 +875,7 @@
</span><span class="cx">                 $this-&gt;prepare_items();
</span><span class="cx"> 
</span><span class="cx">                 extract( $this-&gt;_args );
</span><del>-                extract( $this-&gt;_pagination_args );
</del><ins>+                extract( $this-&gt;_pagination_args, EXTR_SKIP );
</ins><span class="cx"> 
</span><span class="cx">                 ob_start();
</span><span class="cx">                 if ( ! empty( $_REQUEST['no_placeholder'] ) )
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpthemeinstalllisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-theme-install-list-table.php (20093 => 20094)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-theme-install-list-table.php        2012-03-02 22:03:15 UTC (rev 20093)
+++ trunk/wp-admin/includes/class-wp-theme-install-list-table.php        2012-03-02 22:09:26 UTC (rev 20094)
</span><span class="lines">@@ -7,25 +7,30 @@
</span><span class="cx">  * @since 3.1.0
</span><span class="cx">  * @access private
</span><span class="cx">  */
</span><del>-class WP_Theme_Install_List_Table extends WP_List_Table {
</del><ins>+class WP_Theme_Install_List_Table extends WP_Themes_List_Table {
</ins><span class="cx"> 
</span><del>-        function __construct() {
-                parent::__construct( array(
-                        'ajax' =&gt; true,
-                ) );
-        }
</del><ins>+        var $features = array();
</ins><span class="cx"> 
</span><span class="cx">         function ajax_user_can() {
</span><del>-                return current_user_can('install_themes');
</del><ins>+                return current_user_can( 'install_themes' );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function prepare_items() {
</span><span class="cx">                 include( ABSPATH . 'wp-admin/includes/theme-install.php' );
</span><span class="cx"> 
</span><del>-                global $tabs, $tab, $paged, $type, $term, $theme_field_defaults;
-
</del><ins>+                global $tabs, $tab, $paged, $type, $theme_field_defaults;
</ins><span class="cx">                 wp_reset_vars( array( 'tab' ) );
</span><span class="cx"> 
</span><ins>+                $search_terms = array();
+                $search_string = '';
+                if ( ! empty( $_REQUEST['s'] ) ){
+                        $search_string = strtolower( stripslashes( $_REQUEST['s'] ) );
+                        $search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) );
+                }
+
+                if ( ! empty( $_REQUEST['features'] ) )
+                        $this-&gt;features = $_REQUEST['features'];
+
</ins><span class="cx">                 $paged = $this-&gt;get_pagenum();
</span><span class="cx"> 
</span><span class="cx">                 $per_page = 36;
</span><span class="lines">@@ -55,29 +60,21 @@
</span><span class="cx">                 switch ( $tab ) {
</span><span class="cx">                         case 'search':
</span><span class="cx">                                 $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
</span><del>-                                $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
-
</del><span class="cx">                                 switch ( $type ) {
</span><span class="cx">                                         case 'tag':
</span><del>-                                                $terms = explode( ',', $term );
-                                                $terms = array_map( 'trim', $terms );
-                                                $terms = array_map( 'sanitize_title_with_dashes', $terms );
-                                                $args['tag'] = $terms;
</del><ins>+                                                $args['tag'] = array_map( 'sanitize_title_with_dashes', $search_terms );
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         case 'term':
</span><del>-                                                $args['search'] = $term;
</del><ins>+                                                $args['search'] = $search_string;
</ins><span class="cx">                                                 break;
</span><span class="cx">                                         case 'author':
</span><del>-                                                $args['author'] = $term;
</del><ins>+                                                $args['author'] = $search_string;
</ins><span class="cx">                                                 break;
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><del>-                                if ( !empty( $_REQUEST['features'] ) ) {
-                                        $terms = $_REQUEST['features'];
-                                        $terms = array_map( 'trim', $terms );
-                                        $terms = array_map( 'sanitize_title_with_dashes', $terms );
-                                        $args['tag'] = $terms;
-                                        $_REQUEST['s'] = implode( ',', $terms );
</del><ins>+                                if ( ! empty( $this-&gt;features ) ) {
+                                        $args['tag'] = $this-&gt;features;
+                                        $_REQUEST['s'] = implode( ',', $this-&gt;features );
</ins><span class="cx">                                         $_REQUEST['type'] = 'tag';
</span><span class="cx">                                 }
</span><span class="cx"> 
</span><span class="lines">@@ -95,7 +92,7 @@
</span><span class="cx">                                 $args = false;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-                if ( !$args )
</del><ins>+                if ( ! $args )
</ins><span class="cx">                         return;
</span><span class="cx"> 
</span><span class="cx">                 $api = themes_api( 'query_themes', $args );
</span><span class="lines">@@ -108,6 +105,7 @@
</span><span class="cx">                 $this-&gt;set_pagination_args( array(
</span><span class="cx">                         'total_items' =&gt; $api-&gt;info['results'],
</span><span class="cx">                         'per_page' =&gt; $per_page,
</span><ins>+                        'infinite_scroll' =&gt; true,
</ins><span class="cx">                 ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -128,12 +126,7 @@
</span><span class="cx">                 return $display_tabs;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        function get_columns() {
-                return array();
-        }
-
</del><span class="cx">         function display() {
</span><del>-
</del><span class="cx">                 wp_nonce_field( &quot;fetch-list-&quot; . get_class( $this ), '_ajax_fetch_list_nonce' );
</span><span class="cx"> ?&gt;
</span><span class="cx">                 &lt;div class=&quot;tablenav top themes&quot;&gt;
</span><span class="lines">@@ -149,12 +142,8 @@
</span><span class="cx">                         &lt;?php $this-&gt;display_rows_or_placeholder(); ?&gt;
</span><span class="cx">                 &lt;/div&gt;
</span><span class="cx"> 
</span><del>-                &lt;div class=&quot;tablenav bottom themes&quot;&gt;
-                        &lt;?php $this-&gt;pagination( 'bottom' ); ?&gt;
-                        &lt;img src=&quot;&lt;?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?&gt;&quot; class=&quot;ajax-loading list-ajax-loading&quot; alt=&quot;&quot; /&gt;
-                        &lt;br class=&quot;clear&quot; /&gt;
-                &lt;/div&gt;
-&lt;?php
</del><ins>+                &lt;?php
+                parent::tablenav( 'bottom' );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function display_rows() {
</span><span class="lines">@@ -170,4 +159,18 @@
</span><span class="cx">                                 ?&gt;&lt;/div&gt;
</span><span class="cx">                 &lt;?php } // end foreach $theme_names
</span><span class="cx">         }
</span><ins>+
+        /**
+         * Send required variables to JavaScript land
+         *
+         * @since 3.4
+         * @access private
+         *
+         * @uses $tab Global; current tab within Themes-&gt;Install screen
+         * @uses $type Global; type of search.
+         */
+        function _js_vars() {
+                global $tab, $type;
+                parent::_js_vars( compact( $tab, $type ) );
+        }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludesclasswpthemeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-wp-themes-list-table.php (20093 => 20094)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-wp-themes-list-table.php        2012-03-02 22:03:15 UTC (rev 20093)
+++ trunk/wp-admin/includes/class-wp-themes-list-table.php        2012-03-02 22:09:26 UTC (rev 20094)
</span><span class="lines">@@ -20,7 +20,7 @@
</span><span class="cx"> 
</span><span class="cx">         function ajax_user_can() {
</span><span class="cx">                 // Do not check edit_theme_options here. AJAX calls for available themes require switch_themes.
</span><del>-                return current_user_can('switch_themes');
</del><ins>+                return current_user_can( 'switch_themes' );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         function prepare_items() {
</span><span class="lines">@@ -52,6 +52,7 @@
</span><span class="cx">                 $this-&gt;set_pagination_args( array(
</span><span class="cx">                         'total_items' =&gt; count( $themes ),
</span><span class="cx">                         'per_page' =&gt; $per_page,
</span><ins>+                        'infinite_scroll' =&gt; true,
</ins><span class="cx">                 ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -202,4 +203,35 @@
</span><span class="cx"> 
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><ins>+
+        /**
+         * Send required variables to JavaScript land
+         *
+         * @since 3.4
+         * @access private
+         *
+         * @uses $this-&gt;features Array of all feature search terms.
+         * @uses get_pagenum()
+         * @uses _pagination_args['total_pages']
+         */
+         function _js_vars( $extra_args = array() ) {
+                $search_string = isset( $_REQUEST['s'] ) ? esc_attr( stripslashes( $_REQUEST['s'] ) ) : '';
+
+                $total_pages = 1;
+                if ( ! empty( $this-&gt;_pagination_args['total_pages'] ) )
+                        $total_pages = $this-&gt;_pagination_args['total_pages'];
+
+                $args = array(
+                        'search' =&gt; $search_string,
+                        'features' =&gt; $this-&gt;features,
+                        'paged' =&gt; $this-&gt;get_pagenum(),
+                        'total_pages' =&gt; $total_pages,
+                );
+
+                if ( is_array( $extra_args ) )
+                $args = array_merge( $args, $extra_args );
+
+                printf( &quot;&lt;script type='text/javascript'&gt;var theme_list_args = %s;&lt;/script&gt;\n&quot;, json_encode( $args ) );
+                parent::_js_vars();
+        }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkwpadminincludeslisttablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/list-table.php (20093 => 20094)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/list-table.php        2012-03-02 22:03:15 UTC (rev 20093)
+++ trunk/wp-admin/includes/list-table.php        2012-03-02 22:09:26 UTC (rev 20094)
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx">                 'WP_Links_List_Table' =&gt; 'links',
</span><span class="cx">                 'WP_Plugin_Install_List_Table' =&gt; 'plugin-install',
</span><span class="cx">                 'WP_Themes_List_Table' =&gt; 'themes',
</span><del>-                'WP_Theme_Install_List_Table' =&gt; 'theme-install',
</del><ins>+                'WP_Theme_Install_List_Table' =&gt; array( 'themes', 'theme-install' ),
</ins><span class="cx">                 'WP_Plugins_List_Table' =&gt; 'plugins',
</span><span class="cx">                 // Network Admin
</span><span class="cx">                 'WP_MS_Sites_List_Table' =&gt; 'ms-sites',
</span><span class="lines">@@ -37,7 +37,8 @@
</span><span class="cx">         );
</span><span class="cx"> 
</span><span class="cx">         if ( isset( $core_classes[ $class ] ) ) {
</span><del>-                require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $core_classes[ $class ] . '-list-table.php' );
</del><ins>+                foreach ( (array) $core_classes[ $class ] as $required )
+                        require_once( ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php' );
</ins><span class="cx">                 return new $class;
</span><span class="cx">         }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkwpadminjsthemedevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/theme.dev.js (20093 => 20094)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/theme.dev.js        2012-03-02 22:03:15 UTC (rev 20093)
+++ trunk/wp-admin/js/theme.dev.js        2012-03-02 22:09:26 UTC (rev 20094)
</span><span class="lines">@@ -54,48 +54,50 @@
</span><span class="cx">         theme_viewer.init();
</span><span class="cx"> });
</span><span class="cx"> 
</span><ins>+
+/**
+ * Class that provides infinite scroll for Themes admin screens
+ *
+ * @since 3.4
+ *
+ * @uses ajaxurl
+ * @uses list_args
+ * @uses theme_list_args
+ * @uses $('#_ajax_fetch_list_nonce').val()
+* */
</ins><span class="cx"> var ThemeScroller;
</span><del>-
</del><span class="cx"> (function($){
</span><span class="cx">         ThemeScroller = {
</span><del>-                // Inputs
</del><span class="cx">                 nonce: '',
</span><del>-                search: '',
-                tab: '',
-                type: '',
-                nextPage: 2,
-                features: {},
-
-                // Preferences
</del><ins>+                nextPage: 2, // By default, assume we're on the first page.
+                querying: false,
</ins><span class="cx">                 scrollPollingDelay: 500,
</span><span class="cx">                 failedRetryDelay: 4000,
</span><span class="cx">                 outListBottomThreshold: 300,
</span><span class="cx"> 
</span><del>-                // Flags
-                scrolling: false,
-                querying: false,
-
</del><ins>+                /**
+                 * Initializer
+                 *
+                 * @since 3.4
+                 * @access private
+                 */
</ins><span class="cx">                 init: function() {
</span><span class="cx">                         var self = this,
</span><del>-                                startPage,
-                                queryArray = {},
-                                queryString = window.location.search;
</del><ins>+                                startPage;
</ins><span class="cx"> 
</span><del>-                        // We're using infinite scrolling, so hide all pagination.
-                        $('.pagination-links').hide();
</del><ins>+                        // Get out early if we don't have the required arguments.
+                        if ( typeof ajaxurl === 'undefined' ||
+                                 typeof list_args === 'undefined' ||
+                                 typeof theme_list_args === 'undefined' ) {
+                                        $('.pagination-links').show();
+                                        return;
+                        }
</ins><span class="cx"> 
</span><del>-                        // Parse GET query string
-                        queryArray = this.parseQuery( queryString.substring( 1 ) );
-
</del><span class="cx">                         // Handle inputs
</span><span class="cx">                         this.nonce = $('#_ajax_fetch_list_nonce').val();
</span><del>-                        this.search = queryArray['s'];
-                        this.features = queryArray['features'];
-                        this.tab = queryArray['tab'];
-                        this.type = queryArray['type'];
</del><span class="cx"> 
</span><del>-                        startPage = parseInt( queryArray['paged'], 10 );
-                        if ( ! isNaN( startPage ) )
</del><ins>+                        startPage = theme_list_args.paged;
+                        if ( startPage !== undefined )
</ins><span class="cx">                                 this.nextPage = ( startPage + 1 );
</span><span class="cx"> 
</span><span class="cx">                         // Cache jQuery selectors
</span><span class="lines">@@ -104,12 +106,25 @@
</span><span class="cx">                         this.$window = $(window);
</span><span class="cx">                         this.$document = $(document);
</span><span class="cx"> 
</span><del>-                        if ( $('.tablenav-pages').length )
</del><ins>+                        /**
+                         * If there are more pages to query, then start polling to track
+                         * when user hits the bottom of the current page
+                         */
+                        if ( theme_list_args.total_pages !== undefined &amp;&amp;
+                                 theme_list_args.total_pages &gt;= this.nextPage )
</ins><span class="cx">                                 this.pollInterval =
</span><span class="cx">                                         setInterval( function() {
</span><span class="cx">                                                 return self.poll();
</span><span class="cx">                                         }, this.scrollPollingDelay );
</span><span class="cx">                 },
</span><ins>+
+                /**
+                 * Checks to see if user has scrolled to bottom of page.
+                 * If so, requests another page of content from self.ajax().
+                 *
+                 * @since 3.4
+                 * @access private
+                 */
</ins><span class="cx">                 poll: function() {
</span><span class="cx">                         var bottom = this.$document.scrollTop() + this.$window.innerHeight();
</span><span class="cx"> 
</span><span class="lines">@@ -119,32 +134,49 @@
</span><span class="cx"> 
</span><span class="cx">                         this.ajax();
</span><span class="cx">                 },
</span><ins>+
+                /**
+                 * Applies results passed from this.ajax() to $outList
+                 *
+                 * @since 3.4
+                 * @access private
+                 *
+                 * @param results Array with results from this.ajax() query.
+                 */
</ins><span class="cx">                 process: function( results ) {
</span><span class="cx">                         if ( ( results === undefined ) ||
</span><del>-                                ( results.rows.indexOf( 'no-items' ) != -1 ) ) {
</del><ins>+                                 ( results.rows === undefined ) ||
+                                 ( results.rows.indexOf( 'no-items' ) != -1 ) ) {
</ins><span class="cx">                                 clearInterval( this.pollInterval );
</span><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="cx"> 
</span><del>-                        var totalPages = parseInt( results.total_pages, 10 );
-                        if ( this.nextPage &gt; totalPages )
</del><ins>+                        if ( this.nextPage &gt; theme_list_args.total_pages )
</ins><span class="cx">                                 clearInterval( this.pollInterval );
</span><span class="cx"> 
</span><del>-                        if ( this.nextPage &lt;= ( totalPages + 1 ) )
</del><ins>+                        if ( this.nextPage &lt;= ( theme_list_args.total_pages + 1 ) )
</ins><span class="cx">                                 this.$outList.append( results.rows );
</span><span class="cx">                 },
</span><ins>+
+                /**
+                 * Queries next page of themes
+                 *
+                 * @since 3.4
+                 * @access private
+                 */
</ins><span class="cx">                 ajax: function() {
</span><span class="cx">                         var self = this;
</span><ins>+
</ins><span class="cx">                         this.querying = true;
</span><span class="cx"> 
</span><span class="cx">                         var query = {
</span><span class="cx">                                 action: 'fetch-list',
</span><del>-                                tab: this.tab,
</del><span class="cx">                                 paged: this.nextPage,
</span><del>-                                s: this.search,
-                                type: this.type,
</del><ins>+                                s: theme_list_args.search,
+                                tab: theme_list_args.tab,
+                                type: theme_list_args.type,
</ins><span class="cx">                                 _ajax_fetch_list_nonce: this.nonce,
</span><del>-                                'features[]': this.features,
</del><ins>+                                'features[]': theme_list_args.features,
</ins><span class="cx">                                 'list_args': list_args
</span><span class="cx">                         };
</span><span class="cx"> 
</span><span class="lines">@@ -159,40 +191,13 @@
</span><span class="cx">                                 .fail( function() {
</span><span class="cx">                                         self.$spinner.css( 'visibility', 'hidden' );
</span><span class="cx">                                         self.querying = false;
</span><del>-                                        setTimeout( function() { self.ajax(); }, self.failedRetryDelay )
</del><ins>+                                        setTimeout( function() { self.ajax(); }, self.failedRetryDelay );
</ins><span class="cx">                                 });
</span><del>-                },
-                parseQuery: function( query ) {
-                        var params = {};
-                        if ( ! query )
-                                return params;
-
-                        var pairs = query.split( /[;&amp;]/ );
-                        for ( var i = 0; i &lt; pairs.length; i++ ) {
-                                var keyVal = pairs[i].split( '=' );
-
-                                if ( ! keyVal || keyVal.length != 2 )
-                                        continue;
-
-                                var key = unescape( keyVal[0] );
-                                var val = unescape( keyVal[1] );
-                                val = val.replace( /\+/g, ' ' );
-                                key = key.replace( /\[.*\]$/g, '' );
-
-                                if ( params[key] === undefined ) {
-                                        params[key] = val;
-                                } else {
-                                        var oldVal = params[key];
-                                        if ( ! $.isArray( params[key] ) )
-                                                params[key] = new Array( oldVal, val );
-                                        else
-                                                params[key].push( val );
-                                }
-                        }
-                        return params;
</del><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $(document).ready( function( $ ) { ThemeScroller.init(); });
</del><ins>+        $(document).ready( function($) {
+                ThemeScroller.init();
+        });
</ins><span class="cx"> 
</span><span class="cx"> })(jQuery);
</span></span></pre>
</div>
</div>

</body>
</html>