<commit_before>Backbone.Factlink ||= {}

class TooltipCreator
  constructor: (@$offsetParent, @positioning, @tooltipViewFactory)->
    region_options = _.defaults fadeTime: 100, positioning
    @positionedRegion = new Backbone.Factlink.PositionedRegion region_options

  createTooltip: ($target) ->
    popoverOptions = _.defaults
      contentView: @tooltipViewFactory(),
      @positioning

    @positionedRegion.bindToElement $target, @$offsetParent
    @positionedRegion.show new PopoverView popoverOptions
    @positionedRegion.updatePosition()

    @positionedRegion.$el

  removeTooltip: ->
    @positionedRegion.resetFade()


Backbone.Factlink.makeTooltipForView = (parentView, options) ->
  _.defaults options, $offsetParent: parentView.$el

  tooltipCreator = new TooltipCreator options.$offsetParent,
    options.positioning, options.tooltipViewFactory

  tooltipOpener = new Backbone.Factlink.TooltipOpener
    $container: parentView.$el
    selector: options.selector
    tooltipCreator: tooltipCreator

  tooltipOpener.render()

  parentView.on 'close', => tooltipOpener.close()
<commit_msg>made properties private<commit_after>Backbone.Factlink ||= {}

class TooltipCreator
  constructor: (@_$offsetParent, @positioning, @_tooltipViewFactory)->
    region_options = _.defaults fadeTime: 100, positioning
    @positionedRegion = new Backbone.Factlink.PositionedRegion region_options

  createTooltip: ($target) ->
    popoverOptions = _.defaults
      contentView: @_tooltipViewFactory(),
      @positioning

    @positionedRegion.bindToElement $target, @_$offsetParent
    @positionedRegion.show new PopoverView popoverOptions
    @positionedRegion.updatePosition()

    @positionedRegion.$el

  removeTooltip: ->
    @positionedRegion.resetFade()


Backbone.Factlink.makeTooltipForView = (parentView, options) ->
  _.defaults options, $offsetParent: parentView.$el

  tooltipCreator = new TooltipCreator options.$offsetParent,
    options.positioning, options.tooltipViewFactory

  tooltipOpener = new Backbone.Factlink.TooltipOpener
    $container: parentView.$el
    selector: options.selector
    tooltipCreator: tooltipCreator

  tooltipOpener.render()

  parentView.on 'close', => tooltipOpener.close()

{'fraction_non_alphanumeric': 0.09622302158273381, 'fraction_numerical': 0.002697841726618705, 'mean_word_length': 4.901856763925729, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3830419', 'n_tokens_mistral': 649, 'n_tokens_neox': 622, 'n_words': 122}