             (if title then title else 'Commentary')
     
     createReplyLink: (anchor) ->
-        $("<a class=\"annotatable-reply\" href=\"##{anchor}\">Reply to this comment</a>")
+        cls = 'annotatable-reply'
+        href = '#' + anchor
+        text = 'Reply to this comment'
+        $("<a class=\"#{cls}\" href=\"#{href}\">#{text}</a>")
 
-    getVisibleTips: () ->
+    openSavedTips: () ->
+        @showTips @savedTips
+
+    closeAndSaveTips: () ->
+        @savedTips = @findVisibleTips()
+        @hideTips @savedTips
+
+    findVisibleTips: () ->
         visible = []
         @$(@spanSelector).each (index, el) ->
             api = $(el).qtip('api')

    @_debug: true

    wrapperSelector: '.annotatable-wrapper'
    toggleSelector: '.annotatable-toggle'
    spanSelector: '.annotatable-span'
    commentSelector: '.annotatable-comment'
    replySelector: '.annotatable-reply'
    helpSelector: '.annotatable-help-icon'
 
    constructor: (el) ->
        console.log 'loaded Annotatable' if @_debug

        event.preventDefault() if @annotationsHidden

    onClickToggleAnnotations: (e) =>
        @annotationsHidden = not @annotationsHidden
        @toggleButtonText @annotationsHidden
        @toggleSpans @annotationsHidden
        @toggleTips @annotationsHidden

    onClickReply: (e) =>
        hash = $(e.currentTarget).attr('href')
        if hash?.charAt(0) == '#'
            name = hash.substr(1)
            anchor = $("a[name='#{name}']").first()
            @scrollTo(anchor)

    toggleTips: (hide) ->
        if hide
            @closeAndSaveTips()
        else
            @openSavedTips()

    toggleButtonText: (hide) ->
        buttonText = (if hide then 'Show' else 'Hide')+' Annotations'
        @$(@toggleSelector).text(buttonText)

    toggleSpans: (hide) ->
        @$(@spanSelector).toggleClass 'hide', hide

    scrollTo: (el) ->
        options =
            duration: 500
            onAfter: @_once -> el.effect 'highlight', {}, 2000
        $('html,body').scrollTo(el, options)

    makeTipContent: (el) ->
        (api) =>
            anchor = $(el).data('discussion-anchor')
            comment = $(@commentSelector, el).first().clone()
            comment.append(@createReplyLink(anchor)) if anchor
            comment.contents()

    makeTipTitle: (el) ->
