From 29688d9880fcceb3033a7a2a1bdc0eea5eadfd55 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 5 Sep 2010 15:46:02 -0700 Subject: Make it so that 'gotoFirstInput' does not require the text box to have an ID on it. --- commands.js | 2 +- vimiumFrontend.js | 14 +++++--------- 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(); } -- cgit v1.2.3