 
   stopLoading: ->
     @_loading = false
-    @stopEmphasis()
+    @highlighter.dehighlight()
+    @button.hide()
 
   destroy: ->
     for el in @elements


  highlight_temporary: (duration) ->
    @highlighter.highlight()
    setTimeout (=> @stopEmphasis()), duration

  onBlur: -> @attention_span.neglect()
  onFocus: (e) =>
    if e?
      @show_button.setCoordinates($(e.target).offset().top, e.pageX)
    @attention_span.attend()

  startEmphasis: ->
    @highlighter.highlight()
    @show_button.show()

  stopEmphasis: =>
    return if @shouldHaveEmphasis()

    @highlighter.dehighlight()
    @show_button.hide()

  shouldHaveEmphasis: =>
    @attention_span.has_attention() || @_loading

  openFactlinkModal: =>
    @startLoading()


class Factlink.Fact
  constructor: (@id, @elements) ->
    @button_attention = new Factlink.AttentionSpan
      lost_attention:   => @show_button.hide()
      gained_attention: => @show_button.show()

    @highlight_attention = new Factlink.AttentionSpan
      lost_attention:   => @highlighter.dehighlight()
      gained_attention: => @highlighter.highlight()

    @highlighter = new Highlighter $(@elements)

