PageSourceSearch

https://allmansright.com/cdn/shop/t/28/assets/header-menu.js?v=1177411761452820701790536234

js allmansright.com collected 2026-10-04 02:23:21 UTC 10,908 bytes, 2 lines download raw bytes

1import{Component}from"@theme/component";import{debounce,onDocumentLoaded,setHeaderMenuStyle}from"@theme/utilities";import{MegaMenuHoverEvent}from"@theme/events";const HOVER_COMMIT_DELAY_MS=150;class HeaderMenu extends Component{requiredRefs=["overflowMenu"];#submenuMutationObserver=null;#hoverDispatchTimer;connectedCallback(){super.connectedCallback(),onDocumentLoaded(this.#preloadImages),window.addEventListener("resize",this.#resizeListener),this.addEventListener("keydown",this.#onKeydown),this.overflowMenu?.addEventListener("pointerleave",this.#overflowSubmenuListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.#resizeListener),this.removeEventListener("keydown",this.#onKeydown),document.body.removeEventListener("pointermove",this.#onPointerMove),this.#state.activeItem&&this.#stopPointerTracking(this.#state.activeItem),this.overflowMenu?.removeEventListener("pointerleave",this.#overflowSubmenuListener),this.#cleanupMutationObserver(),clearTimeout(this.#hoverDispatchTimer),this.#hoverDispatchTimer=void 0}#resizeListener=debounce(()=>{setHeaderMenuStyle()},100);#overflowSubmenuListener=()=>{this.#deactivate()};#onKeydown=event=>{if(event.key!=="Escape")return;const item=this.#state.activeItem;if(!item)return;const control=this.#focusTargetAfterClose(item);this.#deactivate(item,{force:!0}),control.focus()};toggle=event=>{const button=event.target;if(!(button instanceof HTMLElement))return;const item=findMenuItem(button);if(!item)return;if(button.getAttribute("aria-expanded")==="true"){this.#deactivate(this.#state.activeItem??item,{force:!0});const focusTarget=this.#focusTargetAfterClose(item);focusTarget!==button&&focusTarget.focus()}else this.activate(event)};#focusTargetAfterClose(item){const listItem=item.closest(".menu-list__list-item"),slot=listItem instanceof HTMLElement?listItem.slot:"";if(slot==="overflow"||slot==="more"){const moreButton=this.querySelector('[slot="more"] [ref="menuitem"]');if(moreButton instanceof HTMLElement)return moreButton}return this.#expandableFor(item)}#expandableFor(item){const disclosure=item.closest(".menu-list__list-item")?.querySelector('[ref="disclosure[]"]');return disclosure instanceof HTMLElement?disclosure:item}#state={activeItem:null,activeOverflowItem:null};#pointerIdleTimer;#lastPointer={x:0,y:0};#onPointerMove=event=>{const activeLink=this.#state.activeItem;if(!activeLink)return;this.#lastPointer.x=event.clientX,this.#lastPointer.y=event.clientY;const moving=Math.abs(event.movementX)>=1||event.movementY>=1;activeLink.dataset.safetyBox=`${moving}
1`,clearTimeout(this.#pointerIdleTimer),moving?this.#pointerIdleTimer=setTimeout(()=>{this.#state.activeItem&&(this.#state.activeItem.dataset.safetyBox="false",this.#reconcilePointerTarget())},50):this.#reconcilePointerTarget()};#reconcilePointerTarget(){const{x,y}=this.#lastPointer;requestAnimationFrame(()=>{const target=document.elementFromPoint(x,y);if(!target)return;const listItem=target.closest(".menu-list__list-item");listItem&&!listItem.contains(this.#state.activeItem)&&listItem.dispatchEvent(new PointerEvent("pointerenter",{bubbles:!1}))})}#startPointerTracking(item,previousItem){previousItem?this.#stopPointerTracking(previousItem):document.body.addEventListener("pointermove",this.#onPointerMove);const rect=item.getBoundingClientRect(),boundary=this.headerComponent?.hasAttribute("data-submenu-overlap-bottom-row")?this.headerComponent?.querySelector(".header__row--top"):this.headerComponent;item.style.setProperty("--box-height",`${(boundary?.getBoundingClientRect().bottom??0)-rect.top}px`)}#stopPointerTracking(item){window.clearTimeout(this.#pointerIdleTimer),this.#pointerIdleTimer=void 0,item.style.removeProperty("--box-height"),delete item.dataset.safetyBox}get overflowMenu(){return this.refs.overflowMenu?.shadowRoot?.querySelector('[part="overflow"]')}get overflowListHovered(){return this.refs.overflowMenu?.shadowRoot?.querySelector('[part="overflow-list"]')?.matches(":hover")??!1}#getFirstOverflowMenuItem(){const menuItem=this.refs.overflowMenu?.querySelector('[slot="overflow"] [ref="menuitem"]');return menuItem instanceof HTMLElement?menuItem:null}get headerComponent(){return this.closest("header-component")}activate=event=>{if(!(event.target instanceof Element)||!this.headerComponent)return;const item=findMenuItem(event.target);if(!item||item==this.#state.activeItem)return;const listItem=item.closest(".menu-list__list-item"),slot=listItem instanceof HTMLElement?listItem.slot:"",isMoreTrigger=slot==="more",isDefaultSlot=slot==="",overflowItem=isMoreTrigger?this.#getFirstOverflowMenuItem():null;this.dataset.overflowExpanded=(!isDefaultSlot).toString();const previouslyActiveItem=this.#state.activeItem,previouslyActiveOverflowItem=this.#state.activeOverflowItem;if(previouslyActiveItem){this.#expandableFor(previouslyActiveItem).ariaExpanded="false";const previousSubmenu=findSubmenu(previouslyActiveItem);previousSubmenu&&(previousSubmenu.inert=!0)}if(previouslyActiveOverflowItem&&previouslyActiveOverflowItem!==previouslyActiveItem){this.#expandableFor(previouslyActiveOverflowItem).ariaExpanded="false";const previousOverflowSubmenu=findSubmenu(previouslyActiveOverflowItem);previousOverflowSubmenu&&(previousOverflowSubmenu.inert=!0)}if(this.#state.activeItem=item,this.#state.activeOverflowItem=overflowItem,this.ariaExpanded="true",this.#expandableFor(item).ariaExpanded="true",overflowItem&&overflowItem!==item){this.#expandableFor(overflowItem).ariaExpanded="true";const activeOverflowSubmenu=findSubmenu(overflowItem);activeOverflowSubmenu&&(activeOverflowSubmenu.inert=!1)}const overflowItemSubmenu=isMoreTrigger?findSubmenu(overflowItem):null;let submenu=findSubmenu(item)||(overflowItemSubmenu?this.overflowMenu:null);const hasSubmenu=!!submenu;if(!hasSubmenu&&!isDefaultSlot&&(submenu=this.overflowMenu),submenu){clearTimeout(this.#hoverDispatchTimer),this.#hoverDispatchTimer=void 0;const committedItem=item;event instanceof FocusEvent?this.dispatchEvent(new MegaMenuHoverEvent):this.#hoverDispatchTimer=setTimeout(()=>{this.#hoverDispatchTimer=void 0,this.#state.activeItem===committedItem&&this.dispatchEvent(new MegaMenuHoverEvent)},HOVER_COMMIT_DELAY_MS),submenu.dataset.active="",submenu.inert=!1,this.#cleanupMutationObserver(),this.#submenuMutationObserver=new MutationObserver(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{submenu.offsetHeight>0&&(this.headerComponent?.style.setProperty("--submenu-height",`${submenu.offsetHeight}px`),this.#cleanupMutationObserver())})})}),this.#submenuMutationObserver.observe(submenu,{childList:!0,subtree:!0}),setTimeout(()=>{this.#cleanupMutationObserver()},500)}let finalHeight=submenu?.offsetHeight||0;if(!isDefaultSlot){const overflowListHeight=this.#getOverflowListLinksHeight();if(hasSubmenu){const overflowHeight=this.overflowMenu?.offsetHeight||0;finalHeight=Math.max(overflowHeight,overflowListHeight)}else finalHeight=overflowListHeight}submenu||(finalHeight=0);const headerVisibleHeight=this.#getHeaderVisibleHeight();this.headerComponent.style.setProperty("--submenu-height",`${finalHeight}px`),this.#setFullOpenHeaderHeight(finalHeight,headerVisibleHeight),this.style.setProperty("--submenu-opacity","1"),this.#startPointerTracking(item,previouslyActiveItem)};deactivate(event){if(!(event.target instanceof Element))return;const menu=findSubmenu(this.#state.activeItem),isMovingWithinItem=event.relatedTarget instanceof Node&&event.target instanceof Element&&event.target.contains(event.relatedTarget),isMovingWithinMenu=event.relatedTarget instanceof Node&&menu?.contains(document.activeElement),isMovingToSubmenu=event.relatedTarget instanceof Node&&event.type==="blur"&&menu?.contains(event.relatedTarget),isMovingToOverflowMenu=event.relatedTarget instanceof Element&&!!event.relatedTarget.closest('[slot="overflow"]');if(isMovingWithinItem||isMovingWithinMenu||isMovingToOverflowMenu||isMovingToSubmenu){this.#state.activeItem&&this.#stopPointerTracking(this.#state.activeItem);return}this.#deactivate()}#deactivate=(item=this.#state.activeItem,{force=!1}={})=>
1{if(!item||item!=this.#state.activeItem||!force&&(this.overflowListHovered||this.overflowMenu?.matches(":hover")))return;clearTimeout(this.#hoverDispatchTimer),this.#hoverDispatchTimer=void 0,this.headerComponent?.style.setProperty("--submenu-height","0px"),this.#setFullOpenHeaderHeight(0,0),this.style.setProperty("--submenu-opacity","0"),this.dataset.overflowExpanded="false";const submenu=findSubmenu(item)||(item.closest('[slot="more"]')?this.overflowMenu:null),activeOverflowItem=this.#state.activeOverflowItem;if(document.body.removeEventListener("pointermove",this.#onPointerMove),this.#stopPointerTracking(item),this.#state.activeItem=null,this.#state.activeOverflowItem=null,this.ariaExpanded="false",this.#expandableFor(item).ariaExpanded="false",activeOverflowItem&&activeOverflowItem!==item){this.#expandableFor(activeOverflowItem).ariaExpanded="false";const activeOverflowSubmenu=findSubmenu(activeOverflowItem);activeOverflowSubmenu&&(activeOverflowSubmenu.inert=!0)}submenu&&(delete submenu.dataset.active,submenu.inert=!0)};#getOverflowListLinksHeight(){const slottedMenuLinks=this.overflowMenu?.querySelector("slot")?.assignedElements();if(!slottedMenuLinks)return this.overflowMenu?.offsetHeight||0;const mapSubmenus=cb=>{slottedMenuLinks.forEach(link=>{const submenu=link.querySelector('[ref="submenu[]"]');submenu&&cb(submenu)})};mapSubmenus(submenu=>{submenu.style.setProperty("display","none")});const height=this.overflowMenu?.offsetHeight||0;return mapSubmenus(submenu=>{submenu.style.removeProperty("display")}),height}#getHeaderVisibleHeight(){return this.headerComponent?this.headerComponent.hasAttribute("data-submenu-overlap-bottom-row")&&this.headerComponent.offsetHeight>0?this.headerComponent.querySelector(".header__row--top")?.offsetHeight??0:this.headerComponent.offsetHeight:0}#setFullOpenHeaderHeight(submenuHeight,headerVisibleHeight){if(!this.headerComponent)return;const fullOpenHeaderHeight=submenuHeight===0?0:submenuHeight+headerVisibleHeight;this.headerComponent?.style.setProperty("--full-open-header-height",`${fullOpenHeaderHeight}px`)}#preloadImages=()=>{this.querySelectorAll('img[loading="lazy"]')?.forEach(image=>image.removeAttribute("loading"))};#cleanupMutationObserver(){this.#submenuMutationObserver?.disconnect(),this.#submenuMutationObserver=null}}customElements.get("header-menu")||customElements.define("header-menu",HeaderMenu);function findMenuItem(element){return element instanceof Element?(element.closest(".menu-list__list-item")??element).querySelector('[ref="menuitem"]'):null}function findSubmenu(element){const submenu=element?.closest?.(".menu-list__list-item")?.querySelector(':scope > [ref="submenu[]"]');return submenu instanceof HTMLElement?submenu:null}
2//# sourceMappingURL=/cdn/shop/t/28/assets/header-menu.js.map?v=1177411761452820701790536234

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.