<commit_before>define (require) ->
  $ = require('jquery')
  BaseView = require('cs!helpers/backbone/views/base')
  template = require('hbs!helpers/backbone/views/attached/tooltip/tooltip-template')
  require('less!helpers/backbone/views/attached/tooltip/tooltip')

  # Close tooltips and popovers when clicking outside of them
  $(document).on 'click', (e) ->
    $('.popover, .tooltip').hide().removeClass('in')

  return class Tooltip extends BaseView
    containerTemplate: template

    type: 'tooltip'
    trigger: 'hover'
    placement: 'top'

    renderDom: (data) ->
      @$el?.html @containerTemplate
        title: @title
        placement: @placement
        content: @getTemplate()

    initialize: (options = {}) ->
      super()
      @$owner = $(options.owner)

    onShow: () ->
      @onBeforeClose() # Remove event handlers in case they were previously added

      # Don't close due to clicks on this element
      @$el.on "click.#{@type}.#{@cid}", (e) -> e.stopPropagation(e)

      switch @trigger
        when 'click'
          @$owner.on "click.#{@type}.#{@cid}", (e) => @toggle(e)
        when 'hover'
          @$owner.on "mouseenter.#{@type}.#{@cid}", (e) => @show(e)
          @$owner.on "mouseleave.#{@type}.#{@cid}", (e) => @hide(e)

    show: (e) ->
      e.stopPropagation(e)
      @reposition()
      @$el.children(".#{@type}").show().addClass('in')

    hide: (e) ->
      e.stopPropagation(e)
      @$el.children(".#{@type}").hide().removeClass('in')
<commit_msg>Fix typo<commit_after>define (require) ->
  $ = require('jquery')
  BaseView = require('cs!helpers/backbone/views/base')
  template = require('hbs!helpers/backbone/views/attached/tooltip/tooltip-template')
  require('less!helpers/backbone/views/attached/tooltip/tooltip')

  # Close tooltips and popovers when clicking outside of them
  $(document).on 'click', (e) ->
    $('.popover, .tooltip').hide().removeClass('in')

  return class Tooltip extends BaseView
    containerTemplate: template

    type: 'tooltip'
    trigger: 'hover'
    placement: 'top'

    renderDom: (data) ->
      @$el?.html @containerTemplate
        title: @title
        placement: @placement
        content: @getTemplate()

    initialize: (options = {}) ->
      super()
      @$owner = $(options.owner)

    onShow: () ->
      @onBeforeClose() # Remove event handlers in case they were previously added

      # Don't close due to clicks on this element
      @$el.on "click.#{@type}.#{@cid}", (e) -> e.stopPropagation()

      switch @trigger
        when 'click'
          @$owner.on "click.#{@type}.#{@cid}", (e) => @toggle(e)
        when 'hover'
          @$owner.on "mouseenter.#{@type}.#{@cid}", (e) => @show(e)
          @$owner.on "mouseleave.#{@type}.#{@cid}", (e) => @hide(e)

    show: (e) ->
      e.stopPropagation(e)
      @reposition()
      @$el.children(".#{@type}").show().addClass('in')

    hide: (e) ->
      e.stopPropagation(e)
      @$el.children(".#{@type}").hide().removeClass('in')

{'fraction_non_alphanumeric': 0.18983957219251338, 'fraction_numerical': 0.0, 'mean_word_length': 2.9278215223097113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '678847', 'n_tokens_mistral': 977, 'n_tokens_neox': 994, 'n_words': 201}