<commit_before>/*
 * DropKick
 *
 * Highly customizable <select> lists
 * https://github.com/robdel12/DropKick
 *
*/

(function( window, document, undefined ) {


var

  // Browser testing stuff
  isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ),
  isIframe = (window.parent !== window.self && location.host === parent.location.host),
  isIE = navigator.appVersion.indexOf("MSIE")!==-1,

  /**
  * # Getting started
  * After you've cloned the repo you will need to add the library to your page. In the `build/js` folder use
  * one of the two DropKick files given. One has a version number in the file name and the other is a version
  * number-less version. You will also need to grab the css from `build/css` and load it on the page.
  *
  * Once those files are imported into the page you can call DropKick on any HTMLSelectElement:
  * `new Dropkick( HTMLSelectElement, Options );` or `new Dropkick( "ID", Options );`. This returns the dropkick
  * object to you. It may be useful for you to store this in a var to reference later.
  *
  * If you're using jQuery you can do this instead:
  * `$('#select').dropkick( Options );`
  *
  *
  * @class Dropkick
  * @return { object } DropKick Object for that select. You can call your methods on this if stored in a var
  * @param {elem} sel HTMLSelect Element being passed.
  * @param {opts} options See list of [properties you can pass in here](#list_of_properties)
  * @constructor
  * @example
  *  ```js
  *    // Pure JS
  *    var select = new Dropkick("#select");
  *  ```
  * @example
  *  ```js
  *    // jQuery
  *    $("#select").dropkick();
  *  ```
  */
  Dropkick = function( sel, opts ) {
    var i, dk;

    // Safety if `Dropkick` is called without `new`
    if ( this === window ) {
      return new Dropkick( sel, opts );
    }

    if ( typeof sel === "string" && sel[0] === "#" ) {
      sel = document.getElementById( sel.substr( 1 ) );
    }

    // Check if select has already been DK'd and return the DK Object
    for ( i = 0; i < Dropkick.uid; i++) {
      dk = Dropkick.cache[ i ];

      if ( dk instanceof Dropkick && dk.data.select === sel ) {
        _.extend( dk.data.settings, opts );
        return dk;
      }
    }

    if ( !sel ) {
      console.error("You must pass a select to DropKick");
      return false;
    }

    if ( sel.nodeName === "SELECT" ) {
      return this.init( sel, opts );
    }
  },

  noop = function() {},
  _docListener,

  // DK default options
  defaults = {

    /**
     * Called once after the DK element is inserted into the DOM.
     * The value of `this` is the Dropkick object itself.
     *
     * @config initialize
     * @type Function
     *
     */
    initialize: noop,

    /**
     * Called whenever the value of the Dropkick select changes (by user action or through the API).
     * The value of `this` is the Dropkick object itself.
     *
     * @config change
     * @type Function
     *
     */
    change: noop,

    /**
     * Called whenever the Dropkick select is opened. The value of `this` is the Dropkick object itself.
     *
     * @config open
     * @type Function
     *
     */
    open: noop,

    /**
     * Called whenever the Dropkick select is closed. The value of `this` is the Dropkick object itself.
     *
     * @config close
     * @type Function
     *
     */
    close: noop,

    // Search method; "strict", "partial", or "fuzzy"
    /**
     * `"strict"` - The search string matches exactly from the beginning of the option's text value (case insensitive).
     *
     * `"partial"` - The search string matches part of the option's text value (case insensitive).
     *
     * `"fuzzy"` - The search string matches the characters in the given order (not exclusively).
     * The strongest match is selected first. (case insensitive).
     *
     * @default "strict"
     * @config search
     * @type string
     *
     */
    search: "strict"
  },

  // Common Utilities
  _ = {

    hasClass: function( elem, classname ) {
      var reg = new RegExp( "(^|\\s+)" + classname + "(\\s+|$)" );
      return elem && reg.test( elem.className );
    },

    addClass: function( elem, classname ) {
      if( elem && !_.hasClass( elem, classname ) ) {
        elem.className += " " + classname;
      }
    },

    removeClass: function( elem, classname ) {
      var reg = new RegExp( "(^|\\s+)" + classname + "(\\s+|$)" );
      elem && ( elem.className = elem.className.replace( reg, " " ) );
    },

    toggleClass: function( elem, classname ) {
      var fn = _.hasClass( elem, classname ) ? "remove" : "add";
      _[ fn + "Class" ]( elem, classname );
    },

    // Shallow object extend
    extend: function( obj ) {
      Array.prototype.slice.call( arguments, 1 ).forEach( function( source ) {
        if ( source ) { for ( var prop in source ) obj[ prop ] = source[ prop ]; }
      });

      return obj;
    },

    // Returns the top and left offset of an element
    offset: function( elem ) {
      var box = elem.getBoundingClientRect() || { top: 0, left: 0 },
        docElem = document.documentElement,
        offsetTop = isIE ? docElem.scrollTop : window.pageYOffset,
        offsetLeft = isIE ? docElem.scrollLeft : window.pageXOffset;

        return {
          top: box.top + offsetTop - docElem.clientTop,
          left: box.left + offsetLeft - docElem.clientLeft
        };
    },

    // Returns the top and left position of an element relative to an ancestor
    position: function( elem, relative ) {
      var pos = { top: 0, left: 0 };

      while ( elem !== relative ) {
        pos.top += elem.offsetTop;
        pos.left += elem.offsetLeft;
        elem = elem.parentNode;
      }

      return pos;
    },

    // Returns the closest ancestor element of the child or false if not found
    closest: function( child, ancestor ) {
      while ( child ) {
        if ( child === ancestor ) { return child; }
        child = child.parentNode;
      }
      return false;
    },

    // Creates a DOM node with the specified attributes
    create: function( name, attrs ) {
      var a, node = document.createElement( name );

      if ( !attrs ) { attrs = {}; }

      for ( a in attrs ) {
        if ( attrs.hasOwnProperty( a ) ) {
          if ( a === "innerHTML" ) {
            node.innerHTML = attrs[ a ];<commit_msg>Fixes #289<commit_after>/*
 * DropKick
 *
 * Highly customizable <select> lists
 * https://github.com/robdel12/DropKick
 *
*/

(function( window, document, undefined ) {


var

  // Browser testing stuff
  isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( navigator.userAgent ),
  isIframe = (window.parent !== window.self && location.host === parent.location.host),
  isIE = navigator.appVersion.indexOf("MSIE")!==-1,

  /**
  * # Getting started
  * After you've cloned the repo you will need to add the library to your page. In the `build/js` folder use
  * one of the two DropKick files given. One has a version number in the file name and the other is a version
  * number-less version. You will also need to grab the css from `build/css` and load it on the page.
  *
  * Once those files are imported into the page you can call DropKick on any HTMLSelectElement:
  * `new Dropkick( HTMLSelectElement, Options );` or `new Dropkick( "ID", Options );`. This returns the dropkick
  * object to you. It may be useful for you to store this in a var to reference later.
  *
  * If you're using jQuery you can do this instead:
  * `$('#select').dropkick( Options );`
  *
  *
  * @class Dropkick
  * @return { object } DropKick Object for that select. You can call your methods on this if stored in a var
  * @param {elem} sel HTMLSelect Element being passed.
  * @param {opts} options See list of [properties you can pass in here](#list_of_properties)
  * @constructor
  * @example
  *  ```js
  *    // Pure JS
  *    var select = new Dropkick("#select");
  *  ```
  * @example
  *  ```js
  *    // jQuery
  *    $("#select").dropkick();
  *  ```
  */
  Dropkick = function( sel, opts ) {
    var i, dk;

    // Safety if `Dropkick` is called without `new`
    if ( this === window ) {
      return new Dropkick( sel, opts );
    }

    if ( typeof sel === "string" && sel[0] === "#" ) {
      sel = document.getElementById( sel.substr( 1 ) );
    }

    // Check if select has already been DK'd and return the DK Object
    for ( i = 0; i < Dropkick.uid; i++) {
      dk = Dropkick.cache[ i ];

      if ( dk instanceof Dropkick && dk.data.select === sel ) {
        _.extend( dk.data.settings, opts );
        return dk;
      }
    }

    if ( !sel ) {
      console.error("You must pass a select to DropKick");
      return false;
    }

    if ( sel.nodeName === "SELECT" ) {
      return this.init( sel, opts );
    }
  },

  noop = function() {},
  _docListener,

  // DK default options
  defaults = {

    /**
     * Called once after the DK element is inserted into the DOM.
     * The value of `this` is the Dropkick object itself.
     *
     * @config initialize
     * @type Function
     *
     */
    initialize: noop,

    /**
     * Called whenever the value of the Dropkick select changes (by user action or through the API).
     * The value of `this` is the Dropkick object itself.
     *
     * @config change
     * @type Function
     *
     */
    change: noop,

    /**
     * Called whenever the Dropkick select is opened. The value of `this` is the Dropkick object itself.
     *
     * @config open
     * @type Function
     *
     */
    open: noop,

    /**
     * Called whenever the Dropkick select is closed. The value of `this` is the Dropkick object itself.
     *
     * @config close
     * @type Function
     *
     */
    close: noop,

    // Search method; "strict", "partial", or "fuzzy"
    /**
     * `"strict"` - The search string matches exactly from the beginning of the option's text value (case insensitive).
     *
     * `"partial"` - The search string matches part of the option's text value (case insensitive).
     *
     * `"fuzzy"` - The search string matches the characters in the given order (not exclusively).
     * The strongest match is selected first. (case insensitive).
     *
     * @default "strict"
     * @config search
     * @type string
     *
     */
    search: "strict"
  },

  // Common Utilities
  _ = {

    hasClass: function( elem, classname ) {
      var reg = new RegExp( "(^|\\s+)" + classname + "(\\s+|$)" );
      return elem && reg.test( elem.className );
    },

    addClass: function( elem, classname ) {
      if( elem && !_.hasClass( elem, classname ) ) {
        elem.className += " " + classname;
      }
    },

    removeClass: function( elem, classname ) {
      var reg = new RegExp( "(^|\\s+)" + classname + "(\\s+|$)" );
      elem && ( elem.className = elem.className.replace( reg, " " ) );
    },

    toggleClass: function( elem, classname ) {
      var fn = _.hasClass( elem, classname ) ? "remove" : "add";
      _[ fn + "Class" ]( elem, classname );
    },

    // Shallow object extend
    extend: function( obj ) {
      Array.prototype.slice.call( arguments, 1 ).forEach( function( source ) {
        if ( source ) { for ( var prop in source ) obj[ prop ] = source[ prop ]; }
      });

      return obj;
    },

    // Returns the top and left offset of an element
    offset: function( elem ) {
      var box = elem.getBoundingClientRect() || { top: 0, left: 0 },
        docElem = document.documentElement,
        offsetTop = isIE ? docElem.scrollTop : window.pageYOffset,
        offsetLeft = isIE ? docElem.scrollLeft : window.pageXOffset;

        return {
          top: box.top + offsetTop - docElem.clientTop,
          left: box.left + offsetLeft - docElem.clientLeft
        };
    },

    // Returns the top and left position of an element relative to an ancestor
    position: function( elem, relative ) {
      var pos = { top: 0, left: 0 };

      while ( elem && elem !== relative ) {
        pos.top += elem.offsetTop;
        pos.left += elem.offsetLeft;
        elem = elem.parentNode;
      }

      return pos;
    },

    // Returns the closest ancestor element of the child or false if not found
    closest: function( child, ancestor ) {
      while ( child ) {
        if ( child === ancestor ) { return child; }
        child = child.parentNode;
      }
      return false;
    },

    // Creates a DOM node with the specified attributes
    create: function( name, attrs ) {
      var a, node = document.createElement( name );

      if ( !attrs ) { attrs = {}; }

      for ( a in attrs ) {
        if ( attrs.hasOwnProperty( a ) ) {
          if ( a === "innerHTML" ) {
            node.innerHTML = attrs[ a ];
{'fraction_non_alphanumeric': 0.12646021168169344, 'fraction_numerical': 0.001960015680125441, 'mean_word_length': 2.2507645259938838, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '7080949', 'n_tokens_mistral': 3944, 'n_tokens_neox': 3781, 'n_words': 1336}