Commit 89d66da8 authored by Randall Leeds's avatar Randall Leeds

Merge pull request #1735 from hypothesis/highlight-state-considation

Highlight state considation
parents 81807551 1b497e2b
......@@ -337,7 +337,7 @@ class ViewerController
highlights = []
for p in annotator.providers
p.channel.notify
method: 'setFocusedHighlights'
method: 'focusAnnotations'
params: highlights
$scope.scrollTo = (annotation) ->
......@@ -353,7 +353,7 @@ class ViewerController
else
true
$scope.isFocused = (annotation) ->
$scope.hasFocus = (annotation) ->
annotation?.$$tag in ($scope.focusedAnnotations ? [])
angular.module('h')
......
......@@ -143,14 +143,12 @@ class Annotator.Guest extends Annotator
if value then @plugins.Heatmap._update()
)
.bind('setFocusedHighlights', (ctx, tags=[]) =>
.bind('focusAnnotations', (ctx, tags=[]) =>
for hl in @getHighlights()
if hl.annotation.$$tag in tags
hl.setActive true, true
hl.setFocused true
else
unless hl.isTemporary()
hl.setActive false, true
this.publish "finalizeHighlights"
hl.setFocused false
)
.bind('scrollTo', (ctx, tag) =>
......@@ -250,9 +248,9 @@ class Annotator.Guest extends Annotator
method: "showEditor"
params: annotation.$$tag
focusInViewer: (annotations) =>
focusAnnotations: (annotations) =>
@panel?.notify
method: "setViewerFocus"
method: "focusAnnotations"
params: (a.$$tag for a in annotations)
onAnchorMousedown: ->
......@@ -303,14 +301,14 @@ class Annotator.Guest extends Annotator
if @visibleHighlights or @tool is 'highlight'
event.stopPropagation()
annotations = event.data.getAnnotations(event)
this.focusInViewer annotations
this.focusAnnotations 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()
this.focusInViewer []
this.focusAnnotations []
# When clicking on a highlight in highlighting mode,
# tell the sidebar to bring up the viewer for the relevant annotations
......
......@@ -320,18 +320,14 @@ class Annotator.Plugin.Heatmap extends Annotator.Plugin
bucket = @tabs.index(event.currentTarget)
for hl in @annotator.getHighlights()
if hl.annotation in @buckets[bucket]
hl.setActive true, true
hl.setFocus true
else
unless hl.isTemporary()
hl.setActive false, true
@annotator.publish "finalizeHighlights"
hl.setFocus false
# Gets rid of them after
.on 'mouseout', =>
for hl in @annotator.getHighlights()
unless hl.isTemporary()
hl.setActive false, true
@annotator.publish "finalizeHighlights"
hl.setFocus false
# Does one of a few things when a tab is clicked depending on type
.on 'click', (event) =>
......
......@@ -164,9 +164,9 @@ class Hypothesis extends Annotator
this.updateViewer this._getLocalAnnotations(tags)
)
.bind('setViewerFocus', (ctx, tags=[]) =>
.bind('focusAnnotations', (ctx, tags=[]) =>
@element.scope().$apply =>
this.setViewerFocus tags
this.focusAnnotations tags
)
.bind('toggleViewerSelection', (ctx, tags=[]) =>
......@@ -236,7 +236,7 @@ class Hypothesis extends Annotator
@_setSelectedAnnotations selected
this
setViewerFocus: (tags) ->
focusAnnotations: (tags) ->
@element.scope().focusedAnnotations = tags
updateViewer: (annotations=[]) ->
......
......@@ -55,13 +55,10 @@ $negative: #d11c2b;
$neutral: #0171ba;
//OTHER VARIABLES
$highlight-color: rgba(192, 236, 253, 0.5);
$highlight-color-second: rgba(181, 234, 255, 0.8);
$highlight-color-third: rgba(149, 224, 253, 0.8);
$highlight-mode-color: rgba(255, 255, 60, 0.3);
$highlight-mode-color-second: rgba(206, 206, 60, 0.4);
$highlight-mode-color-third: rgba(192, 192, 49, 0.4);
$highlight-mode-active-color: rgba(255, 255, 60, 0.7);
$highlight-color: rgba(255, 255, 60, 0.3);
$highlight-color-second: rgba(206, 206, 60, 0.4);
$highlight-color-third: rgba(192, 192, 49, 0.4);
$highlight-color-focus: rgba(192, 236, 253, 0.5);
$score-width: 40px;
$score-height: $score-width;
$heatmap-width: 22px;
......
......@@ -99,18 +99,7 @@ $base-font-size: 14px;
}
//HIGHLIGHTS////////////////////////////////
.annotator-highlights-always-on .annotator-hl,
.annotator-hl-active, .annotator-hl-temporary, .annotator-hl-focused {
background: $highlight-color;
.annotator-hl {
background-color: $highlight-color-second;
}
.annotator-hl .annotator-hl {
background-color: $highlight-color-third;
}
.annotator-hl {
&::-moz-selection {
background: $highlight-color;
}
......@@ -123,20 +112,20 @@ $base-font-size: 14px;
}
.annotator-highlights-always-on .annotator-hl {
background: $highlight-mode-color;
background: $highlight-color;
.annotator-hl {
background-color: $highlight-mode-color-second;
background-color: $highlight-color-second;
}
.annotator-hl .annotator-hl {
background-color: $highlight-mode-color-third;
background-color: $highlight-color-third;
}
}
.annotator-highlights-always-on .annotator-hl-active,
.annotator-highlights-always-on .annotator-hl-focused {
background-color: $highlight-mode-active-color;
.annotator-hl-focused,
.annotator-highlights-always-on .annotator-hl.annotator-hl-focused {
background-color: $highlight-color-focus;
}
// Sidebar
......
......@@ -34,7 +34,7 @@
</span>
</li>
<li class="paper thread"
ng-class="{'js-hover': isFocused(child.message)}"
ng-class="{'js-hover': hasFocus(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