Sha256: 5cb1c79c32e4282c45bad46d3ba4d47acc5377e6cc57294a5b3c33acb191cc4b

Contents?: true

Size: 1.68 KB

Versions: 16

Compression:

Stored size: 1.68 KB

Contents

document.addEventListener("spree:load", function() {
  var body = $('body')
  var modalBackdrop = $('#multi-backdrop')

  // Fail safe on screen resize
  var resizeTimer;
  window.addEventListener('resize', function() {
    document.body.classList.remove('modal-open', 'sidebar-open', 'contextualSideMenu-open');
    document.body.classList.add('resize-animation-stopper');
    clearTimeout(resizeTimer);
    resizeTimer = setTimeout(function() {
      document.body.classList.remove('resize-animation-stopper');
    }, 400);
  });

  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')
  }
  sidebarOpen.click(openMenu)
  sidebarClose.click(closeAllMenus)

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

  function toggleContextualMenu() {
    if (document.body.classList.contains('contextualSideMenu-open')) {
      closeAllMenus()
    } else {
      closeAllMenus()
      body.addClass('contextualSideMenu-open modal-open')
      modalBackdrop.addClass('show')
    }
  }

  contextualSidebarMenuToggle.click(toggleContextualMenu)
  contextualSidebarMenuClose.click(toggleContextualMenu)
})

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spree_backend-4.8.4 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.8.3 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.8.2 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.8.1 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.7.2 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.6.2 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.7.1 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.7.0 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.6.1 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.6.0 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.5.1 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.5.0 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.4.1 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.4.0 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.4.0.rc2 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.4.0.rc1 app/assets/javascripts/spree/backend/global/responsive_menus.es6