<commit_before>/**!
 Plugin toggle trigger
 Triggers hide/show on target elements (or do whatever with classes) from a source element
 */

(function($) {

  $.toggleTrigger = function(el, options) {

    // Default settings values
    var defaults = {
      active:false,
      target:undefined,
      targetInvert:undefined,
      classToggle:'js-hidden',
      classActive:'is-active',
      selectorContainer:undefined, // could be '.js-toggle-container'
      selectorTarget:'.js-toggle-target',
      selectorTargetInvert:undefined,
      selectorToggleInvert:undefined,
      useChecked:false // if true, $element needs to be checked (input radio/checkbox) to activate the target
    };

    var plugin = this;

    plugin.settings = {};

    var $element = $(el),
      element = el;

    // Plugin initialization
    plugin.init = function() {
      plugin.settings = $.extend({}, defaults, options);
      updateSettingsFromHTMLData();
      registerEvents();
      if(plugin.settings.useChecked) plugin.settings.active = $element.is(':checked');
      else plugin.settings.active = $element.hasClass(plugin.settings.classActive);
      if(!plugin.settings.target) {
        if(plugin.settings.selectorContainer) {
          // When using a container
          var $c = $element.closest(plugin.settings.selectorContainer);
          plugin.settings.target = $c.find(plugin.settings.selectorTarget);
          if(plugin.settings.selectorTargetInvert) plugin.settings.targetInvert = $c.find(plugin.settings.selectorTargetInvert);
        } else {
          // Not within a container, search the whole DOM
          plugin.settings.target = $(plugin.settings.selectorTarget);
          if(plugin.settings.selectorTargetInvert) plugin.settings.targetInvert = $(plugin.settings.selectorTargetInvert);
          if(plugin.settings.selectorToggleInvert) plugin.settings.toggleInvert = $(plugin.settings.selectorToggleInvert);
        }
      }
      if(plugin.settings.target && !plugin.settings.active) {
        plugin.settings.target.addClass(plugin.settings.classToggle);
      }
    };

    // Reads plugin settings from HTML data-* attributes (camelCase)
    var updateSettingsFromHTMLData = function() {
      var data = $element.data();
      for (var dat in data) plugin.settings[dat] = data[dat];
    };

    // Set event handlers on HTML elements (private method)
    var registerEvents = function() {
      $element.on('click.toggletrigger', plugin.toggleTarget);
      $element.on('toggle-trigger-off', plugin.toggleOff);
    };

    // Toggle the state on the target element (public method)
    plugin.toggleTarget = function() {
      if(plugin.settings.useChecked) plugin.settings.active = $element.is(':checked');
      else plugin.settings.active = plugin.settings.target.hasClass(plugin.settings.classToggle);
      // Toggle the active class on the element itself
      $element.toggleClass(plugin.settings.classActive,plugin.settings.active);
      // Toggle the defined class on the target
      if(plugin.settings.target) {
        plugin.settings.target.toggleClass(plugin.settings.classToggle,!plugin.settings.active);
      }
      if(plugin.settings.targetInvert) {
        plugin.settings.targetInvert.toggleClass(plugin.settings.classToggle,plugin.settings.active);
      }
      if(plugin.settings.toggleInvert && plugin.settings.active) {
        plugin.settings.toggleInvert.not($element).trigger('toggle-trigger-off');
      }
      // If needed : toggle internal icon state
      // $('.icon-plus, .icon-minus',$element).toggleClass('icon-plus icon-minus');
      var textLabel = $('span.visually-hidden',$element);
      if(plugin.settings.active) textLabel.text(textLabel.data('togglemsg-on'));
      else textLabel.text(textLabel.data('togglemsg-off'));
    };

    // Toggle the state off the inverted target (public method)
    plugin.toggleOff = function() {
      plugin.settings.target.addClass(plugin.settings.classToggle);
    };

    // Initialization
    plugin.init();

  };

  $.fn.toggleTrigger = function(options) {

    return this.each(function() {
      if (undefined === $(this).data('toggleTrigger')) {<commit_msg>Fix élément reste is-active même s'il est off<commit_after>/**!
 Plugin toggle trigger
 Triggers hide/show on target elements (or do whatever with classes) from a source element
 */

(function($) {

  $.toggleTrigger = function(el, options) {

    // Default settings values
    var defaults = {
      active:false,
      target:undefined,
      targetInvert:undefined,
      classToggle:'js-hidden',
      classActive:'is-active',
      selectorContainer:undefined, // could be '.js-toggle-container'
      selectorTarget:'.js-toggle-target',
      selectorTargetInvert:undefined,
      selectorToggleInvert:undefined,
      useChecked:false // if true, $element needs to be checked (input radio/checkbox) to activate the target
    };

    var plugin = this;

    plugin.settings = {};

    var $element = $(el),
      element = el;

    // Plugin initialization
    plugin.init = function() {
      plugin.settings = $.extend({}, defaults, options);
      updateSettingsFromHTMLData();
      registerEvents();
      if(plugin.settings.useChecked) plugin.settings.active = $element.is(':checked');
      else plugin.settings.active = $element.hasClass(plugin.settings.classActive);
      if(!plugin.settings.target) {
        if(plugin.settings.selectorContainer) {
          // When using a container
          var $c = $element.closest(plugin.settings.selectorContainer);
          plugin.settings.target = $c.find(plugin.settings.selectorTarget);
          if(plugin.settings.selectorTargetInvert) plugin.settings.targetInvert = $c.find(plugin.settings.selectorTargetInvert);
        } else {
          // Not within a container, search the whole DOM
          plugin.settings.target = $(plugin.settings.selectorTarget);
          if(plugin.settings.selectorTargetInvert) plugin.settings.targetInvert = $(plugin.settings.selectorTargetInvert);
          if(plugin.settings.selectorToggleInvert) plugin.settings.toggleInvert = $(plugin.settings.selectorToggleInvert);
        }
      }
      if(plugin.settings.target && !plugin.settings.active) {
        plugin.settings.target.addClass(plugin.settings.classToggle);
      }
    };

    // Reads plugin settings from HTML data-* attributes (camelCase)
    var updateSettingsFromHTMLData = function() {
      var data = $element.data();
      for (var dat in data) plugin.settings[dat] = data[dat];
    };

    // Set event handlers on HTML elements (private method)
    var registerEvents = function() {
      $element.on('click.toggletrigger', plugin.toggleTarget);
      $element.on('toggle-trigger-off', plugin.toggleOff);
    };

    // Toggle the state on the target element (public method)
    plugin.toggleTarget = function() {
      if(plugin.settings.useChecked) plugin.settings.active = $element.is(':checked');
      else plugin.settings.active = plugin.settings.target.hasClass(plugin.settings.classToggle);
      // Toggle the active class on the element itself
      $element.toggleClass(plugin.settings.classActive,plugin.settings.active);
      // Toggle the defined class on the target
      if(plugin.settings.target) {
        plugin.settings.target.toggleClass(plugin.settings.classToggle,!plugin.settings.active);
      }
      if(plugin.settings.targetInvert) {
        plugin.settings.targetInvert.toggleClass(plugin.settings.classToggle,plugin.settings.active);
      }
      if(plugin.settings.toggleInvert && plugin.settings.active) {
        plugin.settings.toggleInvert.not($element).trigger('toggle-trigger-off');
      }
      // If needed : toggle internal icon state
      // $('.icon-plus, .icon-minus',$element).toggleClass('icon-plus icon-minus');
      var textLabel = $('span.visually-hidden',$element);
      if(plugin.settings.active) textLabel.text(textLabel.data('togglemsg-on'));
      else textLabel.text(textLabel.data('togglemsg-off'));
    };

    // Toggle the state off the inverted target (public method)
    plugin.toggleOff = function() {
      plugin.settings.target.addClass(plugin.settings.classToggle);
      $element.removeClass(plugin.settings.classActive);
    };

    // Initialization
    plugin.init();

  };

  $.fn.toggleTrigger = function(options) {

    return this.each(function() {
      if (undefined === $(this).data('toggleTrigger')) {
{'fraction_non_alphanumeric': 0.1263195350492231, 'fraction_numerical': 0.0, 'mean_word_length': 3.1929388363998013, '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': '629687', 'n_tokens_mistral': 2283, 'n_tokens_neox': 2250, 'n_words': 458}