PageSourceSearch

https://ymijeans.com/cdn/shop/t/131/assets/collection-ux.js?v=39208674119749185081789670067

js ymijeans.com collected 2026-09-25 18:52:13 UTC 13,570 bytes, 2 lines download raw bytes

1(function(){"use strict";var STORAGE_INSTOCK="ymi_in_stock_my_size",INSTOCK_PARAM="ymi_instock",bar=null,spacer=null,fixed=!1,naturalTop=0,syncTimer=null;function qs(sel,root){return(root||document).querySelector(sel)}function qsa(sel,root){return Array.prototype.slice.call((root||document).querySelectorAll(sel))}function isMobile(){return window.matchMedia("(max-width: 768px)").matches}function isVisible(el){if(!el)return!1;var style=window.getComputedStyle(el);return style.display==="none"||style.visibility==="hidden"?!1:el.getBoundingClientRect().height>0}function isDrawerOpen(){return document.documentElement.classList.contains("js-drawer-open-collection-filters")||document.body.classList.contains("js-drawer-open-collection-filters")}function normalizeSize(value){return String(value==null?"":value).trim().toLowerCase()}function getInstockFromUrl(){try{var params=new URLSearchParams(window.location.search),v=params.get(INSTOCK_PARAM);return v==null||v===""?null:v==="1"||v==="true"||v==="on"}catch(e){return null}}function isInstockEnabled(){var fromUrl=getInstockFromUrl();if(fromUrl!==null)return fromUrl;try{return localStorage.getItem(STORAGE_INSTOCK)==="1"}catch(e){return!1}}function syncInstockFormInputs(on){qsa(".filter-form").forEach(function(form){var input=form.querySelector('input[name="'+INSTOCK_PARAM+'"]');input||(input=document.createElement("input"),input.type="hidden",input.name=INSTOCK_PARAM,input.setAttribute("data-ymi-instock-url","1"),form.appendChild(input)),on?(input.value="1",input.disabled=!1):(input.value="",input.disabled=!0)})}function writeInstockUrl(on){try{var url=new URL(window.location.href);on?url.searchParams.set(INSTOCK_PARAM,"1"):url.searchParams.delete(INSTOCK_PARAM);var qs2=url.searchParams.toString(),next=url.pathname+(qs2?"?"+qs2:"")+url.hash,cur=window.location.pathname+window.location.search+window.location.hash;next!==cur&&window.history.replaceState(window.history.state||{},"",next)}catch(e){}syncInstockFormInputs(on)}function saveInstock(on){try{localStorage.setItem(STORAGE_INSTOCK,on?"1":"0")}catch(e){}writeInstockUrl(!!on)}function isSizeParam(name){if(!name)return!1;var n=String(name).toLowerCase();return n.indexOf("availability")!==-1||n.indexOf("size-group")!==-1||n.indexOf("size_group")!==-1||n.indexOf("sizegroup")!==-1?!1:n.indexOf("filter.v.option.")===0&&n.indexOf("size")!==-1}function getActiveSizeFilters(){var sizes=[],seen={};function addSize(value){var v=String(value==null?"":value).trim();if(v){var key=normalizeSize(v);seen[key]||(seen[key]=!0,sizes.push(v))}}try{var params=new URLSearchParams(window.location.search);params.forEach(function(value,key){isSizeParam(key)&&addSize(value)})}catch(e){}return qsa(".filter-form input.tag__input:checked").forEach(function(input){isSizeParam(input.name)&&addSize(input.value)}),qsa(".ymi-filter-chips .tag--remove a, .col-top-filter .tag--remove a").forEach(function(a){var label=(a.getAttribute("data-filter-label")||"").toLowerCase(),text=(a.textContent||"").replace(/\s+/g," ").trim();if(label==="size"||/^size\s*:/i.test(text)){var parts=text.split(":");parts.length>1&&addSize(parts.slice(1).join(":").replace(/\s*remove\s*$/i,"").trim())}}),sizes}function getProductGridRoot(){return qs("#CollectionAjaxContent .collection-grid__wrapper .js-infinite-wrapper")||qs("#CollectionAjaxContent .js-infinite-wrapper")||qs(".collection-grid__wrapper .js-infinite-wrapper")||qs("#CollectionAjaxContent .collection-grid__wrapper")}function getProductCards(){var root=getProductGridRoot();return root?qsa(".grid-product",root):qsa("#CollectionAjaxContent .grid-product")}function clearClientHides(){getProductCards().forEach(function(card){card.classList.remove("ymi-hidden-by-mysize")})}function compactFilteredGrid(){var root=getProductGridRoot();if(root){var cards=qsa(".grid-product",root);if(cards.length){var visible=[],hidden=[];cards.forEach(function(card){card.classList.contains("ymi-hidden-by-mysize")?hidden.push(card):visible.push(card)});var loadMore=qs(".js-load-more",root),loadMoreIcon=qs(".load-more__icon",root.parentNode)||qs(".load-more__icon");visible.forEach(function(card){root.appendChild(card)}
1),hidden.forEach(function(card){root.appendChild(card)}),loadMore&&root.appendChild(loadMore),loadMoreIcon&&loadMoreIcon.parentNode===root&&root.appendChild(loadMoreIcon)}}}function updateResultsCount(){var hasSizeFilter=getActiveSizeFilters().length>0,countEls=qsa(".filtered-product-count, [data-ymi-results-count], .collection-filter__item--count");if(!hasSizeFilter){countEls.forEach(function(el){if(!(el.classList.contains("collection-filter__item--count")&&!el.textContent.match(/\d/))){var serverCount=el.getAttribute("data-ymi-server-count");if(!(serverCount==null||serverCount==="")){var n=parseInt(serverCount,10);isNaN(n)||(el.textContent=n+(n===1?" Result":" Results"),el.setAttribute("data-ymi-results-count",String(n)),el.classList.remove("ymi-count-pending"))}}}),document.documentElement.classList.remove("ymi-count-pending");return}var cards=getProductCards(),visible=0,seen={};cards.forEach(function(card){if(!card.classList.contains("ymi-hidden-by-mysize")){var id=card.getAttribute("data-product-id")||card.getAttribute("data-product-handle")||"",key=id?String(id):"node:"+visible+":"+(card.textContent||"").slice(0,24);seen[key]||(seen[key]=!0,visible+=1)}});var label=visible+(visible===1?" Result":" Results");countEls.forEach(function(el){el.classList.contains("collection-filter__item--count")&&!el.textContent.match(/\d/)||(el.textContent=label,el.setAttribute("data-ymi-results-count",String(visible)),el.classList.remove("ymi-count-pending"))}),document.documentElement.classList.remove("ymi-count-pending"),qsa(".size-container li.tag--active label, .size-container li.tag--active .tag__checkbox-wrapper").forEach(function(labelEl){var textEl=qs(".tag__text:not(.hide)",labelEl);if(textEl){var parent=textEl.parentNode;if(parent){Array.prototype.slice.call(parent.childNodes).forEach(function(node){node!==textEl&&node.nodeType===3&&(node.textContent="")});var countEl=qs("[data-ymi-size-count]",parent);countEl||(countEl=document.createElement("span"),countEl.setAttribute("data-ymi-size-count","1"),parent.appendChild(document.createTextNode(" ")),parent.appendChild(countEl)),countEl.textContent="("+visible+")"}}})}function applyClientSizeFilter(enable,sizes,instockOnly){if(!enable){clearClientHides(),compactFilteredGrid(),updateResultsCount();return}var sizeList=sizes||getActiveSizeFilters(),norms=sizeList.map(normalizeSize);if(!norms.length){clearClientHides(),compactFilteredGrid(),updateResultsCount();return}getProductCards().forEach(function(card){var available=(card.getAttribute("data-available-sizes")||"").trim(),allSizes=(card.getAttribute("data-all-sizes")||"").trim(),source=instockOnly?available||allSizes:allSizes||available;if(!source){card.classList.remove("ymi-hidden-by-mysize");return}var match=source.split("|").filter(Boolean).some(function(s){return norms.indexOf(normalizeSize(s))!==-1});card.classList.toggle("ymi-hidden-by-mysize",!match)}),compactFilteredGrid(),updateResultsCount()}function stripStaleAvailability(){var dirty=!1;qsa('.filter-form input[name*="availability"]').forEach(function(input){input.checked&&(input.checked=!1,dirty=!0)});try{var url=new URL(window.location.href),keys=[];url.searchParams.forEach(function(_value,key){String(key).toLowerCase().indexOf("filter.v.availability")===0&&keys.push(key)}),keys.length&&(keys.forEach(function(k){url.searchParams.delete(k)}),window.history.replaceState({},"",url.pathname+(url.search?url.search:"")+url.hash),dirty=!0)}catch(e){}return dirty}function syncInstockUI(){var sizes=getActiveSizeFilters(),hasSizeFilter=sizes.length>0,instock=isInstockEnabled();hasSizeFilter?writeInstockUrl(instock):(instock||getInstockFromUrl()!==null?saveInstock(!1):syncInstockFormInputs(!1),instock=!1,clearClientHides()),document.documentElement.classList.toggle("ymi-size-filter-active",hasSizeFilter),document.body.classList.toggle("ymi-size-filter-active",hasSizeFilter),qsa("[data-ymi-my-size], .ymi-my-size-bar").forEach(function(wrap){wrap.classList.toggle("ymi-my-size--size-active",hasSizeFilter),wrap.classList.toggle("ymi-my-size--instock-on",hasSizeFilter&&instock),hasSizeFilter?(wrap.hidden=!1,wrap.style.removeProperty("display")):(wrap.hidden=!0,wrap.style.display="none");var toggle=qs("[data-ymi-instock-toggle]",wrap);toggle&&(toggle.disabled=!hasSizeFilter,toggle.checked=hasSizeFilter&&instock)}),applyClientSizeFilter(hasSizeFilter,sizes,hasSizeFilter&&instock)}function scheduleSync(delay){clearTimeout(syncTimer),syncTimer=setTimeout(syncInstockUI,delay||0)}function initInstockInMySize(){qsa(".ymi-my-size__row, .ymi-my-size__label, .ymi-my-size__select, .ymi-my-size__change, [data-ymi-my-size-select], [data-ymi-my-size-change]").forEach(function(el){el.style.display="none"}),stripStaleAvailability(),syncInstockUI(),document.addEventListener("change",function(e){var toggle=e.target.closest&&e.target.closest("[data-ymi-instock-toggle]");if(!toggle&&e.target.matches&&e.target.matches("[data-ymi-instock-toggle]")&&(toggle=e.target),toggle){if(toggle.disabled)return;var sizes=getActiveSizeFilters();if(!sizes.length){toggle.checked=!1,saveInstock(!1),syncInstockUI();return}saveInstock(!!toggle.checked),qsa("[data-ymi-instock-toggle]").forEach(function(other){other!==toggle&&(other.checked=toggle.checked)}),syncInstockUI();return}e.target.closest&&e.target.closest(".filter-form")&&(scheduleSync(300),scheduleSync(900))}),document.addEventListener("click",function(e){e.target.closest&&e.target.closest(".tag--remove, #reset, .form_clear, .ymi-filter-chips a")&&(scheduleSync(300),scheduleSync(900));var instockLabel=e.target.closest&&e.target.closest(".ymi-my-size__instock");if(instockLabel){var input=qs("[data-ymi-instock-toggle]",instockLabel);
1!input||input.disabled||e.target!==input&&(e.preventDefault(),input.checked=!input.checked,input.dispatchEvent(new Event("change",{bubbles:!0})))}}),window.addEventListener("popstate",function(){scheduleSync(100)}),document.addEventListener("collection:reloaded",function(){scheduleSync(50),scheduleSync(400)})}function getStickyTop(){var banner=document.getElementById("shopify-section-birthday-banner");if(banner&&isVisible(banner))return Math.max(0,Math.round(banner.getBoundingClientRect().bottom));var headerEl=qs('.active-header [data-section-type="header"]')||qs(".active-header .site-header")||qs(".active-header");if(headerEl&&isVisible(headerEl))return Math.max(0,Math.round(headerEl.getBoundingClientRect().bottom));var stack=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--mobile-sticky-stack"));return isNaN(stack)?0:Math.round(stack)}function ensureSpacer(){return!bar||!bar.parentNode?null:(spacer&&spacer.parentNode||(spacer=document.createElement("div"),spacer.className="ymi-filter-bar-spacer",spacer.setAttribute("aria-hidden","true"),bar.parentNode.insertBefore(spacer,bar)),spacer)}function unpinBar(){!bar||!fixed||(bar.classList.remove("ymi-filter-bar--fixed"),bar.style.top="",bar.style.width="",bar.style.left="",spacer&&(spacer.classList.remove("is-active"),spacer.style.height=""),fixed=!1)}function pinBar(top){if(bar){var height=Math.ceil(bar.getBoundingClientRect().height),sp=ensureSpacer();sp&&(sp.style.height=height+"px",sp.classList.add("is-active")),bar.classList.add("ymi-filter-bar--fixed"),bar.style.top=top+"px",fixed=!0}}function updateStickyBar(){if(bar=qs(".collection-sidebar .filters-container_mobile")||qs(".filters-container_mobile"),!bar||!isMobile()||isDrawerOpen()){unpinBar(),document.documentElement.style.removeProperty("--collection-sticky-top");return}var top=getStickyTop();document.documentElement.style.setProperty("--collection-sticky-top",top+"px"),fixed?spacer&&spacer.classList.contains("is-active")&&(naturalTop=spacer.getBoundingClientRect().top+window.scrollY):naturalTop=bar.getBoundingClientRect().top+window.scrollY,window.scrollY+top>=naturalTop-1?pinBar(top):unpinBar()}function preventDrawerCloseOnInnerClick(){var drawer=document.getElementById("FilterDrawer");!drawer||drawer.getAttribute("data-ymi-drawer-guard")==="1"||(drawer.setAttribute("data-ymi-drawer-guard","1"),["click","touchend","mousedown"].forEach(function(evtName){drawer.addEventListener(evtName,function(e){e.target.closest(".js-drawer-close, .form_close, .drawer__close")||e.stopPropagation()})}))}function init(){initInstockInMySize(),preventDrawerCloseOnInnerClick(),updateStickyBar();var ajaxScheduled=!1;function onAjaxDomChange(){ajaxScheduled||(ajaxScheduled=!0,requestAnimationFrame(function(){ajaxScheduled=!1,scheduleSync(50),scheduleSync(400),scheduleSync(1e3),preventDrawerCloseOnInnerClick(),updateStickyBar()}))}if(window.addEventListener("scroll",function(){requestAnimationFrame(updateStickyBar)},{passive:!0}),window.addEventListener("resize",function(){updateStickyBar(),scheduleSync(100)},{passive:!0}),window.addEventListener("orientationchange",function(){updateStickyBar(),scheduleSync(100)}),document.addEventListener("header:toggle",updateStickyBar),document.addEventListener("mobile-header:sticky-change",updateStickyBar),typeof MutationObserver!="undefined"){var ajaxRoot=document.getElementById("CollectionAjaxContent");if(ajaxRoot){var mo=new MutationObserver(onAjaxDomChange);mo.observe(ajaxRoot,{childList:!0,subtree:!1})}}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",init):init()})();
2//# sourceMappingURL=/cdn/shop/t/131/assets/collection-ux.js.map?v=39208674119749185081789670067

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.