 
     highlightStartPosition = null
     highlightStartIndex = -1
+    highlightEndIndex = -1
 
 displayPublication = (publication) ->
   PDFJS.getDocument(publication.url()).then (pdf) ->


  return if start is -1 or end is -1

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

  $textLayer.children().slice(start, end + 1).css
    'background-color': 'rgba(255,0,0,0.3)'


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

    highlightStartPosition = null
    highlightStartIndex = -1
    highlightEndIndex = -1

  $textLayer.mouseleave (e) ->
    return if highlightStartIndex is -1
