<commit_before>class FactlinkJailRoot.ShowButton
  constructor: (highlightElements, factId) ->
    @$el = $('<factlink-show-button></factlink-show-button>')
    FactlinkJailRoot.$factlinkCoreContainer.append(@$el)

    @$highlightElements = $(highlightElements)
    @_factId = factId

    @_robustHover = new FactlinkJailRoot.RobustHover
      $el: @$el
      mouseenter: @_onHover
      mouseleave: @_onUnhover
    @$el.on 'click', @_onClick

    @$el.addClass 'factlink-control-visible'

    @_tether = new Tether
      element: @$el[0]
      target: @_textContainer(@$highlightElements[0])
      attachment: 'top left'
      targetAttachment: 'top right'
      classPrefix: 'factlink-tether'

  destroy: ->
    @_tether.destroy()
    @_robustHover.destroy()
    @$el.remove()

  _onHover: =>
    @$highlightElements.addClass 'fl-active'

  _onUnhover: =>
    @$highlightElements.removeClass 'fl-active'
<commit_msg>Do a hacky offset for annotations inside paragraphs<commit_after>class FactlinkJailRoot.ShowButton
  constructor: (highlightElements, factId) ->
    @$el = $('<factlink-show-button></factlink-show-button>')
    FactlinkJailRoot.$factlinkCoreContainer.append(@$el)

    @$highlightElements = $(highlightElements)
    @_factId = factId

    @_robustHover = new FactlinkJailRoot.RobustHover
      $el: @$el
      mouseenter: @_onHover
      mouseleave: @_onUnhover
    @$el.on 'click', @_onClick

    @$el.addClass 'factlink-control-visible'

    # TODO: really do grouping, so we don't have to do hacks like this!
    textContainer = @_textContainer(@$highlightElements[0])
    verticalOffset = @$highlightElements.offset().top - $(textContainer).offset().top
    verticalOffsetPercentage = verticalOffset*100 / $(textContainer).height()

    @_tether = new Tether
      element: @$el[0]
      target: textContainer
      attachment: 'top left'
      targetAttachment: 'top right'
      classPrefix: 'factlink-tether'
      targetOffset: "#{verticalOffsetPercentage}% 0"

  destroy: ->
    @_tether.destroy()
    @_robustHover.destroy()
    @$el.remove()

  _onHover: =>
    @$highlightElements.addClass 'fl-active'

  _onUnhover: =>
    @$highlightElements.removeClass 'fl-active'

{'fraction_non_alphanumeric': 0.13148316651501366, 'fraction_numerical': 0.003639672429481347, 'mean_word_length': 3.7392241379310347, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4112078', 'n_tokens_mistral': 746, 'n_tokens_neox': 707, 'n_words': 133}