1class BlogSorting{constructor(){this.articleGrid=null,this.articles=[],this.currentSort="published-desc",this.init()}init(){if(this.articleGrid=document.querySelector("#blog-article-grid"),!this.articleGrid){console.warn("[BlogSorting] Article grid not found");return}const urlParams=new URLSearchParams(window.location.search);this.currentSort=urlParams.get("sort_by")||"published-desc",this.storeArticlesData(),this.sortArticles(this.currentSort),this.attachSortListeners()}storeArticlesData(){this.articleGrid.querySelectorAll("li.article-item").forEach(item=>{const title=item.getAttribute("data-article-title")||"",dateStr=item.getAttribute("data-article-date"),date=dateStr?new Date(dateStr):new Date;this.articles.push({element:item,title,date,originalClass:item.className,isLarge:item.classList.contains("article-large")})})}sortArticles(sortType){let sortedArticles=[...this.articles];switch(sortType){case"title-asc":sortedArticles.sort((a,b)=>a.title.localeCompare(b.title));break;case"title-desc":sortedArticles.sort((a,b)=>b.title.localeCompare(a.title));break;case"published-asc":sortedArticles.sort((a,b)=>a.date-b.date);break;default:sortedArticles.sort((a,b)=>b.date-a.date);break}this.articleGrid.innerHTML="",sortedArticles.forEach((article,index)=>{const position=index%7+1,shouldBeLarge=position===1||position===7,element=article.element;element.className=article.originalClass,shouldBeLarge&&!element.classList.contains("article-large")?element.classList.add("article-large"):!shouldBeLarge&&element.classList.contains("article-large")&&element.classList.remove("article-large"),this.articleGrid.appendChild(element)}),this.currentSort=sortType}attachSortListeners(){document.querySelectorAll(".facet-checkbox[data-sort-value]").forEach(link=>{link.addEventListener("click",e=>{e.preventDefault();const sortValue=link.getAttribute("data-sort-value");this.sortArticles(sortValue);const url=new URL(window.location);url.searchParams.set("sort_by",sortValue),window.history.pushState({},"",url),document.querySelectorAll(".facet-checkbox").forEach(l=>l.classList.remove("active")),link.classList.add("active"),this.updateSortLabel(sortValue);const details=link.closest("details");details&&details.removeAttribute("open")})})}updateSortLabel(sortValue){const label=document.getElementById("current-sort-label");if(!label)return;const labels={"title-asc":"A-Z","title-desc":"Z-A","published-asc":"Old to New","published-desc":"New to Old"};label.textContent=labels[sortValue]||"New to Old"}reinitialize(){this.articles=[],this.articleGrid=document.querySelector("#blog-article-grid"),this.articleGrid&&(this.storeArticlesData(),this.sortArticles(this.currentSort))}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{window.blogSorting=new BlogSorting}):window.blogSorting=new BlogSorting,window.addEventListener("blogArticlesLoaded",()=>{window.blogSorting&&window.blogSorting.reinitialize()}); 2//# sourceMappingURL=/cdn/shop/t/426/assets/blog-sorting.js.map?v=93241942339776268571771605017
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.