const hamburger = document.querySelector("#hamburger"); const appscmsToolbar = document.querySelector(".appscms-toolbar"); const appscmsToolbarListItems = document.querySelectorAll( ".appscms-toolbar-list-item-span" ); hamburger.addEventListener("click", () => { if (hamburger.dataset.open === "1") { hamburger.dataset.open = "0"; appscmsToolbar.style.right = "-272px"; appscmsToolbar.style.display = "none"; hamburger.innerHTML =` ` } else { hamburger.dataset.open = "1"; appscmsToolbar.style.right = "0px"; appscmsToolbar.style.display = "block"; hamburger.innerHTML = ` ` } }); Array.from(appscmsToolbarListItems).map((item) => { item.addEventListener("click", (e) => { e.preventDefault(); var style = window.getComputedStyle(item.nextElementSibling); var maxHeight = style.getPropertyValue("max-height"); if (maxHeight && maxHeight !== "0px") { // If the item is expanded, collapse it item.nextElementSibling.style.maxHeight = "0"; item.nextElementSibling.style.opacity = "0"; item.nextElementSibling.style.height = "0"; } else { // If the item is collapsed, expand it item.nextElementSibling.style.maxHeight = item.nextElementSibling.scrollHeight + "px"; item.nextElementSibling.style.opacity = "1"; item.nextElementSibling.style.height = "auto"; } }); });