<commit_before>highlight_time_on_load    = 1500
highlight_time_on_in_view = 1500

class Factlink.Fact
  constructor: (id, elems) ->
    @id = id
    @elements = elems

    @highlight highlight_time_on_load

    @balloon = new Factlink.Balloon @id, @

    $(@elements)
      .on('mouseenter', (e)=> @focus(e))
      .on('mouseleave', => @blur())
      .on('click', => @click())
      .on 'inview', (event, isInView, visiblePart) =>
        @highlight(highlight_time_on_in_view) if ( isInView && visiblePart == 'both' )

  highlight: (duration) ->
    clearTimeout @highlight_timeout

    $( @elements ).addClass('fl-active')

    @stopHighlighting(duration) if duration

  stopHighlighting: (delay=0) ->
    clearTimeout(@highlight_timeout)

    deActivateElements = =>
      $(@elements).removeClass('fl-active')

    if delay > 0
      @highlight_timeout = setTimeout deActivateElements, delay
    else
      deActivateElements()

  focus: (e) =>
    clearTimeout(@balloon_timeout)

    @highlight()

    unless @balloon.isVisible() # this enables the balloon to call this without e
      # Need to call a direct .hide() here to make sure not two popups are
      # open at a time
      Factlink.el.find('div.fl-popup').hide()

      @balloon.show($(e.target).offset().top, e.pageX, e.show_fast)

  blur: =>
    clearTimeout(@balloon_timeout)

    unless @balloon.loading()
      @stopHighlighting()

      hideBalloon = =>
        @balloon.hide()

      @balloon_timeout = setTimeout hideBalloon, 300

  click: =>
    @balloon.startLoading()

    Factlink.showInfo @id, =>
      @balloon.stopLoading()

  destroy: ->
    for el in @elements
      $el = $(el)
      unless $el.is('.fl-first')
        $el.before $el.html()

      $el.remove()

    @balloon.destroy()<commit_msg>extracted method with intention revealing name<commit_after>highlight_time_on_load    = 1500
highlight_time_on_in_view = 1500

class Factlink.Fact
  constructor: (id, elems) ->
    @id = id
    @elements = elems

    @highlight highlight_time_on_load

    @balloon = new Factlink.Balloon @id, @

    $(@elements)
      .on('mouseenter', (e)=> @focus(e))
      .on('mouseleave', => @blur())
      .on('click', => @click())
      .on 'inview', (event, isInView, visiblePart) =>
        @highlight(highlight_time_on_in_view) if ( isInView && visiblePart == 'both' )

  highlight: (duration) ->
    clearTimeout @highlight_timeout

    $( @elements ).addClass('fl-active')

    @stopHighlighting(duration) if duration

  stopHighlighting: (delay=0) ->
    clearTimeout(@highlight_timeout)

    deActivateElements = =>
      $(@elements).removeClass('fl-active')

    if delay > 0
      @highlight_timeout = setTimeout deActivateElements, delay
    else
      deActivateElements()

  focus: (e) =>
    clearTimeout(@balloon_timeout)

    @highlight()

    unless @balloon.isVisible() # this enables the balloon to call this without e
      # Need to call a direct .hide() here to make sure not two popups are
      # open at a time
      Factlink.el.find('div.fl-popup').hide()

      @balloon.show($(e.target).offset().top, e.pageX, e.show_fast)

  blur: =>
    clearTimeout(@balloon_timeout)

    unless @balloon.loading()
      @stopHighlighting()

      hideBalloon = =>
        @balloon.hide()

      @balloon_timeout = setTimeout hideBalloon, 300
  click: => @openFactlinkModal()

  openFactlinkModal: =>
    @balloon.startLoading()

    Factlink.showInfo @id, =>
      @balloon.stopLoading()

  destroy: ->
    for el in @elements
      $el = $(el)
      unless $el.is('.fl-first')
        $el.before $el.html()

      $el.remove()

    @balloon.destroy()
{'fraction_non_alphanumeric': 0.13806380638063806, 'fraction_numerical': 0.007150715071507151, 'mean_word_length': 2.966194111232279, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 34, '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': '5378495', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1142, 'n_words': 258}