Commit dbe42025 authored by Kristof Csillag's avatar Kristof Csillag

Merge pull request #1868 from hypothesis/dedupe-highlights

Clean up unused and duplicate TextHighlight code.
parents 0565f6af 1459c189
......@@ -84,7 +84,8 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
acc
, {}
next.paddedScrollDownTo()
# Scroll down to the annotation from the top of the annotation's page
next.paddedScrollTo('down')
delete @pendingScroll
@annotator.subscribe "highlightRemoved", (highlight) =>
......@@ -128,7 +129,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
dir = if direction is "up" then +1 else -1
{next} = annotations.reduce (acc, ann) ->
{start, next} = acc
anchor = ann.anchoring.anchors[0]
anchor = ann.anchors[0]
if not next? or start.page*dir < anchor.startPage*dir
# This one is obviously better
start:
......
......@@ -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
......
......@@ -2,10 +2,6 @@
class Annotator.Plugin.TextSelection extends Annotator.Plugin
pluginInit: ->
# We need text highlights
unless @annotator.plugins.TextHighlights
throw new Error "The TextSelection Annotator plugin requires the TextHighlights plugin."
@Annotator = Annotator
@$ = Annotator.$
......@@ -88,9 +84,6 @@ 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
return if @annotator.isAnnotator(container)
if selectedRanges.length
......
/*
** Annotator v1.2.9-dev-b091a74
** Annotator v1.2.9-dev-368b5cf
** https://github.com/okfn/annotator/
**
** Copyright 2015, the Annotator project contributors.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2015-01-19 11:35:26Z
** Built at: 2015-01-19 16:53:10Z
*/
......
/*
** Annotator v1.2.9-dev-b091a74
** Annotator v1.2.9-dev-368b5cf
** https://github.com/okfn/annotator/
**
** Copyright 2015, the Annotator project contributors.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2015-01-19 11:35:26Z
** Built at: 2015-01-19 16:53:10Z
*/
......
/*
** Annotator v1.2.9-dev-b091a74
** Annotator v1.2.9-dev-368b5cf
** https://github.com/okfn/annotator/
**
** Copyright 2015, the Annotator project contributors.
** Dual licensed under the MIT and GPLv3 licenses.
** https://github.com/okfn/annotator/blob/master/LICENSE
**
** Built at: 2015-01-19 11:35:26Z
** Built at: 2015-01-19 16:53:10Z
*/
......@@ -1236,9 +1236,6 @@
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
range = _ref1[_k];
container = range.commonAncestor;
if ($(container).hasClass('annotator-hl')) {
container = $(container).parents('[class!=annotator-hl]')[0];
}
if (this.isAnnotator(container)) {
return;
}
......@@ -1251,7 +1248,7 @@
};
Annotator.prototype.isAnnotator = function(element) {
return !!$(element).parents().addBack().filter('[class^=annotator-]').not(this.wrapper).length;
return !!$(element).parents().addBack().filter('[class^=annotator-]').not('[class=annotator-hl]').not(this.wrapper).length;
};
Annotator.prototype.onHighlightMouseover = function(event) {
......
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