1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 18:17:58 +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 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;
let computedStyle = util.computedStyle(elem);
return computedStyle.visibility != "hidden" && computedStyle.display != "none";

View File

@@ -712,8 +712,8 @@ const Events = Module("events", {
// displayed too. --djk
function isInputField() {
let elem = dactyl.focus;
return ((elem instanceof HTMLInputElement && !/image/.test(elem.type))
|| elem instanceof HTMLIsIndexElement);
return elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type)
|| elem instanceof HTMLIsIndexElement;
}
if (options["insertmode"] || isInputField())
@@ -767,8 +767,8 @@ const Events = Module("events", {
if (elem && elem.readOnly)
return;
if ((elem instanceof HTMLInputElement && /^(search|text|password)$/.test(elem.type)) ||
(elem instanceof HTMLSelectElement)) {
if (elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type) ||
elem instanceof HTMLSelectElement) {
dactyl.mode = modes.INSERT;
if (hasHTMLDocument(win))
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 () {
let elem = dactyl.focus;
return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) ||
elem instanceof HTMLTextAreaElement ||
elem instanceof HTMLIsIndexElement ||
elem instanceof HTMLObjectElement ||
elem instanceof HTMLEmbedElement);
return elem instanceof HTMLInputElement && set.has(Events.editableInputs, elem.type) ||
isinstance(elem, [HTMLIsIndexElement, HTMLEmbedElement,
HTMLObjectElement, HTMLTextAreaElement]);
}
}, {
commands: function () {

View File

@@ -114,7 +114,7 @@ const Hints = Module("hints", {
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];
else {
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")
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);
else
hint.text = elem.textContent.toLowerCase();