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:
@@ -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";
|
||||||
|
|||||||
@@ -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())
|
||||||
@@ -743,7 +743,7 @@ const Events = Module("events", {
|
|||||||
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
let win = elem.ownerDocument && elem.ownerDocument.defaultView || elem;
|
||||||
|
|
||||||
if (hasHTMLDocument(win) && !buffer.focusAllowed(win)
|
if (hasHTMLDocument(win) && !buffer.focusAllowed(win)
|
||||||
&& isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement]))
|
&& isinstance(elem, [HTMLInputElement, HTMLSelectElement, HTMLTextAreaElement]))
|
||||||
elem.blur();
|
elem.blur();
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -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 () {
|
||||||
|
|||||||
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user