Skip to content

Commit

Permalink
Improve middle click and prevent double activation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed May 22, 2021
1 parent 671d9c2 commit 6580907
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
}
});
// Add event listeners to the main document so user can open current document in new tab or window
addListenersToLink(articleDocument, encodeURIComponent(dirEntry.url.replace(/[^/]+\//g, '')));
if (articleWindow.document.body) addListenersToLink(articleWindow.document.body, encodeURIComponent(dirEntry.url.replace(/[^/]+\//g, '')));
}

/**
Expand Down Expand Up @@ -1591,7 +1591,9 @@ define(['jquery', 'zimArchiveLoader', 'uiUtil', 'settingsStore','abstractFilesys
});
// This detects the middle-click event
a.addEventListener('mousedown', function (e) {
if (!params.windowOpener || a.launched) return; // Prevent double activations
if (e.which === 2 || e.button === 4) {
e.stopPropagation();
e.preventDefault();
a.launched = true;
a.click();
Expand Down

0 comments on commit 6580907

Please sign in to comment.