<commit_before>define([ "jquery", "lib/utils/debounce" ], function($, debounce) {

  "use strict";

  var LISTENER = "#js-row--content";

  function ToggleActive(args) {
    var defaults = {
      listener: null,
      context: null,
      selector: ".js-toggle-active"
    };

    this.config = $.extend({}, defaults, args);

    LISTENER = this.config.listener || LISTENER;

    this.$toggles = $(this.config.selector, this.config.context);

    if (this.$toggles.length) {
      this._init();
    }
  }

  ToggleActive.prototype._init = function() {
    var i, len, $toggle, $targets;

    this.$toggles.css("cursor", "pointer");

    if (this.config.context) {
      $(this.config.context).on("click", this.config.selector, $.proxy(this._handleClick, this));
    } else {
      this.$toggles.on("click", $.proxy(this._handleClick, this));
    }

    for (i = 0, len = this.$toggles.length; i < len; i++) {
      $toggle = this.$toggles.eq(i);
      $targets = this._getTargetEls($toggle);

      if ($toggle.data("toggleMe") && !$toggle.hasClass("is-active")) {
        $toggle.addClass("is-not-active");
      }

      $targets.addClass("is-not-active");
    }

    this._listen();
  };

  ToggleActive.prototype._listen = function() {
    var _this = this;

    $(LISTENER).on(":toggleActive/update", function(e, target) {
      _this._updateClasses($(target));
    });
  };

  ToggleActive.prototype._broadcast = function($toggle) {
    var $targets = this._getTargetEls($toggle);

    $toggle.trigger(":toggleActive/click", {
      isActive: $targets.hasClass("is-active"),
      targets: $targets
    });
  };

  ToggleActive.prototype._handleClick = function(e) {
    var $toggle = $(e.currentTarget);

    e.stopPropagation();

    if (e.target.nodeName.toUpperCase() === "A" && !$toggle.data("allowLinks")) {
      e.preventDefault();
    }

    if (!this.debounce) {
      this.debounce = debounce($.proxy(this._toggle, this, $toggle), 100);
    }
<commit_msg>Fixed toggle active behaviour when using context<commit_after>define([ "jquery", "lib/utils/debounce" ], function($, debounce) {

  "use strict";

  var LISTENER = "#js-row--content";

  function ToggleActive(args) {
    var defaults = {
      listener: null,
      context: null,
      selector: ".js-toggle-active"
    };

    this.config = $.extend({}, defaults, args);

    LISTENER = this.config.listener || LISTENER;

    this.$toggles = $(this.config.selector, this.config.context);

    if (this.$toggles.length) {
      this._init();
    }
  }

  ToggleActive.prototype._init = function() {
    var i, len, $toggle, $targets;

    this.$toggles.css("cursor", "pointer");

    if (this.config.context) {
      $(this.config.context).on("click", this.config.selector, $.proxy(this._handleClick, this));
    } else {
      this.$toggles.on("click", $.proxy(this._handleClick, this));
    }

    for (i = 0, len = this.$toggles.length; i < len; i++) {
      $toggle = this.$toggles.eq(i);
      $targets = this._getTargetEls($toggle);

      if ($toggle.data("toggleMe") && !$toggle.hasClass("is-active")) {
        $toggle.addClass("is-not-active");
      }

      $targets.addClass("is-not-active");
    }

    this._listen();
  };

  ToggleActive.prototype._listen = function() {
    var _this = this;

    $(this.config.context || LISTENER).on(":toggleActive/update", function(e, target) {
      _this._updateClasses($(target));
    });
  };

  ToggleActive.prototype._broadcast = function($toggle) {
    var $targets = this._getTargetEls($toggle);

    $toggle.trigger(":toggleActive/click", {
      isActive: $targets.hasClass("is-active"),
      targets: $targets
    });
  };

  ToggleActive.prototype._handleClick = function(e) {
    var $toggle = $(e.currentTarget);

    e.stopPropagation();

    if (e.target.nodeName.toUpperCase() === "A" && !$toggle.data("allowLinks")) {
      e.preventDefault();
    }

    if (!this.debounce) {
      this.debounce = debounce($.proxy(this._toggle, this, $toggle), 100);
    }

{'fraction_non_alphanumeric': 0.1838161838161838, 'fraction_numerical': 0.001998001998001998, 'mean_word_length': 3.017051153460381, 'pattern_counts': {'":': 4, '<': 5, '<?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': '7655700', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1289, 'n_words': 221}