Media Grid: exit selection mode when Esc is pressed.

Fixes #29366.

Built from https://develop.svn.wordpress.org/trunk@29600


git-svn-id: http://core.svn.wordpress.org/trunk@29374 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-08-25 17:45:17 +00:00
parent fa8e82efab
commit 32e896f5b8
2 changed files with 20 additions and 1 deletions

View File

@ -65,6 +65,7 @@
mode: [ 'grid', 'edit' ]
});
this.$body = $( document.body );
this.$window = $( window );
this.$adminBar = $( '#wpadminbar' );
this.$window.on( 'scroll resize', _.debounce( _.bind( this.fixPosition, this ), 15 ) );
@ -149,6 +150,24 @@
// Handle a frame-level event for editing an attachment.
this.on( 'edit:attachment', this.openEditAttachmentModal, this );
this.on( 'select:activate', this.bindKeydown, this );
this.on( 'select:deactivate', this.unbindKeydown, this );
},
handleKeydown: function( e ) {
if ( 27 === e.which ) {
e.preventDefault();
this.deactivateMode( 'select' ).activateMode( 'edit' );
}
},
bindKeydown: function() {
this.$body.on( 'keydown.select', _.bind( this.handleKeydown, this ) );
},
unbindKeydown: function() {
this.$body.off( 'keydown.select' );
},
fixPosition: function() {

File diff suppressed because one or more lines are too long