From: Daniel Carl Date: Fri, 12 Jul 2013 21:48:38 +0000 (+0200) Subject: Show image title or alt in hint label. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=0f606aaf0d2a2a13f57ebed1b93d54aa1d7b7038;p=vimb.git Show image title or alt in hint label. This allow the user to filter the hints. The hints where already filtered by the image title or alt attributes, but they aren't visible normally so this made less sense. But now the title or alt attributes content is visible in hinting mode. --- diff --git a/src/hints.js b/src/hints.js index eddf326..8f6d739 100644 --- a/src/hints.js +++ b/src/hints.js @@ -68,6 +68,15 @@ var VbHint = (function(){ label.style.top = Math.max((rect.top + win.scrollY), win.scrollY) - 3 + "px"; label.innerText = count + 1; + /* 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 */ + if (e instanceof HTMLImageElement) { + var text = e.alt || e.title; + if (text) { + label.innerText += ": " + text.substr(0, 20); + } + } + fragment.appendChild(label); /* add the hint class to the hinted element */