Commit dd307c61 authored by Randall Leeds's avatar Randall Leeds

fix highlights for jschannel

parent 22260caf
......@@ -56,17 +56,11 @@ class App
unless $location.path() == '/viewer' and $location.search()?.id?
provider.notify
method: 'setActiveHighlights'
params: heatmap.buckets[bucket]?.map (a) => a.id
params: heatmap.buckets[bucket]?.map (a) => a.$$tag
# Gets rid of them after
.on 'mouseout', =>
if $location.path() == '/viewer'
unless $location.search()?.id?
bucket = heatmap.buckets[$location.search()?.bucket]
provider.notify
method: 'setActiveHighlights'
params: bucket?.map (a) => a.id
else
if $location.path() == '/viewer' and not $location.search()?.id?
provider.notify method: 'setActiveHighlights'
# Does one of a few things when a tab is clicked depending on type
......@@ -147,7 +141,6 @@ class App
else
plugins.Permissions.setUser(null)
delete plugins.Auth
provider.setActiveHighlights []
if annotator.plugins.Store?
for annotation in annotator.dumpAnnotations()
provider.deleteAnnotation annotation
......@@ -364,13 +357,13 @@ class Viewer
search.id = annotation.id
$location.search(search).replace()
$scope.focus = (annotation=$scope.annotations) ->
$scope.focus = (annotation) ->
if $routeParams.id?
highlights = [$routeParams.id]
highlights = [$scope.thread.message.annotation.$$tag]
else if angular.isArray annotation
highlights = (a.id for a in annotation when a?)
highlights = (a.$$tag for a in annotation when a?)
else if angular.isObject annotation
highlights = [annotation.id]
highlights = [annotation.$$tag]
else
highlights = []
provider.notify method: 'setActiveHighlights', params: highlights
......@@ -389,7 +382,7 @@ class Viewer
$scope.focus $scope.thread.message.annotation
else
$scope.detail = false
$scope.focus $scope.annotations
$scope.focus []
angular.module('h.controllers', [])
......
......@@ -60,7 +60,7 @@ class Annotator.Host extends Annotator
formatted
parser: (annotation) =>
parsed = {}
for k, v of annotation when k in ['id', 'quote', 'ranges']
for k, v of annotation when k in ['quote', 'ranges']
parsed[k] = v
parsed
......@@ -103,15 +103,15 @@ class Annotator.Host extends Annotator
highlights: $(@wrapper).find('.annotator-hl').map ->
offset: $(this).offset()
height: $(this).outerHeight(true)
data: $(this).data('annotation').id
data: $(this).data('annotation').$$tag
.get()
offset: $(window).scrollTop()
)
.bind('setActiveHighlights', (ctx, ids=[]) =>
.bind('setActiveHighlights', (ctx, tags=[]) =>
@wrapper.find('.annotator-hl')
.each ->
if $(this).data('annotation').id in ids
if $(this).data('annotation').$$tag in tags
$(this).addClass('annotator-hl-active')
else if not $(this).hasClass('annotator-hl-temporary')
$(this).removeClass('annotator-hl-active')
......
......@@ -72,6 +72,7 @@ class Hypothesis extends Annotator
references: annotation.thread?.split '/'
# Update the heatmap when the host is updated or annotations are loaded
bridge = @plugins.Bridge
heatmap = @plugins.Heatmap
for event in ['hostUpdated', 'annotationsLoaded']
this.subscribe event, =>
......@@ -79,10 +80,10 @@ class Hypothesis extends Annotator
method: 'getHighlights'
success: ({highlights, offset}) ->
heatmap.updateHeatmap
highlights: highlights.map (hl) ->
thread = (threading.getContainer hl.data)
hl.data = thread.message?.annotation
hl
highlights:
for hl in highlights when hl.data
annotation = bridge.cache[hl.data]
angular.extend hl, data: annotation
offset: offset
_setupXDM: ->
......@@ -96,7 +97,7 @@ class Hypothesis extends Annotator
window: $window.parent
formatter: (annotation) =>
formatted = {}
for k, v of annotation when k in ['id', 'quote', 'ranges']
for k, v of annotation when k in ['quote', 'ranges']
formatted[k] = v
formatted
parser: (annotation) =>
......@@ -256,10 +257,10 @@ class Hypothesis extends Annotator
_setupEditor: -> this
setupAnnotation: (annotation) ->
# Delagate to Annotator implementation after we give it a valid array of
# ranges. This is needed until Annotator stops assuming ranges need to be
# added.
# This is needed until Annotator stops assuming ranges and highlights
# are always added.
unless annotation.ranges?
annotation.highlights = []
annotation.ranges = []
# Assign a temporary id if necessary
......
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