From: Daniel Carl Date: Fri, 12 Jul 2013 22:26:28 +0000 (+0200) Subject: All to filter link hints also by the title or alt of image. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=1b4115574184843726c3c3926377c0226c3ecce1;p=vimb.git 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. --- 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":