summaryrefslogtreecommitdiff
path: root/assets/js/minified/mobile-cart.min.js
blob: 66f5fc434c117f5f7bd837ea34e1a464facdb1c6 (plain) (blame)
1
!function(){var t,a,c,e,o=document.getElementById("astra-mobile-cart-drawer"),n=document.getElementById("masthead");function d(){var e,t,c;document.addEventListener("keyup",function(e){27===e.keyCode&&(e.preventDefault(),o.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")&&(o.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&&(e.addEventListener("click",cartFlyoutOpen,!1),e.cart_type="woocommerce")}),void 0!==t&&""!==t&&null!==t&&(t.addEventListener("click",cartFlyoutOpen,!1),t.cart_type="edd"),void 0!==c&&""!==c&&null!==c&&c.addEventListener("click",cartFlyoutClose,!1))}n&&(t="",a=n.querySelector("#ast-mobile-header"),c="",void 0!==o&&""!==o&&null!==o&&(t=o.querySelector(".widget_shopping_cart.woocommerce"),c=o.querySelector(".widget_edd_cart_widget")),cartFlyoutOpen=function(e){e.preventDefault();e=e.currentTarget.cart_type;"woocommerce"===e&&document.body.classList.contains("woocommerce-cart")||(o.classList.remove("active"),o.classList.remove("woocommerce-active"),o.classList.remove("edd-active"),void 0!==o&&""!==o&&null!==o&&(o.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",o.classList.add("woocommerce-active"))),void 0!==t&&""!==t&&null!==t&&(t.style.display="block","edd"===e&&(t.style.display="none",o.classList.add("edd-active")))))},cartFlyoutClose=function(e){e.preventDefault(),void 0!==o&&""!==o&&null!==o&&(o.classList.remove("active"),document.documentElement.classList.remove("ast-mobile-cart-active"))},window.addEventListener("resize",function(){var e=document.querySelector(".astra-cart-drawer-close");void 0!==e&&""!==e&&null!==e&&"INPUT"!==document.activeElement.tagName&&e.click()}),window.addEventListener("load",function(){d()}),document.addEventListener("astLayoutWidthChanged",function(){d()}),document.addEventListener("astPartialContentRendered",function(){d()}),window.addEventListener("resize",function(){clearTimeout(e),e=setTimeout(function(){d(),document.dispatchEvent(new CustomEvent("astLayoutWidthChanged",{detail:{response:""}}))},50)}))}();