PageSourceSearch

https://milagrosbeauty.com/cdn/shop/t/50/assets/dialog.js?v=163716602385408873071788887151

js milagrosbeauty.com collected 2026-09-25 18:57:42 UTC 8,104 bytes, 2 lines download raw bytes

1import{Component}from"@theme/component";import{isClickedOutside,onAnimationEnd,removeScrollLockClass}from"@theme/utilities";let lockDialogCount=0;export function acquireThemeScrollLock(){lockDialogCount++,document.documentElement.setAttribute("scroll-lock",""),document.documentElement.classList.add("scroll-locked")}export function releaseThemeScrollLock(){lockDialogCount=Math.max(0,lockDialogCount-1),lockDialogCount===0&&document.documentElement.removeAttribute("scroll-lock"),removeScrollLockClass(document.documentElement,"scroll-locked",()=>lockDialogCount===0)}export class DialogComponent extends Component{requiredRefs=["dialog"];#shopifyAbortController;#previousActiveElement=null;#focusableElements=[];#focusTrapHandler=null;#keyboardDetectionHandlers=null;connectedCallback(){super.connectedCallback(),this.#registerDesignModeEvents()}disconnectedCallback(){this.#shopifyAbortController?.abort(),this.#shopifyAbortController=void 0,super.disconnectedCallback()}showDialog(){const{dialog}=this.refs;dialog.open||(this.#previousActiveElement=document.activeElement,dialog.hasAttribute("scroll-lock")&&acquireThemeScrollLock(),dialog.showModal(),dialog.setAttribute("open",""),this.dispatchEvent(new DialogOpenEvent),setTimeout(()=>{this.#setupFocusManagement(),this.addEventListener("click",this.#handleClick),this.addEventListener("keydown",this.#handleKeyDown)}))}closeDialog=async()=>{const{dialog}=this.refs;dialog.open&&(this.removeEventListener("click",this.#handleClick),this.removeEventListener("keydown",this.#handleKeyDown),dialog.classList.add("dialog-closing"),await onAnimationEnd(dialog,void 0,{subtree:!1}),dialog.close(),dialog.classList.remove("dialog-closing"),dialog.hasAttribute("scroll-lock")&&releaseThemeScrollLock(),this.#restoreFocus(),this.dispatchEvent(new DialogCloseEvent))};#registerDesignModeEvents(){if(!this.hasAttribute("shopify-design-mode")||!(window.Shopify&&Shopify.designMode))return;const section=this.closest(".shopify-section");if(!section)return;this.#shopifyAbortController?.abort(),this.#shopifyAbortController=new AbortController;const{signal}=this.#shopifyAbortController;section.addEventListener("shopify:section:select",()=>{this.showDialog()},{signal}),section.addEventListener("shopify:section:deselect",()=>{this.closeDialog()},{signal})}toggleDialog=()=>{this.refs.dialog.open?this.closeDialog():this.showDialog()};#handleClick(event){const{dialog}=this.refs;isClickedOutside(event,dialog)&&(this.closeDialog(),event.stopPropagation())}#handleKeyDown(event){event.key==="Escape"&&(event.preventDefault(),this.closeDialog())}#setupFocusManagement(){const{dialog}=this.refs;this.#focusableElements=this.#getFocusableElements(dialog),this.#setupKeyboardNavigationDetection(),this.#focusTargetElement(),this.#shouldEnableFocusTrap()&&this.#setupFocusTrap()}#shouldEnableFocusTrap(){return this.getAttribute("focus-trap")!=="false"}#focusTargetElement(){const{dialog}=this.refs,focusTarget=this.getAttribute("focus-target");let targetElement=null;if(focusTarget){const foundElement=dialog.querySelector(focusTarget);if(foundElement)if(this.#isElementFocusable(foundElement))targetElement=foundElement;else{const focusableChild=this.#getFocusableElements(foundElement)[0];focusableChild&&(targetElement=focusableChild)}}!targetElement&&this.#focusableElements.length>0&&(targetElement=this.#focusableElements[0]),targetElement?this.#focusWithoutOutline(targetElement):console.log("No focusable element found")}#setupFocusTrap(){const{dialog}=this.refs,handleTabKey=event=>{if(event.key!=="Tab"||(this.#focusableElements=this.#getFocusableElements(dialog),this.#focusableElements.length===0))return;const firstElement=this.#focusableElements[0],lastElement=this.#focusableElements[this.#focusableElements.length-1],activeElement=document.activeElement,isFocusInDialog=dialog.contains(activeElement),activeIndex=this.#focusableElements.indexOf(activeElement),shouldWrap=!isFocusInDialog||activeIndex===-1;event.shiftKey?(activeElement===firstElement||shouldWrap)&&(event.preventDefault(),event.stopPropagation(),lastElement.focus()):(activeElement===lastElement||shouldWrap)&&(event.preventDefault(),event.stopPropagation(),firstElement.focus())};this.addEventListener("keydown",handleTabKey,!0),this.#focusTrapHandler=handleTabKey}#isElementFocusable(element){if(!["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not
1([tabindex="-1"])','[contenteditable="true"]'].some(selector=>{try{return element.matches(selector)}catch{return!1}}))return!1;const style=window.getComputedStyle(element);return style.display!=="none"&&style.visibility!=="hidden"&&!element.hasAttribute("disabled")}#getFocusableElements(container){const focusableSelectors=["button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])','[contenteditable="true"]'].join(", ");return Array.from(container.querySelectorAll(focusableSelectors)).filter(element=>this.#isElementFocusable(element))}#setupKeyboardNavigationDetection(){const{dialog}=this.refs,handleKeyDown=event=>{event.key==="Tab"&&(dialog.classList.add("keyboard-navigation"),handleKeyDown._detected=!0)},handleMouseDown=()=>{dialog.classList.remove("keyboard-navigation")};dialog.addEventListener("keydown",handleKeyDown),dialog.addEventListener("mousedown",handleMouseDown),this.#keyboardDetectionHandlers={keydown:handleKeyDown,mousedown:handleMouseDown}}#focusWithoutOutline(element){element.classList.add("focus-no-outline"),element.focus(),setTimeout(()=>{element.classList.remove("focus-no-outline")},100),this.#isInputOrTextarea(element)&&this.#scrollInputIntoView(element)}#isInputOrTextarea(element){return element.tagName==="INPUT"||element.tagName==="TEXTAREA"||element.matches("input, textarea")}#scrollInputIntoView(element){requestAnimationFrame(()=>{setTimeout(()=>{if(!document.contains(element)||document.activeElement!==element)return;element.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"});const{dialog}=this.refs;if(dialog&&dialog.contains(element)){const scrollableParent=this.#findScrollableParent(element,dialog);if(scrollableParent&&scrollableParent!==dialog){const elementRect=element.getBoundingClientRect(),parentRect=scrollableParent.getBoundingClientRect(),elementTop=elementRect.top-parentRect.top+scrollableParent.scrollTop;scrollableParent.scrollTo({top:elementTop-scrollableParent.clientHeight/2+elementRect.height/2,behavior:"smooth"})}}},350)})}#findScrollableParent(element,container){let parent=element.parentElement;for(;parent&&parent!==container;){const style=window.getComputedStyle(parent),hasOverflow=style.overflow==="auto"||style.overflow==="scroll"||style.overflowY==="auto"||style.overflowY==="scroll",hasScrollableContent=parent.scrollHeight>parent.clientHeight;if(hasOverflow&&hasScrollableContent)return parent;parent=parent.parentElement}return null}#restoreFocus(){if(this.#previousActiveElement&&this.#previousActiveElement!==document.body&&document.contains(this.#previousActiveElement)&&this.#previousActiveElement.focus(),this.#previousActiveElement=null,this.#focusTrapHandler&&(this.removeEventListener("keydown",this.#focusTrapHandler,!0),this.#focusTrapHandler=null),this.#keyboardDetectionHandlers){const{dialog}=this.refs;this.#keyboardDetectionHandlers.keydown&&dialog.removeEventListener("keydown",this.#keyboardDetectionHandlers.keydown),this.#keyboardDetectionHandlers.mousedown&&dialog.removeEventListener("mousedown",this.#keyboardDetectionHandlers.mousedown),this.#keyboardDetectionHandlers=null}this.#focusableElements=[]}}customElements.get("dialog-component")||customElements.define("dialog-component",DialogComponent);export class DialogOpenEvent extends CustomEvent{constructor(){super(DialogOpenEvent.eventName)}static eventName="dialog:open"}export class DialogCloseEvent extends CustomEvent{constructor(){super(DialogCloseEvent.eventName)}static eventName="dialog:close"}
2//# sourceMappingURL=/cdn/shop/t/50/assets/dialog.js.map?v=163716602385408873071788887151

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.