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