Fixed none working hint class replacing.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 30 Mar 2013 01:13:27 +0000 (02:13 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 30 Mar 2013 01:13:27 +0000 (02:13 +0100)
If a hint become focused the new hint class was not set properly to the
element. And the hint class was already set if the hints where cleared.

src/hints.js

index 632cb4a..b00aebb 100644 (file)
@@ -69,6 +69,7 @@ function VimbHints(mode, usage, bg, bgf, fg, style, maxHints)
                 var hint        = hintSpan.cloneNode(false);
                 hint.style.left = Math.max((rect.left + win.scrollX), win.scrollX) - 3 + "px";
                 hint.style.top  = Math.max((rect.top + win.scrollY), win.scrollY) - 3 + "px";
+                hint.className  = hClass;
                 hint.appendChild(doc.createTextNode(hCount + 1));
 
                 fragment.appendChild(hint);
@@ -176,6 +177,8 @@ function VimbHints(mode, usage, bg, bgf, fg, style, maxHints)
             if (hint.e) {
                 hint.e.style.background = hint.bg;
                 hint.e.style.color = hint.fg;
+                hint.e.classList.remove(hClassFocus);
+                hint.e.classList.remove(hClass);
                 hint.span.parentNode.removeChild(hint.span);
             }
         }
@@ -244,7 +247,7 @@ function VimbHints(mode, usage, bg, bgf, fg, style, maxHints)
         /* reset previous focused hint */
         var hint = _getHintByNum(focusNum);
         if (hint) {
-            hint.e.className        = hint.e.className.replace(hClassFocus, hClass);
+            hint.e.classList.remove(hClassFocus);
             hint.e.style.background = bg;
             _mouseEvent(hint.e, "mouseout");
         }
@@ -254,7 +257,7 @@ function VimbHints(mode, usage, bg, bgf, fg, style, maxHints)
         /* mark new hint as focused */
         hint = _getHintByNum(focusNum);
         if (hint) {
-            hint.e.className        = hint.e.className.replace(hClass, hClassFocus);
+            hint.e.classList.add(hClassFocus);
             hint.e.style.background = bgf;
             var source              = _getSrc(hint.e);
             _mouseEvent(hint.e, "mouseover");