<commit_before>/**
This is a collection of javascript functions and whatnot
under the spree namespace that do stuff we find helpful.
Hopefully, this will evolve into a propper class.
**/

/* global AUTH_TOKEN, order_number, Sortable */

jQuery(function ($) {
  // Add some tips
  $('.with-tip').tooltip()

  $('.js-show-index-filters').click(function () {
    $('.filter-well').slideToggle()
    $(this).parents('.filter-wrap').toggleClass('collapsed')
  })

  // Off Canvas Sidebar Functionality
  var sidebarOpen    = $('#sidebar-open')
  var sidebarClose   = $('#sidebar-close')
  var body            = $('body')
  var activeItem     = $('#main-sidebar').find('.selected')
  var modalBackdrop  = $('#multi-backdrop')

  function closeAllMenus() {
    $(body).removeClass()
    body.addClass('admin')
    modalBackdrop.removeClass('show')
  }
  modalBackdrop.click(closeAllMenus)

  activeItem.closest('.nav-sidebar').addClass('active-option')
  activeItem.closest('.nav-pills').addClass('in show')

  function openMenu() {
    closeAllMenus()
    body.addClass('sidebar-open modal-open')
    modalBackdrop.addClass('show')
  }

  function closeMenu() {
    body.removeClass('sidebar-open modal-open')
    modalBackdrop.removeClass('show')
  }

  sidebarOpen.click(openMenu)
  sidebarClose.click(closeMenu)

  // Contextual Sidebar Menu Functionality
  var contextualSidebarMenuToggle    = $('#contextual-menu-toggle')

  function openContextualToggle() {<commit_msg>Tidy up JS and add a fail safe for resizing screens with menus open.<commit_after>/**
This is a collection of javascript functions and whatnot
under the spree namespace that do stuff we find helpful.
Hopefully, this will evolve into a propper class.
**/

/* global AUTH_TOKEN, order_number, Sortable */

jQuery(function ($) {
  // Add some tips
  $('.with-tip').tooltip()

  $('.js-show-index-filters').click(function () {
    $('.filter-well').slideToggle()
    $(this).parents('.filter-wrap').toggleClass('collapsed')
  })

  // Responsive Menus
  var body  = $('body')
  var modalBackdrop  = $('#multi-backdrop')

  // Fail safe on resize
  document.getElementsByTagName("BODY")[0].onresize = function() {closeAllMenus()};

  function closeAllMenus() {
    $(body).removeClass()
    body.addClass('admin')
    modalBackdrop.removeClass('show')
  }
  modalBackdrop.click(closeAllMenus)

  // Main Menu Functionality
  var sidebarOpen    = $('#sidebar-open')
  var sidebarClose   = $('#sidebar-close')
  var activeItem     = $('#main-sidebar').find('.selected')

  activeItem.closest('.nav-sidebar').addClass('active-option')
  activeItem.closest('.nav-pills').addClass('in show')

  function openMenu() {
    closeAllMenus()
    body.addClass('sidebar-open modal-open')
    modalBackdrop.addClass('show')
  }

  function closeMenu() {
    body.removeClass('sidebar-open modal-open')
    modalBackdrop.removeClass('show')
  }

  sidebarOpen.click(openMenu)
  sidebarClose.click(closeMenu)

  // Contextual Sidebar Menu
  var contextualSidebarMenuToggle    = $('#contextual-menu-toggle')

  function openContextualToggle() {
{'fraction_non_alphanumeric': 0.15163271904300032, 'fraction_numerical': 0.00032331070158422246, 'mean_word_length': 4.014586709886548, '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': '8885', 'n_tokens_mistral': 945, 'n_tokens_neox': 913, 'n_words': 200}