adds support for closing menus by pressing esc

This commit is contained in:
Matthew Kastor 2013-04-01 18:12:58 -04:00 committed by nightwing
commit 8244231254

View file

@ -77,6 +77,13 @@ module.exports.overlayPage = function overlayPage (contentElement, top, right, b
var closer = document.createElement('div');
var contentContainer = document.createElement('div');
function documentEscListener (e) {
if (e.keyCode === 27) {
closer.click();
}
document.removeEventListener('keydown', documentEscListener);
}
closer.style.cssText = 'margin: 0; padding: 0; ' +
'position: fixed; top:0; bottom:0; left:0; right:0;' +
'z-index: 9990; ' +
@ -85,6 +92,8 @@ module.exports.overlayPage = function overlayPage (contentElement, top, right, b
closer.parentNode.removeChild(closer);
closer = null;
});
// click closer if esc key is pressed
document.addEventListener('keydown', documentEscListener);
contentContainer.style.cssText = 'margin: 0; padding: 0; ' +
'position: absolute;' +