1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 10:37:59 +01:00

Fix some variable references in Hints.

--HG--
extra : rebase_source : cc651cba7e6da7dee9c363f85b3b5459194cce06
This commit is contained in:
Doug Kearns
2009-11-15 17:49:37 +11:00
parent cd17b12177
commit 9937c2965a

View File

@@ -6,19 +6,19 @@
/** @scope modules */ /** @scope modules */
/** @instance hints */ /** @instance hints */
const ELEM = 0, TEXT = 1, SPAN = 2, IMG_SPAN = 3;
const Hints = Module("hints", { const Hints = Module("hints", {
requires: ["config"], requires: ["config"],
init: function () { init: function () {
this._hintMode; this._hintMode = null;
this._submode = ""; // used for extended mode, can be "o", "t", "y", etc. this._submode = ""; // used for extended mode, can be "o", "t", "y", etc.
this._hintString = ""; // the typed string part of the hint is in this string this._hintString = ""; // the typed string part of the hint is in this string
this._hintNumber = 0; // only the numerical part of the hint this._hintNumber = 0; // only the numerical part of the hint
this._usedTabKey = false; // when we used <Tab> to select an element this._usedTabKey = false; // when we used <Tab> to select an element
this._prevInput = ""; // record previous user input type, "text" || "number" this._prevInput = ""; // record previous user input type, "text" || "number"
this._extendedhintCount; // for the count argument of Mode#action (extended hint only) this._extendedhintCount = null; // for the count argument of Mode#action (extended hint only)
// hints[] = [elem, text, span, imgSpan, elem.style.backgroundColor, elem.style.color] // hints[] = [elem, text, span, imgSpan, elem.style.backgroundColor, elem.style.color]
this._pageHints = []; this._pageHints = [];
@@ -384,7 +384,7 @@ const Hints = Module("hints", {
imgSpan.style.top = (rect.top + offsetY) + "px"; imgSpan.style.top = (rect.top + offsetY) + "px";
imgSpan.style.width = (rect.right - rect.left) + "px"; imgSpan.style.width = (rect.right - rect.left) + "px";
imgSpan.style.height = (rect.bottom - rect.top) + "px"; imgSpan.style.height = (rect.bottom - rect.top) + "px";
hint[IMG_SPAN] = imgSpan; hint[Hints.IMG_SPAN] = imgSpan;
span.parentNode.appendChild(imgSpan); span.parentNode.appendChild(imgSpan);
} }
this._setClass(imgSpan, activeHint == hintnum); this._setClass(imgSpan, activeHint == hintnum);
@@ -431,8 +431,8 @@ const Hints = Module("hints", {
elem.parentNode.removeChild(elem); elem.parentNode.removeChild(elem);
for (let i in util.range(start, end + 1)) { for (let i in util.range(start, end + 1)) {
let hint = this._pageHints[i]; let hint = this._pageHints[i];
if (!timeout || hint[ELEM] != firstElem) if (!timeout || hint[Hints.ELEM] != firstElem)
hint[ELEM].removeAttributeNS(NS.uri, "highlight"); hint[Hints.ELEM].removeAttributeNS(NS.uri, "highlight");
} }
// animate the disappearance of the first hint // animate the disappearance of the first hint
@@ -489,10 +489,11 @@ const Hints = Module("hints", {
if (timeout == 0) if (timeout == 0)
// force a possible mode change, based on whether an input field has focus // force a possible mode change, based on whether an input field has focus
events.onFocusChange(); events.onFocusChange();
this.setTimeout(function () { this.setTimeout(function () {
if (modes.extended & modes.HINTS) if (modes.extended & modes.HINTS)
modes.reset(); modes.reset();
this._hintMode.action(elem, elem.href || "", hints._extendedhintCount); this._hintMode.action(elem, elem.href || "", this._extendedhintCount);
}, timeout); }, timeout);
return true; return true;
}, },
@@ -658,7 +659,7 @@ const Hints = Module("hints", {
* @param {Array(string)} words The words to search in. * @param {Array(string)} words The words to search in.
* @param {boolean} allowWordOverleaping Whether matches may be * @param {boolean} allowWordOverleaping Whether matches may be
* non-contiguous. * non-contiguous.
* @returns boolean Whether all the strings matched. * @returns {boolean} Whether all the strings matched.
*/ */
function stringsAtBeginningOfWords(strings, words, allowWordOverleaping) { function stringsAtBeginningOfWords(strings, words, allowWordOverleaping) {
let strIdx = 0; let strIdx = 0;
@@ -743,7 +744,7 @@ const Hints = Module("hints", {
this._submode = minor; this._submode = minor;
this._hintString = filter || ""; this._hintString = filter || "";
this._hintNumber = 0; this._hintNumber = 0;
usedTab = false; this._usedTabKey = false;
this._prevInput = ""; this._prevInput = "";
this._canUpdate = false; this._canUpdate = false;
@@ -886,6 +887,12 @@ const Hints = Module("hints", {
//}}} //}}}
}, { }, {
ELEM: 0,
TEXT: 1,
SPAN: 2,
IMG_SPAN: 3,
indexOf: (function () { indexOf: (function () {
const table = [ const table = [
[0x00c0, 0x00c6, ["A"]], [0x00c0, 0x00c6, ["A"]],
@@ -1022,6 +1029,7 @@ const Hints = Module("hints", {
return -1; return -1;
} }
})(), })(),
Mode: Struct("prompt", "action", "tags") Mode: Struct("prompt", "action", "tags")
}, { }, {
mappings: function () { mappings: function () {