Skip to content

Commit

Permalink
Merge pull request solidusio#5423 from solidusio/elia/stop-auto-hidin…
Browse files Browse the repository at this point in the history
…g-the-navbar

Skip all the navbar hiding logic when using the new version
  • Loading branch information
elia authored Oct 6, 2023
2 parents 4b17a5d + 039fe9c commit c64e9fd
Showing 1 changed file with 23 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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");
Expand Down

0 comments on commit c64e9fd

Please sign in to comment.