diff options
| author | Phil Crosby | 2009-12-06 01:14:18 -0800 |
|---|---|---|
| committer | Phil Crosby | 2009-12-06 01:14:18 -0800 |
| commit | 4ccf344ba6fc874f506e8e31d87216ba44533409 (patch) | |
| tree | bda98cac8eaf69abe55d86f36abc6a8404a6f6b1 | |
| parent | 5a6aad001e9da5bbe891711fd93975980d1e8fc5 (diff) | |
| download | vimium-4ccf344ba6fc874f506e8e31d87216ba44533409.tar.bz2 | |
Enter insert mode when we click on a flash embed. Fixes #23.
| -rw-r--r-- | vimiumFrontend.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index e74b1fbd..c48b5b36 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -173,9 +173,12 @@ function onKeydown(event) { if (insertMode && event.keyCode == keyCodes.ESC) { - // Remove focus so the user can't just get himself back into insert mode by typing in the same input box. - if (isInputOrText(event.srcElement)) { event.srcElement.blur(); } - exitInsertMode(); + // Note that we can't programmatically blur out of Flash embeds from Javascript. + if (event.srcElement.tagName != "EMBED") { + // Remove focus so the user can't just get himself back into insert mode by typing in the same input box. + if (isInputOrText(event.srcElement)) { event.srcElement.blur(); } + exitInsertMode(); + } } else if (findMode) { @@ -197,15 +200,20 @@ function onKeydown(event) { } function onFocusCapturePhase(event) { - if (isInputOrText(event.target)) + if (isFocusable(event.target)) enterInsertMode(); } function onBlurCapturePhase(event) { - if (isInputOrText(event.target)) + if (isFocusable(event.target)) exitInsertMode(); } +/* + * Returns true if the element is focusable. This includes embeds like Flash, which steal the keybaord focus. + */ +function isFocusable(element) { return isInputOrText(element) || element.tagName == "EMBED"; } + function isInputOrText(target) { return ((target.tagName == "INPUT" && (target.type == "text" || target.type == "password")) || target.tagName == "TEXTAREA"); |
