     Annotations.update @_id, $set: body: $(template.find '.text').text()
 
   'mouseenter .annotation': (e, template) ->
+    currentHighlight = true
     unless _.isEqual Session.get('currentHighlight'), @location
       Session.set 'currentHighlight', null
-
-    showHighlight $('#viewer .display .display-text').eq(@location.page - 1), @location.start, @location.end
+      currentHighlight = false
+
+    showHighlight $('#viewer .display .display-text').eq(@location.page - 1), @location.start, @location.end, currentHighlight
 
   'mouseleave .annotation': (e, template) ->
     unless _.isEqual Session.get('currentHighlight'), @location
       hideHiglight $('#viewer .display .display-text')
 
   'click .annotation': (e, template) ->
-    Session.set 'currentHighlight', @location
-    showHighlight $('#viewer .display .display-text').eq(@location.page - 1), @location.start, @location.end
+    currentHighlight = true
+    unless _.isEqual Session.get('currentHighlight'), @location
+      Session.set 'currentHighlight', @location
+      currentHighlight = false
+
+    showHighlight $('#viewer .display .display-text').eq(@location.page - 1), @location.start, @location.end, currentHighlight
 
 Template.publicationAnnotationsItem.highlighted = ->
   currentHighlight = Session.get 'currentHighlight'
 
   currentHighlight?.page is @location.page and currentHighlight?.start is @location.start and currentHighlight?.end is @location.end
+
+Template.publicationAnnotationsItem.rendered = ->
+  $(@firstNode).data
+    annotation: @data
 
 Template.publicationEntry.displayDay = (time) ->
   moment(time).format 'MMMM Do YYYY'

normalizeStartEnd = (start, end) ->
  [Math.min(start, end), Math.max(start, end)]

hideHiglight = ($textLayer) ->
  $textLayer.children().removeClass 'highlighted'

showHighlight = ($textLayer, start, end) ->
  hideHiglight $textLayer

  return if start is -1 or end is -1



    offset = $textLayer.offset()
    if highlightStartPosition.left is e.pageX - offset.left and highlightStartPosition.top is e.pageY - offset.top
      closeHighlight publication, page, $textLayer
    else
      openHihglight publication, page, $textLayer, highlightStartIndex, highlightEndIndex

