From 618d66bbd57d7709f211149305ebc41f1b6941f9 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 21 Apr 2016 07:43:59 +0100 Subject: Prime focus input on the Vimium options page. This is a bit of a hack, and pertains to focusInput (`gf`). The problem... On the options page, there are *lots* of inputs (specifically, for every exclusion rule there are two inputs). This makes `gf` almost unusable. It's impossibly to `Tab` through them all. Here, on the options page, we prime the pre-selected input to be the key-mappings input: - arguably, this is the most frequently used input, and - other inputs (such as custom search engines) are just one `Tab` away. --- content_scripts/vimium_frontend.coffee | 6 ++++++ pages/options.coffee | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 06b447fc..2d6d66be 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -391,6 +391,12 @@ extend window, HUD.showForDuration("There are no inputs to focus.", 1000) return + # This is a hack to improve usability on the Vimium options page. We prime the recently-focused input + # to be the key-mappings input. Arguably, this is the input that the user is most likely to use. + unless recentlyFocusedElement? + if window.isVimiumOptionsPage + recentlyFocusedElement = document.getElementById "keyMappings" + selectedInputIndex = if count == 1 # As the starting index, we pick that of the most recently focused input element (or 0). diff --git a/pages/options.coffee b/pages/options.coffee index ff6ad15a..883405e6 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -324,4 +324,4 @@ document.addEventListener "DOMContentLoaded", -> # Exported for tests. root = exports ? window -extend root, {Options} +extend root, {Options, isVimiumOptionsPage: true} -- cgit v1.2.3 From b809fd8d2245793decb45160455939c3cc7993d8 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Fri, 22 Apr 2016 14:18:52 +0100 Subject: Simplify 618d66bbd57d7709f211149305ebc41f1b6941f9. --- content_scripts/vimium_frontend.coffee | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 2d6d66be..d316da4c 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -393,9 +393,7 @@ extend window, # This is a hack to improve usability on the Vimium options page. We prime the recently-focused input # to be the key-mappings input. Arguably, this is the input that the user is most likely to use. - unless recentlyFocusedElement? - if window.isVimiumOptionsPage - recentlyFocusedElement = document.getElementById "keyMappings" + recentlyFocusedElement ?= document.getElementById "keyMappings" if window.isVimiumOptionsPage selectedInputIndex = if count == 1 -- cgit v1.2.3