1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-12 23:45:47 +01:00

Refactor isFormElemFocused and rename isInputElemFocused.

This commit is contained in:
Doug Kearns
2009-06-17 18:52:55 +10:00
parent ebe4c574c0
commit 8a834b3386

View File

@@ -458,30 +458,12 @@ function Events() //{{{
code_key[60] = "lt"; code_key[60] = "lt";
} }
function isFormElemFocused() function isInputElemFocused()
{ {
let elem = liberator.focus; let elem = liberator.focus;
if (elem == null) return ((elem instanceof HTMLInputElement && !/image/.test(elem.type)) ||
return false; elem instanceof HTMLTextAreaElement ||
elem instanceof HTMLIsIndexElement)
try
{ // sometimes the elem doesn't have .localName
let tagname = elem.localName.toLowerCase();
let type = elem.type.toLowerCase();
if ((tagname == "input" && (type != "image")) ||
tagname == "textarea" ||
// tagName == "SELECT" ||
// tagName == "BUTTON" ||
tagname == "isindex") // isindex is a deprecated one-line input box
return true;
}
catch (e)
{
// FIXME: do nothing?
}
return false;
} }
function triggerLoadAutocmd(name, doc) function triggerLoadAutocmd(name, doc)
@@ -1659,7 +1641,7 @@ function Events() //{{{
// this is need for sites like msn.com which focus the input field on keydown // this is need for sites like msn.com which focus the input field on keydown
onKeyUpOrDown: function (event) onKeyUpOrDown: function (event)
{ {
if (modes.passNextKey ^ modes.passAllKeys || isFormElemFocused()) if (modes.passNextKey ^ modes.passAllKeys || isInputElemFocused())
return; return;
event.stopPropagation(); event.stopPropagation();