From 7c4f41a35b6af3efbc3adfa5a1e6bbab667fc096 Mon Sep 17 00:00:00 2001 From: abe Date: Thu, 23 Sep 2010 00:25:11 +0200 Subject: added resetLinkHintsMode --- linkHints.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'linkHints.js') diff --git a/linkHints.js b/linkHints.js index 5a7fb118..b30c74e0 100644 --- a/linkHints.js +++ b/linkHints.js @@ -151,9 +151,10 @@ function isVisible(element, clientRect) { } function onKeyDownInLinkHintsMode(event) { + console.log("Key Down"); if (event.keyCode == keyCodes.shiftKey && !openLinkModeToggle) { // Toggle whether to open link in a new or current tab. - setOpenLinkMode(!shouldOpenLinkHintInNewTab); + setOpenLinkMode(!shouldOpenLinkHintInNewTab, shouldOpenLinkHintWithQueue); openLinkModeToggle = true; } @@ -185,7 +186,7 @@ function onKeyDownInLinkHintsMode(event) { function onKeyUpInLinkHintsMode(event) { if (event.keyCode == keyCodes.shiftKey && openLinkModeToggle) { // Revert toggle on whether to open link in new or current tab. - setOpenLinkMode(!shouldOpenLinkHintInNewTab); + setOpenLinkMode(!shouldOpenLinkHintInNewTab, shouldOpenLinkHintWithQueue); openLinkModeToggle = false; } event.stopPropagation(); @@ -210,17 +211,25 @@ function updateLinkHints() { } else { // When we're opening the link in the current tab, don't navigate to the selected link immediately; // we want to give the user some feedback depicting which link they've selected by focusing it. - if (!shouldOpenLinkHintInNewTab) - setTimeout(function() { simulateClick(matchedLink); }, 400); - else + if (shouldOpenLinkHintWithQueue) { + simulateClick(matchedLink); + resetLinkHintsMode(); + } else if (shouldOpenLinkHintInNewTab) { simulateClick(matchedLink); - if (!shouldOpenLinkHintWithQueue) { + matchedLink.focus(); + deactivateLinkHintsMode(); + } else { + setTimeout(function() { simulateClick(matchedLink); }, 400); + matchedLink.focus(); + deactivateLinkHintsMode(); + } + /*if (!shouldOpenLinkHintWithQueue) { matchedLink.focus(); deactivateLinkHintsMode(); } else { console.log("Reseting Hint Link Mode"); resetLinkHintsMode(); - } + }*/ } } } @@ -303,7 +312,8 @@ function deactivateLinkHintsMode() { } function resetLinkHintsMode() { - hintKeystrokeQueue = []; + deactivateLinkHintsMode(); + activeteLinkHintsModeWithQueue(); } /* -- cgit v1.2.3