<commit_before>class Backbone.Factlink.PopoverView extends Backbone.Marionette.ItemView
  constructor: (options) ->
    super(options)
    throw "PopoverView needs a popover property"  unless _.isArray(@popover)
    _.each @popover, @bindPopover, this
    @on "render", @realOnRender, this

  bindPopover: (obj, key) ->
    method = _.bind(@popoverToggle, this, obj, key)
    blockMethod = (e) ->
      e.stopPropagation()

    @$el.on "click.popover", obj.selector, method
    @$el.on "click.popover_menu", obj.popoverSelector, blockMethod

  realOnRender: ->
    _.each @popover, @onRenderPopover, this

  onRenderPopover: (obj, key) ->
    @$el.find(obj.selector).hide()  if @$el.find(obj.popoverSelector).children("li").length <= 0

  popoverToggle: (obj, key, e) ->
    $popover = @$el.find(obj.popoverSelector)
    if $popover.is(":hidden")
      @showPopover $popover, obj, key
    else
      @hidePopover $popover, obj, key

  showPopover: ($popover, obj, key) ->
    $popoverButton = @$el.find(obj.selector)
    $popover.show()
    $popoverButton.addClass "active"
    @bindWindowClick $popover, obj, key

  hidePopover: ($popover, obj, key) ->
    $popoverButton = @$el.find(obj.selector)
    $popover.hide()
    $popoverButton.removeClass "active"
    @unbindWindowClick key

  bindWindowClick: ($popover, obj, key) ->
    $(window).on "click.popover." + @cid + "." + key, (e) =>
      @hidePopover $popover, obj, key  if $(e.target).closest(obj.selector)[0] isnt @$el.find(obj.selector)[0]

  unbindWindowClick: (key) ->
    $(window).off "click.popover." + @cid + "." + key

  close: ->
    super()
    @$el.off "click.popover"
<commit_msg>use compact syntax<commit_after>class Backbone.Factlink.PopoverView extends Backbone.Marionette.ItemView
  constructor: (options) ->
    super(options)
    throw "PopoverView needs a popover property"  unless _.isArray(@popover)
    _.each @popover, @bindPopover, this
    @on "render", @realOnRender, this

  bindPopover: (obj, key) ->
    method = _.bind(@popoverToggle, this, obj, key)
    blockMethod = (e) ->
      e.stopPropagation()

    @$el.on "click.popover", obj.selector, method
    @$el.on "click.popover_menu", obj.popoverSelector, blockMethod

  realOnRender: ->
    _.each @popover, @onRenderPopover, this

  onRenderPopover: (obj, key) ->
    @$(obj.selector).hide()  if @$(obj.popoverSelector).children("li").length <= 0

  popoverToggle: (obj, key, e) ->
    $popover = @$(obj.popoverSelector)
    if $popover.is(":hidden")
      @showPopover $popover, obj, key
    else
      @hidePopover $popover, obj, key

  showPopover: ($popover, obj, key) ->
    $popoverButton = @$(obj.selector)
    $popover.show()
    $popoverButton.addClass "active"
    @bindWindowClick $popover, obj, key

  hidePopover: ($popover, obj, key) ->
    $popoverButton = @$(obj.selector)
    $popover.hide()
    $popoverButton.removeClass "active"
    @unbindWindowClick key

  bindWindowClick: ($popover, obj, key) ->
    $(window).on "click.popover." + @cid + "." + key, (e) =>
      @hidePopover $popover, obj, key  if $(e.target).closest(obj.selector)[0] isnt @$(obj.selector)[0]

  unbindWindowClick: (key) ->
    $(window).off "click.popover." + @cid + "." + key

  close: ->
    super()
    @$el.off "click.popover"

{'fraction_non_alphanumeric': 0.16457632303456715, 'fraction_numerical': 0.0018354236769654328, 'mean_word_length': 3.510344827586207, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 27, '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': '3740168', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1144, 'n_words': 246}