aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/context.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-19 22:30:16 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-19 22:30:16 -0400
commitd9ae34821ca5e0189248c015c2f30b88a8a6a7b2 (patch)
tree0e670d53f4364830468ebfa71a0d2cc6a9805cf1 /ext/bg/js/context.js
parentdbec4bffda00615fe768f66c1eb5d895aea05585 (diff)
Add support for middle clicks opening new tabs on the context buttons
Diffstat (limited to 'ext/bg/js/context.js')
-rw-r--r--ext/bg/js/context.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/ext/bg/js/context.js b/ext/bg/js/context.js
index a29f7aa7..a16c8769 100644
--- a/ext/bg/js/context.js
+++ b/ext/bg/js/context.js
@@ -25,6 +25,20 @@ function showExtensionInfo() {
node.textContent = `${manifest.name} v${manifest.version}`;
}
+function setupButtonEvents(selector, command) {
+ $(selector)
+ .on('click', (e) => {
+ if (e.button !== 0) { return; }
+ apiCommandExec(command, {newTab: e.ctrlKey});
+ e.preventDefault();
+ })
+ .on('auxclick', (e) => {
+ if (e.button !== 1) { return; }
+ apiCommandExec(command, {newTab: true});
+ e.preventDefault();
+ });
+}
+
$(document).ready(utilAsync(() => {
showExtensionInfo();
@@ -33,9 +47,9 @@ $(document).ready(utilAsync(() => {
document.documentElement.dataset.mode = (browser === 'firefox-mobile' ? 'full' : 'mini');
});
- $('.action-open-search').click(() => apiCommandExec('search'));
- $('.action-open-options').click(() => apiCommandExec('options'));
- $('.action-open-help').click(() => apiCommandExec('help'));
+ setupButtonEvents('.action-open-search', 'search');
+ setupButtonEvents('.action-open-options', 'options');
+ setupButtonEvents('.action-open-help', 'help');
const optionsContext = {
depth: 0,