aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-08-30 10:43:02 +0300
committerGravatar Vitaly Takmazov2017-08-30 10:43:02 +0300
commit8df5b345f0c2f32011e9550274d2001ff26d2c66 (patch)
tree0b86cd302656dd1fe6b6e6535fc0526e1892f980 /juick-www/src
parented866d55630fd3875aa6d2299f68c008171e7bf7 (diff)
www: close dialogs with ESC
Diffstat (limited to 'juick-www/src')
-rw-r--r--juick-www/src/main/static/scripts.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js
index 244c83c6..a2f25d07 100644
--- a/juick-www/src/main/static/scripts.js
+++ b/juick-www/src/main/static/scripts.js
@@ -273,13 +273,19 @@ function updateRepliesCounter() {
/******************************************************************************/
function postformListener(formEl, ev) {
- var form = formEl.closest('form');
if (ev.ctrlKey && (ev.keyCode == 10 || ev.keyCode == 13)) {
+ let form = formEl.closest('form');
if (!form.onsubmit || form.onsubmit()) {
form.submit();
}
}
}
+function closeDialogListener(ev) {
+ ev = ev || window.event;
+ if (ev.keyCode == 27) {
+ closeDialog();
+ }
+}
function newMessage() {
if (document.querySelector('#newmessage textarea').value.length == 0) {
@@ -516,6 +522,7 @@ function openDialog(html) {
</div>
</div>`;
document.querySelector('body').insertAdjacentHTML('afterbegin', dialogHtml);
+ document.addEventListener('keydown', closeDialogListener);
document.querySelector('#dialogb').addEventListener('click', closeDialog);
document.querySelector('#dialogc').addEventListener('click', closeDialog);
}