diff options
| author | Ilya Sukhar | 2010-12-14 02:24:32 -0800 |
|---|---|---|
| committer | Ilya Sukhar | 2010-12-14 02:24:32 -0800 |
| commit | def44f37109c2cd120893060e95551fd9a64c4ac (patch) | |
| tree | a60ca4a05300b393f9294bc02f1b14c52622bf41 /vimiumFrontend.js | |
| parent | 031b3453f1f34df0a6b3bc83d5e920d869b329e9 (diff) | |
| download | vimium-def44f37109c2cd120893060e95551fd9a64c4ac.tar.bz2 | |
Expand the XPath used to find DOM elements for focusInput(). Closes #250.
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index b108d141..16f0fdde 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -26,6 +26,17 @@ var linkHintCss; // TODO(philc): This should be pulled from the extension's storage when the page loads. var currentZoomLevel = 100; +// The types in <input type="..."> that we consider for focusInput command. Right now this is recalculated in +// each content script. Alternatively we could calculate it once in the background page and use a request to +// fetch it each time. +// +// Should we include the HTML5 date pickers here? +var textInputTypes = ["text", "search", "email", "url", "number"]; +// The corresponding XPath for such elements. +var textInputXPath = '//input[' + + textInputTypes.map(function (type) { return '@type="' + type + '"'; }).join(" or ") + + ' or not(@type)]'; + /* * Give this frame a unique id. */ @@ -232,8 +243,8 @@ function scrollLeft() { window.scrollBy(-1 * settings["scrollStepSize"], 0); } function scrollRight() { window.scrollBy(settings["scrollStepSize"], 0); } function focusInput(count) { - var xpath = '//input[@type="text" or @type="search"]'; - var results = document.evaluate(xpath, document.documentElement, null, + var results = document.evaluate(textInputXPath, + document.documentElement, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); var lastInputBox; |
