<commit_before>/*jslint unparam: true, browser: true, indent: 2 */

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

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

    version : '4.0.0.alpha',

    settings : {
      dropdownAsToggle: true,
      activeClass: 'active'
    },

    init : function (scope, method, options) {
      this.scope = scope || this.scope;
      Foundation.inherit(this, 'throttle');

      if (typeof method === 'object') {
        $.extend(true, this.settings, method);
      }

      if (typeof method != 'string') {
  
        if (!this.settings.init) {
          this.events();
        }

        return this.settings.init;
      } else {
        // fire method
        return this[method].call(this, options);
      }
    },

    events : function () {
      var self = this;

      $(this.scope)
        .on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
          e.preventDefault();
          e.stopPropagation();
          self.toggle($(this));
        });

      $('body').on('click.fndtn.dropdown', function (e) {
        $('[data-dropdown-content]:visible').hide();
      });

      $('[data-dropdown-content]').on('click.fndtn.dropdown', function (e) {
        e.stopPropagation();
      });

      $(window).on('resize.fndtn.dropdown', self.throttle(function () {
        self.resize.call(self);
      }, 75));

      this.settings.init = true;
    },

    toggle : function (target, resize) {
      var dropdown = $('#' + target.data('dropdown')),
          offset = this.offset(dropdown, target);

      $('[data-dropdown-content]').not(dropdown).hide();

      if (dropdown.hasClass('open')) {
        dropdown
          .hide()
          .removeClass('open');
      } else {
        this.css(dropdown.show().addClass('open'), target);
      }
    },

    resize : function () {
      var dropdown = $('[data-dropdown-content].open'),
          target = $("[data-dropdown='" + dropdown.attr('id') + "']");

      if (dropdown.length && target.length) {
        this.css(dropdown, target);
      }
    },

    css : function (dropdown, target) {
      var offset = this.offset(dropdown, target);

      return dropdown.css({
        position : 'absolute',
        width: target.width(),
        top: offset.top + target.height(),
        left: offset.left
      });
    },

    offset : function (dropdown, target) {
      if (/body/i.test(dropdown.parent().selector)) {
        return target.offset();
      }

      return target.position();
    },

    off: function () {
      $(this.scope).off('.fndtn.dropdown');
    }
  };
}(Foundation.zj, this, this.document));<commit_msg>Unbind events for dropdown.<commit_after>/*jslint unparam: true, browser: true, indent: 2 */

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

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

    version : '4.0.0.alpha',

    settings : {
      activeClass: 'open'
    },

    init : function (scope, method, options) {
      this.scope = scope || this.scope;
      Foundation.inherit(this, 'throttle');

      if (typeof method === 'object') {
        $.extend(true, this.settings, method);
      }

      if (typeof method != 'string') {
  
        if (!this.settings.init) {
          this.events();
        }

        return this.settings.init;
      } else {
        // fire method
        return this[method].call(this, options);
      }
    },

    events : function () {
      var self = this;

      $(this.scope)
        .on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
          e.preventDefault();
          e.stopPropagation();
          self.toggle($(this));
        });

      $('body').on('click.fndtn.dropdown', function (e) {
        if (!$(e.target).data('dropdown')) {
          $('[data-dropdown-content]').hide().removeClass(self.settings.activeClass);
        }
      });

      $('[data-dropdown-content]').on('click.fndtn.dropdown', function (e) {
        e.stopPropagation();
      });

      $(window).on('resize.fndtn.dropdown', self.throttle(function () {
        self.resize.call(self);
      }, 75));

      this.settings.init = true;
    },

    toggle : function (target, resize) {
      var dropdown = $('#' + target.data('dropdown')),
          offset = this.offset(dropdown, target);

      $('[data-dropdown-content]').not(dropdown).hide();

      if (dropdown.hasClass(self.settings.activeClass)) {
        dropdown
          .hide()
          .removeClass(self.settings.activeClass);
      } else {
        this
          .css(dropdown.show()
          .addClass(self.settings.activeClass), target);
      }
    },

    resize : function () {
      var dropdown = $('[data-dropdown-content].open'),
          target = $("[data-dropdown='" + dropdown.attr('id') + "']");

      if (dropdown.length && target.length) {
        this.css(dropdown, target);
      }
    },

    css : function (dropdown, target) {
      var offset = this.offset(dropdown, target);

      return dropdown.css({
        position : 'absolute',
        width: target.width(),
        top: offset.top + target.height(),
        left: offset.left
      });
    },

    offset : function (dropdown, target) {
      if (/body/i.test(dropdown.parent().selector)) {
        return target.offset();
      }

      return target.position();
    },

    off: function () {
      $(this.scope).off('.fndtn.dropdown');
      $('body').off('.fndtn.dropdown');
      $(window).off('.fndtn.dropdown');
      $('[data-dropdown-content]').off('.fndtn.dropdown');
    }
  };
}(Foundation.zj, this, this.document));
{'fraction_non_alphanumeric': 0.17970703822793854, 'fraction_numerical': 0.0021436227224008574, 'mean_word_length': 2.138452914798206, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3306089', 'n_tokens_mistral': 1717, 'n_tokens_neox': 1653, 'n_words': 305}