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 ...@@ -84,7 +84,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
acc acc
, {} , {}
next.paddedScrollDownTo() next.paddedScrollTo('down')
delete @pendingScroll delete @pendingScroll
@annotator.subscribe "highlightRemoved", (highlight) => @annotator.subscribe "highlightRemoved", (highlight) =>
......
...@@ -83,12 +83,6 @@ class Anchor ...@@ -83,12 +83,6 @@ class Anchor
# Kill the list if it's empty # Kill the list if it's empty
delete @anchoring.anchors[index] unless anchors.length 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 Annotator.Anchor = Anchor
# This plugin contains the enhanced anchoring framework. # This plugin contains the enhanced anchoring framework.
...@@ -107,13 +101,6 @@ class Annotator.Plugin.EnhancedAnchoring extends Annotator.Plugin ...@@ -107,13 +101,6 @@ class Annotator.Plugin.EnhancedAnchoring extends Annotator.Plugin
this 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 # Initializes the components used for analyzing the document
_chooseAccessPolicy: -> _chooseAccessPolicy: ->
...@@ -161,7 +148,6 @@ class Annotator.Plugin.EnhancedAnchoring extends Annotator.Plugin ...@@ -161,7 +148,6 @@ class Annotator.Plugin.EnhancedAnchoring extends Annotator.Plugin
@selectorCreators = [] @selectorCreators = []
@strategies = [] @strategies = []
@_setupDocumentAccessStrategies() @_setupDocumentAccessStrategies()
this._setupAnchorEvents()
self = this self = this
@annotator.anchoring = this @annotator.anchoring = this
......
...@@ -62,7 +62,7 @@ class Annotator.Plugin.TextRange extends Annotator.Plugin ...@@ -62,7 +62,7 @@ class Annotator.Plugin.TextRange extends Annotator.Plugin
# Create a RangeSelector around a range # Create a RangeSelector around a range
_getRangeSelector: (selection) => _getRangeSelector: (selection) =>
return [] unless selection.type is "text range" 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" type: "RangeSelector"
startContainer: sr.start startContainer: sr.start
......
...@@ -88,9 +88,8 @@ class Annotator.Plugin.TextSelection extends Annotator.Plugin ...@@ -88,9 +88,8 @@ class Annotator.Plugin.TextSelection extends Annotator.Plugin
for range in selectedRanges for range in selectedRanges
container = range.commonAncestor container = range.commonAncestor
# TODO: what is selection ends inside a different type of highlight? if @$(container).hasClass('annotator-hl')
if @Annotator.TextHighlight.isInstance container container = @$(container).parents(':not([class^=annotator-hl])')[0]
container = @Annotator.TextHighlight.getIndependentParent container
return if @annotator.isAnnotator(container) return if @annotator.isAnnotator(container)
if selectedRanges.length 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