PageSourceSearch

https://www.hannoush.com/cdn/shop/t/40/assets/accessibility-widget.js?v=68178804598888878251779931333

js hannoush.com collected 2026-09-24 12:06:31 UTC 16,894 bytes, 2 lines download raw bytes

1(function(){"use strict";if(window.customElements&&customElements.get("accessibility-widget"))return;var DEFAULT_STORAGE_KEY="theme:a11y:prefs",TOGGLE_KEYS=["contrast","text-size","text-spacing","line-height","text-align","pause-animations","hide-images","dyslexia","cursor","highlight-links","saturation","oversized"],VALID_POSITIONS=["bottom-right","bottom-left","middle-right","middle-left","top-right","top-left","left","right","hidden"];function normalisePosition(pos,fallback){return VALID_POSITIONS.indexOf(pos)===-1?fallback:pos}var PROFILES={motor_impaired:{cursor:"large","highlight-links":!0,oversized:!0},blind:{"pause-animations":!0,"hide-images":!0,"highlight-links":!0},color_blind:{saturation:"grey",contrast:"high","highlight-links":!0},dyslexia:{dyslexia:!0,"text-spacing":!0,"line-height":!0,"text-align":"left","text-size":"L"},low_vision:{"text-size":"XL",contrast:"high",cursor:"large",oversized:!0},cognitive:{"text-spacing":!0,"line-height":!0,"hide-images":!0,"pause-animations":!0,"text-size":"L"},seizure:{"pause-animations":!0,saturation:"low","hide-images":!0},adhd:{"pause-animations":!0,"hide-images":!0,"text-align":"left","line-height":!0}};function safeAnnounce(message,politeness){window.A11y&&typeof window.A11y.announce=="function"&&window.A11y.announce(message,{politeness:politeness||"polite"})}function safeTrapFocus(container,opts){window.A11y&&typeof window.A11y.trapFocus=="function"&&window.A11y.trapFocus(container,opts)}function safeReleaseFocus(){window.A11y&&typeof window.A11y.releaseFocus=="function"&&window.A11y.releaseFocus()}function emptyPrefs(defaultPosition){for(var p={},i=0;i<TOGGLE_KEYS.length;i++)p[TOGGLE_KEYS[i]]=null;return p.position=normalisePosition(defaultPosition,"bottom-right"),p}class AccessibilityWidget extends HTMLElement{constructor(){super(),this._defaultPosition="bottom-right",this._prefs=emptyPrefs(this._defaultPosition),this._open=!1,this._mutationDebounce=null,this._activeProfile=null,this._reducedMotionQuery=null,this._onReducedMotionChange=this._onReducedMotionChange.bind(this),this._onGlobalKeydown=this._onGlobalKeydown.bind(this)}connectedCallback(){this.storageKey=this.dataset.storageKey||DEFAULT_STORAGE_KEY,this._defaultPosition=normalisePosition(this.dataset.defaultPosition,"bottom-right"),this.launcher=this.querySelector(".a11y-widget__launcher"),this.panel=this.querySelector(".a11y-widget__panel"),this.closeBtn=this.querySelector(".a11y-widget__close"),this.resetBtn=this.querySelector(".a11y-widget__reset"),this.profileButtons=Array.from(this.querySelectorAll(".a11y-widget__profile")),this.toggleButtons=Array.from(this.querySelectorAll(".a11y-widget__toggle[data-toggle-key]")),this.pageStructureToggle=this.querySelector(".a11y-widget__toggle--page-structure"),this.pageStructureSection=this.querySelector(".a11y-widget__page-structure"),this.positionButtons=Array.from(this.querySelectorAll(".a11y-widget__position-grid button[data-position], .a11y-widget__position-options button[data-position]")),this.psTabs=Array.from(this.querySelectorAll('[role="tab"][data-ps-tab]')),this.psPanels={headings:this.querySelector("#ps-panel-headings"),landmarks:this.querySelector("#ps-panel-landmarks"),links:this.querySelector("#ps-panel-links")},this._loadPrefs(),this._applyAllPrefs(),this._renderAllToggles(),this._renderPosition(),this._bindEvents(),this._initReducedMotionLock(),this._initPageStructureScanner()}disconnectedCallback(){document.removeEventListener("keydown",this._onGlobalKeydown),this._reducedMotionQuery&&(typeof this._reducedMotionQuery.removeEventListener=="function"?this._reducedMotionQuery.removeEventListener("change",this._onReducedMotionChange):typeof this._reducedMotionQuery.removeListener=="function"&&this._reducedMotionQuery.removeListener(this._onReducedMotionChange)),this._mutationObserver&&this._mutationObserver.disconnect(),this._mutationDebounce&&clearTimeout(this._mutationDebounce)}_loadPrefs(){var raw=null;try{raw=localStorage.getItem(this.storageKey)}catch{}if(!raw){this._prefs=emptyPrefs(this._defaultPosition),this._prefs.merchantDefaultSeen=this._defaultPosition;return}try{var parsed=JSON.parse(raw),fresh=emptyPrefs(this._defaultPosition);for(var k in parsed)Object.prototype.hasOwnProperty.call(parsed,k)&&Object.prototype.hasOwnProperty.call(fresh,k)&&
1(fresh[k]=parsed[k]);var lastSeen=parsed.merchantDefaultSeen||null;lastSeen!==this._defaultPosition?fresh.position=this._defaultPosition:fresh.position=normalisePosition(parsed.position,this._defaultPosition),fresh.position==="hidden"&&(fresh.position=this._defaultPosition),fresh.merchantDefaultSeen=this._defaultPosition,this._prefs=fresh}catch{this._prefs=emptyPrefs(this._defaultPosition),this._prefs.merchantDefaultSeen=this._defaultPosition}}_savePrefs(){for(var toSave={},i=0;i<TOGGLE_KEYS.length;i++)toSave[TOGGLE_KEYS[i]]=this._prefs[TOGGLE_KEYS[i]];toSave.position=this._prefs.position,toSave.merchantDefaultSeen=this._defaultPosition;try{localStorage.setItem(this.storageKey,JSON.stringify(toSave))}catch{}}_applyAllPrefs(){for(var html=document.documentElement,i=0;i<TOGGLE_KEYS.length;i++){var k=TOGGLE_KEYS[i];this._applyPrefAttr(k,this._prefs[k])}this.setAttribute("data-position",normalisePosition(this._prefs.position,this._defaultPosition))}_applyPrefAttr(key,value){var html=document.documentElement,attr="data-a11y-"+key;value==null||value===!1?html.removeAttribute(attr):html.setAttribute(attr,String(value))}_bindEvents(){var self=this;this.launcher&&this.launcher.addEventListener("click",function(){self.toggle()}),this.closeBtn&&this.closeBtn.addEventListener("click",function(){self.close()}),this.resetBtn&&this.resetBtn.addEventListener("click",function(){self._onReset()}),this.toggleButtons.forEach(function(btn){btn.addEventListener("click",function(){self._onToggleClick(btn)})}),this.pageStructureToggle&&this.pageStructureToggle.addEventListener("click",function(){self._onPageStructureToggle()}),this.profileButtons.forEach(function(btn){btn.addEventListener("click",function(){self._onProfileClick(btn)})}),this.positionButtons.forEach(function(btn){btn.addEventListener("click",function(){self._onPositionClick(btn)})}),this.psTabs.forEach(function(tab){tab.addEventListener("click",function(){self._activateTab(tab)}),tab.addEventListener("keydown",function(e){self._onTabKeydown(e,tab)})}),document.addEventListener("keydown",this._onGlobalKeydown)}_onGlobalKeydown(e){(e.ctrlKey||e.metaKey)&&!e.shiftKey&&!e.altKey&&(e.key==="u"||e.key==="U")&&(e.preventDefault(),this.toggle())}toggle(){this._open?this.close():this.open()}open(){if(!(this._open||!this.panel)){this._open=!0,this.panel.setAttribute("aria-hidden","false"),this.panel.removeAttribute("inert"),document.body.classList.add("a11y-widget-open"),this.launcher&&this.launcher.setAttribute("aria-expanded","true");var self=this;safeTrapFocus(this.panel,{initialFocus:this.closeBtn||this.panel,returnFocus:this.launcher,onEscape:function(){self.close()}})}}close(){!this._open||!this.panel||(this._open=!1,this.panel.setAttribute("aria-hidden","true"),this.panel.setAttribute("inert",""),document.body.classList.remove("a11y-widget-open"),this.launcher&&this.launcher.setAttribute("aria-expanded","false"),safeReleaseFocus())}_onToggleClick(btn){var key=btn.getAttribute("data-toggle-key");if(key&&!(btn.hasAttribute("disabled")||btn.getAttribute("aria-disabled")==="true")){var cycle=btn.getAttribute("data-toggle-cycle"),newValue;if(cycle){var values=cycle.split(",").map(function(v){return v.trim()}).filter(Boolean),current=this._prefs[key],idx=values.indexOf(current);idx===-1?newValue=values[0]||null:idx===values.length-1?newValue=null:newValue=values[idx+1]}else{var rawVal=btn.getAttribute("data-toggle-value"),isOn=this._prefs[key]!==null&&this._prefs[key]!==void 0&&this._prefs[key]!==!1;isOn?newValue=null:newValue=rawVal==="true"?!0:rawVal}this._prefs[key]=newValue,this._savePrefs(),this._applyPrefAttr(key,newValue),this._renderToggle(btn),this._refreshActiveProfile();var label=(btn.textContent||key).trim(),stateText=newValue===null?"off":typeof newValue=="string"&&newValue!=="true"?newValue:"on";
1safeAnnounce(label+" "+stateText,"polite")}}_renderToggle(btn){var key=btn.getAttribute("data-toggle-key");if(key){var value=this._prefs[key],on=value!=null&&value!==!1;btn.setAttribute("aria-pressed",on?"true":"false"),on&&typeof value=="string"?btn.setAttribute("data-current-value",value):btn.removeAttribute("data-current-value")}}_renderAllToggles(){var self=this;this.toggleButtons.forEach(function(btn){self._renderToggle(btn)}),this._refreshActiveProfile()}_onPageStructureToggle(){if(!(!this.pageStructureSection||!this.pageStructureToggle)){var shown=!this.pageStructureSection.hasAttribute("hidden");shown?(this.pageStructureSection.setAttribute("hidden",""),this.pageStructureToggle.setAttribute("aria-pressed","false"),safeAnnounce("Page structure hidden","polite")):(this.pageStructureSection.removeAttribute("hidden"),this.pageStructureToggle.setAttribute("aria-pressed","true"),this._scanPageStructure(),safeAnnounce("Page structure shown","polite"))}}_showPageStructure(){if(!(!this.pageStructureSection||!this.pageStructureToggle)){this.pageStructureSection.removeAttribute("hidden"),this.pageStructureToggle.setAttribute("aria-pressed","true"),this._scanPageStructure();var self=this;window.requestAnimationFrame(function(){try{self.pageStructureSection.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}catch{self.pageStructureSection.scrollIntoView()}})}}_onProfileClick(btn){var key=btn.getAttribute("data-profile");if(!(!key||!PROFILES[key])){var bundle=PROFILES[key],label=(btn.textContent||key).trim();if(this._activeProfile===key){for(var k in bundle)Object.prototype.hasOwnProperty.call(bundle,k)&&(this._prefs[k]=null,this._applyPrefAttr(k,null));this._activeProfile=null,btn.setAttribute("aria-pressed","false"),this._savePrefs(),this._renderAllToggles(),safeAnnounce(label
1+" off","polite");return}for(var k2 in bundle)Object.prototype.hasOwnProperty.call(bundle,k2)&&(this._prefs[k2]=bundle[k2],this._applyPrefAttr(k2,bundle[k2]));this._activeProfile=key,this.profileButtons.forEach(function(b){b.setAttribute("aria-pressed",b===btn?"true":"false")}),this._savePrefs(),this._renderAllToggles(),key==="blind"&&this._showPageStructure(),safeAnnounce(label+" on","polite")}}_refreshActiveProfile(){var active=null;for(var name in PROFILES)if(Object.prototype.hasOwnProperty.call(PROFILES,name)){var bundle=PROFILES[name],keys=Object.keys(bundle);if(keys.length!==0){for(var match=!0,i=0;i<keys.length;i++)if(this._prefs[keys[i]]!==bundle[keys[i]]){match=!1;break}if(match){active=name;break}}}this._activeProfile=active,this.profileButtons.forEach(function(b){b.setAttribute("aria-pressed",b.getAttribute("data-profile")===active?"true":"false")})}_onReset(){try{localStorage.removeItem(this.storageKey)}catch{}var pos=this._prefs.position;this._prefs=emptyPrefs(this._defaultPosition),this._prefs.position=normalisePosition(pos,this._defaultPosition),this._prefs.merchantDefaultSeen=this._defaultPosition;for(var i=0;i<TOGGLE_KEYS.length;i++)document.documentElement.removeAttribute("data-a11y-"+TOGGLE_KEYS[i]);this._renderAllToggles(),this.profileButtons.forEach(function(b){b.setAttribute("aria-pressed","false")}),this._activeProfile=null,this.pageStructureSection&&this.pageStructureSection.setAttribute("hidden",""),this.pageStructureToggle&&this.pageStructureToggle.setAttribute("aria-pressed","false"),this._initReducedMotionLock(),safeAnnounce("All settings reset","polite")}_onPositionClick(btn){var pos=normalisePosition(btn.getAttribute("data-position"),this._defaultPosition);this._prefs.position=pos,this._savePrefs(),this._renderPosition();var label=(btn.textContent||pos).trim();safeAnnounce("Widget position: "+label,"polite")}_renderPosition(){var current=normalisePosition(this._prefs.position,this._defaultPosition);this.setAttribute("data-position",current),this.positionButtons.forEach(function(b){b.setAttribute("aria-pressed",b.getAttribute("data-position")===current?"true":"false")})}_initPageStructureScanner(){if(this.pageStructureSection){var self=this;this._scanPageStructure(),this.psTabs[0]&&this._activateTab(this.psTabs[0],{skipFocus:!0}),this._mutationObserver=new MutationObserver(function(){self._mutationDebounce&&clearTimeout(self._mutationDebounce),self._mutationDebounce=setTimeout(function(){self.pageStructureSection&&!self.pageStructureSection.hasAttribute("hidden")&&self._scanPageStructure()},400)});try{this._mutationObserver.observe(document.body,{childList:!0,subtree:!0})}catch{}}}_scanPageStructure(){var widget=this,headings=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")).filter(function(el){return!widget.contains(el)}),landmarkSelector='header,nav,main,aside,footer,[role="banner"],[role="navigation"],[role="main"],[role="complementary"],[role="contentinfo"],[role="region"],[role="search"]',landmarks=Array.from(document.querySelectorAll(landmarkSelector)).filter(function(el){return!widget.contains(el)}),links=Array.from(document.querySelectorAll("a[href]")).filter(function(el){return!widget.contains(el)});this._renderPsList(this.psPanels.headings,headings,function(el){return(el.tagName+": "+(el.textContent||"").trim()).slice(0,120)||el.tagName}),this._renderPsList(this.psPanels.landmarks,landmarks,function(el){var role=el.getAttribute("role")||el.tagName.toLowerCase(),label=el.getAttribute("aria-label")||(el.textContent||"").trim().slice(0,60);return role+(label?": "+label:"")}),this._renderPsList(this.psPanels.links,links,function(el){var label=(el.getAttribute("aria-label")||el.textContent||"").trim();return label||(label=el.getAttribute("href")||"(link)"),label.slice(0,120)})}_renderPsList(panel,items,labelFn){if(panel){if(panel.textContent="",items.length===0){var empty=document.createElement("p");empty.className="a11y-widget__ps-empty",empty.textContent="None found on this page.",panel.appendChild(empty);return}var list=document.createElement("ul");list.className="a11y-widget__ps-list";for(var i=0;i<items.length;i++){var target=items[i],li=document.createElement("li"),btn=document.createElement("button");btn.type="button",btn.className="a11y-widget__ps-item",btn.textContent=labelFn(target),
1(function(el,button){button.addEventListener("click",function(){try{el.scrollIntoView({behavior:"smooth",block:"center"})}catch{el.scrollIntoView()}var prevOutline=el.style.outline,prevOffset=el.style.outlineOffset;el.style.outline="3px solid #ff8c00",el.style.outlineOffset="2px",setTimeout(function(){document.body.contains(el)&&(el.style.outline=prevOutline,el.style.outlineOffset=prevOffset)},1800)})})(target,btn),li.appendChild(btn),list.appendChild(li)}panel.appendChild(list)}}_activateTab(tab,opts){opts=opts||{};var name=tab.getAttribute("data-ps-tab");this.psTabs.forEach(function(t){var active=t===tab;t.setAttribute("aria-selected",active?"true":"false"),t.setAttribute("tabindex",active?"0":"-1")});for(var key in this.psPanels)if(Object.prototype.hasOwnProperty.call(this.psPanels,key)){var p=this.psPanels[key];if(!p)continue;key===name?p.removeAttribute("hidden"):p.setAttribute("hidden","")}!opts.skipFocus&&typeof tab.focus=="function"&&tab.focus()}_onTabKeydown(e,tab){var idx=this.psTabs.indexOf(tab);if(idx!==-1){var next=null;e.key==="ArrowRight"?next=this.psTabs[(idx+1)%this.psTabs.length]:e.key==="ArrowLeft"?next=this.psTabs[(idx-1+this.psTabs.length)%this.psTabs.length]:e.key==="Home"?next=this.psTabs[0]:e.key==="End"&&(next=this.psTabs[this.psTabs.length-1]),next&&(e.preventDefault(),this._activateTab(next))}}_initReducedMotionLock(){window.matchMedia&&(this._reducedMotionQuery||(this._reducedMotionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),typeof this._reducedMotionQuery.addEventListener=="function"?this._reducedMotionQuery.addEventListener("change",this._onReducedMotionChange):typeof this._reducedMotionQuery.addListener=="function"&&this._reducedMotionQuery.addListener(this._onReducedMotionChange)),this._applyReducedMotionLock(this._reducedMotionQuery.matches))}_onReducedMotionChange(e){this._applyReducedMotionLock(!!e.matches)}_applyReducedMotionLock(reduced){for(var btn=null,i=0;i<this.toggleButtons.length;i++)if(this.toggleButtons[i].getAttribute("data-toggle-key")==="pause-animations"){btn=this.toggleButtons[i];break}reduced?(this._prefs["pause-animations"]=!0,this._applyPrefAttr("pause-animations",!0),this._savePrefs(),btn&&(btn.setAttribute("disabled",""),btn.setAttribute("aria-disabled","true"),this._renderToggle(btn))):btn&&(btn.removeAttribute("disabled"),btn.removeAttribute("aria-disabled"),this._renderToggle(btn))}}window.customElements&&!customElements.get("accessibility-widget")&&customElements.define("accessibility-widget",AccessibilityWidget)})();
2//# sourceMappingURL=/cdn/shop/t/40/assets/accessibility-widget.js.map?v=68178804598888878251779931333

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.