Commit cdfbf804 authored by csillag's avatar csillag

Adapt to Annotator changes

parent 7faa6cec
...@@ -113,7 +113,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -113,7 +113,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
_collectVirtualAnnotations: (startPage, endPage) -> _collectVirtualAnnotations: (startPage, endPage) ->
results = [] results = []
for page in [startPage .. endPage] for page in [startPage .. endPage]
anchors = @annotator.anchors[page] anchors = @annotator.anchoring.anchors[page]
if anchors? if anchors?
$.merge results, (anchor.annotation for anchor in anchors when not anchor.fullyRealized) $.merge results, (anchor.annotation for anchor in anchors when not anchor.fullyRealized)
results results
...@@ -128,7 +128,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -128,7 +128,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
dir = if direction is "up" then +1 else -1 dir = if direction is "up" then +1 else -1
{next} = annotations.reduce (acc, ann) -> {next} = annotations.reduce (acc, ann) ->
{start, next} = acc {start, next} = acc
anchor = ann.anchors[0] anchor = ann.anchoring.anchors[0]
if not next? or start.page*dir < anchor.startPage*dir if not next? or start.page*dir < anchor.startPage*dir
# This one is obviously better # This one is obviously better
start: start:
...@@ -164,7 +164,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -164,7 +164,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
startPage = anchor.startPage startPage = anchor.startPage
# Is this rendered? # Is this rendered?
if @annotator.domMapper.isPageMapped startPage if @annotator.anchoring.document.isPageMapped startPage
# If it was rendered, then we only have one result. Go there. # If it was rendered, then we only have one result. Go there.
hl = anchor.highlight[startPage] hl = anchor.highlight[startPage]
hl.paddedScrollTo direction hl.paddedScrollTo direction
...@@ -175,11 +175,11 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -175,11 +175,11 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
count: next.length count: next.length
page: startPage page: startPage
direction: direction direction: direction
@annotator.domMapper.setPageIndex startPage @annotator.anchoring.document.setPageIndex startPage
_update: => _update: =>
wrapper = @annotator.wrapper wrapper = @annotator.wrapper
highlights = @annotator.getHighlights() highlights = @annotator.anchoring.getHighlights()
defaultView = wrapper[0].ownerDocument.defaultView defaultView = wrapper[0].ownerDocument.defaultView
# Keep track of buckets of annotations above and below the viewport # Keep track of buckets of annotations above and below the viewport
...@@ -187,7 +187,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -187,7 +187,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
below = [] below = []
# Get the page numbers # Get the page numbers
mapper = @annotator.domMapper mapper = @annotator.anchoring.document
return unless mapper? # Maybe it's too soon to do this return unless mapper? # Maybe it's too soon to do this
firstPage = 0 firstPage = 0
currentPage = mapper.getPageIndex() currentPage = mapper.getPageIndex()
...@@ -315,7 +315,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -315,7 +315,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
# TODO: This should use event delegation on the container. # TODO: This should use event delegation on the container.
.on 'mousemove', (event) => .on 'mousemove', (event) =>
bucket = @tabs.index(event.currentTarget) bucket = @tabs.index(event.currentTarget)
for hl in @annotator.getHighlights() for hl in @annotator.anchoring.getHighlights()
if hl.annotation in @buckets[bucket] if hl.annotation in @buckets[bucket]
hl.setFocused true hl.setFocused true
else else
...@@ -323,7 +323,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin ...@@ -323,7 +323,7 @@ class Annotator.Plugin.BucketBar extends Annotator.Plugin
# Gets rid of them after # Gets rid of them after
.on 'mouseout', => .on 'mouseout', =>
for hl in @annotator.getHighlights() for hl in @annotator.anchoring.getHighlights()
hl.setFocused false hl.setFocused false
# Does one of a few things when a tab is clicked depending on type # Does one of a few things when a tab is clicked depending on type
......
...@@ -16,8 +16,9 @@ class Annotator.Guest extends Annotator ...@@ -16,8 +16,9 @@ class Annotator.Guest extends Annotator
# Plugin configuration # Plugin configuration
options: options:
TextHighlights: {} TextHighlights: {}
EnhancedAnchoring: {}
DomTextMapper: {} DomTextMapper: {}
TextAnchors: {} TextSelection: {}
TextRange: {} TextRange: {}
TextPosition: {} TextPosition: {}
TextQuote: {} TextQuote: {}
...@@ -76,7 +77,7 @@ class Annotator.Guest extends Annotator ...@@ -76,7 +77,7 @@ class Annotator.Guest extends Annotator
unless config.dontScan unless config.dontScan
# Scan the document text with the DOM Text libraries # Scan the document text with the DOM Text libraries
this._scan() this.anchoring._scan()
# Watch for newly rendered highlights, and update positions in sidebar # Watch for newly rendered highlights, and update positions in sidebar
this.subscribe "highlightsCreated", (highlights) => this.subscribe "highlightsCreated", (highlights) =>
...@@ -136,7 +137,7 @@ class Annotator.Guest extends Annotator ...@@ -136,7 +137,7 @@ class Annotator.Guest extends Annotator
.bind('onEditorSubmit', this.onEditorSubmit) .bind('onEditorSubmit', this.onEditorSubmit)
.bind('focusAnnotations', (ctx, tags=[]) => .bind('focusAnnotations', (ctx, tags=[]) =>
for hl in @getHighlights() for hl in @anchoring.getHighlights()
if hl.annotation.$$tag in tags if hl.annotation.$$tag in tags
hl.setFocused true hl.setFocused true
else else
...@@ -144,7 +145,7 @@ class Annotator.Guest extends Annotator ...@@ -144,7 +145,7 @@ class Annotator.Guest extends Annotator
) )
.bind('scrollToAnnotation', (ctx, tag) => .bind('scrollToAnnotation', (ctx, tag) =>
for hl in @getHighlights() for hl in @anchoring.getHighlights()
if hl.annotation.$$tag is tag if hl.annotation.$$tag is tag
hl.scrollTo() hl.scrollTo()
return return
......
...@@ -40,7 +40,7 @@ class Annotator.Host extends Annotator.Guest ...@@ -40,7 +40,7 @@ class Annotator.Host extends Annotator.Guest
# Host frame dictates the toolbar options. # Host frame dictates the toolbar options.
this.on 'panelReady', => this.on 'panelReady', =>
this.setTool('comment') this.setTool('comment')
this._scan() # Scan the document this.anchoring._scan() # Scan the document
this.setVisibleHighlights(!!options.showHighlights) this.setVisibleHighlights(!!options.showHighlights)
if @plugins.BucketBar? if @plugins.BucketBar?
......
...@@ -38,6 +38,8 @@ module.exports = function(config) { ...@@ -38,6 +38,8 @@ module.exports = function(config) {
'h/static/scripts/annotator/plugin/bridge.js', 'h/static/scripts/annotator/plugin/bridge.js',
'h/static/scripts/annotator/plugin/bucket-bar.js', 'h/static/scripts/annotator/plugin/bucket-bar.js',
'h/static/scripts/annotator/plugin/threading.js', 'h/static/scripts/annotator/plugin/threading.js',
'h/static/scripts/vendor/dom_text_mapper.js',
'h/static/scripts/annotator/annotator.anchoring.js',
'h/static/scripts/app.js', 'h/static/scripts/app.js',
'h/static/scripts/account.js', 'h/static/scripts/account.js',
'h/static/scripts/helpers.js', 'h/static/scripts/helpers.js',
......
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