]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/js/theme.js
Wordpress 4.5.3-scripts
[autoinstalls/wordpress.git] / wp-admin / js / theme.js
index 77054b5cbf24983aaed1c9cb80ad7d7c076ecc74..9cd738a1c32af144b83ee91432ba9a0e4817242a 100644 (file)
@@ -79,12 +79,11 @@ themes.view.Appearance = wp.Backbone.View.extend({
 
                // Render and append
                this.view.render();
-               this.$el.empty().append( this.view.el ).addClass('rendered');
-               this.$el.append( '<br class="clear"/>' );
+               this.$el.empty().append( this.view.el ).addClass( 'rendered' );
        },
 
        // Defines search element container
-       searchContainer: $( '#wpbody h2:first' ),
+       searchContainer: $( '#wpbody h1:first' ),
 
        // Search input and view
        // for current theme collection
@@ -105,7 +104,7 @@ themes.view.Appearance = wp.Backbone.View.extend({
                // Render and append after screen title
                view.render();
                this.searchContainer
-                       .append( $.parseHTML( '<label class="screen-reader-text" for="theme-search-input">' + l10n.search + '</label>' ) )
+                       .append( $.parseHTML( '<label class="screen-reader-text" for="wp-filter-search-input">' + l10n.search + '</label>' ) )
                        .append( view.el );
        },
 
@@ -156,16 +155,17 @@ themes.Collection = Backbone.Collection.extend({
                // Useful for resetting the views when you clean the input
                if ( this.terms === '' ) {
                        this.reset( themes.data.themes );
+                       $( 'body' ).removeClass( 'no-results' );
                }
 
-               // Trigger an 'update' event
-               this.trigger( 'update' );
+               // Trigger a 'themes:update' event
+               this.trigger( 'themes:update' );
        },
 
        // Performs a search within the collection
        // @uses RegExp
        search: function( term ) {
-               var match, results, haystack;
+               var match, results, haystack, name, description, author;
 
                // Start with a full collection
                this.reset( themes.data.themes, { silent: true } );
@@ -181,7 +181,11 @@ themes.Collection = Backbone.Collection.extend({
                // Find results
                // _.filter and .test
                results = this.filter( function( data ) {
-                       haystack = _.union( data.get( 'name' ), data.get( 'id' ), data.get( 'description' ), data.get( 'author' ), data.get( 'tags' ) );
+                       name        = data.get( 'name' ).replace( /(<([^>]+)>)/ig, '' );
+                       description = data.get( 'description' ).replace( /(<([^>]+)>)/ig, '' );
+                       author      = data.get( 'author' ).replace( /(<([^>]+)>)/ig, '' );
+
+                       haystack = _.union( [ name, data.get( 'id' ), description, author, data.get( 'tags' ) ] );
 
                        if ( match.test( data.get( 'author' ) ) && term.length > 2 ) {
                                data.set( 'displayAuthor', true );
@@ -190,6 +194,12 @@ themes.Collection = Backbone.Collection.extend({
                        return match.test( haystack );
                });
 
+               if ( results.length === 0 ) {
+                       this.trigger( 'query:empty' );
+               } else {
+                       $( 'body' ).removeClass( 'no-results' );
+               }
+
                this.reset( results );
        },
 
@@ -254,7 +264,7 @@ themes.Collection = Backbone.Collection.extend({
 
                                // Trigger a collection refresh event
                                // and a `query:success` event with a `count` argument.
-                               self.trigger( 'update' );
+                               self.trigger( 'themes:update' );
                                self.trigger( 'query:success', count );
 
                                if ( data.themes && data.themes.length === 0 ) {
@@ -298,7 +308,7 @@ themes.Collection = Backbone.Collection.extend({
                                this.count = this.length;
                        }
 
-                       this.trigger( 'update' );
+                       this.trigger( 'themes:update' );
                        this.trigger( 'query:success', this.count );
                }
        },
@@ -336,7 +346,7 @@ themes.Collection = Backbone.Collection.extend({
                        beforeSend: function() {
                                if ( ! paginated ) {
                                        // Spin it
-                                       $( 'body' ).addClass( 'loading-themes' ).removeClass( 'no-results' );
+                                       $( 'body' ).addClass( 'loading-content' ).removeClass( 'no-results' );
                                }
                        }
                });
@@ -362,7 +372,6 @@ themes.view.Theme = wp.Backbone.View.extend({
 
        events: {
                'click': themes.isInstall ? 'preview': 'expand',
-               'click .preview': 'preview',
                'keydown': themes.isInstall ? 'preview': 'expand',
                'touchend': themes.isInstall ? 'preview': 'expand',
                'keyup': 'addFocus',
@@ -444,6 +453,8 @@ themes.view.Theme = wp.Backbone.View.extend({
                var self = this,
                        current, preview;
 
+               event = event || window.event;
+
                // Bail if the user scrolled on a touch device
                if ( this.touchDrag === true ) {
                        return this.touchDrag = false;
@@ -487,7 +498,7 @@ themes.view.Theme = wp.Backbone.View.extend({
                        preview.$el.removeClass( 'no-navigation' );
                }
 
-               // Apend preview
+               // Append preview
                $( 'div.wrap' ).append( preview.el );
 
                // Listen to our preview object
@@ -502,7 +513,7 @@ themes.view.Theme = wp.Backbone.View.extend({
                                current = self.current;
                        }
 
-                       // Get previous theme model.
+                       // Get next theme model.
                        self.current = self.model.collection.at( self.model.collection.indexOf( current ) + 1 );
 
                        // If we have no more themes, bail.
@@ -511,15 +522,11 @@ themes.view.Theme = wp.Backbone.View.extend({
                                return self.current = current;
                        }
 
-                       // Construct a new Preview view.
-                       preview = new themes.view.Preview({
-                               model: self.current
-                       });
+                       preview.model = self.current;
 
                        // Render and append.
                        preview.render();
                        this.setNavButtonsState();
-                       $( 'div.wrap' ).append( preview.el );
                        $( '.next-theme' ).focus();
                })
                .listenTo( preview, 'theme:previous', function() {
@@ -545,15 +552,11 @@ themes.view.Theme = wp.Backbone.View.extend({
                                return;
                        }
 
-                       // Construct a new Preview view.
-                       preview = new themes.view.Preview({
-                               model: self.current
-                       });
+                       preview.model = self.current;
 
                        // Render and append.
                        preview.render();
                        this.setNavButtonsState();
-                       $( 'div.wrap' ).append( preview.el );
                        $( '.previous-theme' ).focus();
                });
 
@@ -704,7 +707,7 @@ themes.view.Details = wp.Backbone.View.extend({
        // Performs the actions to effectively close
        // the theme details overlay
        closeOverlay: function() {
-               $( 'body' ).removeClass( 'theme-overlay-open' );
+               $( 'body' ).removeClass( 'modal-open' );
                this.remove();
                this.unbind();
                this.trigger( 'theme:collapse' );
@@ -753,6 +756,7 @@ themes.view.Preview = themes.view.Details.extend({
        events: {
                'click .close-full-overlay': 'close',
                'click .collapse-sidebar': 'collapse',
+               'click .devices button': 'previewDevice',
                'click .previous-theme': 'previousTheme',
                'click .next-theme': 'nextTheme',
                'keyup': 'keyEvent'
@@ -762,16 +766,30 @@ themes.view.Preview = themes.view.Details.extend({
        html: themes.template( 'theme-preview' ),
 
        render: function() {
-               var data = this.model.toJSON();
+               var self = this, currentPreviewDevice,
+                       data = this.model.toJSON();
 
-               this.$el.html( this.html( data ) );
+               this.$el.removeClass( 'iframe-ready' ).html( this.html( data ) );
 
-               themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } );
+               currentPreviewDevice = this.$el.data( 'current-preview-device' );
+               if ( currentPreviewDevice ) {
+                       self.tooglePreviewDeviceButtons( currentPreviewDevice );
+               }
+
+               themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: true } );
 
                this.$el.fadeIn( 200, function() {
                        $( 'body' ).addClass( 'theme-installer-active full-overlay-active' );
                        $( '.close-full-overlay' ).focus();
                });
+
+               this.$el.find( 'iframe' ).one( 'load', function() {
+                       self.iframeLoaded();
+               });
+       },
+
+       iframeLoaded: function() {
+               this.$el.addClass( 'iframe-ready' );
        },
 
        close: function() {
@@ -782,20 +800,50 @@ themes.view.Preview = themes.view.Details.extend({
                        if ( themes.focusedTheme ) {
                                themes.focusedTheme.focus();
                        }
-               });
+               }).removeClass( 'iframe-ready' );
 
                themes.router.navigate( themes.router.baseUrl( '' ) );
                this.trigger( 'preview:close' );
+               this.undelegateEvents();
                this.unbind();
                return false;
        },
 
-       collapse: function() {
+       collapse: function( event ) {
+               var $button = $( event.currentTarget );
+               if ( 'true' === $button.attr( 'aria-expanded' ) ) {
+                       $button.attr({ 'aria-expanded': 'false', 'aria-label': l10n.expandSidebar });
+               } else {
+                       $button.attr({ 'aria-expanded': 'true', 'aria-label': l10n.collapseSidebar });
+               }
 
                this.$el.toggleClass( 'collapsed' ).toggleClass( 'expanded' );
                return false;
        },
 
+       previewDevice: function( event ) {
+               var device = $( event.currentTarget ).data( 'device' );
+
+               this.$el
+                       .removeClass( 'preview-desktop preview-tablet preview-mobile' )
+                       .addClass( 'preview-' + device )
+                       .data( 'current-preview-device', device );
+
+               this.tooglePreviewDeviceButtons( device );
+       },
+
+       tooglePreviewDeviceButtons: function( newDevice ) {
+               var $devices = $( '.wp-full-overlay-footer .devices' );
+
+               $devices.find( 'button' )
+                       .removeClass( 'active' )
+                       .attr( 'aria-pressed', false );
+
+               $devices.find( 'button.preview-' + newDevice )
+                       .addClass( 'active' )
+                       .attr( 'aria-pressed', true );
+       },
+
        keyEvent: function( event ) {
                // The escape key closes the preview
                if ( event.keyCode === 27 ) {
@@ -818,7 +866,7 @@ themes.view.Preview = themes.view.Details.extend({
 // a wrapper that will hold all the theme elements
 themes.view.Themes = wp.Backbone.View.extend({
 
-       className: 'themes',
+       className: 'themes wp-clearfix',
        $overlay: $( 'div.theme-overlay' ),
 
        // Number to keep track of scroll position
@@ -826,7 +874,10 @@ themes.view.Themes = wp.Backbone.View.extend({
        index: 0,
 
        // The theme count element
-       count: $( '.theme-count' ),
+       count: $( '.wrap .theme-count' ),
+
+       // The live themes count
+       liveThemeCount: 0,
 
        initialize: function( options ) {
                var self = this;
@@ -841,18 +892,20 @@ themes.view.Themes = wp.Backbone.View.extend({
                self.currentTheme();
 
                // When the collection is updated by user input...
-               this.listenTo( self.collection, 'update', function() {
+               this.listenTo( self.collection, 'themes:update', function() {
                        self.parent.page = 0;
                        self.currentTheme();
                        self.render( this );
-               });
+               } );
 
                // Update theme count to full result set when available.
                this.listenTo( self.collection, 'query:success', function( count ) {
                        if ( _.isNumber( count ) ) {
                                self.count.text( count );
+                               self.announceSearchResults( count );
                        } else {
                                self.count.text( self.collection.length );
+                               self.announceSearchResults( self.collection.length );
                        }
                });
 
@@ -897,7 +950,7 @@ themes.view.Themes = wp.Backbone.View.extend({
        // and keeping theme count in sync
        render: function() {
                // Clear the DOM, please
-               this.$el.html( '' );
+               this.$el.empty();
 
                // If the user doesn't have switch capabilities
                // or there is only one theme in the collection
@@ -923,7 +976,10 @@ themes.view.Themes = wp.Backbone.View.extend({
                }
 
                // Display a live theme count for the collection
-               this.count.text( this.collection.count ? this.collection.count : this.collection.length );
+               this.liveThemeCount = this.collection.count ? this.collection.count : this.collection.length;
+               this.count.text( this.liveThemeCount );
+
+               this.announceSearchResults( this.liveThemeCount );
        },
 
        // Iterates through each instance of the collection
@@ -941,7 +997,7 @@ themes.view.Themes = wp.Backbone.View.extend({
                }
 
                // Make sure the add-new stays at the end
-               if ( page >= 1 ) {
+               if ( ! themes.isInstall && page >= 1 ) {
                        $( '.add-new-theme' ).remove();
                }
 
@@ -963,8 +1019,8 @@ themes.view.Themes = wp.Backbone.View.extend({
                });
 
                // 'Add new theme' element shown at the end of the grid
-               if ( themes.data.settings.canInstall ) {
-                       this.$el.append( '<div class="theme add-new-theme"><a href="' + themes.data.settings.installURI + '"><div class="theme-screenshot"><span></span></div><h3 class="theme-name">' + l10n.addNew + '</h3></a></div>' );
+               if ( ! themes.isInstall && themes.data.settings.canInstall ) {
+                       this.$el.append( '<div class="theme add-new-theme"><a href="' + themes.data.settings.installURI + '"><div class="theme-screenshot"><span></span></div><h2 class="theme-name">' + l10n.addNew + '</h2></a></div>' );
                }
 
                this.parent.page++;
@@ -998,11 +1054,11 @@ themes.view.Themes = wp.Backbone.View.extend({
                this.model = self.collection.get( id );
 
                // Trigger a route update for the current model
-               themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.id ) );
+               themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.id ) );
 
                // Sets this.view to 'detail'
                this.setView( 'detail' );
-               $( 'body' ).addClass( 'theme-overlay-open' );
+               $( 'body' ).addClass( 'modal-open' );
 
                // Set up the theme details view
                this.overlay = new themes.view.Details({
@@ -1075,6 +1131,15 @@ themes.view.Themes = wp.Backbone.View.extend({
                        self.theme.trigger( 'theme:expand', previousModel.cid );
 
                }
+       },
+
+       // Dispatch audible search results feedback message
+       announceSearchResults: function( count ) {
+               if ( 0 === count ) {
+                       wp.a11y.speak( l10n.noThemesFound );
+               } else {
+                       wp.a11y.speak( l10n.themesFound.replace( '%d', count ) );
+               }
        }
 });
 
@@ -1082,21 +1147,20 @@ themes.view.Themes = wp.Backbone.View.extend({
 themes.view.Search = wp.Backbone.View.extend({
 
        tagName: 'input',
-       className: 'theme-search',
-       id: 'theme-search-input',
+       className: 'wp-filter-search',
+       id: 'wp-filter-search-input',
        searching: false,
 
        attributes: {
                placeholder: l10n.searchPlaceholder,
-               type: 'search'
+               type: 'search',
+               'aria-describedby': 'live-search-desc'
        },
 
        events: {
-               'input':  'search',
-               'keyup':  'search',
-               'change': 'search',
-               'search': 'search',
-               'blur':   'pushState'
+               'input': 'search',
+               'keyup': 'search',
+               'blur': 'pushState'
        },
 
        initialize: function( options ) {
@@ -1109,19 +1173,21 @@ themes.view.Search = wp.Backbone.View.extend({
 
        },
 
-       // Runs a search on the theme collection.
        search: function( event ) {
-               var options = {};
-
                // Clear on escape.
                if ( event.type === 'keyup' && event.which === 27 ) {
                        event.target.value = '';
                }
 
-               // Lose input focus when pressing enter
-               if ( event.which === 13 ) {
-                       this.$el.trigger( 'blur' );
-               }
+               /**
+                * Since doSearch is debounced, it will only run when user input comes to a rest
+                */
+               this.doSearch( event );
+       },
+
+       // Runs a search on the theme collection.
+       doSearch: _.debounce( function( event ) {
+               var options = {};
 
                this.collection.doSearch( event.target.value );
 
@@ -1134,17 +1200,17 @@ themes.view.Search = wp.Backbone.View.extend({
 
                // Update the URL hash
                if ( event.target.value ) {
-                       themes.router.navigate( themes.router.baseUrl( '?search=' + event.target.value ), options );
+                       themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + event.target.value ), options );
                } else {
                        themes.router.navigate( themes.router.baseUrl( '' ) );
                }
-       },
+       }, 500 ),
 
        pushState: function( event ) {
                var url = themes.router.baseUrl( '' );
 
                if ( event.target.value ) {
-                       url = themes.router.baseUrl( '?search=' + event.target.value );
+                       url = themes.router.baseUrl( themes.router.searchPath + event.target.value );
                }
 
                this.searching = false;
@@ -1169,12 +1235,15 @@ themes.Router = Backbone.Router.extend({
                return 'themes.php' + url;
        },
 
+       themePath: '?theme=',
+       searchPath: '?search=',
+
        search: function( query ) {
-               $( '.theme-search' ).val( query );
+               $( '.wp-filter-search' ).val( query );
        },
 
        themes: function() {
-               $( '.theme-search' ).val( '' );
+               $( '.wp-filter-search' ).val( '' );
        },
 
        navigate: function() {
@@ -1231,7 +1300,7 @@ themes.Run = {
 
                // Handles search route event
                themes.router.on( 'route:search', function() {
-                       $( '.theme-search' ).trigger( 'keyup' );
+                       $( '.wp-filter-search' ).trigger( 'keyup' );
                });
 
                this.extraRoutes();
@@ -1246,6 +1315,7 @@ themes.Run = {
 themes.view.InstallerSearch =  themes.view.Search.extend({
 
        events: {
+               'input': 'search',
                'keyup': 'search'
        },
 
@@ -1264,7 +1334,7 @@ themes.view.InstallerSearch =  themes.view.Search.extend({
                        event.target.value = '';
                }
 
-               _.debounce( _.bind( this.doSearch, this ), 300 )( event.target.value );
+               this.doSearch( event.target.value );
        },
 
        doSearch: _.debounce( function( value ) {
@@ -1290,16 +1360,16 @@ themes.view.InstallerSearch =  themes.view.Search.extend({
                        request.tag = [ value.slice( 4 ) ];
                }
 
-               $( '.theme-section.current' ).removeClass( 'current' );
-               $( 'body' ).removeClass( 'more-filters-opened filters-applied' );
+               $( '.filter-links li > a.current' ).removeClass( 'current' );
+               $( 'body' ).removeClass( 'show-filters filters-applied show-favorites-form' );
 
                // Get the themes by sending Ajax POST request to api.wordpress.org/themes
                // or searching the local cache
                this.collection.query( request );
 
                // Set route
-               themes.router.navigate( themes.router.baseUrl( '?search=' + value ), { replace: true } );
-       }, 300 )
+               themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + value ), { replace: true } );
+       }, 500 )
 });
 
 themes.view.Installer = themes.view.Appearance.extend({
@@ -1308,14 +1378,15 @@ themes.view.Installer = themes.view.Appearance.extend({
 
        // Register events for sorting and filters in theme-navigation
        events: {
-               'click .theme-section': 'onSort',
+               'click .filter-links li > a': 'onSort',
                'click .theme-filter': 'onFilter',
-               'click .more-filters': 'moreFilters',
-               'click .apply-filters': 'applyFilters',
-               'click [type="checkbox"]': 'addFilter',
-               'click .clear-filters': 'clearFilters',
-               'click .feature-name': 'filterSection',
-               'click .filtering-by a': 'backToFilters'
+               'click .drawer-toggle': 'moreFilters',
+               'click .filter-drawer .apply-filters': 'applyFilters',
+               'click .filter-group [type="checkbox"]': 'addFilter',
+               'click .filter-drawer .clear-filters': 'clearFilters',
+               'click .filtered-by': 'backToFilters',
+               'click .favorites-form-submit' : 'saveUsername',
+               'keyup #wporg-username-input': 'saveUsername'
        },
 
        // Initial render method
@@ -1345,12 +1416,12 @@ themes.view.Installer = themes.view.Appearance.extend({
                });
 
                this.listenTo( this.collection, 'query:success', function() {
-                       $( 'body' ).removeClass( 'loading-themes' );
+                       $( 'body' ).removeClass( 'loading-content' );
                        $( '.theme-browser' ).find( 'div.error' ).remove();
                });
 
                this.listenTo( this.collection, 'query:fail', function() {
-                       $( 'body' ).removeClass( 'loading-themes' );
+                       $( 'body' ).removeClass( 'loading-content' );
                        $( '.theme-browser' ).find( 'div.error' ).remove();
                        $( '.theme-browser' ).find( 'div.themes' ).before( '<div class="error"><p>' + l10n.error + '</p></div>' );
                });
@@ -1388,7 +1459,7 @@ themes.view.Installer = themes.view.Appearance.extend({
 
                event.preventDefault();
 
-               $( 'body' ).removeClass( 'filters-applied more-filters-opened' );
+               $( 'body' ).removeClass( 'filters-applied show-filters' );
 
                // Bail if this is already active
                if ( $el.hasClass( this.activeClass ) ) {
@@ -1398,15 +1469,21 @@ themes.view.Installer = themes.view.Appearance.extend({
                this.sort( sort );
 
                // Trigger a router.naviagte update
-               themes.router.navigate( themes.router.baseUrl( '?browse=' + sort ) );
+               themes.router.navigate( themes.router.baseUrl( themes.router.browsePath + sort ) );
        },
 
        sort: function( sort ) {
                this.clearSearch();
 
-               $( '.theme-section, .theme-filter' ).removeClass( this.activeClass );
+               $( '.filter-links li > a, .theme-filter' ).removeClass( this.activeClass );
                $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass );
 
+               if ( 'favorites' === sort ) {
+                       $ ( 'body' ).addClass( 'show-favorites-form' );
+               } else {
+                       $ ( 'body' ).removeClass( 'show-favorites-form' );
+               }
+
                this.browse( sort );
        },
 
@@ -1421,7 +1498,7 @@ themes.view.Installer = themes.view.Appearance.extend({
                        return;
                }
 
-               $( '.theme-filter, .theme-section' ).removeClass( this.activeClass );
+               $( '.filter-links li > a, .theme-section' ).removeClass( this.activeClass );
                $el.addClass( this.activeClass );
 
                if ( ! filter ) {
@@ -1430,7 +1507,7 @@ themes.view.Installer = themes.view.Appearance.extend({
 
                // Construct the filter request
                // using the default values
-               filter = _.union( filter, this.filtersChecked() );
+               filter = _.union( [ filter, this.filtersChecked() ] );
                request = { tag: [ filter ] };
 
                // Get the themes by sending Ajax POST request to api.wordpress.org/themes
@@ -1448,18 +1525,18 @@ themes.view.Installer = themes.view.Appearance.extend({
                var name,
                        tags = this.filtersChecked(),
                        request = { tag: tags },
-                       filteringBy = $( '.filtering-by .tags' );
+                       filteringBy = $( '.filtered-by .tags' );
 
                if ( event ) {
                        event.preventDefault();
                }
 
                $( 'body' ).addClass( 'filters-applied' );
-               $( '.theme-section.current' ).removeClass( 'current' );
+               $( '.filter-links li > a.current' ).removeClass( 'current' );
                filteringBy.empty();
 
                _.each( tags, function( tag ) {
-                       name = $( 'label[for="feature-id-' + tag + '"]' ).text();
+                       name = $( 'label[for="filter-id-' + tag + '"]' ).text();
                        filteringBy.append( '<span class="tag">' + name + '</span>' );
                });
 
@@ -1468,10 +1545,39 @@ themes.view.Installer = themes.view.Appearance.extend({
                this.collection.query( request );
        },
 
+       // Save the user's WordPress.org username and get his favorite themes.
+       saveUsername: function ( event ) {
+               var username = $( '#wporg-username-input' ).val(),
+                       nonce = $( '#wporg-username-nonce' ).val(),
+                       request = { browse: 'favorites', user: username },
+                       that = this;
+
+               if ( event ) {
+                       event.preventDefault();
+               }
+
+               // save username on enter
+               if ( event.type === 'keyup' && event.which !== 13 ) {
+                       return;
+               }
+
+               return wp.ajax.send( 'save-wporg-username', {
+                       data: {
+                               _wpnonce: nonce,
+                               username: username
+                       },
+                       success: function () {
+                               // Get the themes by sending Ajax POST request to api.wordpress.org/themes
+                               // or searching the local cache
+                               that.collection.query( request );
+                       }
+               } );
+       },
+
        // Get the checked filters
        // @return {array} of tags or false
        filtersChecked: function() {
-               var items = $( '.feature-group' ).find( ':checkbox' ),
+               var items = $( '.filter-group' ).find( ':checkbox' ),
                        tags = [];
 
                _.each( items.filter( ':checked' ), function( item ) {
@@ -1480,14 +1586,14 @@ themes.view.Installer = themes.view.Appearance.extend({
 
                // When no filters are checked, restore initial state and return
                if ( tags.length === 0 ) {
-                       $( '.apply-filters' ).find( 'span' ).text( '' );
-                       $( '.clear-filters' ).hide();
+                       $( '.filter-drawer .apply-filters' ).find( 'span' ).text( '' );
+                       $( '.filter-drawer .clear-filters' ).hide();
                        $( 'body' ).removeClass( 'filters-applied' );
                        return false;
                }
 
-               $( '.apply-filters' ).find( 'span' ).text( tags.length );
-               $( '.clear-filters' ).css( 'display', 'inline-block' );
+               $( '.filter-drawer .apply-filters' ).find( 'span' ).text( tags.length );
+               $( '.filter-drawer .clear-filters' ).css( 'display', 'inline-block' );
 
                return tags;
        },
@@ -1496,7 +1602,7 @@ themes.view.Installer = themes.view.Appearance.extend({
 
        // Overwrite search container class to append search
        // in new location
-       searchContainer: $( '.theme-navigation' ),
+       searchContainer: $( '.wp-filter .search-form' ),
 
        uploader: function() {
                $( 'a.upload' ).on( 'click', function( event ) {
@@ -1521,25 +1627,20 @@ themes.view.Installer = themes.view.Appearance.extend({
 
                // If the filters section is opened and filters are checked
                // run the relevant query collapsing to filtered-by state
-               if ( $( 'body' ).hasClass( 'more-filters-opened' ) && this.filtersChecked() ) {
+               if ( $( 'body' ).hasClass( 'show-filters' ) && this.filtersChecked() ) {
                        return this.addFilter();
                }
 
                this.clearSearch();
 
                themes.router.navigate( themes.router.baseUrl( '' ) );
-               $( 'body' ).toggleClass( 'more-filters-opened' );
-       },
-
-       // Expand/collapse each individual filter section
-       filterSection: function() {
-               $( event.target ).parent().toggleClass( 'open' );
+               $( 'body' ).toggleClass( 'show-filters' );
        },
 
        // Clears all the checked filters
        // @uses filtersChecked()
        clearFilters: function( event ) {
-               var items = $( '.feature-group' ).find( ':checkbox' ),
+               var items = $( '.filter-group' ).find( ':checkbox' ),
                        self = this;
 
                event.preventDefault();
@@ -1559,7 +1660,7 @@ themes.view.Installer = themes.view.Appearance.extend({
        },
 
        clearSearch: function() {
-               $( '#theme-search-input').val( '' );
+               $( '#wp-filter-search-input').val( '' );
        }
 });
 
@@ -1576,8 +1677,12 @@ themes.InstallerRouter = Backbone.Router.extend({
                return 'theme-install.php' + url;
        },
 
+       themePath: '?theme=',
+       browsePath: '?browse=',
+       searchPath: '?search=',
+
        search: function( query ) {
-               $( '.theme-search' ).val( query );
+               $( '.wp-filter-search' ).val( query );
        },
 
        navigate: function() {
@@ -1629,6 +1734,9 @@ themes.RunInstaller = {
                themes.router.on( 'route:preview', function( slug ) {
                        request.theme = slug;
                        self.view.collection.query( request );
+                       self.view.collection.once( 'update', function() {
+                               self.view.view.theme.preview();
+                       });
                });
 
                // Handles sorting / browsing routes
@@ -1649,7 +1757,7 @@ themes.RunInstaller = {
 
                // The `search` route event. The router populates the input field.
                themes.router.on( 'route:search', function() {
-                       $( '.theme-search' ).focus().trigger( 'keyup' );
+                       $( '.wp-filter-search' ).focus().trigger( 'keyup' );
                });
 
                this.extraRoutes();
@@ -1667,6 +1775,10 @@ $( document ).ready(function() {
        } else {
                themes.Run.init();
        }
+
+       $( '.broken-themes .delete-theme' ).on( 'click', function() {
+               return confirm( _wpThemeSettings.settings.confirmDelete );
+       });
 });
 
 })( jQuery );