diff options
| -rw-r--r-- | content_scripts/link_hints.coffee | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index ca529b1f..a6597554 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -24,7 +24,8 @@ LinkHints = delayMode: false # Handle the link hinting marker generation and matching. Must be initialized after settings have been # loaded, so that we can retrieve the option setting. - markerMatcher: undefined + markerMatcher: -> + if settings.get("filterLinkHints") then filterHints else alphabetHints # lock to ensure only one instance runs at a time isActive: false @@ -32,7 +33,6 @@ LinkHints = # To be called after linkHints has been generated from linkHintsBase. # init: -> - @markerMatcher = if settings.get("filterLinkHints") then filterHints else alphabetHints # # Generate an XPath describing what a clickable element is. @@ -60,7 +60,7 @@ LinkHints = @isActive = true @setOpenLinkMode(mode) - hintMarkers = @markerMatcher.fillInMarkers(@createMarkerFor(el) for el in @getVisibleClickableElements()) + hintMarkers = @markerMatcher().fillInMarkers(@createMarkerFor(el) for el in @getVisibleClickableElements()) # 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 @@ -161,7 +161,7 @@ LinkHints = visibleElements # - # Handles shift and esc keys. The other keys are passed to markerMatcher.matchHintsByKey. + # Handles shift and esc keys. The other keys are passed to markerMatcher().matchHintsByKey. # onKeyDownInMode: (hintMarkers, event) -> return if @delayMode @@ -183,7 +183,7 @@ LinkHints = if (KeyboardUtils.isEscape(event)) @deactivateMode() else if (event.keyCode != keyCodes.shiftKey) - keyResult = @markerMatcher.matchHintsByKey(hintMarkers, event) + keyResult = @markerMatcher().matchHintsByKey(hintMarkers, event) linksMatched = keyResult.linksMatched delay = keyResult.delay ? 0 if (linksMatched.length == 0) @@ -194,7 +194,7 @@ LinkHints = for marker in hintMarkers @hideMarker(marker) for matched in linksMatched - @showMarker(matched, @markerMatcher.hintKeystrokeQueue.length) + @showMarker(matched, @markerMatcher().hintKeystrokeQueue.length) false # We've handled this key, so prevent propagation. # @@ -239,8 +239,8 @@ LinkHints = # deactivateMode: (delay, callback) -> deactivate = => - if (LinkHints.markerMatcher.deactivate) - LinkHints.markerMatcher.deactivate() + if (LinkHints.markerMatcher().deactivate) + LinkHints.markerMatcher().deactivate() if (LinkHints.hintMarkerContainingDiv) DomUtils.removeElement LinkHints.hintMarkerContainingDiv LinkHints.hintMarkerContainingDiv = null |
