Make WordPress Core

Ticket #36613: 36613.diff

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

     
    492492                themes.focusedTheme = this.$el;
    493493
    494494                // Construct a new Preview view.
    495                 preview = new themes.view.Preview({
     495                themes.currentPreview = preview = new themes.view.Preview({
    496496                        model: this.model
    497497                });
    498498
     
    572572                this.listenTo( preview, 'preview:close', function() {
    573573                        self.current = self.model;
    574574                });
     575
     576                // Listen for closepreview events, closing the preview.
     577                this.listenTo( preview, 'closepreview', function() {
     578                        preview.close();
     579                });
    575580        },
    576581
    577582        // Handles .disabled classes for previous/next buttons in theme installer preview
     
    885890                        self.tooglePreviewDeviceButtons( currentPreviewDevice );
    886891                }
    887892
    888                 themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: true } );
     893                themes.router.navigate( themes.router.baseUrl( themes.router.themePath + this.model.get( 'id' ) ), { replace: false } );
    889894
    890895                this.$el.fadeIn( 200, function() {
    891896                        $body.addClass( 'theme-installer-active full-overlay-active' );
     
    19021907                // Handles `theme` route event
    19031908                // Queries the API for the passed theme slug
    19041909                themes.router.on( 'route:preview', function( slug ) {
    1905                         request.theme = slug;
    1906                         self.view.collection.query( request );
    1907                         self.view.collection.once( 'update', function() {
     1910
     1911                        // If the theme preview is active, set the current theme.
     1912                        if ( self.view.view.theme && self.view.view.theme.preview ) {
     1913                                self.view.view.theme.model = self.view.collection.findWhere( { 'slug': slug } );
    19081914                                self.view.view.theme.preview();
    1909                         });
     1915                        } else {
     1916
     1917                                // Open the theme preview.
     1918                                request.theme = slug;
     1919                                self.view.collection.query( request );
     1920                                self.view.collection.trigger( 'update' );
     1921                        }
    19101922                });
    19111923
    19121924                // Handles sorting / browsing routes
     
    19171929                                sort = 'featured';
    19181930                        }
    19191931                        self.view.sort( sort );
    1920                         self.view.trigger( 'theme:close' );
     1932
     1933                        // Close the current preview.
     1934                        if ( themes.currentPreview ) {
     1935                                themes.currentPreview.trigger( 'closepreview' );
     1936                        }
    19211937                });
    19221938
    19231939                // The `search` route event. The router populates the input field.