Commit 8381000a authored by Nick Stenning's avatar Nick Stenning

Clean up unused and duplicate TextHighlight code

This commit is intended as a pure refactoring. No behaviour should be
changed.
parent 74519983
......@@ -84,7 +84,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
acc
, {}
next.paddedScrollDownTo()
next.paddedScrollTo('down')
delete @pendingScroll
@annotator.subscribe "highlightRemoved", (highlight) =>
......
......@@ -83,12 +83,6 @@ class Anchor
# Kill the list if it's empty
delete @anchoring.anchors[index] unless anchors.length
# This is called when the underlying Annotator has been udpated
annotationUpdated: ->
# Notify the highlights
for index in [@startPage .. @endPage]
@highlight[index]?.annotationUpdated()
Annotator.Anchor = Anchor
# This plugin contains the enhanced anchoring framework.
......@@ -107,13 +101,6 @@ class Annotator.Plugin.EnhancedAnchoring extends Annotator.Plugin
this
# Sets up handlers to anchor-related events
_setupAnchorEvents: ->
# When annotations are updated
@annotator.on 'annotationUpdated', (annotation) =>
# Notify the anchors
for anchor in annotation.anchors or []
anchor.annotationUpdated()
# Initializes the components used for analyzing the document
_chooseAccessPolicy: ->
......@@ -161,7 +148,6 @@ class Annotator.Plugin.EnhancedAnchoring extends Annotator.Plugin
@selectorCreators = []
@strategies = []
@_setupDocumentAccessStrategies()
this._setupAnchorEvents()
self = this
@annotator.anchoring = this
......
......@@ -62,7 +62,7 @@ class Annotator.Plugin.TextRange extends Annotator.Plugin
# Create a RangeSelector around a range
_getRangeSelector: (selection) =>
return [] unless selection.type is "text range"
sr = selection.range.serialize @annotator.wrapper[0], '.' + @Annotator.TextHighlight.highlightClass
sr = selection.range.serialize @annotator.wrapper[0], '.annotator-hl'
[
type: "RangeSelector"
startContainer: sr.start
......
......@@ -88,9 +88,8 @@ class Annotator.Plugin.TextSelection extends Annotator.Plugin
for range in selectedRanges
container = range.commonAncestor
# TODO: what is selection ends inside a different type of highlight?
if @Annotator.TextHighlight.isInstance container
container = @Annotator.TextHighlight.getIndependentParent container
if @$(container).hasClass('annotator-hl')
container = @$(container).parents(':not([class^=annotator-hl])')[0]
return if @annotator.isAnnotator(container)
if selectedRanges.length
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment