1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:47:59 +01:00

Support all HTML 5 editable input types.

This commit is contained in:
Kris Maglione
2010-08-28 18:58:37 -04:00
parent f1ca59a83d
commit 9f0b293881
3 changed files with 14 additions and 13 deletions

View File

@@ -1508,7 +1508,7 @@ const Buffer = Module("buffer", {
let xpath = ["input", "textarea[not(@disabled) and not(@readonly)]"]; let xpath = ["input", "textarea[not(@disabled) and not(@readonly)]"];
let elements = [m for (m in util.evaluateXPath(xpath))].filter(function (elem) { let elements = [m for (m in util.evaluateXPath(xpath))].filter(function (elem) {
if (elem.readOnly || elem instanceof HTMLInputElement && ["file", "search", "text", "password"].indexOf(elem.type) < 0) if (elem.readOnly || elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type))
return false; return false;
let computedStyle = util.computedStyle(elem); let computedStyle = util.computedStyle(elem);
return computedStyle.visibility != "hidden" && computedStyle.display != "none"; return computedStyle.visibility != "hidden" && computedStyle.display != "none";

View File

@@ -712,8 +712,8 @@ const Events = Module("events", {
// displayed too. --djk // displayed too. --djk
function isInputField() { function isInputField() {
let elem = dactyl.focus; let elem = dactyl.focus;
return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) return elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type)
|| elem instanceof HTMLIsIndexElement); || elem instanceof HTMLIsIndexElement;
} }
if (options["insertmode"] || isInputField()) if (options["insertmode"] || isInputField())
@@ -767,8 +767,8 @@ const Events = Module("events", {
if (elem && elem.readOnly) if (elem && elem.readOnly)
return; return;
if ((elem instanceof HTMLInputElement && /^(search|text|password)$/.test(elem.type)) || if (elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type) ||
(elem instanceof HTMLSelectElement)) { elem instanceof HTMLSelectElement) {
dactyl.mode = modes.INSERT; dactyl.mode = modes.INSERT;
if (hasHTMLDocument(win)) if (hasHTMLDocument(win))
buffer.lastInputField = elem; buffer.lastInputField = elem;
@@ -1104,13 +1104,14 @@ const Events = Module("events", {
// } // }
} }
}, { }, {
editableInputs: set(["date", "datetime", "datetime-local", "email", "file",
"month", "number", "password", "range", "search",
"tel", "text", "time", "url", "week"]),
isInputElemFocused: function () { isInputElemFocused: function () {
let elem = dactyl.focus; let elem = dactyl.focus;
return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) || return elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type) ||
elem instanceof HTMLTextAreaElement || isinstance(elem, [HTMLIsIndexElement, HTMLEmbedElement,
elem instanceof HTMLIsIndexElement || HTMLObjectElement, HTMLTextAreaElement]);
elem instanceof HTMLObjectElement ||
elem instanceof HTMLEmbedElement);
} }
}, { }, {
commands: function () { commands: function () {

View File

@@ -114,7 +114,7 @@ const Hints = Module("hints", {
let type = elem.type; let type = elem.type;
if (elem instanceof HTMLInputElement && /(submit|button|reset)/.test(type)) if (elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type))
return [elem.value, false]; return [elem.value, false];
else { else {
for (let [, option] in Iterator(options["hintinputs"].split(","))) { for (let [, option] in Iterator(options["hintinputs"].split(","))) {
@@ -261,7 +261,7 @@ const Hints = Module("hints", {
if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none") if (computedStyle.getPropertyValue("visibility") != "visible" || computedStyle.getPropertyValue("display") == "none")
continue; continue;
if (elem instanceof HTMLInputElement || elem instanceof HTMLSelectElement || elem instanceof HTMLTextAreaElement) if (isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement]))
[hint.text, hint.showText] = this._getInputHint(elem, doc); [hint.text, hint.showText] = this._getInputHint(elem, doc);
else else
hint.text = elem.textContent.toLowerCase(); hint.text = elem.textContent.toLowerCase();