PageSourceSearch

https://www.firstmats.co.uk/cdn/shop/t/342/assets/fm-sort-select.js?v=102392696400075559561785944296

js firstmats.co.uk collected 2026-10-02 05:29:27 UTC 5,178 bytes, 2 lines download raw bytes

1(function(){"use strict";var uid=0;function enhance(select){if(select.getAttribute("data-fm-sortsel")==="on")return;var wrap=select.closest(".select");if(!wrap)return;select.setAttribute("data-fm-sortsel","on"),uid+=1;var listId="FmSortSelList-"+uid,optIdBase="FmSortSelOpt-"+uid+"-",box=document.createElement("div");box.className="fm-sortsel";var btn=document.createElement("button");btn.type="button",btn.className="fm-sortsel__btn",btn.setAttribute("aria-haspopup","listbox"),btn.setAttribute("aria-expanded","false"),btn.setAttribute("aria-controls",listId),btn.setAttribute("aria-label","Sort by");var valueEl=document.createElement("span");valueEl.className="fm-sortsel__value";var chev=document.createElement("span");chev.className="fm-sortsel__chev",chev.setAttribute("aria-hidden","true"),btn.appendChild(valueEl),btn.appendChild(chev);var list=document.createElement("ul");list.className="fm-sortsel__list",list.id=listId,list.setAttribute("role","listbox"),list.setAttribute("tabindex","-1"),list.hidden=!0;var rows=[];if(Array.prototype.forEach.call(select.options,function(opt,i){var li=document.createElement("li");li.className="fm-sortsel__opt",li.id=optIdBase+i,li.setAttribute("role","option"),li.setAttribute("data-value",opt.value),li.textContent=opt.text.trim(),li.setAttribute("aria-selected",opt.selected?"true":"false"),opt.selected&&li.classList.add("is-selected"),list.appendChild(li),rows.push(li)}),!rows.length)return;var activeIndex=Math.max(0,select.selectedIndex);function syncButton(){var opt=select.options[select.selectedIndex];valueEl.textContent=opt?opt.text.trim():""}function setActive(i){i<0&&(i=0),i>rows.length-1&&(i=rows.length-1),activeIndex=i,rows.forEach(function(r,n){r.classList.toggle("is-active",n===i)}),list.setAttribute("aria-activedescendant",rows[i].id),rows[i].scrollIntoView&&rows[i].scrollIntoView({block:"nearest"})}var isOpen=!1;function open(){if(!isOpen){isOpen=!0,list.hidden=!1,box.classList.add("is-open"),btn.setAttribute("aria-expanded","true"),box.classList.remove("is-above");var btnRect=btn.getBoundingClientRect(),listH=list.getBoundingClientRect().height,roomBelow=window.innerHeight-btnRect.bottom,roomAbove=btnRect.top;roomBelow<listH+12&&roomAbove>roomBelow&&box.classList.add("is-above"),setActive(select.selectedIndex<0?0:select.selectedIndex),list.focus({preventScroll:!0})}}function close(returnFocus){isOpen&&(isOpen=!1,list.hidden=!0,box.classList.remove("is-open"),btn.setAttribute("aria-expanded","false"),list.removeAttribute("aria-activedescendant"),returnFocus&&btn.focus())}function commit(i){var opt=select.options[i];if(opt){var changed=select.selectedIndex!==i;select.selectedIndex=i,rows.forEach(function(r,n){r.setAttribute("aria-selected",n===i?"true":"false"),r.classList.toggle("is-selected",n===i)}),syncButton(),close(!0),changed&&(select.dispatchEvent(new Event("input",{bubbles:!0})),select.dispatchEvent(new Event("change",{bubbles:!0})))}}btn.addEventListener("click",function(){isOpen?close(!0):open()}),btn.addEventListener("keydown",function(event){var k=event.key;(k==="ArrowDown"||k==="ArrowUp"||k==="Enter"||k===" "||k==="Spacebar")&&(event.preventDefault(),open())}),list.addEventListener("keydown",function(event){var k=event.key;k==="Escape"?(event.preventDefault(),close(!0)):k==="ArrowDown"?(event.preventDefault(),setActive(activeIndex+1)):k==="ArrowUp"?(event.preventDefault(),setActive(activeIndex-1)):k==="Home"?(event.preventDefault(),setActive(0)):k==="End"?(event.preventDefault(),setActive(rows.length-1)):k==="Enter"||k===" "||k==="Spacebar"?(event.preventDefault(),commit(activeIndex)):k==="Tab"&&close(!1)}),list.addEventListener("mousedown",function(event){var row=event.target.closest(".fm-sortsel__opt");row&&(event.preventDefault(),commit(rows.indexOf(row)))}),list.addEventListener("mousemove",function(event){var row=event.target.closest(".fm-sortsel__opt");row&&setActive(rows.indexOf(row))}),document.addEventListener("mousedown",function(event){isOpen&&(box.contains(event.target)||close(!1))}),select.addEventListener("change",function(){syncButton(),rows.forEach(function(r,n){r.setAttribute("aria-selected",n===select.selectedIndex?"true":"false"),r.classList.toggle("is-selected",n===select.selectedIndex)})}),syncButton(),box.appendChild(btn),box.appendChild(list),wrap.appendChild(box),wrap.classList.add("fm-sortsel-host")}function run(){var selects=document.querySelectorAll('select[name="sort_by"]');Array.prototype.forEach.call(selects,function(select){select.closest(".mobile-facets__wrapper")||select.id!=="SortBy-mobile"&&enhance(select)})}var observed=[];function watch(){var pending,rerun=function(){clearTimeout(pending),pending=setTimeout(run,120)};Array.prototype.forEach.call(document.querySelectorAll(".sorting"),function(row){observed.indexOf(row)===-1&&(observed.push(row),new MutationObserver(rerun).observe(row,{childList:!0,subtree:!0}))})}function boot(){run(),watch()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",boot):boot(),document.addEventListener("fm:sort-select:refresh",boot)})();
2//# sourceMappingURL=/cdn/shop/t/342/assets/fm-sort-select.js.map?v=102392696400075559561785944296

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.