Sha256: 6c2c5835833262c43e5e49990b7d7a9c7654ff7a8bfb9f0764dbeb342d0e2364

Contents?: true

Size: 1.68 KB

Versions: 7

Compression:

Stored size: 1.68 KB

Contents

document.addEventListener('DOMContentLoaded', 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

7 entries across 7 versions & 1 rubygems

Version Path
spree_backend-4.3.3 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.3.2 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.3.1 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.3.0 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.3.0.rc3 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.3.0.rc2 app/assets/javascripts/spree/backend/global/responsive_menus.es6
spree_backend-4.3.0.rc1 app/assets/javascripts/spree/backend/global/responsive_menus.es6