aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-09-25 16:01:38 +0100
committerStephen Blott2016-09-25 16:01:38 +0100
commit91976ed2fc8026d1b688f210e086af764f1f057a (patch)
tree5fa6d4991e52fc208632f732707aaff949109efe
parent194229b6d469d28fa784387a7972aa7306d4f153 (diff)
downloadvimium-91976ed2fc8026d1b688f210e086af764f1f057a.tar.bz2
Refactor z-index allocation to a separate function.
-rw-r--r--content_scripts/link_hints.coffee51
1 files changed, 26 insertions, 25 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index aef6f46d..69ef79c1 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -197,36 +197,37 @@ class LinkHintsMode
indicator = @mode.indicator + (if typedCharacters then ": \"#{typedCharacters}\"" else "") + "."
@hintMode.setIndicator indicator
- #
- # Creates a link marker for the given link.
- #
- createMarkerFor: do ->
+ getNextZIndex: do ->
# This is the starting z-index value; it produces z-index values which are greater than all of the other
# z-index values used by Vimium.
baseZIndex = 2140000000
+ -> baseZIndex += 1
- (desc) ->
- marker =
- if desc.frameId == frameId
- localHintDescriptor = HintCoordinator.getLocalHintMarker desc
- el = DomUtils.createElement "div"
- el.rect = localHintDescriptor.rect
- el.style.left = el.rect.left + "px"
- el.style.top = el.rect.top + "px"
- # Each hint marker is assigned a different z-index.
- el.style.zIndex = baseZIndex += 1
- extend el,
- className: "vimiumReset internalVimiumHintMarker vimiumHintMarker"
- showLinkText: localHintDescriptor.showLinkText
- localHintDescriptor: localHintDescriptor
- else
- {}
+ #
+ # Creates a link marker for the given link.
+ #
+ createMarkerFor: (desc) ->
+ marker =
+ if desc.frameId == frameId
+ localHintDescriptor = HintCoordinator.getLocalHintMarker desc
+ el = DomUtils.createElement "div"
+ el.rect = localHintDescriptor.rect
+ el.style.left = el.rect.left + "px"
+ el.style.top = el.rect.top + "px"
+ # Each hint marker is assigned a different z-index.
+ el.style.zIndex = @getNextZIndex()
+ extend el,
+ className: "vimiumReset internalVimiumHintMarker vimiumHintMarker"
+ showLinkText: localHintDescriptor.showLinkText
+ localHintDescriptor: localHintDescriptor
+ else
+ {}
- extend marker,
- hintDescriptor: desc
- isLocalMarker: desc.frameId == frameId
- linkText: desc.linkText
- stableSortCount: ++@stableSortCount
+ extend marker,
+ hintDescriptor: desc
+ isLocalMarker: desc.frameId == frameId
+ linkText: desc.linkText
+ stableSortCount: ++@stableSortCount
# Handles <Shift> and <Ctrl>.
onKeyDownInMode: (event) ->