Pressing escape now closes the media modal. props koopersmith, see #22502.

git-svn-id: https://develop.svn.wordpress.org/trunk@22946 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin 2012-11-30 08:37:17 +00:00
parent 17622c2daa
commit be096cf4a5
1 changed files with 16 additions and 2 deletions

View File

@ -1616,8 +1616,13 @@
tagName: 'div', tagName: 'div',
template: media.template('media-modal'), template: media.template('media-modal'),
attributes: {
tabindex: 0
},
events: { events: {
'click .media-modal-backdrop, .media-modal-close' : 'closeHandler' 'click .media-modal-backdrop, .media-modal-close': 'closeHandler',
'keydown': 'keydown'
}, },
initialize: function() { initialize: function() {
@ -1658,7 +1663,7 @@
}, },
open: function() { open: function() {
this.$el.show(); this.$el.show().focus();
return this.propagate('open'); return this.propagate('open');
}, },
@ -1691,6 +1696,15 @@
this.controller.trigger( id ); this.controller.trigger( id );
return this; return this;
},
keydown: function( event ) {
// Close the modal when escape is pressed.
if ( 27 === event.which ) {
event.preventDefault();
this.close();
return;
}
} }
}); });