Show image title or alt in hint label.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 12 Jul 2013 21:48:38 +0000 (23:48 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 12 Jul 2013 22:04:19 +0000 (00:04 +0200)
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.

src/hints.js

index eddf326..8f6d739 100644 (file)
@@ -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 */