aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorJez Ng2012-01-19 01:09:41 +0800
committerJez Ng2012-01-19 01:11:07 +0800
commit469acff29be41e60eb8e1c24f007d435711d2b50 (patch)
treee4282b6a903ee46ff8915ce5541fdfcdbdea7699 /vimiumFrontend.js
parent5972613b7a0b7933d2736ea6190f652263ad37a3 (diff)
downloadvimium-469acff29be41e60eb8e1c24f007d435711d2b50.tar.bz2
Exit implicit insert mode only upon tab switch.
Don't do it when the user has merely switched windows.
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 693d1232..6f02bb1c 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -106,6 +106,11 @@ function initializePreDomReady() {
focusThisFrame(request.highlight);
} else if (request.name == "refreshCompletionKeys") {
refreshCompletionKeys(request);
+ } else if (request.name == "exitImplicitInsertMode") {
+ if (!HUD.isShowing) {
+ document.activeElement.blur();
+ exitInsertMode();
+ }
}
sendResponse({}); // Free up the resources used by this open connection.
});
@@ -159,7 +164,7 @@ function initializeWhenEnabled() {
document.addEventListener("keypress", onKeypress, true);
document.addEventListener("keyup", onKeyup, true);
document.addEventListener("focus", onFocusCapturePhase, true);
- window.addEventListener("blur", onBlurCapturePhase, true);
+ document.addEventListener("blur", onBlurCapturePhase, true);
document.addEventListener("DOMActivate", onDOMActivate, true);
enterInsertModeIfElementIsFocused();
}
@@ -533,12 +538,7 @@ function onFocusCapturePhase(event) {
}
function onBlurCapturePhase(event) {
- if (event.target == window)
- // At this point, we will have exited insert mode already, but the browser remembers which element last
- // had focus, and fires a focus event on it when the window regains focus. We blur this element to prevent
- // implicit insert mode from reactivating when we switch back to this tab.
- document.activeElement.blur();
- else if (isFocusable(event.target))
+ if (isFocusable(event.target))
exitInsertMode(event.target);
}
@@ -777,6 +777,7 @@ HUD = {
_tweenId: -1,
_displayElement: null,
_upgradeNotificationElement: null,
+ isShowing: false,
// This HUD is styled to precisely mimick the chrome HUD on Mac. Use the "has_popup_and_link_hud.html"
// test harness to tweak these styles to match Chrome's. One limitation of our HUD display is that
@@ -793,6 +794,7 @@ HUD = {
clearInterval(HUD._tweenId);
HUD._tweenId = Tween.fade(HUD.displayElement(), 1.0, 150);
HUD.displayElement().style.display = "";
+ this.isShowing = true;
},
showUpgradeNotification: function(version) {
@@ -850,6 +852,7 @@ HUD = {
clearInterval(HUD._tweenId);
HUD._tweenId = Tween.fade(HUD.displayElement(), 0, 150,
function() { HUD.displayElement().style.display = "none"; });
+ this.isShowing = false;
},
isReady: function() { return document.body != null; }