Handling middle click in image viewer

main
Nicolas Ong 2025-03-01 23:15:39 +01:00
parent 8b119d332b
commit bba932ab2c
1 changed files with 15 additions and 1 deletions

View File

@ -22,6 +22,18 @@ function unpop(event) {
}
}
function display(event) {
if (event.button != 1) {
return;
}
var target = event.target.parentNode;
if (target.nodeName != "FIGURE") {
target = event.target;
}
var href = target.parentNode.dataset.href;
window.open(href, '_blank');
}
function displayNeighbour(which) {
var viewer = document.getElementById('viewer');
var current = viewer.lastChild;
@ -98,6 +110,8 @@ document.body.addEventListener(
/* Makes thumbnails interactive */
for (var thumb of document.getElementsByClassName('thumbnail')) {
thumb.dataset.href = thumb.href;
thumb.href = 'javascript: void(0);';
thumb.removeAttribute('href');
thumb.style = "cursor: pointer;";
thumb.addEventListener('click', pop);
thumb.addEventListener('auxclick', display);
}