Make WordPress Core

Changeset 29600


Ignore:
Timestamp:
08/25/2014 05:44:28 PM (12 years ago)
Author:
wonderboymusic
Message:

Media Grid: exit selection mode when Esc is pressed.

Fixes #29366.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/media-grid.js

    r29566 r29600  
    6666                        });
    6767
     68                        this.$body = $( document.body );
    6869                        this.$window = $( window );
    6970                        this.$adminBar = $( '#wpadminbar' );
     
    150151                        // Handle a frame-level event for editing an attachment.
    151152                        this.on( 'edit:attachment', this.openEditAttachmentModal, this );
     153
     154                        this.on( 'select:activate', this.bindKeydown, this );
     155                        this.on( 'select:deactivate', this.unbindKeydown, this );
     156                },
     157
     158                handleKeydown: function( e ) {
     159                        if ( 27 === e.which ) {
     160                                e.preventDefault();
     161                                this.deactivateMode( 'select' ).activateMode( 'edit' );
     162                        }
     163                },
     164
     165                bindKeydown: function() {
     166                        this.$body.on( 'keydown.select', _.bind( this.handleKeydown, this ) );
     167                },
     168
     169                unbindKeydown: function() {
     170                        this.$body.off( 'keydown.select' );
    152171                },
    153172
Note: See TracChangeset for help on using the changeset viewer.