| | |
| | | (()=>{class e{constructor(){this.liveRegion=document.querySelector(".screen-reader-text.live-region"),this.liveRegion||console.log("No accessibility region.")}announce(e,t="polite"){this.liveRegion&&(this.liveRegion.setAttribute("aria-live",t),this.liveRegion.textContent="",setTimeout((()=>{this.liveRegion.textContent=e}),50))}announceItems(e,t=!1,n=!0){const o=t?"Added":"Loaded",i=n?". More available to load.":". No more available to load.";this.announce(`${o} ${e} new items${i}`)}announceEmpty(e=!1){const t=e?"No favourites found. Try adding some items to your collection.":"No items found matching your current filters.";this.announce(t)}announceNavigation(e,t,n=!1,o=!1){n?this.announce("At first image"):o?this.announce("At last image"):this.announce(`Image ${e} of ${t}`)}trapFocus(e,t=null){if(!e)return()=>{};const n=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!n.length)return()=>{};const o=n[0],i=n[n.length-1],a=t||document.activeElement;o.focus();const r=e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===o?(i.focus(),e.preventDefault()):e.shiftKey||document.activeElement!==i||(o.focus(),e.preventDefault()))};return e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r),a&&"function"==typeof a.focus&&a.focus()}}makeNavigable(e,t){e&&e.length&&Array.from(e).forEach((e=>{e.getAttribute("data-keyboard-nav")||(e.setAttribute("data-keyboard-nav","true"),e.setAttribute("tabindex","0"),e.addEventListener("keydown",(n=>{if("Enter"===n.key||" "===n.key)if(n.preventDefault(),t)t(e);else{const t=e.querySelector("a");t&&t.click()}})))}))}}document.addEventListener("DOMContentLoaded",(function(){window.jvbA11y=new e}))})(); |
| | | (()=>{class e{constructor(){this.liveRegion=document.querySelector(".screen-reader-text.live-region"),this.liveRegion||console.log("No accessibility region.")}announce(e,t="polite"){this.liveRegion&&(this.liveRegion.setAttribute("aria-live",t),this.liveRegion.textContent="",setTimeout(()=>{this.liveRegion.textContent=e},50))}announceItems(e,t=!1,n=!0){const o=t?"Added":"Loaded",i=n?". More available to load.":". No more available to load.";this.announce(`${o} ${e} new items${i}`)}announceEmpty(e=!1){const t=e?"No favourites found. Try adding some items to your collection.":"No items found matching your current filters.";this.announce(t)}announceNavigation(e,t,n=!1,o=!1){n?this.announce("At first image"):o?this.announce("At last image"):this.announce(`Image ${e} of ${t}`)}trapFocus(e,t=null){if(!e)return()=>{};const n=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!n.length)return()=>{};const o=n[0],i=n[n.length-1],a=t||document.activeElement;o.focus();const r=e=>{"Tab"===e.key&&(e.shiftKey&&document.activeElement===o?(i.focus(),e.preventDefault()):e.shiftKey||document.activeElement!==i||(o.focus(),e.preventDefault()))};return e.addEventListener("keydown",r),()=>{e.removeEventListener("keydown",r),a&&"function"==typeof a.focus&&a.focus()}}makeNavigable(e,t){e&&e.length&&Array.from(e).forEach(e=>{e.getAttribute("data-keyboard-nav")||(e.setAttribute("data-keyboard-nav","true"),e.setAttribute("tabindex","0"),e.addEventListener("keydown",n=>{if("Enter"===n.key||" "===n.key)if(n.preventDefault(),t)t(e);else{const t=e.querySelector("a");t&&t.click()}}))})}}document.addEventListener("DOMContentLoaded",function(){window.jvbA11y=new e})})(); |