Commit 14d12283 authored by csillag's avatar csillag

Change annotation card focusing implementation

So that
 - Instead of a map, we now store a list of focused tags
 - The check for being focused has been moved
   into a method in the controller
 - The sidebar now exepts simply a list of tags to
   focus on (no more add/remove tags to existing list)
parent 1cc8e3c9
......@@ -358,6 +358,8 @@ class ViewerController
else
true
$scope.isFocused = (annotation) ->
annotation?.$$tag in ($scope.focusedAnnotations ? [])
angular.module('h')
.controller('AppController', AppController)
......
......@@ -250,12 +250,10 @@ class Annotator.Guest extends Annotator
method: "showEditor"
params: annotation.$$tag
focusInViewer: (annotations, state) =>
focusInViewer: (annotations) =>
@panel?.notify
method: "setFocusState"
params:
tags: (a.$$tag for a in annotations)
state: state
method: "setViewerFocus"
params: (a.$$tag for a in annotations)
onAnchorMousedown: ->
......@@ -305,15 +303,14 @@ class Annotator.Guest extends Annotator
if @visibleHighlights or @tool is 'highlight'
event.stopPropagation()
annotations = event.data.getAnnotations(event)
this.focusInViewer annotations, true
this.focusInViewer annotations
# When leaving a highlight (with the cursor) in highlighting mode,
# tell the sidebar to stop hiliting the relevant annotations
onAnchorMouseout: (event) ->
if @visibleHighlights or @tool is 'highlight'
event.stopPropagation()
annotations = event.data.getAnnotations(event)
this.focusInViewer annotations, false
this.focusInViewer []
# When clicking on a highlight in highlighting mode,
# tell the sidebar to bring up the viewer for the relevant annotations
......
......@@ -164,9 +164,9 @@ class Hypothesis extends Annotator
this.updateViewer this._getLocalAnnotations(tags)
)
.bind('setFocusState', (ctx, data) =>
.bind('setViewerFocus', (ctx, tags=[]) =>
@element.scope().$apply =>
this.setViewerFocusState data.tags, data.state
this.setViewerFocus tags
)
.bind('toggleViewerSelection', (ctx, tags=[]) =>
......@@ -236,15 +236,8 @@ class Hypothesis extends Annotator
@_setSelectedAnnotations selected
this
setViewerFocusState: (tags, state) ->
scope = @element.scope()
focused = scope.focusedAnnotations ?= {}
for tag in tags
if state
focused[tag] = true
else
delete focused[tag]
this
setViewerFocus: (tags) ->
@element.scope().focusedAnnotations = tags
updateViewer: (annotations=[]) ->
# TODO: re-implement
......
......@@ -34,7 +34,7 @@
</span>
</li>
<li class="paper thread"
ng-class="{'card-emphasis': focusedAnnotations[child.message.$$tag]}"
ng-class="{'card-emphasis': isFocused(child.message)}"
deep-count="count"
thread="child" thread-filter
thread-collapsed="!search.query"
......
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