refactor of keydown event (for future enhancements and features)

This commit is contained in:
Matteo Manzinello 2019-05-12 12:28:21 +02:00
parent ec515f6a06
commit d00d0e7149
3 changed files with 27 additions and 35 deletions

30
dist/mailgo.js vendored
View File

@ -155,25 +155,11 @@ mailgoInit = () => {
// add the modal at the end of the body
document.body.appendChild(modal);
// allow the escape key to hide the modal
mailgo.addEventListener(
"keydown",
event => {
if (event.keyCode === 27) {
hideMailgo();
}
},
false
);
// add the event mailgoKeydown on mailgo
mailgo.addEventListener("keydown", mailgoKeydown, false);
// every click outside the modal will hide the modal
modalBackground.addEventListener(
"click",
event => {
hideMailgo();
},
false
);
modalBackground.addEventListener("click", hideMailgo, false);
};
/**
@ -328,6 +314,16 @@ mailgoCheckRender = event => {
}
};
/**
* mailgoKeydown
* function to manage the keydown event when the modal is showing
*/
mailgoKeydown = event => {
if (event.keyCode === 27) {
hideMailgo();
}
};
// DOMContentLoaded -> mailgoInit (creates the modal)
document.addEventListener("DOMContentLoaded", mailgoInit, false);

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -155,25 +155,11 @@ mailgoInit = () => {
// add the modal at the end of the body
document.body.appendChild(modal);
// allow the escape key to hide the modal
mailgo.addEventListener(
"keydown",
event => {
if (event.keyCode === 27) {
hideMailgo();
}
},
false
);
// add the event mailgoKeydown on mailgo
mailgo.addEventListener("keydown", mailgoKeydown, false);
// every click outside the modal will hide the modal
modalBackground.addEventListener(
"click",
event => {
hideMailgo();
},
false
);
modalBackground.addEventListener("click", hideMailgo, false);
};
/**
@ -328,6 +314,16 @@ mailgoCheckRender = event => {
}
};
/**
* mailgoKeydown
* function to manage the keydown event when the modal is showing
*/
mailgoKeydown = event => {
if (event.keyCode === 27) {
hideMailgo();
}
};
// DOMContentLoaded -> mailgoInit (creates the modal)
document.addEventListener("DOMContentLoaded", mailgoInit, false);