aboutsummaryrefslogtreecommitdiffstats
path: root/vimiumFrontend.js
diff options
context:
space:
mode:
authorilya2009-12-06 12:41:21 -0800
committerilya2009-12-06 12:41:21 -0800
commita0a59d19d90d46836ff2077e9301895447c8d3b5 (patch)
tree6443c56fe80d90a9756ce020556ac4088f42fe1d /vimiumFrontend.js
parent0215cd8444fba8cc3b536b2c6016678e3e756c1f (diff)
parent13c8e6dfdeda45700ea29dd8cfc413d9e93f8a07 (diff)
downloadvimium-a0a59d19d90d46836ff2077e9301895447c8d3b5.tar.bz2
Merge branch 'master' of git://github.com/philc/vimium
Diffstat (limited to 'vimiumFrontend.js')
-rw-r--r--vimiumFrontend.js53
1 files changed, 39 insertions, 14 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js
index 1c9a4b50..ce37db3f 100644
--- a/vimiumFrontend.js
+++ b/vimiumFrontend.js
@@ -106,7 +106,10 @@ function saveZoomLevel(domain, zoomLevel) {
* Zoom in increments of 20%; this matches chrome's CMD+ and CMD- keystrokes.
* Set the zoom style on documentElement because document.body does not exist pre-page load.
*/
-function setPageZoomLevel(zoomLevel) { document.documentElement.style.zoom = zoomLevel + "%"; }
+function setPageZoomLevel(zoomLevel) {
+ document.documentElement.style.zoom = zoomLevel + "%";
+ HUD.updatePageZoomLevel(zoomLevel);
+}
function zoomIn() {
setPageZoomLevel(currentZoomLevel += 20);
@@ -177,9 +180,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)
{
@@ -201,15 +207,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");
@@ -294,27 +305,41 @@ HUD = {
HUD.displayElement().style.display = "";
},
+ updatePageZoomLevel: function(pageZoomLevel) {
+ // Since the chrome HUD does not scale with the page's zoom level, neither will this HUD.
+ HUD.displayElement().style.zoom = (100.0 / pageZoomLevel) * 100 + "%";
+ },
+
/*
* Retrieves the HUD HTML element, creating it if necessary.
*/
displayElement: function() {
if (!HUD._displayElement) {
+ // This is styled to precisely mimick the chrome HUD. 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 it doesn't sit
+ // on top of horizontal scrollbars like Chrome's HUD does.
var element = document.createElement("div");
- element.innerHTML = "howdy";
element.style.position = "fixed";
element.style.bottom = "0px";
- element.style.right = "20px";
- element.style.backgroundColor = " #e5e5e5";
+ // Keep this far enough to the right so that it doesn't collide with the "popups blocked" chrome HUD.
+ element.style.right = "150px";
+ element.style.height = "13px";
element.style.maxWidth = "400px";
+ element.style.minWidth = "150px";
+ element.style.backgroundColor = "#ebebeb";
element.style.fontSize = "11px";
- element.style.padding = "3px";
- element.style.border = "1px solid #cccccc";
- element.style.borderBottomWidth = "0px";
- // element.style.fontFamily = "monospace";
+ element.style.padding = "3px 3px 2px 3px";
+ element.style.border = "1px solid #b3b3b3";
+ element.style.borderRadius = "4px 4px 0 0";
+ element.style.fontFamily = "Lucida Grande";
+ element.style.textShadow = "0px 1px 2px #FFF";
+ element.style.display = "none";
+
document.body.appendChild(element);
HUD._displayElement = element
+ HUD.updatePageZoomLevel(currentZoomLevel);
}
- return HUD._displayElement
+ return HUD._displayElement;
},
hide: function() {