<commit_before>(function() {
  "use strict";

  window.GOVUK = window.GOVUK || {};

  function CheckboxFilter(options){
    GOVUK.Proxifier.proxifyMethods(this, ['toggleFacet', 'resetCheckboxes', 'updateCheckboxResetter', 'checkSiblings', 'listenForKeys','stopListeningForKeys', 'ensureFacetIsOpen', 'open', 'close', 'setupHeight']);

    this.$facet = options.el;

    this.$checkboxResetter = this.$facet.find('.clear-selected');
    this.$checkboxes = this.$facet.find("input[type='checkbox']");

    this.$facet.find('.head').on('click', this.toggleFacet);
    this.$facet.on('focus', this.listenForKeys);
    this.$facet.on('blur', this.stopListeningForKeys);

    this.$checkboxResetter.on('click', this.resetCheckboxes);

    this.$checkboxes.on('click', $.proxy(this.updateCheckboxes,this));
    this.$checkboxes.on('focus', this.ensureFacetIsOpen);
  }

  CheckboxFilter.prototype.setupHeight = function setupHeight(){
    var checkboxContainer = this.$facet.find('.checkbox-container');
    var checkboxList = checkboxContainer.children('ul');
    var initCheckboxContainerHeight = checkboxContainer.height();
    var height = checkboxList.height();

    if (height < initCheckboxContainerHeight) {
      // Resize if the list is smaller than its container
      checkboxContainer.height(height);

    } else if (checkboxList.height() < initCheckboxContainerHeight + 50) {
      // Resize if the list is only slightly bigger than its container
      checkboxContainer.height(checkboxList.height());
    }
  }

  CheckboxFilter.prototype.open = function open(){
    this.$facet.removeClass('closed');
    this.setupHeight();
  };

  CheckboxFilter.prototype.close = function close(){
    this.$facet.addClass('closed');
  };

  CheckboxFilter.prototype.listenForKeys = function listenForKeys(){
    this.$facet.keypress($.proxy(this.checkForSpecialKeys, this));
  };

  CheckboxFilter.prototype.checkForSpecialKeys = function checkForSpecialKeys(e){
    if(e.keyCode == 13) {
      this.toggleFacet();
    }
  };

  CheckboxFilter.prototype.stopListeningForKeys = function stopListeningForKeys(){
    this.$facet.unbind('keypress');
  };

  CheckboxFilter.prototype.ensureFacetIsOpen = function ensureFacetIsOpen(){
    if (this.$facet.hasClass('closed')) {
      this.open();
    }
  };

  CheckboxFilter.prototype.toggleFacet = function toggleFacet(){
    if (this.$facet.hasClass('closed')) {
      this.open();
    } else {
      this.close();
    }
  };

  CheckboxFilter.prototype.resetCheckboxes = function resetCheckboxes(){
    this.$facet.find("input[type='checkbox']").prop({
      indeterminate: false,
      "checked": false
    });<commit_msg>Add comment as to what keyCode 13 is<commit_after>(function() {
  "use strict";

  window.GOVUK = window.GOVUK || {};

  function CheckboxFilter(options){
    GOVUK.Proxifier.proxifyMethods(this, ['toggleFacet', 'resetCheckboxes', 'updateCheckboxResetter', 'checkSiblings', 'listenForKeys','stopListeningForKeys', 'ensureFacetIsOpen', 'open', 'close', 'setupHeight']);

    this.$facet = options.el;

    this.$checkboxResetter = this.$facet.find('.clear-selected');
    this.$checkboxes = this.$facet.find("input[type='checkbox']");

    this.$facet.find('.head').on('click', this.toggleFacet);
    this.$facet.on('focus', this.listenForKeys);
    this.$facet.on('blur', this.stopListeningForKeys);

    this.$checkboxResetter.on('click', this.resetCheckboxes);

    this.$checkboxes.on('click', $.proxy(this.updateCheckboxes,this));
    this.$checkboxes.on('focus', this.ensureFacetIsOpen);
  }

  CheckboxFilter.prototype.setupHeight = function setupHeight(){
    var checkboxContainer = this.$facet.find('.checkbox-container');
    var checkboxList = checkboxContainer.children('ul');
    var initCheckboxContainerHeight = checkboxContainer.height();
    var height = checkboxList.height();

    if (height < initCheckboxContainerHeight) {
      // Resize if the list is smaller than its container
      checkboxContainer.height(height);

    } else if (checkboxList.height() < initCheckboxContainerHeight + 50) {
      // Resize if the list is only slightly bigger than its container
      checkboxContainer.height(checkboxList.height());
    }
  }

  CheckboxFilter.prototype.open = function open(){
    this.$facet.removeClass('closed');
    this.setupHeight();
  };

  CheckboxFilter.prototype.close = function close(){
    this.$facet.addClass('closed');
  };

  CheckboxFilter.prototype.listenForKeys = function listenForKeys(){
    this.$facet.keypress($.proxy(this.checkForSpecialKeys, this));
  };

  CheckboxFilter.prototype.checkForSpecialKeys = function checkForSpecialKeys(e){
    if(e.keyCode == 13) {

      // keyCode 13 is the return key.
      this.toggleFacet();
    }
  };

  CheckboxFilter.prototype.stopListeningForKeys = function stopListeningForKeys(){
    this.$facet.unbind('keypress');
  };

  CheckboxFilter.prototype.ensureFacetIsOpen = function ensureFacetIsOpen(){
    if (this.$facet.hasClass('closed')) {
      this.open();
    }
  };

  CheckboxFilter.prototype.toggleFacet = function toggleFacet(){
    if (this.$facet.hasClass('closed')) {
      this.open();
    } else {
      this.close();
    }
  };

  CheckboxFilter.prototype.resetCheckboxes = function resetCheckboxes(){
    this.$facet.find("input[type='checkbox']").prop({
      indeterminate: false,
      "checked": false
    });
{'fraction_non_alphanumeric': 0.14884151992585729, 'fraction_numerical': 0.0022242817423540314, 'mean_word_length': 4.183477425552353, 'pattern_counts': {'":': 2, '<': 7, '<?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': '811055', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1579, 'n_words': 265}