<commit_before>;(function ($, window, document, undefined) {
  'use strict';

  Foundation.libs.tooltip = {
    name : 'tooltip',

    version : '5.0.0',
    
    settings : {
      additional_inheritable_classes : [],
      tooltip_class : '.tooltip',
      append_to: 'body',
      touch_close_text: 'Tap To Close',
      disable_for_touch: false,
      tip_template : function (selector, content) {
        return '<span data-selector="' + selector + '" class="' 
          + Foundation.libs.tooltip.settings.tooltip_class.substring(1) 
          + '">' + content + '<span class="nub"></span></span>';
      }
    },

    cache : {},

    init : function (scope, method, options) {
      this.bindings(method, options);
    },

    events : function () {
      var self = this;
      
      $(this.scope)
        .off('.tooltip')
        .on('mouseenter.fndtn.tooltip touchstart.fndtn.tooltip', 
            '[data-tooltip]:not(".open")', function (e) {
          var $this = $(this),
              settings = $.extend({}, self.settings, self.data_options($this)),
              is_touch = /touchstart/i.test(e.type);
            
            if(settings.disable_for_touch && is_touch) {
              return;
            }
            else if(!settings.disable_for_touch && self.is_touch) {
              e.preventDefault();
            }
            
            // Close all tooltips so they don't overlap
            $('.open[data-tooltip]').each(function() {
                self.hide($(this));
            });
            
            if(is_touch) {
              $this.data('tooltip-open-event-type', 'touch');
            } else {
              $this.data('tooltip-open-event-type', 'mouse');
            }

            self.showOrCreateTip($this);
        })
        .on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip', '.open[data-tooltip]', function (e) {
          if($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
            return;
          }
          else if($(this).data('tooltip-open-event-type') == 'mouse' && e.type == 'touchstart') {
            self.convert_to_touch($(this));
          } else {
            self.hide($(this));
          }
        });
    },

    showOrCreateTip : function ($target) {
      var $tip = this.getTip($target);
      
      if ($tip && $tip.length > 0) {
        return this.show($target);
      }

      return this.create($target);
    },

    getTip : function ($target) {
      var selector = this.selector($target),
          tip = null;

      if (selector) {
        var settings = $.extend({}, this.settings, this.data_options($('[data-tooltip="' + selector + '"]'))),
        tip = $('[data-selector="' + selector + '"]' + settings.tooltip_class);
      }

      return (typeof tip === 'object') ? tip : false;
    },

    selector : function ($target) {
      var id = $target.attr('id'),
          dataSelector = $target.attr('data-tooltip') || $target.attr('data-selector');

      if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
        dataSelector = 'tooltip' + Math.random().toString(36).substring(7);
        $target.attr('data-selector', dataSelector);
      }

      return (id && id.length > 0) ? id : dataSelector;
    },

    create : function ($target) {
      var settings = $.extend({}, this.settings, this.data_options($target)),
          tip_template = this.settings.tip_template;
      <commit_msg>A little bit of cleanup.<commit_after>;(function ($, window, document, undefined) {
  'use strict';

  Foundation.libs.tooltip = {
    name : 'tooltip',

    version : '5.0.0',

    settings : {
      additional_inheritable_classes : [],
      tooltip_class : '.tooltip',
      append_to: 'body',
      touch_close_text: 'Tap To Close',
      disable_for_touch: false,
      tip_template : function (selector, content) {
        return '<span data-selector="' + selector + '" class="' 
          + Foundation.libs.tooltip.settings.tooltip_class.substring(1) 
          + '">' + content + '<span class="nub"></span></span>';
      }
    },

    cache : {},

    init : function (scope, method, options) {
      this.bindings(method, options);
    },

    events : function () {
      var self = this;
      
      $(this.scope)
        .off('.tooltip')
        .on('mouseenter.fndtn.tooltip touchstart.fndtn.tooltip', 
            '[data-tooltip]:not(".open")', function (e) {
          var $this = $(this),
              settings = $.extend({}, self.settings, self.data_options($this)),
              is_touch = /touchstart/i.test(e.type);
            
            if(settings.disable_for_touch && is_touch) {
              return;
            }
            else if(!settings.disable_for_touch && self.is_touch) {
              e.preventDefault();
            }
            
            // Close all tooltips so they don't overlap
            $('.open[data-tooltip]').each(function() {
                self.hide($(this));
            });
            
            if(is_touch) {
              $this.data('tooltip-open-event-type', 'touch');
            } else {
              $this.data('tooltip-open-event-type', 'mouse');
            }

            self.showOrCreateTip($this);
        })
        .on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip', '.open[data-tooltip]', function (e) {
          if($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
            return;
          }
          else if($(this).data('tooltip-open-event-type') == 'mouse' && e.type == 'touchstart') {
            self.convert_to_touch($(this));
          } else {
            self.hide($(this));
          }
        });
    },

    showOrCreateTip : function ($target) {
      var $tip = this.getTip($target);
      
      if ($tip && $tip.length > 0) {
        return this.show($target);
      }

      return this.create($target);
    },

    getTip : function ($target) {
      var selector = this.selector($target),
          settings = $.extend({}, this.settings, this.data_options($target)),
          tip = null;

      if (selector) {
        tip = $('[data-selector="' + selector + '"]' + settings.tooltip_class);
      }

      return (typeof tip === 'object') ? tip : false;
    },

    selector : function ($target) {
      var id = $target.attr('id'),
          dataSelector = $target.attr('data-tooltip') || $target.attr('data-selector');

      if ((id && id.length < 1 || !id) && typeof dataSelector != 'string') {
        dataSelector = 'tooltip' + Math.random().toString(36).substring(7);
        $target.attr('data-selector', dataSelector);
      }

      return (id && id.length > 0) ? id : dataSelector;
    },

    create : function ($target) {
      var settings = $.extend({}, this.settings, this.data_options($target)),
          tip_template = this.settings.tip_template;
      
{'fraction_non_alphanumeric': 0.16856060606060605, 'fraction_numerical': 0.002913752913752914, 'mean_word_length': 1.9565030146425495, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '6420381', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1972, 'n_words': 370}