From 039fe9c95d2d8b7a9a52c902f8b36bec9a002904 Mon Sep 17 00:00:00 2001 From: Elia Schito Date: Fri, 6 Oct 2023 18:15:01 +0200 Subject: [PATCH] Skip all the navbar hiding logic when using the new version --- .../spree/backend/components/admin_nav.js | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/backend/app/assets/javascripts/spree/backend/components/admin_nav.js b/backend/app/assets/javascripts/spree/backend/components/admin_nav.js index 7242357280b..eb7f040ecf7 100644 --- a/backend/app/assets/javascripts/spree/backend/components/admin_nav.js +++ b/backend/app/assets/javascripts/spree/backend/components/admin_nav.js @@ -1,25 +1,27 @@ Spree.ready(function() { - if (window.screen.width <= 1024 && !document.cookie.includes("admin_nav_hidden")) { - // Set default nav to collapse on small screens - but don't override user preference - document.body.classList.add("admin-nav-hidden"); - document.cookie = "admin_nav_hidden=true; expires=Fri, 31 Dec 9999 23:59:59 GMT"; - } - - var adminNavToggle = document.querySelector("#admin-nav-toggle"); - - if (adminNavToggle) { - adminNavToggle.addEventListener("click", function(e) { - e.preventDefault(); - document.body.classList.toggle("admin-nav-hidden"); - $(document.body).trigger("sticky_kit:recalc"); - adminNavToggle.classList.toggle("fa-chevron-circle-left"); - adminNavToggle.classList.toggle("fa-chevron-circle-right"); - document.cookie = "admin_nav_hidden=" + document.body.classList.contains("admin-nav-hidden") + "; expires=Fri, 31 Dec 9999 23:59:59 GMT"; - }); - } - - if (document.body.classList.contains('admin-nav-hidden')) { - $(adminNavToggle).removeClass('fa-chevron-circle-left').addClass('fa-chevron-circle-right'); + if (!document.querySelector(".solidus-admin--nav")) { + if (window.screen.width <= 1024 && !document.cookie.includes("admin_nav_hidden")) { + // Set default nav to collapse on small screens - but don't override user preference + document.body.classList.add("admin-nav-hidden"); + document.cookie = "admin_nav_hidden=true; expires=Fri, 31 Dec 9999 23:59:59 GMT"; + } + + var adminNavToggle = document.querySelector("#admin-nav-toggle"); + + if (adminNavToggle) { + adminNavToggle.addEventListener("click", function(e) { + e.preventDefault(); + document.body.classList.toggle("admin-nav-hidden"); + $(document.body).trigger("sticky_kit:recalc"); + adminNavToggle.classList.toggle("fa-chevron-circle-left"); + adminNavToggle.classList.toggle("fa-chevron-circle-right"); + document.cookie = "admin_nav_hidden=" + document.body.classList.contains("admin-nav-hidden") + "; expires=Fri, 31 Dec 9999 23:59:59 GMT"; + }); + } + + if (document.body.classList.contains('admin-nav-hidden')) { + $(adminNavToggle).removeClass('fa-chevron-circle-left').addClass('fa-chevron-circle-right'); + } } let solidusAdminSwitch = document.querySelector("#solidus-admin-switch");