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

Fix "gi" for file input fields.

This commit is contained in:
Doug Kearns
2009-05-15 17:36:06 +10:00
parent b665e766e7
commit 19d51ebb17

View File

@@ -135,6 +135,19 @@ function Buffer() //{{{
pageInfo[option] = [fn, title]; pageInfo[option] = [fn, title];
} }
function openUploadPrompt(elem)
{
commandline.input("Upload file: ", function (path) {
let file = io.getFile(path);
if (!file.exists())
return liberator.beep();
elem.value = file.path;
},
{ completer: completion.file, default: elem.value });
}
/////////////////////////////////////////////////////////////////////////////}}} /////////////////////////////////////////////////////////////////////////////}}}
////////////////////// OPTIONS ///////////////////////////////////////////////// ////////////////////// OPTIONS /////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
@@ -360,16 +373,13 @@ function Buffer() //{{{
function (count) function (count)
{ {
if (count < 1 && buffer.lastInputField) if (count < 1 && buffer.lastInputField)
{ buffer.focusElement(buffer.lastInputField);
buffer.lastInputField.focus();
}
else else
{ {
let elements = []; let elements = [];
let matches = buffer.evaluateXPath( let matches = buffer.evaluateXPath(
// TODO: type="file" "//input[not(@type) or @type='text' or @type='password' or @type='file'] | //textarea[not(@disabled) and not(@readonly)] |" +
"//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' or @type='file'] | //xhtml:textarea[not(@disabled) and not(@readonly)]"
"//xhtml:input[not(@type) or @type='text' or @type='password'] | //xhtml:textarea[not(@disabled) and not(@readonly)]"
); );
for (let match in matches) for (let match in matches)
@@ -382,12 +392,10 @@ function Buffer() //{{{
if (elements.length > 0) if (elements.length > 0)
{ {
count = Math.min(Math.max(count, 1), elements.length); count = Math.min(Math.max(count, 1), elements.length);
elements[count - 1].focus(); buffer.focusElement(elements[count - 1]);
} }
else else
{
liberator.beep(); liberator.beep();
}
} }
}, },
{ flags: Mappings.flags.COUNT }); { flags: Mappings.flags.COUNT });
@@ -1071,18 +1079,10 @@ function Buffer() //{{{
elem.contentWindow.focus(); elem.contentWindow.focus();
return; return;
} }
else if (elemTagName == "input" && elem.getAttribute('type').toLowerCase() == "file") else if (elemTagName == "input" && elem.type.toLowerCase() == "file")
{ {
commandline.input("Upload file: ", function (path) openUploadPrompt(elem);
{ buffer.lastInputField = elem;
let file = io.getFile(path);
if (!file.exists())
return liberator.beep();
elem.value = file.path;
}
, {completer: completion.file, default: elem.value});
return; return;
} }
@@ -1192,14 +1192,7 @@ function Buffer() //{{{
} }
else if (localName == "input" && elem.type.toLowerCase() == "file") else if (localName == "input" && elem.type.toLowerCase() == "file")
{ {
commandline.input("Upload file: ", function (path) { openUploadPrompt(elem);
let file = io.getFile(path);
if (!file.exists())
return liberator.beep();
elem.value = file.path;
}, { completer: completion.file, default: elem.value });
return; return;
} }