From 1b4115574184843726c3c3926377c0226c3ecce1 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Sat, 13 Jul 2013 00:26:28 +0200 Subject: [PATCH] All to filter link hints also by the title or alt of image. Show the images title or alt attribute in hint label if the link contains no text content. --- src/hints.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/hints.js b/src/hints.js index 8f6d739..0969be4 100644 --- a/src/hints.js +++ b/src/hints.js @@ -70,11 +70,14 @@ var VbHint = (function(){ /* if hinted element is an image - show title or alt of the image in hint label */ /* this allows to see how to filter for the image */ + var text = ""; if (e instanceof HTMLImageElement) { - var text = e.alt || e.title; - if (text) { - label.innerText += ": " + text.substr(0, 20); - } + text = e.alt || e.title; + } else if (e.firstElementChild instanceof HTMLImageElement && /^\s*$/.test(e.textContent)) { + text = e.firstElementChild.title || e.firstElementChild.alt; + } + if (text) { + label.innerText += ": " + text.substr(0, 20); } fragment.appendChild(label); @@ -373,8 +376,8 @@ var VbHint = (function(){ return "//a[@href] | //*[@onclick or @tabindex or @class='lk' or @role='link' or @role='button'] | //input[not(@type='hidden' or @disabled or @readonly)] | //area[@href] | //textarea[not(@disabled or @readonly)] | //button | //select"; } return buildQuery( - ["@value", ".", "@placeholder"], - "//a[@href and $.] | //*[(@onclick or @class='lk' or @role='link' or role='button') and $.] | //input[not(@type='hidden' or @disabled or @readonly) and ($@value or $@placeholder)] | //area[$.] | //textarea[not(@disabled or @readonly) and $.] | //button[$.] | //select[$.]", + ["@value", ".", "@placeholder", "@title", "@alt"], + "//a[@href and ($. or child::img[$@title or $@alt])] | //*[(@onclick or @class='lk' or @role='link' or role='button') and $.] | //input[not(@type='hidden' or @disabled or @readonly) and ($@value or $@placeholder)] | //area[$.] | //textarea[not(@disabled or @readonly) and $.] | //button[$.] | //select[$.]", s ); case "e": -- 2.20.1