PageSourceSearch

https://tacsi.org.au/wp-content/themes/tacsi/blocks/post-archive/block.min.js?ver=1.0.3

js tacsi.org.au collected 2026-10-02 03:42:10 UTC 6,541 bytes, 1 lines download raw bytes

1(()=>{function a(){return window.matchMedia("(prefers-reduced-motion: reduce)").matches}var h="(max-width: 781px)",u=250;function o(e){let t={};return Object.keys(e||{}).forEach(i=>{t[i]=Array.isArray(e[i])?[...e[i]]:[]}),t}function l(e){return Object.values(e||{}).reduce((t,i)=>t+(Array.isArray(i)?i.length:0),0)}function f(e,t){let i=new Set([...Object.keys(e||{}),...Object.keys(t||{})]);for(let s of i){let r=Array.isArray(e?.[s])?[...e[s]].sort().join(","):"",n=Array.isArray(t?.[s])?[...t[s]].sort().join(","):"";if(r!==n)return!1}return!0}function d(e,t){if(!e||typeof t!="string"||!t.trim())return 0;let i=e.querySelectorAll(".post-archive__card").length,s=e.querySelector(".post-archive__grid"),n=new DOMParser().parseFromString(t,"text/html").querySelector(".post-archive__grid");return s&&n?s.insertAdjacentHTML("beforeend",n.innerHTML):e.insertAdjacentHTML("beforeend",t),e.querySelectorAll(".post-archive__card").length-i}function c(){return{config:{},activeFilters:{},pendingFilters:{},page:1,hasMore:!1,loading:!1,loadingMore:!1,mobileOpen:!1,mobileTrigger:null,showBackToTop:!1,announcement:"",fetchTimer:null,mobileMq:null,archiveEl:null,resultsEl:null,backToTopScrollUpdate:null,get activeFilterCount(){return l(this.activeFilters)},init(){let e=this.$el.dataset.postArchiveConfig||"{}";try{this.config=JSON.parse(e)}catch{this.config={}}this.activeFilters=o(this.config.initialFilters||{}),this.pendingFilters=o(this.activeFilters),this.hasMore=!!this.config.initialHasMore,this.archiveEl=this.$el?.closest?.(".post-archive")??this.$el,this.resultsEl=this.archiveEl?.querySelector(".post-archive__results")??null,this.mobileMq=window.matchMedia(h),this.$watch("mobileOpen",t=>{document.body.style.overflow=t?"hidden":""}),this.syncUrl(!1),this.setupBackToTopVisibility()},destroy(){this.backToTopScrollUpdate&&(window.removeEventListener("scroll",this.backToTopScrollUpdate),this.backToTopScrollUpdate=null)},getBackToTopTarget(){return this.config.blockId?document.getElementById(this.config.blockId):this.archiveEl??null},setupBackToTopVisibility(){let e=this.getBackToTopTarget();if(!e)return;let t=()=>{this.showBackToTop=e.getBoundingClientRect().top<0};t(),this.backToTopScrollUpdate=t,window.addEventListener("scroll",t,{passive:!0})},isActive(e,t){return Array.isArray(this.activeFilters[e])?this.activeFilters[e].includes(t):!1},isPending(e,t){return Array.isArray(this.pendingFilters[e])?this.pendingFilters[e].includes(t):!1},hasActive(){return l(this.activeFilters)>0},hasPending(){return l(this.pendingFilters)>0},toggleSlug(e,t,i,s){let r=o(e);return Array.isArray(r[t])||(r[t]=[]),s?r[t].includes(i)||r[t].push(i):r[t]=r[t].filter(n=>n!==i),r[t].length||delete r[t],r},toggleActive(e,t,i){this.activeFilters=this.toggleSlug(this.activeFilters,e,t,i),this.pendingFilters=o(this.activeFilters),this.scheduleFetch(!0)},togglePending(e,t,i){this.pendingFilters=this.toggleSlug(this.pendingFilters,e,t,i)},clearActive(){this.activeFilters={},this.pendingFilters={},this.scheduleFetch(!0)},clearPending(){this.pendingFilters={}},scheduleFetch(e){this.fetchTimer&&window.clearTimeout(this.fetchTimer),this.fetchTimer=window.setTimeout(()=>{this.fetchResults(e)},u)},async fetchResults(e=!0){if(this.config.restUrl){e&&(this.page=1),this.loading=!0;try{let t=await fetch(this.config.restUrl,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":this.config.nonce||""},body:JSON.stringify({post_type:this.config.postType,archive_preset:this.config.archivePreset||this.config.postType,filters:this.activeFilters,page:this.page,per_page:this.config.perPage||18,append:!1})});if(!t.ok)throw new Error("Archive query failed");let i=await t.json();this.resultsEl&&typeof i.html=="string"&&(this.resultsEl.innerHTML=i.html),this.hasMore=!!i.has_more,this.announcement=i.total?`${i.total} results`:"No results",this.syncUrl(!0)}catch{this.announcement="Could not update results"}finally{this.loading=!1}}},async loadMore(){if(this.loadingMore||!this.hasMore||!this.config.restUrl)return;this.loadingMore=!0;let e=this.page+1;try{let t=await fetch(this.config.restUrl,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-WP-Nonce":this.config.nonce||""},body:JSON.stringify({post_type:this.config.postType,archive_preset:this.config.archivePreset||this.config.postType,filters:this.activeFilters,page:e,per_page:this.config.perPage||18,append:!0})});if(!t.ok)throw new Error("Archive load more failed");let i=await t.json(),s=d(this.resultsEl,i.html);this.page=e,s>0&&(this.announcement=s===1?"Loaded 1 more result":`Loaded ${s} more results`),(s>0||!i.has_more)&&(this.hasMore=!!i.has_more)}catch{}finally{this.loadingMore=!1}},syncUrl(e){let t=this.config.filterGroups||[],i=new URL(window.location.href);t.forEach(r=>{r?.taxonomy&&i.searchParams.delete(r.taxonomy)}
1),Object.entries(this.activeFilters).forEach(([r,n])=>{!Array.isArray(n)||!n.length||i.searchParams.set(r,n.join(","))});let s=`${i.pathname}${i.search}${i.hash}`;`${window.location.pathname}${window.location.search}${window.location.hash}`!==s&&e&&window.history.replaceState({},"",s)},openMobile(e){e?.currentTarget instanceof HTMLElement&&(this.mobileTrigger=e.currentTarget),this.pendingFilters=o(this.activeFilters),this.mobileOpen=!0,this.$nextTick(()=>{this.$refs.modalPanel?.querySelector(".post-archive__modal-close")?.focus()})},closeMobile(){let e=this.mobileTrigger;this.pendingFilters=o(this.activeFilters),this.mobileOpen=!1,this.$nextTick(()=>{e instanceof HTMLElement&&document.contains(e)&&e.focus()})},applyMobile(){let e=this.mobileTrigger;f(this.activeFilters,this.pendingFilters)||(this.activeFilters=o(this.pendingFilters),this.scheduleFetch(!0)),this.mobileOpen=!1,this.$nextTick(()=>{e instanceof HTMLElement&&document.contains(e)&&e.focus()})},handleMobileTabKey(e){if(!this.mobileOpen||e.key!=="Tab")return;let t=this.$refs.modalPanel;if(!t)return;let i=[...t.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])')].filter(n=>n instanceof HTMLElement&&n.offsetParent!==null);if(!i.length)return;let s=i[0],r=i[i.length-1];e.shiftKey&&document.activeElement===s?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),s.focus())},backToTop(){this.getBackToTopTarget()?.scrollIntoView({behavior:a()?"auto":"smooth",block:"start"})}}}document.addEventListener("alpine:init",()=>{Alpine.data("postArchive",c)});})();

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.