Commit aadcef8f authored by Randall Leeds's avatar Randall Leeds

re-org hypothesis.coffee

parent 0a7bdf0b
......@@ -38,36 +38,6 @@ class Hypothesis extends Annotator
this
onHeatmapClick: (event) =>
y = event.pageY - @wrapper.offset().top
target = d3.bisect(@heatmap.index, y)-1
annotations = @heatmap.buckets[target]
this.showViewer(annotations)
@heatmap.updateHeatmap()
showViewer: (annotations) ->
@viewer.element.find('.annotator-listing').replaceWith(
Handlebars.templates['summaries']({
annotations: annotations
})
)
@viewer.show()
$(document.documentElement).addClass('hyp-collapse')
@sidebar.removeClass('collapse')
showEditor: (annotation) =>
if @plugins.Permissions?.user
annotation['user'] = @plugins.Permissions.user
@editor.element.find('.annotator-listing').replaceWith(
Handlebars.templates['editor'](annotation)
)
@editor.load(annotation)
$(document.documentElement).addClass('hyp-collapse')
@sidebar.removeClass('collapse')
else
alert("Not logged in!")
# Sets up the selection event listeners to watch mouse actions on the document.
#
# Returns itself for chaining.
......@@ -80,11 +50,6 @@ class Hypothesis extends Annotator
)
this
_setupHeatmap: () ->
# Pull the heatmap into the sidebar
@heatmap = @plugins.Heatmap
this
_setupSidebar: () ->
# Create a sidebar if one does not exist. This is a singleton element --
# even if multiple instances of the app are loaded on a page (some day).
......@@ -100,6 +65,11 @@ class Hypothesis extends Annotator
)
this
_setupHeatmap: () ->
# Pull the heatmap into the sidebar
@heatmap = @plugins.Heatmap
this
# Creates an instance of Annotator.Viewer and assigns it to the @viewer
# property, appends it to the @wrapper and sets up event listeners.
#
......@@ -107,15 +77,15 @@ class Hypothesis extends Annotator
_setupViewer: ->
@viewer = new Annotator.Viewer(readOnly: @options.readOnly)
@viewer.hide()
.on("edit", this.onEditAnnotation)
.on("delete", this.onDeleteAnnotation)
.addField({
load: (field, annotation) =>
if annotation.text
$(field).escape(annotation.text)
else
$(field).html("<i>#{_t 'No Comment'}</i>")
this.publish('annotationViewerTextField', [field, annotation])
.on("edit", this.onEditAnnotation)
.on("delete", this.onDeleteAnnotation)
.addField({
load: (field, annotation) =>
if annotation.text
$(field).escape(annotation.text)
else
$(field).html("<i>#{_t 'No Comment'}</i>")
this.publish('annotationViewerTextField', [field, annotation])
})
this
......@@ -137,4 +107,35 @@ class Hypothesis extends Annotator
submit: (field, annotation) ->
annotation.text = $(field).find('textarea').val()
})
this
\ No newline at end of file
this
onHeatmapClick: (event) =>
y = event.pageY - @wrapper.offset().top
target = d3.bisect(@heatmap.index, y)-1
annotations = @heatmap.buckets[target]
this.showViewer(annotations)
@heatmap.updateHeatmap()
showViewer: (annotations) ->
@viewer.element.find('.annotator-listing').replaceWith(
Handlebars.templates['summaries']({
annotations: annotations
})
)
@viewer.show()
$(document.documentElement).addClass('hyp-collapse')
@sidebar.removeClass('collapse')
showEditor: (annotation) =>
if @plugins.Permissions?.user
annotation['user'] = @plugins.Permissions.user
@editor.element.find('.annotator-listing').replaceWith(
Handlebars.templates['editor'](annotation)
)
@editor.load(annotation)
$(document.documentElement).addClass('hyp-collapse')
@sidebar.removeClass('collapse')
else
alert("Not logged in!")
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