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