aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--background_scripts/commands.coffee5
-rw-r--r--background_scripts/completion.coffee3
-rw-r--r--background_scripts/main.coffee3
-rw-r--r--content_scripts/vimium_frontend.coffee4
-rw-r--r--lib/dom_utils.coffee16
-rw-r--r--tests/dom_tests/dom_utils_test.coffee8
-rw-r--r--tests/unit_tests/utils_test.coffee2
8 files changed, 35 insertions, 7 deletions
diff --git a/README.md b/README.md
index ca2bf7fb..d0ae8213 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,7 @@ Manipulating tabs:
x close current tab
X restore closed tab (i.e. unwind the 'x' command)
T search through your open tabs
+ . pin/unpin current tab
Additional advanced browsing commands:
diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee
index ce159c71..3e30e033 100644
--- a/background_scripts/commands.coffee
+++ b/background_scripts/commands.coffee
@@ -100,7 +100,7 @@ Commands =
historyNavigation:
["goBack", "goForward"]
tabManipulation:
- ["nextTab", "previousTab", "firstTab", "lastTab", "createTab", "duplicateTab", "removeTab", "restoreTab", "moveTabToNewWindow"]
+ ["nextTab", "previousTab", "firstTab", "lastTab", "createTab", "duplicateTab", "removeTab", "restoreTab", "moveTabToNewWindow", "togglePinTab"]
misc:
["showHelp"]
@@ -170,6 +170,8 @@ defaultKeyMappings =
"x": "removeTab"
"X": "restoreTab"
+ ".": "togglePinTab"
+
"o": "Vomnibar.activate"
"O": "Vomnibar.activateInNewTab"
@@ -245,6 +247,7 @@ commandDescriptions =
removeTab: ["Close current tab", { background: true, noRepeat: true }]
restoreTab: ["Restore closed tab", { background: true }]
moveTabToNewWindow: ["Move tab to new window", { background: true }]
+ togglePinTab: ["Pin/unpin current tab", { background: true }]
"Vomnibar.activate": ["Open URL, bookmark, or history entry"]
"Vomnibar.activateInNewTab": ["Open URL, bookmark, history entry, in a new tab"]
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 92e325e1..beb7003a 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -71,7 +71,8 @@ class Suggestion
# Wraps each occurence of the query terms in the given string in a <span>.
highlightTerms: (string) ->
ranges = []
- for term in @queryTerms
+ escapedTerms = @queryTerms.map (term) -> Utils.escapeHtml(term)
+ for term in escapedTerms
@pushMatchingRanges string, term, ranges
return string if ranges.length == 0
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index f564f477..207cbccb 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -257,6 +257,9 @@ BackgroundCommands =
callback()))
openCopiedUrlInCurrentTab: (request) -> openUrlInCurrentTab({ url: Clipboard.paste() })
openCopiedUrlInNewTab: (request) -> openUrlInNewTab({ url: Clipboard.paste() })
+ togglePinTab: (request) ->
+ chrome.tabs.getSelected(null, (tab) ->
+ chrome.tabs.update(tab.id, { pinned: !tab.pinned }))
showHelp: (callback, frameId) ->
chrome.tabs.getSelected(null, (tab) ->
chrome.tabs.sendMessage(tab.id,
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index a2139df6..b9666aa5 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -839,7 +839,7 @@ window.showHelpDialog = (html, fid) ->
container.innerHTML = html
container.getElementsByClassName("closeButton")[0].addEventListener("click", hideHelpDialog, false)
-
+
VimiumHelpDialog =
# This setting is pulled out of local storage. It's false by default.
getShowAdvancedCommands: -> settings.get("helpDialog_showAdvancedCommands")
@@ -908,7 +908,7 @@ HUD =
show: (text) ->
return unless HUD.enabled()
clearTimeout(HUD._showForDurationTimerId)
- HUD.displayElement().innerHTML = text
+ HUD.displayElement().innerText = text
clearInterval(HUD._tweenId)
HUD._tweenId = Tween.fade(HUD.displayElement(), 1.0, 150)
HUD.displayElement().style.display = ""
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 38b23202..70e52a6c 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -46,11 +46,21 @@ DomUtils =
#
getVisibleClientRect: (element) ->
# Note: this call will be expensive if we modify the DOM in between calls.
- clientRects = element.getClientRects()
+ clientRects = ({
+ top: clientRect.top, right: clientRect.right, bottom: clientRect.bottom, left: clientRect.left,
+ width: clientRect.width, height: clientRect.height
+ } for clientRect in element.getClientRects())
for clientRect in clientRects
- if (clientRect.top < -2 || clientRect.top >= window.innerHeight - 4 ||
- clientRect.left < -2 || clientRect.left >= window.innerWidth - 4)
+ if (clientRect.top < 0)
+ clientRect.height += clientRect.top
+ clientRect.top = 0
+
+ if (clientRect.left < 0)
+ clientRect.width += clientRect.left
+ clientRect.left = 0
+
+ if (clientRect.top >= window.innerHeight - 4 || clientRect.left >= window.innerWidth - 4)
continue
if (clientRect.width < 3 || clientRect.height < 3)
diff --git a/tests/dom_tests/dom_utils_test.coffee b/tests/dom_tests/dom_utils_test.coffee
index d0f881ba..130a3014 100644
--- a/tests/dom_tests/dom_utils_test.coffee
+++ b/tests/dom_tests/dom_utils_test.coffee
@@ -42,6 +42,14 @@ context "Check visibility",
assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'foo'
assert.equal null, DomUtils.getVisibleClientRect document.getElementById 'bar'
+ should "detect links only partially outside viewport as visible", ->
+ document.getElementById("test-div").innerHTML = """
+ <a id='foo' style='position:absolute;top:-10px'>test</a>
+ <a id='bar' style='position:absolute;left:-10px'>test</a>
+ """
+ assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'foo') != null
+ assert.isTrue (DomUtils.getVisibleClientRect document.getElementById 'bar') != null
+
should "detect opacity:0 links as hidden", ->
document.getElementById("test-div").innerHTML = """
<a id='foo' style='opacity:0'>test</a>
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index e1aa32c7..91a06135 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -1,5 +1,7 @@
require "./test_helper.js"
extend(global, require "../../lib/utils.js")
+Utils.getCurrentVersion = -> '1.43'
+global.localStorage = {}
extend(global, require "../../background_scripts/settings.js")
context "isUrl",