From 01dee99d9be256e1c62ea822932383fa3f00e593 Mon Sep 17 00:00:00 2001 From: lufte Date: Mon, 1 Jan 2018 19:48:09 -0300 Subject: [PATCH] Implement issue #157. --- src/modes/command/client/commands/hint.js | 4 ++++ src/modes/hints/client/activate.js | 19 +++++++++++++++++-- src/options/Keybindings/config.json | 6 ++++++ src/options/Keybindings/default.json | 11 +++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/modes/command/client/commands/hint.js b/src/modes/command/client/commands/hint.js index b8c8623..74617a9 100644 --- a/src/modes/command/client/commands/hint.js +++ b/src/modes/command/client/commands/hint.js @@ -8,6 +8,10 @@ export const openLinkInBackgroundTab = background('findHints', { filter: '*', activate: 'openLinkInBackgroundTab' }) +export const openMultipleLinksInBackgroundTabs = background('findHints', { + filter: '*', + activate: 'openMultipleLinksInBackgroundTabs' +}) export const openLinkInForegroundTab = background('findHints', { filter: '*', activate: 'openLinkInForegroundTab' diff --git a/src/modes/hints/client/activate.js b/src/modes/hints/client/activate.js index c78152b..a382143 100644 --- a/src/modes/hints/client/activate.js +++ b/src/modes/hints/client/activate.js @@ -1,6 +1,8 @@ import { msg } from 'mosi/client' import { mouseEvent } from 'lib/dom' import { isMac } from 'lib/keys' +import { hideHints } from './HintRenderer' +import { hideVideoControls } from './video' let activator export function configureActivate (_activator = 'openLink') { @@ -10,8 +12,8 @@ export function configureActivate (_activator = 'openLink') { /** * Calls the appropriate activation function on the target hintable element. * Returns the next mode - * @param {KeyboardEvent} event - an object that representing a keyboard event - * @param {HTMLElement} target + * @param {KeyboardEvent} event - an object representing a keyboard event + * @param {HTMLElement} target * @returns {string} */ export function activate (event, target) { @@ -46,6 +48,19 @@ const activators = { target.focus() return 'Reset' }, + openMultipleLinksInBackgroundTabs: (event, target) => { + mouseEvent(target, 'click', { ctrlKey: !isMac, metaKey: isMac }) + if (SAKA_PLATFORM === 'firefox') { + backgroundOpenLink('openLinkInBackgroundTab', target) + } + hideHints() + hideVideoControls() + msg(1, 'findHints', { + filter: '*', + activate: 'openMultipleLinksInBackgroundTabs' + }) + return 'Same' + }, openLinkInForegroundTab: (event, target) => { mouseEvent(target, 'click', { ctrlKey: !isMac, diff --git a/src/options/Keybindings/config.json b/src/options/Keybindings/config.json index 8f2b564..90fb1f6 100644 --- a/src/options/Keybindings/config.json +++ b/src/options/Keybindings/config.json @@ -69,6 +69,12 @@ "key": "openLinkInBackgroundTab", "default": [] }, + { + "type": "keybinding", + "label": "Open Multiple Links in Background Tabs", + "key": "openMultipleLinksInBackgroundTabs", + "default": [] + }, { "type": "keybinding", "label": "Open Link in Foreground Tab", diff --git a/src/options/Keybindings/default.json b/src/options/Keybindings/default.json index 8170ea4..f3c7628 100644 --- a/src/options/Keybindings/default.json +++ b/src/options/Keybindings/default.json @@ -14,6 +14,9 @@ "openLinkInBackgroundTab": [ [{ "code": "KeyF", "key": "f" }, { "code": "KeyB", "key": "b" }] ], + "openMultipleLinksInBackgroundTabs": [ + [{ "code": "KeyF", "key": "f" }, { "code": "KeyM", "key": "m" }] + ], "openLinkInForegroundTab": [ [ { "code": "KeyF", "key": "f" }, @@ -216,6 +219,12 @@ "toggleSaka": [[{ "code": "KeyL", "key": "l" }]], "openLink": [[{ "code": "KeyF", "key": "f" }]], "openLinkInBackgroundTab": [[{ "code": "KeyA", "key": "a" }]], + "openMultipleLinksInBackgroundTabs": [ + [ + { "code": "KeyF", "key": "F", "shiftKey": true }, + { "code": "KeyM", "key": "m" } + ] + ], "openLinkInForegroundTab": [ [{ "code": "KeyA", "key": "A", "shiftKey": true }] ], @@ -402,6 +411,7 @@ "openLinkInBackgroundTab": [ [{ "code": "KeyF", "key": "F", "shiftKey": true }] ], + "openMultipleLinksInBackgroundTabs": [], "openLinkInForegroundTab": [ [ { "code": "KeyF", "key": "ƒ", "altKey": true }, @@ -541,6 +551,7 @@ "openLinkInBackgroundTab": [ [{ "code": "KeyF", "key": "F", "shiftKey": true }] ], + "openMultipleLinksInBackgroundTabs": [], "openLinkInForegroundTab": [], "openLinkInNewWindow": [], "openLinkInIncognitoWindow": [],