Make WordPress Core

Ticket #27521: 27521.15.diff

File 27521.15.diff, 1.2 KB (added by adamsilverstein, 9 years ago)

corrected: Escape to close Preview (removed blank line)

  • src/wp-admin/js/theme.js

     
    716716        html: themes.template( 'theme-preview' ),
    717717
    718718        render: function() {
    719                 var data = this.model.toJSON();
     719                var data = this.model.toJSON(),
     720                        self = this;
    720721                this.$el.html( this.html( data ) );
    721722
    722723                themes.router.navigate( themes.router.baseUrl( '?theme=' + this.model.get( 'id' ) ), { replace: true } );
    723724
    724725                this.$el.fadeIn( 200, function() {
    725                         $( 'body' ).addClass( 'theme-installer-active full-overlay-active' );
     726                        $( 'body' )
     727                                .addClass( 'theme-installer-active full-overlay-active' )
     728                                .on( 'keyup', function( event ) {
     729                                        // Pressing the escape closes the preview
     730                                        if ( event.keyCode === 27 ) {
     731                                                self.close();
     732                                        }
     733                                });;
    726734                        $( '.close-full-overlay' ).focus();
    727735                });
    728736        },
    729737
    730738        close: function() {
    731739                this.$el.fadeOut( 200, function() {
    732                         $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' );
     740                        $( 'body' ).removeClass( 'theme-installer-active full-overlay-active' ).unbind( 'keyup' );
    733741
    734742                        // Return focus to the theme div
    735743                        if ( themes.focusedTheme ) {