refactor of keydown event (for future enhancements and features)
This commit is contained in:
parent
ec515f6a06
commit
d00d0e7149
30
dist/mailgo.js
vendored
30
dist/mailgo.js
vendored
@ -155,25 +155,11 @@ mailgoInit = () => {
|
|||||||
// add the modal at the end of the body
|
// add the modal at the end of the body
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
// allow the escape key to hide the modal
|
// add the event mailgoKeydown on mailgo
|
||||||
mailgo.addEventListener(
|
mailgo.addEventListener("keydown", mailgoKeydown, false);
|
||||||
"keydown",
|
|
||||||
event => {
|
|
||||||
if (event.keyCode === 27) {
|
|
||||||
hideMailgo();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
// every click outside the modal will hide the modal
|
// every click outside the modal will hide the modal
|
||||||
modalBackground.addEventListener(
|
modalBackground.addEventListener("click", hideMailgo, false);
|
||||||
"click",
|
|
||||||
event => {
|
|
||||||
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)
|
// DOMContentLoaded -> mailgoInit (creates the modal)
|
||||||
document.addEventListener("DOMContentLoaded", mailgoInit, false);
|
document.addEventListener("DOMContentLoaded", mailgoInit, false);
|
||||||
|
|
||||||
|
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
@ -155,25 +155,11 @@ mailgoInit = () => {
|
|||||||
// add the modal at the end of the body
|
// add the modal at the end of the body
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
// allow the escape key to hide the modal
|
// add the event mailgoKeydown on mailgo
|
||||||
mailgo.addEventListener(
|
mailgo.addEventListener("keydown", mailgoKeydown, false);
|
||||||
"keydown",
|
|
||||||
event => {
|
|
||||||
if (event.keyCode === 27) {
|
|
||||||
hideMailgo();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
// every click outside the modal will hide the modal
|
// every click outside the modal will hide the modal
|
||||||
modalBackground.addEventListener(
|
modalBackground.addEventListener("click", hideMailgo, false);
|
||||||
"click",
|
|
||||||
event => {
|
|
||||||
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)
|
// DOMContentLoaded -> mailgoInit (creates the modal)
|
||||||
document.addEventListener("DOMContentLoaded", mailgoInit, false);
|
document.addEventListener("DOMContentLoaded", mailgoInit, false);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user