Home / Widgets / ANDRITZ Navigation Panels
Duplicate Snippet

Embed Snippet on Your Site

ANDRITZ Navigation Panels

Jay Play PRO
<10
Code Preview
js
document.addEventListener("DOMContentLoaded", function () {
  const triggers = document.querySelectorAll(".bp-andritz-utility");
  const panels = document.querySelectorAll(".bp-andritz-panel");
  const closes = document.querySelectorAll(".bp-andritz-close");
  const backs = document.querySelectorAll(".bp-andritz-back");
  function closeAllPanels(){
    panels.forEach(panel => panel.classList.remove("bp-open"));
    document.body.classList.remove("bp-andritz-active");
  }
  triggers.forEach(trigger=>{
    trigger.addEventListener("click",function(){
      const target = document.getElementById(this.dataset.target);
      const isOpen = target && target.classList.contains("bp-open");
      closeAllPanels();
      if(target && !isOpen){
        target.classList.add("bp-open");
        document.body.classList.add("bp-andritz-active");
      }
    });
  });
  closes.forEach(btn=>{
    btn.addEventListener("click",closeAllPanels);
  });
  backs.forEach(btn=>{
    btn.addEventListener("click",function(e){
      e.preventDefault();
      closeAllPanels();
    });
  });
  panels.forEach(panel=>{
    panel.addEventListener("click",function(e){
      if(e.target === panel){
        closeAllPanels();
      }
    });
  });
  document.addEventListener("keydown",function(e){
    if(e.key === "Escape"){
      closeAllPanels();
    }
  });
});

Comments

Add a Comment