aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Crosby2010-09-05 15:46:02 -0700
committerPhil Crosby2010-09-05 15:46:40 -0700
commit29688d9880fcceb3033a7a2a1bdc0eea5eadfd55 (patch)
treec6943f00cb9a703e4511b488ecc164f94b6936e7
parentce2093fcfef6f7000edc7eae026c7d529273199d (diff)
downloadvimium-29688d9880fcceb3033a7a2a1bdc0eea5eadfd55.tar.bz2
Make it so that 'gotoFirstInput' does not require the text box to have an ID on it.
-rw-r--r--commands.js2
-rw-r--r--vimiumFrontend.js14
2 files changed, 6 insertions, 10 deletions
diff --git a/commands.js b/commands.js
index 26ef2d34..fa24dee8 100644
--- a/commands.js
+++ b/commands.js
@@ -146,7 +146,7 @@ addCommand('copyCurrentUrl', 'Copy the current URL to the clipboard');
addCommand('enterInsertMode', 'Enter insert mode');
-addCommand('focusFirstInput', 'Focus the first text box on the page.');
+addCommand('focusFirstInput', 'Focus the first text box on the page');
addCommand('activateLinkHintsMode', 'Enter link hints mode to open links in current tab');
addCommand('activateLinkHintsModeToOpenInNewTab', 'Enter link hints mode to open links in new tab');
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index f2f5abd3..d74c6d53 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -200,15 +200,11 @@ function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); }
function focusFirstInput() {
var xpath = '//input[@type="text" or @type="search"]';
- var result = document.evaluate( xpath, document.documentElement, null,
- XPathResult.FIRST_ORDERED_NODE_TYPE, null );
-
- if ( result.singleNodeValue == null ) return;
-
- var el = document.getElementById( result.singleNodeValue.id );
- if ( el ) {
- el.focus();
- }
+ var result = document.evaluate(xpath, document.documentElement, null,
+ XPathResult.FIRST_ORDERED_NODE_TYPE, null);
+ if (!result.singleNodeValue)
+ return;
+ result.singleNodeValue.focus();
}
function reload() { window.location.reload(); }