From 560f84a4bc65b7abd003951f191514761ba35e90 Mon Sep 17 00:00:00 2001 From: hogelog Date: Tue, 11 Jan 2011 10:00:19 +0900 Subject: disable zoom in/out when load iframe. https://github.com/philc/vimium/issuesearch?state=open&q=zoom#issue/271 --- vimiumFrontend.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vimiumFrontend.js b/vimiumFrontend.js index eb3de996..680578c9 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -61,7 +61,8 @@ function initializePreDomReady() { checkIfEnabledForUrl(); var getZoomLevelPort = chrome.extension.connect({ name: "getZoomLevel" }); - getZoomLevelPort.postMessage({ domain: window.location.host }); + if (window.self == window.parent) + getZoomLevelPort.postMessage({ domain: window.location.host }); chrome.extension.sendRequest({handler: "getLinkHintCss"}, function (response) { linkHintCss = response.linkHintCss; -- cgit v1.2.3 From b1f3653ef05b1b225934d502d7fd1eed38785225 Mon Sep 17 00:00:00 2001 From: jez Date: Tue, 1 Feb 2011 11:17:00 +0800 Subject: Fix regression: Deactivate link hinting when a textbox gets selected. --- linkHints.js | 1 + 1 file changed, 1 insertion(+) diff --git a/linkHints.js b/linkHints.js index e1889a47..6ce92ef3 100644 --- a/linkHints.js +++ b/linkHints.js @@ -225,6 +225,7 @@ var linkHints = { this.delayMode = true; if (this.isSelectable(matchedLink)) { this.simulateSelect(matchedLink); + this.deactivateMode(delay, function() { that.delayMode = false; }); } else { if (this.shouldOpenWithQueue) { this.simulateClick(matchedLink); -- cgit v1.2.3 From 8f855b2af46b719978ea6a21d916a586b4983f9e Mon Sep 17 00:00:00 2001 From: jez Date: Wed, 2 Feb 2011 01:33:29 +0800 Subject: Code cleanup. --- linkHints.js | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/linkHints.js b/linkHints.js index 6ce92ef3..e757bef4 100644 --- a/linkHints.js +++ b/linkHints.js @@ -25,7 +25,7 @@ var linkHints = { // While in delayMode, all keypresses have no effect. delayMode: false, // Handle the link hinting marker generation and matching. Must be initialized after settings have been - // loaded. + // loaded, so that we can retrieve the option setting. markerMatcher: undefined, /* @@ -85,14 +85,10 @@ var linkHints = { buildLinkHints: function() { var visibleElements = this.getVisibleClickableElements(); - // Initialize the number used to generate the character hints to be as many digits as we need to - // highlight all the links on the page; we don't want some link hints to have more chars than others. - var linkHintNumber = 0; this.markerMatcher.initSetMarkerAttributes(visibleElements); - for (var i = 0; i < visibleElements.length; i++) { - this.hintMarkers.push(this.createMarkerFor(visibleElements[i], linkHintNumber)); - linkHintNumber++; - } + for (var i = 0; i < visibleElements.length; i++) + this.hintMarkers.push(this.createMarkerFor(visibleElements[i], i)); + // Note(philc): Append these markers as top level children instead of as child nodes to the link itself, // because some clickable elements cannot contain children, e.g. submit buttons. This has the caveat // that if you scroll the page and the link has position=fixed, the marker will not stay fixed. @@ -127,6 +123,7 @@ var linkHints = { // Find all visible clickable elements. for (var i = 0; i < resultSet.snapshotLength; i++) { var element = resultSet.snapshotItem(i); + // Note: this call will be expensive if we modify the DOM in between calls. var clientRect = element.getClientRects()[0]; if (this.isVisible(element, clientRect)) @@ -325,7 +322,6 @@ var linkHints = { marker.clickableItem = link.element; this.markerMatcher.setMarkerAttributes(marker, linkHintNumber); - // Note: this call will be expensive if we modify the DOM in between calls. var clientRect = link.rect; // The coordinates given by the window do not have the zoom factor included since the zoom is set only on // the document node. @@ -343,6 +339,10 @@ var alphabetHints = { digitsNeeded: 1, logXOfBase: function(x, base) { return Math.log(x) / Math.log(base); }, + /* + * Initialize the number used to generate the character hints to be as many digits as we need to highlight + * all the links on the page; we don't want some link hints to have more chars than others. + */ initSetMarkerAttributes: function(visibleElements) { this.digitsNeeded = Math.ceil(this.logXOfBase( visibleElements.length, settings.get('linkHintCharacters').length)); @@ -469,17 +469,13 @@ var filterHints = { var keyChar = getKeyChar(event); if (event.keyCode == keyCodes.backspace || event.keyCode == keyCodes.deleteKey) { - if (this.linkTextKeystrokeQueue.length == 0 && this.hintKeystrokeQueue.length == 0) { + // backspace clears hint key queue first, then acts on link text key queue + if (this.hintKeystrokeQueue.pop()) + linksMatched = this.filterLinkHints(linksMatched); + else if (this.linkTextKeystrokeQueue.pop()) + linksMatched = this.filterLinkHints(linksMatched); + else // both queues are empty. exit hinting mode linksMatched = []; - } else { - // backspace clears hint key queue first, then acts on link text key queue - if (this.hintKeystrokeQueue.pop()) - linksMatched = this.filterLinkHints(linksMatched); - else { - this.linkTextKeystrokeQueue.pop(); - linksMatched = this.filterLinkHints(linksMatched); - } - } } else if (event.keyCode == keyCodes.enter) { // activate the lowest-numbered link hint that is visible for (var i = 0; i < linksMatched.length; i++) -- cgit v1.2.3 From 5f7c1506b774bfc7288bf66103e9f1eddd57115e Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Thu, 3 Feb 2011 16:20:14 -0800 Subject: Update the readme to reflect the new bindings for scrolling up/down a half page --- README.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 9b122f56..512fed22 100644 --- a/README.markdown +++ b/README.markdown @@ -30,10 +30,8 @@ Navigating the current page: l scroll right gg scroll to top of the page G scroll to bottom of the page - , scroll down a page - , scroll up a page - scroll down a full page - scroll up a full page + d, , scroll down half a page + u, , scroll up half a page f open a link in the current tab F open a link in a new tab r reload @@ -69,6 +67,8 @@ Additional advanced browsing commands: zH scroll all the way left zL scroll all the way right z0 reset zoom to default value + scroll down a full page + scroll up a full page Vimium supports command repetition so, for example, hitting '5t' will open 5 tabs in rapid succession. ESC (or -- cgit v1.2.3 From cbb0e6b78c5e8c59e5f027151ed16a20dedaffea Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 9 Feb 2011 00:31:46 -0800 Subject: added hogelog to credits --- CREDITS | 1 + 1 file changed, 1 insertion(+) diff --git a/CREDITS b/CREDITS index 3a01884a..fb4be384 100644 --- a/CREDITS +++ b/CREDITS @@ -10,6 +10,7 @@ Contributors: Christian Stefanescu (github: stchris) ConradIrwin drizzd + hogelog int3 Johannes Emerich (github: knuton) Julian Naydichev (github: naydichev) -- cgit v1.2.3 From 7d5f9b138f77db9a62f2d2847fd182372afdd9b3 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 9 Feb 2011 01:23:52 -0800 Subject: fix a bug with zoomReset --- vimiumFrontend.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vimiumFrontend.js b/vimiumFrontend.js index a5356f3f..6ddc15c3 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -221,18 +221,23 @@ function setPageZoomLevel(zoomLevel, showUINotification) { } function zoomIn() { - setPageZoomLevel(currentZoomLevel += 20, true); - saveZoomLevel(window.location.host, currentZoomLevel); + currentZoomLevel += 20; + setAndSaveZoom(); } function zoomOut() { - setPageZoomLevel(currentZoomLevel -= 20, true); - saveZoomLevel(window.location.host, currentZoomLevel); + currentZoomLevel -= 20; + setAndSaveZoom(); } function zoomReset() { - setPageZoomLevel(100, true); - saveZoomLevel(window.location.host, 100); + currentZoomLevel = 100; + setAndSaveZoom(); +} + +function setAndSaveZoom() { + setPageZoomLevel(currentZoomLevel, true); + saveZoomLevel(window.location.host, currentZoomLevel); } function scrollToBottom() { window.scrollTo(window.pageXOffset, document.body.scrollHeight); } -- cgit v1.2.3 From 1edb16a47eb8a35fc3ea7991bfdfc8434d1d3bff Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Wed, 9 Feb 2011 23:05:40 -0800 Subject: Style --- background_page.html | 8 +++++--- vimiumFrontend.js | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/background_page.html b/background_page.html index d98967b4..77150244 100644 --- a/background_page.html +++ b/background_page.html @@ -18,8 +18,9 @@ var focusedFrame = null; var framesForTab = {}; - // Keys are either literal characters, or "named" - for example (alt+b), (the left arrow) or - // This regular expression captures two groups, the first is a named key, the second is the remainder of the string. + // Keys are either literal characters, or "named" - for example (alt+b), (left arrow) or + // This regular expression captures two groups: the first is a named key, the second is the remainder of + // the string. var namedKeyRegex = /^(<(?:[amc]-.|(?:[amc]-)?[a-z0-9]{2,5})>)(.*)$/; var defaultSettings = { @@ -164,7 +165,8 @@ function showHelp(callback, frameId) { chrome.tabs.getSelected(null, function(tab) { - chrome.tabs.sendRequest(tab.id, { name: "showHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId }); + chrome.tabs.sendRequest(tab.id, + { name: "showHelpDialog", dialogHtml: helpDialogHtml(), frameId:frameId }); }); } diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 6ddc15c3..b7f9308f 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -153,8 +153,8 @@ function initializeWhenEnabled() { /* * The backend needs to know which frame has focus. */ -window.addEventListener("focus", function(e){ - chrome.extension.sendRequest({handler: "frameFocused", frameId: frameId}); +window.addEventListener("focus", function(e) { + chrome.extension.sendRequest({ handler: "frameFocused", frameId: frameId }); }); /* @@ -185,7 +185,8 @@ function initializeOnDomReady() { // This is a little hacky but sometimes the size wasn't available on domReady? function registerFrameIfSizeAvailable (top) { if (innerWidth != undefined && innerWidth != 0 && innerHeight != undefined && innerHeight != 0) - chrome.extension.sendRequest({ handler: "registerFrame", frameId: frameId, area: innerWidth * innerHeight, top: top, total: frames.length + 1 }); + chrome.extension.sendRequest({ handler: "registerFrame", frameId: frameId, + area: innerWidth * innerHeight, top: top, total: frames.length + 1 }); else setTimeout(function () { registerFrameIfSizeAvailable(top); }, 100); } -- cgit v1.2.3 From a036d2dac281b2528c2087b08839e118e3f449ae Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Wed, 9 Feb 2011 23:06:41 -0800 Subject: Preserve the "show advanced commands" setting after you close the vimium help dialog. --- background_page.html | 9 ++++++++- helpDialog.html | 21 ++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/background_page.html b/background_page.html index 77150244..ee12a77d 100644 --- a/background_page.html +++ b/background_page.html @@ -79,7 +79,8 @@ upgradeNotificationClosed: upgradeNotificationClosed, updateScrollPosition: handleUpdateScrollPosition, copyToClipboard: copyToClipboard, - isEnabledForUrl: isEnabledForUrl + isEnabledForUrl: isEnabledForUrl, + saveHelpDialogSettings: saveHelpDialogSettings }; // Event handlers @@ -151,6 +152,10 @@ return { isEnabledForUrl: isEnabled }; } + function saveHelpDialogSettings(request) { + localStorage["helpDialog_showAdvancedCommands"] = request.showAdvancedCommands; + } + /* * Returns the previously saved zoom level for the current tab, or the default zoom level */ @@ -186,6 +191,8 @@ showUnboundCommands, showCommandNames)); dialogHtml = dialogHtml.replace("{{version}}", currentVersion); dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help"); + dialogHtml = dialogHtml.replace("{{showAdvancedCommands}}", + localStorage["helpDialog_showAdvancedCommands"] == "true"); return dialogHtml; } diff --git a/helpDialog.html b/helpDialog.html index c21c8b7b..ae78d149 100644 --- a/helpDialog.html +++ b/helpDialog.html @@ -132,10 +132,14 @@ -- cgit v1.2.3 From dabef2b50b23df370a26031c25e62a410411d5a9 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 11 Feb 2011 18:29:43 -0800 Subject: Change the font size on the help dialog to 11 temporarily because, without more refactoring, the command view in the options page with advanced enabled is way too large. --- helpDialog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helpDialog.html b/helpDialog.html index 0f1cd6e9..51ff1692 100644 --- a/helpDialog.html +++ b/helpDialog.html @@ -5,7 +5,7 @@