<commit_before>Spree.ready(function($) {

  function MobileNavigationManager()  {
    this.mobileNavigation = document.querySelector('.mobile-navigation');

    if (this.mobileNavigation !== null) {
      this.burgerButton = document.querySelector('.navbar-toggler');
      this.closeButton = document.querySelector('#mobile-navigation-close-button');
      this.categoryLinks = document.querySelectorAll('.mobile-navigation-category-link');
      this.backButton = document.querySelector('#mobile-navigation-back-button');
      this.overlay = document.querySelector('#overlay');
      this.navigationOpen = false;
      this.openedCategories = ['main'];

      this.onResize = this.onResize.bind(this);
      this.onCategoryClick = this.onCategoryClick.bind(this);
      this.onBurgerClick = this.onBurgerClick.bind(this);
      this.onCloseClick = this.onCloseClick.bind(this);
      this.onBackClick = this.onBackClick.bind(this);
      this.closeAllCategories = this.closeAllCategories.bind(this);

      window.addEventListener('resize', this.onResize);
      window.addEventListener('turbolinks:request-start', this.onCloseClick);

      this.burgerButton.addEventListener('click', this.onBurgerClick, false);
      this.closeButton.addEventListener('click', this.onCloseClick, false);
      this.backButton.addEventListener('click', this.onBackClick, false);

      this.categoryLinks.forEach(function(link) {
        link.addEventListener('click', this.onCategoryClick)
      }.bind(this))
    }
  }

  MobileNavigationManager.prototype.onResize = function(e) {
    var currentWidth = e.currentTarget.innerWidth;
    if (this.navigationOpen && currentWidth >= 1200) this.close();
  }

  MobileNavigationManager.prototype.onCategoryClick = function(e) {
    var category = e.currentTarget.dataset.category;
    e.preventDefault();
    this.openCategory(category);
  }

  MobileNavigationManager.prototype.onBurgerClick = function() {
    if (this.navigationOpen) {
      this.close();
    } else {
      this.open();
    }
  };

  MobileNavigationManager.prototype.onCloseClick = function() {
    this.close();
    setTimeout(this.closeAllCategories, 500);
  };

  MobileNavigationManager.prototype.onBackClick = function() {
    this.closeCurrentCategory();
  };

  MobileNavigationManager.prototype.open = function() {
    this.navigationOpen = true;
    this.mobileNavigation.classList.add('shown','mobile-navigation-overflow');
    document.body.style.overflow = "hidden";
    this.overlay.classList.add('shown');
  }

  MobileNavigationManager.prototype.close = function() {
    this.navigationOpen = false;
    this.mobileNavigation.classList.remove('shown', 'mobile-navigation-overflow');
    document.body.style.overflow = "";
    this.overlay.classList.remove('shown');
  }

  MobileNavigationManager.prototype.openCategory = function(category) {
    this.openedCategories.push(category);
    var subList = document.querySelector('ul[data-category=' + category + ']');
    if (subList) {
      subList.classList.add('shown');
      this.mobileNavigation.classList.remove('mobile-navigation-overflow');
      this.backButton.classList.add('shown');
    }
    return false;
  }

  MobileNavigationManager.prototype.closeCurrentCategory = function() {
    var category = this.openedCategories.pop();
    var subList = document.querySelector('ul[data-category=' + category + ']');
    if (subList) {
      subList.classList.remove('shown');
      this.mobileNavigation.classList.add('mobile-navigation-overflow');
    }
    if (this.openedCategories[this.openedCategories.length - 1] === 'main') {
      this.backButton.classList.remove('shown');
      this.mobileNavigation.classList.add('mobile-navigation-overflow');
    }
    return false;
  }

  MobileNavigationManager.prototype.closeCategory = function(category) {
    var subList = document.querySelector('ul[data-category=' + category + ']');
    subList.style.transition = 'none';
    subList.classList.remove('shown');
    this.mobileNavigation.classList.add('mobile-navigation-overflow');
    setTimeout(function(){ subList.style.transition = ''; }, 500);
  }

  MobileNavigationManager.prototype.closeAllCategories = function() {
    var openedCategories = this.openedCategories;<commit_msg>Adds small fixes to mobile_navigation.js<commit_after>Spree.ready(function($) {

  function MobileNavigationManager()  {
    this.mobileNavigation = document.querySelector('.mobile-navigation');

    if (this.mobileNavigation !== null) {
      this.burgerButton = document.querySelector('.navbar-toggler');
      this.closeButton = document.querySelector('#mobile-navigation-close-button');
      this.categoryLinks = document.querySelectorAll('.mobile-navigation-category-link');
      this.backButton = document.querySelector('#mobile-navigation-back-button');
      this.overlay = document.querySelector('#overlay');
      this.navigationOpen = false;
      this.openedCategories = ['main'];

      this.onResize = this.onResize.bind(this);
      this.onCategoryClick = this.onCategoryClick.bind(this);
      this.onBurgerClick = this.onBurgerClick.bind(this);
      this.onCloseClick = this.onCloseClick.bind(this);
      this.onBackClick = this.onBackClick.bind(this);
      this.closeAllCategories = this.closeAllCategories.bind(this);

      window.addEventListener('resize', this.onResize);
      window.addEventListener('turbolinks:request-start', this.onCloseClick);

      this.burgerButton.addEventListener('click', this.onBurgerClick, false);
      this.closeButton.addEventListener('click', this.onCloseClick, false);
      this.backButton.addEventListener('click', this.onBackClick, false);

      this.categoryLinks.forEach(function(link) {
        link.addEventListener('click', this.onCategoryClick)
      }.bind(this))
    }
  }

  MobileNavigationManager.prototype.onResize = function(e) {
    var currentWidth = e.currentTarget.innerWidth;
    if (this.navigationOpen && currentWidth >= 1200) this.close();
  }

  MobileNavigationManager.prototype.onCategoryClick = function(e) {
    var category = e.currentTarget.dataset.category;
    e.preventDefault();
    this.openCategory(category);
  }

  MobileNavigationManager.prototype.onBurgerClick = function() {
    if (this.navigationOpen) {
      this.close();
    } else {
      this.open();
    }
  };

  MobileNavigationManager.prototype.onCloseClick = function() {
    this.close();
    setTimeout(this.closeAllCategories, 500);
  };

  MobileNavigationManager.prototype.onBackClick = function() {
    this.closeCurrentCategory();
  };

  MobileNavigationManager.prototype.open = function() {
    this.navigationOpen = true;
    this.mobileNavigation.classList.add('shown', 'mobile-navigation-overflow');
    document.body.style.overflow = "hidden";
    this.overlay.classList.add('shown');
  }

  MobileNavigationManager.prototype.close = function() {
    this.navigationOpen = false;
    this.mobileNavigation.classList.remove('shown', 'mobile-navigation-overflow');
    document.body.style.overflow = "";
    this.overlay.classList.remove('shown');
  }

  MobileNavigationManager.prototype.openCategory = function(category) {
    this.openedCategories.push(category);
    var subList = document.querySelector('ul[data-category=' + category + ']');
    if (subList) {
      subList.classList.add('shown');
      this.backButton.classList.add('shown');
      this.mobileNavigation.classList.remove('mobile-navigation-overflow');
    }
    return false;
  }

  MobileNavigationManager.prototype.closeCurrentCategory = function() {
    var category = this.openedCategories.pop();
    var subList = document.querySelector('ul[data-category=' + category + ']');
    if (subList) {
      subList.classList.remove('shown');
      this.mobileNavigation.classList.add('mobile-navigation-overflow');
    }
    if (this.openedCategories[this.openedCategories.length - 1] === 'main') {
      this.backButton.classList.remove('shown');
      this.mobileNavigation.classList.add('mobile-navigation-overflow');
    }
    return false;
  }

  MobileNavigationManager.prototype.closeCategory = function(category) {
    var subList = document.querySelector('ul[data-category=' + category + ']');
    subList.style.transition = 'none';
    subList.classList.remove('shown');
    this.mobileNavigation.classList.add('mobile-navigation-overflow');
    setTimeout(function(){ subList.style.transition = ''; }, 500);
  }

  MobileNavigationManager.prototype.closeAllCategories = function() {
    var openedCategories = this.openedCategories;
{'fraction_non_alphanumeric': 0.13606633964027096, 'fraction_numerical': 0.002569493109086662, 'mean_word_length': 4.149128081779915, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3144954', 'n_tokens_mistral': 2402, 'n_tokens_neox': 2337, 'n_words': 308}