aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorabe2010-09-22 01:38:54 +0200
committerabe2010-09-22 01:38:54 +0200
commit4473dafcb82103572810cb501ca8bce56ca93c5e (patch)
treecdab3178231cd80225e550f0ffc5f23cbc42cacd
parent0d15a8fbdf78ab1a12783406bf678339882323a5 (diff)
downloadvimium-4473dafcb82103572810cb501ca8bce56ca93c5e.tar.bz2
Added activeteLinkHintsModeWithQueue and resetLinkHintsMode to linkHints.js and added 'q cmd' and 'q help cmd' to commands.js
-rw-r--r--commands.js4
-rw-r--r--linkHints.js37
2 files changed, 30 insertions, 11 deletions
diff --git a/commands.js b/commands.js
index a9fa0aba..01f7735c 100644
--- a/commands.js
+++ b/commands.js
@@ -112,6 +112,7 @@ function clearKeyMappingsAndSetDefaults() {
mapKeyToCommand('f', 'activateLinkHintsMode');
mapKeyToCommand('F', 'activateLinkHintsModeToOpenInNewTab');
+ mapKeyToCommand('q', 'activeteLinkHintsModeWithQueue');
mapKeyToCommand('/', 'enterFindMode');
mapKeyToCommand('n', 'performFind');
@@ -156,6 +157,7 @@ addCommand('focusInput', 'Focus the first (or n-th) text box on the pag
addCommand('activateLinkHintsMode', 'Enter link hints mode to open links in current tab');
addCommand('activateLinkHintsModeToOpenInNewTab', 'Enter link hints mode to open links in new tab');
+addCommand('activeteLinkHintsModeWithQueue', 'Enter link hints mode to open multiple links in a new tab');
addCommand('enterFindMode', 'Enter find mode');
addCommand('performFind', 'Cycle forward to the next find match');
@@ -185,7 +187,7 @@ var commandGroups = {
"scrollPageUp", "scrollFullPageDown",
"reload", "toggleViewSource", "zoomIn", "zoomOut", "copyCurrentUrl", "goUp",
"enterInsertMode", "focusInput",
- "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab",
+ "activateLinkHintsMode", "activateLinkHintsModeToOpenInNewTab", "activeteLinkHintsModeWithQueue",
"enterFindMode", "performFind", "performBackwardsFind"],
historyNavigation:
["goBack", "goForward"],
diff --git a/linkHints.js b/linkHints.js
index fcaa832b..5a7fb118 100644
--- a/linkHints.js
+++ b/linkHints.js
@@ -13,6 +13,7 @@ var hintMarkerContainingDiv = null;
var hintKeystrokeQueue = [];
var linkHintsModeActivated = false;
var shouldOpenLinkHintInNewTab = false;
+var shouldOpenLinkHintWithQueue = false;
// Whether link hint's "open in current/new tab" setting is currently toggled
var openLinkModeToggle = false;
// Whether we have added to the page the CSS needed to display link hints.
@@ -32,25 +33,32 @@ var clickableElementsXPath = (function() {
})();
// We need this as a top-level function because our command system doesn't yet support arguments.
-function activateLinkHintsModeToOpenInNewTab() { activateLinkHintsMode(true); }
+function activateLinkHintsModeToOpenInNewTab() { activateLinkHintsMode(true, false); }
-function activateLinkHintsMode(openInNewTab) {
+function activeteLinkHintsModeWithQueue() { activateLinkHintsMode(true, true); }
+
+function activateLinkHintsMode(openInNewTab, withQueue) {
if (!linkHintsCssAdded)
addCssToPage(linkHintCss); // linkHintCss is declared by vimiumFrontend.js
linkHintCssAdded = true;
linkHintsModeActivated = true;
- setOpenLinkMode(openInNewTab);
+ setOpenLinkMode(openInNewTab, withQueue);
buildLinkHints();
document.addEventListener("keydown", onKeyDownInLinkHintsMode, true);
document.addEventListener("keyup", onKeyUpInLinkHintsMode, true);
}
-function setOpenLinkMode(openInNewTab) {
+function setOpenLinkMode(openInNewTab, withQueue) {
shouldOpenLinkHintInNewTab = openInNewTab;
- if (shouldOpenLinkHintInNewTab)
- HUD.show("Open link in new tab");
- else
- HUD.show("Open link in current tab");
+ shouldOpenLinkHintWithQueue = withQueue
+ if (shouldOpenLinkHintWithQueue) {
+ HUD.show("Open multiple links in a new tab");
+ } else {
+ if (shouldOpenLinkHintInNewTab)
+ HUD.show("Open link in new tab");
+ else
+ HUD.show("Open link in current tab");
+ }
}
/*
@@ -206,9 +214,14 @@ function updateLinkHints() {
setTimeout(function() { simulateClick(matchedLink); }, 400);
else
simulateClick(matchedLink);
- matchedLink.focus();
+ if (!shouldOpenLinkHintWithQueue) {
+ matchedLink.focus();
+ deactivateLinkHintsMode();
+ } else {
+ console.log("Reseting Hint Link Mode");
+ resetLinkHintsMode();
+ }
}
- deactivateLinkHintsMode();
}
}
@@ -289,6 +302,10 @@ function deactivateLinkHintsMode() {
HUD.hide();
}
+function resetLinkHintsMode() {
+ hintKeystrokeQueue = [];
+}
+
/*
* Creates a link marker for the given link.
*/