summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-07-13 14:11:11 +0200
committerYorhel <git@yorhel.nl>2019-07-13 14:11:20 +0200
commit0462e11d5a2736a4d5b9ff692c722c8857d3d1fa (patch)
tree3a1ba13b01d7d1dfc1b06381d93562efb6991601 /data
parente7cf38f4c5b32f73de89bf61bda43ac3876ad897 (diff)
iv.js improvements: Close window when clicking on page + arrow key support
This is some ugly JS, but it'll do.
Diffstat (limited to 'data')
-rw-r--r--data/js/iv.js16
1 files changed, 15 insertions, 1 deletions
diff --git a/data/js/iv.js b/data/js/iv.js
index fa3a6a1d..732e2131 100644
--- a/data/js/iv.js
+++ b/data/js/iv.js
@@ -64,7 +64,7 @@ function fixnav(lnk, cat, i, dir) {
lnk.setAttribute('data-iv', a ? a.getAttribute('data-iv') : '');
}
-function show() {
+function show(ev) {
var u = this.href;
var opt = this.getAttribute('data-iv').split(':');
var idx = this.iv_i;
@@ -110,10 +110,24 @@ function show() {
byId('ivimgload').style.left = ((ww - 100) / 2 - 10)+'px';
byId('ivimgload').style.top = ((wh - 20) / 2 + st)+'px';
setClass(byId('ivimgload'), 'hidden', false);
+
+ document.body.onclick = close;
+ // Capture left/right arrow keys
+ document.onkeydown = function(e) {
+ if(e.keyCode == 37 && byId('ivprev').style.visibility == 'visible') {
+ byId('ivprev').click();
+ }
+ if(e.keyCode == 39 && byId('ivnext').style.visibility == 'visible') {
+ byId('ivnext').click();
+ }
+ };
+ ev.stopPropagation();
return false;
}
function close() {
+ document.body.onclick = null;
+ document.onkeydown = null;
setClass(byId('iv_view'), 'hidden', true);
setClass(byId('ivimgload'), 'hidden', true);
setText(byId('ivimg'), '');