// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
/** @scope modules */
/** @instance hints */
let body = doc.body || doc.querySelector("body");
if (body) {
- let fragment = DOM(<div highlight="hints"/>, doc).appendTo(body);
+ let fragment = DOM(["div", { highlight: "hints" }], doc).appendTo(body);
fragment.style.height; // Force application of binding.
let container = doc.getAnonymousElementByAttribute(fragment[0], "anonid", "hints") || fragment[0];
- let baseNode = DOM(<span highlight="Hint" style="display: none;"/>, doc)[0];
+ let baseNode = DOM(["span", { highlight: "Hint", style: "display: none;" }], doc)[0];
let mode = this.hintMode;
let res = mode.matcher(doc);
let n = 5;
(function next() {
+ if (Cu.isDeadWrapper && Cu.isDeadWrapper(elem))
+ // Hint document has been unloaded.
+ return;
+
let hinted = n || this.validHints.some(function (h) h.elem === elem);
if (!hinted)
hints.setClass(elem, null);
/**
* Display the hints in pageHints that are still valid.
*/
+ showCount: 0,
show: function _show() {
+ let count = ++this.showCount;
let hintnum = 1;
let validHint = hints.hintMatcher(this.hintString.toLowerCase());
let activeHint = this.hintNumber || 1;
inner:
for (let i in (util.interruptibleRange(start, end + 1, 500))) {
+ if (this.showCount != count)
+ return;
+
let hint = this.pageHints[i];
hint.valid = validHint(hint.text);
if (!rect)
continue;
- hint.imgSpan = DOM(<span highlight="Hint" dactyl:hl="HintImage" xmlns:dactyl={NS}/>, doc).css({
+ hint.imgSpan = DOM(["span", { highlight: "Hint", "dactyl:hl": "HintImage" }], doc).css({
display: "none",
left: (rect.left + offsetX) + "px",
top: (rect.top + offsetY) + "px",
this.modes = {};
this.addMode(";", "Focus hint", buffer.closure.focusElement);
this.addMode("?", "Show information for hint", function (elem) buffer.showElementInfo(elem));
+ // TODO: allow for ! override to overwrite existing paths -- where? --djk
this.addMode("s", "Save hint", function (elem) buffer.saveLink(elem, false));
this.addMode("f", "Focus frame", function (elem) dactyl.focus(elem.ownerDocument.defaultView));
this.addMode("F", "Focus frame or pseudo-frame", buffer.closure.focusElement, isScrollable);
}
else if (option == "label") {
if (elem.id) {
- let label = elem.ownerDocument.dactylLabels[elem.id];
+ let label = (elem.ownerDocument.dactylLabels || {})[elem.id];
+ // Urgh.
if (label)
return [label.textContent.toLowerCase(), true];
}
options.add(["hinttags", "ht"],
"XPath or CSS selector strings of hintable elements for Hints mode",
// Make sure to update the docs when you change this.
- "stringlist", ":-moz-any-link,area,button,iframe,input:not([type=hidden]),select,textarea," +
+ "stringlist", ":-moz-any-link,area,button,iframe,input:not([type=hidden]),label[for],select,textarea," +
"[onclick],[onmouseover],[onmousedown],[onmouseup],[oncommand]," +
"[tabindex],[role=link],[role=button],[contenteditable=true]",
{