Commit 22501ba0 authored by Randall Leeds's avatar Randall Leeds

Various small fixes to solidify multi-frame work

parent 7b55bc6d
......@@ -105,9 +105,13 @@ class Annotator.Guest extends Annotator
_setupViewer: -> this
_setupEditor: -> this
showViewer: (annotation) => @plugins.Bridge.showViewer annotation
showViewer: (annotations) =>
@panel?.notify method: "showViewer", params: (a.id for a in annotations)
updateViewer: (annotations) =>
@panel?.notify method: "updateViewer", params: (a.id for a in annotations)
showEditor: (annotation) => @plugins.Bridge.showEditor annotation
updateViewer: (annotations) => @plugins.Bridge.updateViewer annotations
checkForStartSelection: (event) =>
# Override to prevent Annotator choking when this ties to access the
......
......@@ -33,10 +33,6 @@ class Annotator.Host extends Annotator.Guest
_setupXDM: (options) ->
channel = super
# Set dynamic bucket mode on the sidebar
setDynamicBucketMode: (value) ->
@panel?.notify method: 'setDynamicBucketMode', params: value
channel
......@@ -115,45 +111,6 @@ class Annotator.Host extends Annotator.Guest
'margin-left': "#{m}px"
width: "#{w}px"
showViewer: (annotations) =>
@panel?.notify method: "showViewer", params: (a.id for a in annotations)
updateViewer: (annotations) =>
@panel?.notify method: "updateViewer", params: (a.id for a in annotations)
showEditor: (annotation) => @plugins.Bridge.showEditor annotation
createFakeCommentRange: ->
posSelector =
type: "TextPositionSelector"
start: @domMapper.corpus.length - 1
end: @domMapper.corpus.length
anchor = this.findAnchorFromPositionSelector selector: [posSelector]
anchor.range
# Override for setupAnnotation
setupAnnotation: (annotation) ->
# Set up annotation as usual
annotation = super(annotation)
# Does it have proper highlights?
unless annotation.highlights?.length or annotation.references?.length or annotation.target?.length
# No highlights and no references means that this is a comment,
# or re-attachment has failed, but we'll skip orphaned annotations.
# Get a fake range at the end of the document, and highlight it
range = this.createFakeCommentRange()
hl = this.highlightRange range
# Register this highlight for the annotation, and vica versa
$.merge annotation.highlights, hl
$(hl).data('annotation', annotation)
annotation
# Switch off dynamic bucket mode
this.setDynamicBucketMode false
addToken: (token) =>
@api.notify
......@@ -201,4 +158,4 @@ class Annotator.Host extends Annotator.Guest
this.subscribe('annotationEditorSubmit', save)
# Display the editor.
this.showEditor(annotation, position)
this.showEditor(annotation, position)
\ No newline at end of file
......@@ -60,7 +60,12 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
'annotationsLoaded'
]
for event in events
@annotator.subscribe event, this._update
if event is 'annotationCreated'
@annotator.subscribe event, =>
@dynamicBucket = false
this._update()
else
@annotator.subscribe event, this._update
@element.on 'click', (event) =>
event.stopPropagation()
......@@ -229,7 +234,7 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
max = 0
for b in @buckets
info = b.reduce (info, a) ->
subtotal = (a.thread?.flattenChildren()?.length or 0)
subtotal = a.reply_count or 0
return {
top: info.top + 1
replies: (info.replies or 0) + subtotal
......
......@@ -199,23 +199,21 @@ class Hypothesis extends Annotator
.bind('back', =>
# This guy does stuff when you "back out" of the interface.
# (Currently triggered by a click on the source page.)
return unless drafts.discard()
$rootScope.$apply => this.hide()
)
.bind('setDynamicBucketMode', (ctx, value) => $rootScope.$apply =>
this.setDynamicBucketMode value
$rootScope.$apply =>
return unless drafts.discard()
this.hide()
)
.bind('open', =>
# Pop out the sidebar
$rootScope.$apply => this.show())
$rootScope.$apply => this.show()
)
.bind('showViewer', (ctx, tags=[]) =>
.bind('showViewer', (ctx, ids=[]) =>
this.showViewer ((@threading.getContainer id).message for id in ids)
)
.bind('updateViewer', (ctx, tags=[]) =>
.bind('updateViewer', (ctx, ids=[]) =>
this.updateViewer ((@threading.getContainer id).message for id in ids)
)
......@@ -352,9 +350,6 @@ class Hypothesis extends Annotator
hide: =>
@element.scope().frame.visible = false
setDynamicBucketMode: (value) =>
@element.scope().dynamicBucket = value
patch_store: ->
$location = @element.injector().get '$location'
$rootScope = @element.injector().get '$rootScope'
......@@ -381,6 +376,9 @@ class Hypothesis extends Annotator
# if the annotation has a newly-assigned id and ensures that the id
# is enumerable.
Store.prototype.updateAnnotation = (annotation, data) =>
unless Object.keys(data).length
return
if annotation.id? and annotation.id != data.id
# Update the id table for the threading
thread = @threading.getContainer annotation.id
......@@ -404,6 +402,7 @@ class Hypothesis extends Annotator
# Update the annotation with the new data
annotation = angular.extend annotation, data
@plugins.Bridge?.updateAnnotation annotation
# Give angular a chance to react
$rootScope.$digest()
......@@ -430,7 +429,9 @@ class Hypothesis extends Annotator
for ref in (annotation.references?.slice().reverse() or [])
rel = (@threading.getContainer ref).message
if rel?
@element.injector().get('$timeout') (=> this.updateAnnotation rel), 10
$timeout = @element.injector().get('$timeout')
$timeout (=> @plugins.Bridge.updateAnnotation rel), 10
this.updateAncestors(rel)
break # Only the nearest existing ancestor, the rest is by induction.
serviceDiscovery: (options) =>
......
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