Handling middle click in image viewer
parent
8b119d332b
commit
bba932ab2c
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue