PageSourceSearch

https://www.sweedbeauty.global/cdn/shop/t/140/assets/custom-varian…?v=182335014064611595911784212110

js sweedbeauty.global collected 2026-10-09 18:20:17 UTC 11,770 bytes, 2 lines download raw bytes

1(function(){window.initCustomVariantDropdown=window.initCustomVariantDropdown||function(dropdownElement,imageSelector){if(dropdownElement.dataset.dropdownInitialized==="true")return;dropdownElement.dataset.dropdownInitialized="true";const trigger=dropdownElement.querySelector("[data-dropdown-trigger]"),menu=dropdownElement.querySelector("[data-dropdown-menu]"),options=dropdownElement.querySelectorAll("[data-dropdown-option]"),productId=dropdownElement.getAttribute("data-product-id"),location=dropdownElement.getAttribute("data-location"),dropdownType=dropdownElement.getAttribute("data-dropdown-type");let nativeSelect;dropdownType==="cart-upsell"?nativeSelect=document.getElementById("CartSelector-"+productId):nativeSelect=document.getElementById("SingleOptionSelector-"+location+"-"+productId);const container=dropdownElement.closest(imageSelector||".mini-product-card, .product-item, .mobile-product-item"),productImage=container?container.querySelector(".mini-product-card__image, .product-image-mobile, .product-image"):null,triggerColor=trigger?trigger.querySelector("[data-trigger-color]"):null,setColorCircle=function(circle,hex,swatchImage){circle&&(hex?(circle.style.backgroundColor=hex,circle.style.backgroundImage="none"):swatchImage&&swatchImage.includes(".png")&&(circle.style.backgroundImage="url('"+swatchImage+"')",circle.style.backgroundSize="cover"))};if(function(){if(options.forEach(function(option){const colorCircle=option.querySelector("[data-option-color]"),hex=option.getAttribute("data-color-metafield"),swatchImage=option.getAttribute("data-swatch-image");setColorCircle(colorCircle,hex,swatchImage)}),triggerColor){const selectedOption=Array.from(options).find(function(opt){return opt.classList.contains("is-selected")});if(selectedOption){const hex=selectedOption.getAttribute("data-color-metafield"),swatchImage=selectedOption.getAttribute("data-swatch-image");setColorCircle(triggerColor,hex,swatchImage)}else{const swatchImage=triggerColor.getAttribute("data-swatch-image");setColorCircle(triggerColor,null,swatchImage)}}}(),!trigger||!menu||!nativeSelect)return;let focusedIndex=-1;const optionsArray=Array.from(options),updateFocusedOption=function(index){if(options.forEach(function(opt){opt.classList.remove("is-focused")}),index>=0&&index<options.length){focusedIndex=index;const focusedOption=optionsArray[focusedIndex];focusedOption.classList.add("is-focused"),focusedOption.scrollIntoView({block:"nearest"});const optionId=focusedOption.getAttribute("id");optionId&&trigger.setAttribute("aria-activedescendant",optionId)}else focusedIndex=-1,trigger.removeAttribute("aria-activedescendant")},selectOption=function(option){option&&option.click()},openDropdown=function(){if(dropdownElement.classList.contains("is-open"))return;trigger.click();const selectedIndex=optionsArray.findIndex(function(opt){return opt.classList.contains("is-selected")});updateFocusedOption(selectedIndex>=0?selectedIndex:0)},closeDropdown=function(){dropdownElement.classList.contains("is-open")&&(dropdownElement.classList.remove("is-open"),trigger.setAttribute("aria-expanded","false"),menu.style.setProperty("opacity","0","important"),menu.style.setProperty("visibility","hidden","important"),menu.style.setProperty("pointer-events","none","important"),updateFocusedOption(-1),trigger.focus(),setTimeout(function(){menu.parentNode===document.body&&dropdownElement.appendChild(menu)},200))};trigger.addEventListener("keydown",function(e){const isOpen=dropdownElement.classList.contains("is-open");switch(e.key){case"Enter":case" ":e.preventDefault(),isOpen?focusedIndex>=0&&selectOption(optionsArray[focusedIndex]):openDropdown();break;case"ArrowDown":e.preventDefault(),isOpen?updateFocusedOption(Math.min(focusedIndex+1,options.length-1)):openDropdown();break;case"ArrowUp":e.preventDefault(),isOpen?updateFocusedOption(Math.max(focusedIndex-1,0)):openDropdown();break;case"Escape":isOpen&&(e.preventDefault(),closeDropdown());break;case"Home":isOpen&&(e.preventDefault(),updateFocusedOption(0));break;case"End":isOpen&&(e.preventDefault(),updateFocusedOption(options.length-1));break;case"Tab":isOpen&&closeDropdown();break}});const positionMenu=function(){const triggerRect=trigger.getBoundingClientRect(),drawer=dropdownElement.closest('.drawer, .drawer__scrollable, [class*="drawer"]'),modal=dropdownElement.closest('[class*="modal"], [class*="hotspot"]'),containerEl=drawer||modal;let boundaryLeft=10,boundaryRight=window.innerWidth-10;if(containerEl){const containerRect=containerEl.getBoundingClientRect();boundaryLeft=containerRect.left+10,boundaryRight=containerRect.right-10}const spaceRight=boundaryRight-triggerRect.left;let menuWidth=Math.max(150,Math.min(triggerRect.width,spaceRight)),left=triggerRect.left;left+menuWidth>boundaryRight&&(left=Math.max(boundaryLeft,boundaryRight-menuWidth)),left+menuWidth>boundaryRight&&(menuWidth=boundaryRight-left),left<boundaryLeft&&(menuWidth=Math.min(menuWidth,window.innerWidth-20),left=boundaryLeft),menu.style.position="fixed",menu.style.top=triggerRect.bottom+"px",menu.style.left=left+"px",menu.style.width=menuWidth+"px",menu.style.minWidth="150px"};trigger.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();const isOpen=dropdownElement.classList.contains("is-open");if(document.querySelectorAll("[data-custom-dropdown].is-open").forEach(function(other){other!==dropdownElement&&other.classList.remove("is-open")}),document.querySelectorAll("body > [data-dropdown-menu]").forEach(function(menuInBody){menuInBody!==menu&&(menuInBody.style.setProperty("opacity","0","important"),menuInBody.style.setProperty("visibility","hidden","important"),menuInBody.style.setProperty("pointer-events","none","important"))}),isOpen)dropdownElement.classList.remove("is-open"),trigger.setAttribute("aria-expanded","fal
1se"),updateFocusedOption(-1),menu.style.setProperty("opacity","0","important"),menu.style.setProperty("visibility","hidden","important"),menu.style.setProperty("pointer-events","none","important"),setTimeout(function(){menu.parentNode===document.body&&dropdownElement.appendChild(menu)},200);else{const rect=trigger.getBoundingClientRect();document.body.appendChild(menu),menu.style.position="fixed",menu.style.top=Math.round(rect.bottom)+"px",menu.style.left=Math.round(rect.left)+"px",menu.style.width=Math.round(rect.width)+"px",dropdownElement.classList.add("is-open"),trigger.setAttribute("aria-expanded","true"),menu.style.setProperty("transition","none","important"),menu.style.setProperty("opacity","1","important"),menu.style.setProperty("visibility","visible","important"),menu.style.setProperty("transform","translateY(0)","important"),menu.style.setProperty("pointer-events","auto","important"),menu.style.setProperty("display","block","important");const selectedIndex=optionsArray.findIndex(function(opt){return opt.classList.contains("is-selected")});updateFocusedOption(selectedIndex>=0?selectedIndex:0),requestAnimationFrame(function(){menu.style.removeProperty("transition")})}return!1},!0),options.forEach(function(option){option.addEventListener("click",function(e){e.stopPropagation();const variantId=option.getAttribute("data-variant-id"),textElement=option.querySelector(".custom-dropdown__option-text"),variantText=textElement?textElement.textContent.trim():option.textContent.trim(),variantImage=option.getAttribute("data-variant-image");options.forEach(function(opt){opt.classList.remove("is-selected"),opt.setAttribute("aria-selected","false")}),option.classList.add("is-selected"),option.setAttribute("aria-selected","true");const selectedText=trigger.querySelector(".custom-dropdown__selected-text");if(selectedText&&(selectedText.textContent=variantText),triggerColor){const hex=option.getAttribute("data-color-metafield"),swatchImage=option.getAttribute("data-swatch-image");setColorCircle(triggerColor,hex,swatchImage)}if(nativeSelect.value=variantId,variantImage&&productImage&&variantImage!==productImage.src){const img=new Image;img.onload=function(){productImage.src=variantImage,productImage.alt=productImage.alt.split(" - ")[0]+" - "+variantText},img.src=variantImage}const variantInput=document.getElementById(location+"-"+productId);variantInput&&(variantInput.value=variantId),dropdownElement.classList.remove("is-open"),trigger.setAttribute("aria-expanded","false"),updateFocusedOption(-1),menu.style.setProperty("opacity","0","important"),menu.style.setProperty("visibility","hidden","important"),menu.style.setProperty("pointer-events","none","important"),trigger.focus(),setTimeout(function(){menu.parentNode===document.body&&dropdownElement.appendChild(menu)},200)})});const closeOnScroll=function(e){dropdownElement.classList.contains("is-open")&&(e&&e.target&&(e.target===menu||menu.contains(e.target))||(dropdownElement.classList.remove("is-open"),trigger.setAttribute("aria-expanded","false"),updateFocusedOption(-1),menu.style.setProperty("opacity","0","important"),menu.style.setProperty("visibility","hidden","important"),menu.style.setProperty("pointer-events","none","important"),setTimeout(function(){menu.parentNode===document.body&&dropdownElement.appendChild(menu)},200)))};window.addEventListener("scroll",closeOnScroll,!0),window.addEventListener("resize",closeOnScroll)};function setupDropdownListeners(){window.dropdownClickOutsideRegistered||(document.addEventListener("click",function(e){const clickedTrigger=e.target.closest("[data-dropdown-trigger]"),clickedMenu=e.target.closest("[data-dropdown-menu]");clickedTrigger||clickedMenu||(document.querySelectorAll("[data-custom-dropdown].is-open").forEach(function(dropdown){dropdown.classList.remove("is-open");const trigger=dropdown.querySelector("[data-dropdown-trigger]");trigger&&(trigger.setAttribute("aria-expanded","false"),trigger.removeAttribute("aria-activedescendant")),dropdown.querySelectorAll(".is-focused").forEach(function(opt){opt.classList.remove("is-focused")})}),document.querySelectorAll("body > [data-dropdown-menu]").forEach(function(menu){menu.style.setProperty("opacity","0","important"),menu.style.setProperty("visibility","hidden","important"),menu.style.setProperty("pointer-events","none","important")}))},!0),window.dropdownClickOutsideRegistered=!0),!window.dropdownObserverRegistered&&typeof MutationObserver<"u"&&(new MutationObserver(function(mutations){mutations.forEach(function(mutation){mutation.addedNodes.forEac
1h(function(node){node.nodeType===1&&(node.hasAttribute&&node.hasAttribute("data-custom-dropdown")&&node.dataset.dropdownInitialized!=="true"&&window.initCustomVariantDropdown(node),node.querySelectorAll&&node.querySelectorAll('[data-custom-dropdown]:not([data-dropdown-initialized="true"])').forEach(function(dropdown){window.initCustomVariantDropdown(dropdown)}))})})}).observe(document.body,{childList:!0,subtree:!0}),window.dropdownObserverRegistered=!0),document.querySelectorAll('[data-custom-dropdown]:not([data-dropdown-initialized="true"])').forEach(function(dropdown){window.initCustomVariantDropdown(dropdown)})}document.addEventListener("drawerOpen",function(){setTimeout(function(){document.querySelectorAll('[data-custom-dropdown]:not([data-dropdown-initialized="true"])').forEach(function(dropdown){window.initCustomVariantDropdown(dropdown)})},100)}),document.addEventListener("toggle-product-drawer",function(){setTimeout(function(){document.querySelectorAll('[data-custom-dropdown]:not([data-dropdown-initialized="true"])').forEach(function(dropdown){window.initCustomVariantDropdown(dropdown)})},200)}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",setupDropdownListeners):setupDropdownListeners()})();
2//# sourceMappingURL=/cdn/shop/t/140/assets/custom-variant-dropdown.js.map?v=182335014064611595911784212110

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.