Media Grid: exit selection mode when Esc is pressed.
Fixes #29366. git-svn-id: https://develop.svn.wordpress.org/trunk@29600 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
feb1b12df1
commit
9a52936277
|
@ -65,6 +65,7 @@
|
||||||
mode: [ 'grid', 'edit' ]
|
mode: [ 'grid', 'edit' ]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.$body = $( document.body );
|
||||||
this.$window = $( window );
|
this.$window = $( window );
|
||||||
this.$adminBar = $( '#wpadminbar' );
|
this.$adminBar = $( '#wpadminbar' );
|
||||||
this.$window.on( 'scroll resize', _.debounce( _.bind( this.fixPosition, this ), 15 ) );
|
this.$window.on( 'scroll resize', _.debounce( _.bind( this.fixPosition, this ), 15 ) );
|
||||||
|
@ -149,6 +150,24 @@
|
||||||
|
|
||||||
// Handle a frame-level event for editing an attachment.
|
// Handle a frame-level event for editing an attachment.
|
||||||
this.on( 'edit:attachment', this.openEditAttachmentModal, this );
|
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() {
|
fixPosition: function() {
|
||||||
|
|
Loading…
Reference in New Issue