diff options
| author | Jez Ng | 2012-01-09 00:02:25 +0800 | 
|---|---|---|
| committer | Jez Ng | 2012-01-09 00:18:12 +0800 | 
| commit | 6ae84b98b094384e9a5e4eeaa2f041ea1140633f (patch) | |
| tree | 5358daee36109256f7cf6124c139b4b58cfe1d25 /linkHints.js | |
| parent | e2f3b54ba488d5fac6f4f3d2d75b46dada19660a (diff) | |
| download | vimium-6ae84b98b094384e9a5e4eeaa2f041ea1140633f.tar.bz2 | |
Make focusInput detect textareas as well, and refactor the XPath code.
Together with e2f3b54, this closes issue #276.
Diffstat (limited to 'linkHints.js')
| -rw-r--r-- | linkHints.js | 16 | 
1 files changed, 3 insertions, 13 deletions
| diff --git a/linkHints.js b/linkHints.js index fbbf8a51..fed190dc 100644 --- a/linkHints.js +++ b/linkHints.js @@ -39,14 +39,8 @@ var linkHints = {     * Generate an XPath describing what a clickable element is.     * The final expression will be something like "//button | //xhtml:button | ..."     */ -  clickableElementsXPath: (function() { -    var clickableElements = ["a", "area[@href]", "textarea", "button", "select", "input[not(@type='hidden')]", -                             "*[@onclick or @tabindex or @role='link' or @role='button']"]; -    var xpath = []; -    for (var i in clickableElements) -      xpath.push("//" + clickableElements[i], "//xhtml:" + clickableElements[i]); -    return xpath.join(" | ") -  })(), +  clickableElementsXPath: utils.makeXPath(["a", "area[@href]", "textarea", "button", "select","input[not(@type='hidden')]", +                             "*[@onclick or @tabindex or @role='link' or @role='button']"]),    // We need this as a top-level function because our command system doesn't yet support arguments.    activateModeToOpenInNewTab: function() { this.activateMode(true, false, false); }, @@ -115,11 +109,7 @@ var linkHints = {     * of digits needed to enumerate all of the links on screen.     */    getVisibleClickableElements: function() { -    var resultSet = document.evaluate(this.clickableElementsXPath, document.body, -      function(namespace) { -        return namespace == "xhtml" ? "http://www.w3.org/1999/xhtml" : null; -      }, -      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); +    var resultSet = utils.evaluateXPath(this.clickableElementsXPath, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);      var visibleElements = []; | 
