<commit_before>$("#nav-switch").on("click", (event) => {
  const NAV_CLASS_NAME = 'show-navigation';

  event.preventDefault();
  event.stopPropagation();

  $('body').toggleClass(NAV_CLASS_NAME);

  // Close navigation slider when the user clicks ouside of the navigation:
  $(document).one("click", () => {
    $('body').removeClass(NAV_CLASS_NAME);
  });

  // Prevent closing of navigation slider when a normal nav-item is clicked:
  $("#navigation").one("click", (event) => {
    event.stopPropagation();
  });

  // Still close the navigation slider when a nav item from the user menu is clicked:
  // (the items from the entries trigger actions in the SPA, not actual navigation)
  $("#navigation").one("click", "#entries-nav, #signin", () => {
    $('body').removeClass(NAV_CLASS_NAME);
  });
});
<commit_msg>Navigation toggle: Remove jQuery dependency.<commit_after>/* eslint no-use-before-define: ["error", { "functions": false }] */

const openClassName = 'show-navigation';
const body = document.body
const navSwitch = document.getElementById('nav-switch')

function hideNav(event) {
  event.preventDefault()
  navSwitch.removeEventListener('click', hideNav)
  navSwitch.addEventListener('click', showNav)
  body.removeEventListener('click', hideNav)
  body.classList.remove(openClassName)
}

function showNav(event) {
  event.preventDefault()
  event.stopPropagation()
  navSwitch.addEventListener('click', hideNav)
  body.addEventListener('click', hideNav)
  body.classList.add(openClassName)
}

if (navSwitch) navSwitch.addEventListener('click', showNav)

{'fraction_non_alphanumeric': 0.15477707006369426, 'fraction_numerical': 0.0, 'mean_word_length': 5.209486166007905, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 7, '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': '3000957', 'n_tokens_mistral': 456, 'n_tokens_neox': 456, 'n_words': 109}