mobile-cart.min.js 2.7 KB

1
  1. !function(){var t,a,c,o,e,n=document.getElementById("astra-mobile-cart-drawer"),d=document.getElementById("masthead");function i(){var e,t,c;document.addEventListener("keyup",function(e){27===e.keyCode&&(e.preventDefault(),n.classList.remove("active"),document.documentElement.classList.remove("ast-mobile-cart-active"),updateTrigger())}),document.addEventListener("click",function(e){e.target===document.querySelector(".ast-mobile-cart-active .astra-mobile-cart-overlay")&&(n.classList.remove("active"),document.documentElement.classList.remove("ast-mobile-cart-active"))}),void 0!==a&&""!==a&&null!==a&&(e=document.querySelectorAll(".ast-mobile-header-wrap .ast-header-woo-cart"),t=document.querySelector(".ast-mobile-header-wrap .ast-header-edd-cart"),c=document.querySelector(".astra-cart-drawer-close"),0<e.length&&e.forEach(function(e){void 0!==e&&""!==e&&null!==e&&n&&(e.addEventListener("click",cartFlyoutOpen,!1),e.cart_type="woocommerce")}),void 0!==t&&""!==t&&null!==t&&n&&(t.addEventListener("click",cartFlyoutOpen,!1),t.cart_type="edd"),void 0!==c&&""!==c&&null!==c&&c.addEventListener("click",cartFlyoutClose,!1))}d&&(t="",a=d.querySelector("#ast-mobile-header"),c="",void 0!==n&&""!==n&&null!==n&&(t=n.querySelector(".widget_shopping_cart.woocommerce"),c=n.querySelector(".widget_edd_cart_widget")),cartFlyoutOpen=function(e){e.preventDefault();e=e.currentTarget.cart_type;"woocommerce"===e&&document.body.classList.contains("woocommerce-cart")||(n.classList.remove("active"),n.classList.remove("woocommerce-active"),n.classList.remove("edd-active"),void 0!==n&&""!==n&&null!==n&&(n.classList.add("active"),document.documentElement.classList.add("ast-mobile-cart-active"),void 0!==c&&""!==c&&null!==c&&(c.style.display="block","woocommerce"===e&&(c.style.display="none",n.classList.add("woocommerce-active"))),void 0!==t&&""!==t&&null!==t&&(t.style.display="block","edd"===e&&(t.style.display="none",n.classList.add("edd-active")))))},cartFlyoutClose=function(e){e.preventDefault(),void 0!==n&&""!==n&&null!==n&&(n.classList.remove("active"),document.documentElement.classList.remove("ast-mobile-cart-active"))},o=window.innerWidth,window.addEventListener("resize",function(){var e,t=document.querySelector(".astra-cart-drawer-close");void 0!==t&&""!==t&&null!==t&&"INPUT"!==document.activeElement.tagName&&n.classList.contains("active")&&(e=window.innerWidth)!==o&&(o=e,t.click())}),window.addEventListener("load",function(){i()}),document.addEventListener("astLayoutWidthChanged",function(){i()}),document.addEventListener("astPartialContentRendered",function(){i()}),window.addEventListener("resize",function(){clearTimeout(e),e=setTimeout(function(){i(),document.dispatchEvent(new CustomEvent("astLayoutWidthChanged",{detail:{response:""}}))},50)}))}();