adds support for closing menus by pressing esc
This commit is contained in:
parent
0a289d2468
commit
8244231254
1 changed files with 9 additions and 0 deletions
|
|
@ -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;' +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue