Commit 388f17d0 authored by csillag's avatar csillag

Re-implement focusing annotation cards

... when hovering over the highlights in the document,
or over the annotation cards themselves.
parent e4be6357
...@@ -250,8 +250,13 @@ class Annotator.Guest extends Annotator ...@@ -250,8 +250,13 @@ class Annotator.Guest extends Annotator
method: "showEditor" method: "showEditor"
params: annotation.$$tag params: annotation.$$tag
onAnchorMouseover: -> focusInViewer: (annotations, state) =>
onAnchorMouseout: -> @panel?.notify
method: "setFocusState"
params:
tags: (a.$$tag for a in annotations)
state: state
onAnchorMousedown: -> onAnchorMousedown: ->
checkForStartSelection: (event) => checkForStartSelection: (event) =>
...@@ -294,6 +299,22 @@ class Annotator.Guest extends Annotator ...@@ -294,6 +299,22 @@ class Annotator.Guest extends Annotator
# Tell sidebar to show the viewer for these annotations # Tell sidebar to show the viewer for these annotations
this.showViewer annotations this.showViewer annotations
# When hovering on a highlight in highlighting mode,
# tell the sidebar to hilite the relevant annotations
onAnchorMouseover: (event) ->
if @visibleHighlights or @tool is 'highlight'
event.stopPropagation()
annotations = event.data.getAnnotations(event)
this.focusInViewer annotations, true
# 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
# 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
onAnchorClick: (event) => onAnchorClick: (event) =>
......
...@@ -164,6 +164,12 @@ class Hypothesis extends Annotator ...@@ -164,6 +164,12 @@ class Hypothesis extends Annotator
this.updateViewer this._getLocalAnnotations(tags) this.updateViewer this._getLocalAnnotations(tags)
) )
.bind('setFocusState', (ctx, data) =>
@element.scope().$apply =>
annotations = this._getLocalAnnotations data.tags
this.setViewerFocusState annotations, data.state
)
.bind('toggleViewerSelection', (ctx, tags=[]) => .bind('toggleViewerSelection', (ctx, tags=[]) =>
@element.scope().$apply => @element.scope().$apply =>
this.toggleViewerSelection this._getLocalAnnotations(tags) this.toggleViewerSelection this._getLocalAnnotations(tags)
...@@ -231,6 +237,16 @@ class Hypothesis extends Annotator ...@@ -231,6 +237,16 @@ class Hypothesis extends Annotator
@_setSelectedAnnotations selected @_setSelectedAnnotations selected
this this
setViewerFocusState: (annotations, state) ->
scope = @element.scope()
focused = scope.focusedAnnotations ?= {}
for a in annotations
if state
focused[a.id] = true
else
delete focused[a.id]
this
updateViewer: (annotations=[]) -> updateViewer: (annotations=[]) ->
# TODO: re-implement # TODO: re-implement
this this
......
...@@ -6,9 +6,11 @@ $threadexp-width: .6em; ...@@ -6,9 +6,11 @@ $threadexp-width: .6em;
margin-bottom: .72em; margin-bottom: .72em;
} }
li.thread:hover,
.card-emphasis { .card-emphasis {
box-shadow: 6px 6px 8px -2px $gray-light; box-shadow: 4px 4px 4px -2px $gray-light;
} }
} }
.thread-list { .thread-list {
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
</span> </span>
</li> </li>
<li class="paper thread" <li class="paper thread"
ng-class="{'card-emphasis': focusedAnnotations[child.message.id]}"
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