Commit cb6352cf authored by Randall Leeds's avatar Randall Leeds

first click exiting detail goes to bucket

Fixes #21.
parent 84830284
...@@ -14,6 +14,12 @@ class Hypothesis extends Annotator ...@@ -14,6 +14,12 @@ class Hypothesis extends Annotator
annotationData: document.location.href annotationData: document.location.href
Unsupported: {} Unsupported: {}
# The last bucket of annotations shown
@bucket = null
# Whether the detail view is shown
@detail = false
constructor: (element, options) -> constructor: (element, options) ->
super super
...@@ -44,7 +50,10 @@ class Hypothesis extends Annotator ...@@ -44,7 +50,10 @@ class Hypothesis extends Annotator
_setupWrapper: -> _setupWrapper: ->
super super
@wrapper.on 'click', (event) => @wrapper.on 'click', (event) =>
this.hideSidebar() unless @selectedRanges?.length if @bucket and @detail
this.showViewer(@bucket)
else
this.hideSidebar() unless @selectedRanges?.length
this this
_setupSidebar: -> _setupSidebar: ->
...@@ -167,6 +176,11 @@ class Hypothesis extends Annotator ...@@ -167,6 +176,11 @@ class Hypothesis extends Annotator
.data ( -> if detail then root.children else []), (c) -> c.message.id .data ( -> if detail then root.children else []), (c) -> c.message.id
if not detail if not detail
# Save the state so the bucket view can be restored when exiting
# the detail view.
@bucket = annotations
@detail = false
# Remove the excerpts # Remove the excerpts
excerpts.exit().remove() excerpts.exit().remove()
...@@ -190,6 +204,10 @@ class Hypothesis extends Annotator ...@@ -190,6 +204,10 @@ class Hypothesis extends Annotator
if data?.rows then this.updateViewer(data.rows || []) if data?.rows then this.updateViewer(data.rows || [])
this.showViewer([a], true) this.showViewer([a], true)
else else
# Mark that the detail view is now shown, so that exiting returns to the
# bucket view rather than the document.
@detail = true
excerpts.enter() excerpts.enter()
.insert('li', '.hyp-annotation') .insert('li', '.hyp-annotation')
.classed('hyp-widget', true) .classed('hyp-widget', true)
......
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