<commit_before>class Button
  constructor: (dom_events={}) ->
    @$el = $(@template)
    @$el.appendTo(Factlink.el)
    for event, callback of dom_events
      @$el.bind event, callback

  startLoading: -> @$el.addClass    "fl-loading"
  stopLoading:  -> @$el.removeClass "fl-loading"
  isLoading:    -> @$el.hasClass    "fl-loading"

  setCoordinates: (top, left) =>
    return if @$el.hasClass 'active'
    Factlink.set_position_of_element top, left, window, @$el

  show: (top, left) =>
    @stopLoading() if @isLoading()
    Factlink.el.find('div.fl-button').removeClass('active')
    @$el.addClass 'active'

  hide: -> @$el.removeClass 'active'

  destroy: -> @$el.remove()


class Factlink.ShowButton extends Button
  template: """
    <div class="fl-button fl-show-button">
      <span class="fl-default-message">Show Factlink</span>
      <span class="fl-loading-message">Loading...</span>
    </div>
  """

class Factlink.CreateButton extends Button
  template: """
    <div class="fl-button fl-create-button">
      <span class="fl-default-message">Add Factlink</span>
      <span class="fl-loading-message">Loading...</span>
    </div>
  """<commit_msg>Don't reposition show buttons after they have once been shown<commit_after>class Button
  constructor: (dom_events={}) ->
    @$el = $(@template)
    @$el.appendTo(Factlink.el)
    for event, callback of dom_events
      @$el.bind event, callback

  startLoading: -> @$el.addClass    "fl-loading"
  stopLoading:  -> @$el.removeClass "fl-loading"
  isLoading:    -> @$el.hasClass    "fl-loading"

  setCoordinates: (top, left) =>
    return if @$el.hasClass 'active'
    Factlink.set_position_of_element top, left, window, @$el

  show: (top, left) =>
    @stopLoading() if @isLoading()
    Factlink.el.find('div.fl-button').removeClass('active')
    @$el.addClass 'active'

  hide: -> @$el.removeClass 'active'

  destroy: -> @$el.remove()


class Factlink.ShowButton extends Button
  template: """
    <div class="fl-button fl-show-button">
      <span class="fl-default-message">Show Factlink</span>
      <span class="fl-loading-message">Loading...</span>
    </div>
  """

  setCoordinates: (top, left) =>
    return if @position_already_determined
    @position_already_determined = true
    super

class Factlink.CreateButton extends Button
  template: """
    <div class="fl-button fl-create-button">
      <span class="fl-default-message">Add Factlink</span>
      <span class="fl-loading-message">Loading...</span>
    </div>
  """
{'fraction_non_alphanumeric': 0.1660678642714571, 'fraction_numerical': 0.0, 'mean_word_length': 3.4590747330960854, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 44, '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': '6598274', 'n_tokens_mistral': 843, 'n_tokens_neox': 820, 'n_words': 174}