Make WordPress Core

Ticket #36613: 36613.6.diff

File 36613.6.diff, 2.5 KB (added by adamsilverstein, 8 years ago)
  • src/wp-admin/js/theme.js

    diff --git src/wp-admin/js/theme.js src/wp-admin/js/theme.js
    index 39ed26ad94..257f6adccf 100644
    themes.view.Theme = wp.Backbone.View.extend({ 
    491491                // Set focus to current theme.
    492492                themes.focusedTheme = this.$el;
    493493
    494                 // Construct a new Preview view.
    495                 themes.currentPreview = preview = new themes.view.Preview({
     494                themes.preview = preview = new themes.view.Preview({
    496495                        model: this.model
    497496                });
    498497
    themes.view.Theme = wp.Backbone.View.extend({ 
    573572                        self.current = self.model;
    574573                });
    575574
    576                 // Listen for closepreview events, closing the preview.
    577                 this.listenTo( preview, 'closepreview', function() {
    578                         preview.close();
    579                 });
    580575        },
    581576
    582577        // Handles .disabled classes for previous/next buttons in theme installer preview
    themes.view.Preview = themes.view.Details.extend({ 
    916911                        }
    917912                }).removeClass( 'iframe-ready' );
    918913
    919                 themes.router.navigate( themes.router.baseUrl( '' ) );
     914                // Restore the previous browse tab if available.
     915                if ( themes.router.selectedTab ) {
     916                        themes.router.navigate( themes.router.baseUrl( '?browse=' + themes.router.selectedTab ) );
     917                } else {
     918                        themes.router.navigate( themes.router.baseUrl( '' ) );
     919                }
    920920                this.trigger( 'preview:close' );
    921921                this.undelegateEvents();
    922922                this.unbind();
    themes.view.Installer = themes.view.Appearance.extend({ 
    16511651        sort: function( sort ) {
    16521652                this.clearSearch();
    16531653
     1654                // Track sorting so we can restore the correct tab when closing preview.
     1655                themes.router.selectedTab = sort;
     1656
    16541657                $( '.filter-links li > a, .theme-filter' ).removeClass( this.activeClass );
    16551658                $( '[data-sort="' + sort + '"]' ).addClass( this.activeClass );
    16561659
    themes.RunInstaller = { 
    19141917                // Queries the API for the passed theme slug
    19151918                themes.router.on( 'route:preview', function( slug ) {
    19161919
     1920                        // Construct a new Preview view.
     1921                        if ( themes.preview ) {
     1922                                themes.preview.undelegateEvents();
     1923                                themes.preview.unbind();
     1924                        }
     1925
    19171926                        // If the theme preview is active, set the current theme.
    19181927                        if ( self.view.view.theme && self.view.view.theme.preview ) {
    19191928                                self.view.view.theme.model = self.view.collection.findWhere( { 'slug': slug } );
    themes.RunInstaller = { 
    19431952                        self.view.sort( sort );
    19441953
    19451954                        // Close the preview if open.
    1946                         if ( themes.currentPreview ) {
    1947                                 themes.currentPreview.trigger( 'closepreview' );
     1955                        if ( themes.preview ) {
     1956                                themes.preview.close();
    19481957                        }
    19491958                });
    19501959