mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 16:32:27 +01:00
improve input/textarea matching for "gi" and allow an out of range count to
jump to the last field like "gt"
This commit is contained in:
@@ -325,18 +325,42 @@ liberator.Buffer = function () //{{{
|
|||||||
"Focus last used input field",
|
"Focus last used input field",
|
||||||
function (count)
|
function (count)
|
||||||
{
|
{
|
||||||
|
liberator.log(count)
|
||||||
if (count < 1 && liberator.buffer.lastInputField)
|
if (count < 1 && liberator.buffer.lastInputField)
|
||||||
|
{
|
||||||
liberator.buffer.lastInputField.focus();
|
liberator.buffer.lastInputField.focus();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var first = liberator.buffer.evaluateXPath(
|
var elements = [];
|
||||||
"//*[@type='text'] | //textarea | //xhtml:textarea")
|
var matches = liberator.buffer.evaluateXPath(
|
||||||
.snapshotItem(count > 0 ? (count - 1) : 0);
|
// TODO: type="file"
|
||||||
|
"//input[not(@type) or @type='text' or @type='password'] | //textarea[not(@disabled) and not(@readonly)] |" +
|
||||||
|
"//xhtml:input[not(@type) or @type='text' or @type='password'] | //xhtml:textarea[not(@disabled) and not(@readonly)]"
|
||||||
|
);
|
||||||
|
|
||||||
if (first)
|
for (let i = 0; i < matches.snapshotLength; i++)
|
||||||
first.focus();
|
{
|
||||||
|
let match = matches.snapshotItem(i);
|
||||||
|
let computedStyle = window.content.getComputedStyle(match, null);
|
||||||
|
|
||||||
|
if (computedStyle.getPropertyValue("visibility") != "hidden" && computedStyle.getPropertyValue("display") != "none")
|
||||||
|
elements.push(match)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (elements.length > 0)
|
||||||
|
{
|
||||||
|
if (count > elements.length)
|
||||||
|
count = elements.length;
|
||||||
|
else if (count < 1)
|
||||||
|
count = 1;
|
||||||
|
|
||||||
|
elements[count - 1].focus();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
liberator.beep();
|
liberator.beep();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ flags: liberator.Mappings.flags.COUNT });
|
{ flags: liberator.Mappings.flags.COUNT });
|
||||||
|
|||||||
Reference in New Issue
Block a user