aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/link_hints.coffee
diff options
context:
space:
mode:
authorJez Ng2012-08-19 23:27:44 -0700
committerJez Ng2012-08-20 00:43:45 -0700
commitdfb2c58e3d76cfc0131a1e30cba4ae8d23853726 (patch)
tree13632f0978351f03e0142a9b1fa8bafaf2302537 /content_scripts/link_hints.coffee
parentc2257a03126c0e7af77e3c0697498a18c7f6be06 (diff)
downloadvimium-dfb2c58e3d76cfc0131a1e30cba4ae8d23853726.tar.bz2
More refactoring-cleanup.
* vimium_frontend now has a pretty decent set of exports * Generic linkHints code has been moved to DomUtils, so future features can reuse the code.
Diffstat (limited to 'content_scripts/link_hints.coffee')
-rw-r--r--content_scripts/link_hints.coffee26
1 files changed, 8 insertions, 18 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index 34ecb431..5cdbc6a7 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -54,7 +54,14 @@ LinkHints =
@setOpenLinkMode(openInNewTab, withQueue, copyLinkUrl)
hintMarkers = @markerMatcher.fillInMarkers(@createMarkerFor(el) for el in @getVisibleClickableElements())
- @hintMarkerContainingDiv = @displayHints(hintMarkers)
+
+ DomUtils.addCssToPage(settings.get("userDefinedLinkHintCss"), "vimiumLinkHintCss")
+ # 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.
+ @hintMarkerContainingDiv = DomUtils.addElementList(hintMarkers,
+ { id: "vimiumHintMarkerContainer", className: "vimiumReset" })
+
# handlerStack is declared by vimiumFrontend.js
handlerStack.push({
keydown: @onKeyDownInMode.bind(this, hintMarkers),
@@ -104,23 +111,6 @@ LinkHints =
marker
- displayHints: (hintMarkers) ->
- if (!document.getElementById("vimiumLinkHintCss"))
- # linkHintCss is declared by vimiumFrontend.js and contains the user supplied css overrides.
- addCssToPage(settings.get("userDefinedLinkHintCss"), "vimiumLinkHintCss")
-
- # 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.
- # Also note that adding these nodes to document.body all at once is significantly faster than one-by-one.
- hintMarkerContainingDiv = document.createElement("div")
- hintMarkerContainingDiv.id = "vimiumHintMarkerContainer"
- hintMarkerContainingDiv.className = "vimiumReset"
- hintMarkerContainingDiv.appendChild(marker) for marker in hintMarkers
-
- document.documentElement.appendChild(hintMarkerContainingDiv)
- hintMarkerContainingDiv
-
#
# Returns all clickable elements that are not hidden and are in the current viewport.
# We prune invisible elements partly for performance reasons, but moreso it's to decrease the number