CoreFiles by mySites.guru
joomla-tab.min.js1 lines, 6,561 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
76a58f43b6509e78e8ebf46b38a846b0
sha1
9abb09b2ff4715954600f9d5f654a4b8606d3628
sha256
7f1725211066ba5bccf5062e3da84603aa53133f18c9bad828a0a8d6627a4761
customElements.define("joomla-tab",class extends HTMLElement{static get observedAttributes(){return["recall","orientation","view"]}get recall(){return this.getAttribute("recall")}get view(){return this.getAttribute("view")}set view(t){this.setAttribute("view",t)}get orientation(){return this.getAttribute("orientation")}set orientation(t){this.setAttribute("orientation",t)}constructor(){super(),this.hasActive=!1,this.currentActive="",this.hasNested=!1,this.isNested=!1,this.tabs=[]}connectedCallback(){(!this.orientation||this.orientation&&-1===["horizontal","vertical"].indexOf(this.orientation))&&(this.orientation="horizontal");const t=this,e=[].slice.call(this.querySelectorAll("section"));let i=[];const r=[];if(e){if(this.findAncestor(this,"joomla-tab")&&(this.isNested=!0),this.querySelector("joomla-tab")&&(this.hasNested=!0),this.hasAttribute("recall")){const t=sessionStorage.getItem(this.getStorageKey());t&&r.push(t)}if(this.hasNested){const s=sessionStorage.getItem(this.getStorageKey());if(s&&r.push(s),r.length&&""!==r[0]){const t=r[0].substring(5),e=this.querySelector(`#${t}`);if(e){const t=this.findAncestor(e,"joomla-tab");if(this.findAncestor(t,"joomla-tab")){const e=this.findAncestor(t,"section");e&&r.push(`#tab-${e.id}`)}}}e.forEach(e=>{if(r.length){const t=`#tab-${e.id}`;-1===r.indexOf(t)?e.removeAttribute("active"):e.setAttribute("active","")}e.parentNode===t&&i.push(e)})}else e.forEach(t=>{if(r.length){const e=`#tab-${t.id}`;-1===r.indexOf(e)?t.removeAttribute("active"):t.setAttribute("active","")}}),i=e;if("accordion"!==this.view&&this.createNavigation(i),i.forEach(t=>{t.setAttribute("role","tabpanel"),this.tabs.push(`#tab-${t.id}`),t.hasAttribute("active")&&(this.hasActive=!0,this.currentActive=t.id,this.querySelector(`#tab-${t.id}`).setAttribute("aria-selected","true"),this.querySelector(`#tab-${t.id}`).setAttribute("active",""),this.querySelector(`#tab-${t.id}`).setAttribute("tabindex","0"))}),this.hasActive||(i[0].setAttribute("active",""),this.hasActive=!0,this.currentActive=i[0].id,this.querySelector(`#tab-${i[0].id}`).setAttribute("aria-selected","true"),this.querySelector(`#tab-${i[0].id}`).setAttribute("tabindex","0"),this.querySelector(`#tab-${i[0].id}`).setAttribute("active","")),window.location.href.match(/#\S[^&]*/)){const t=window.location.href.match(/#\S[^&]*/),e=this.querySelector(t[0]);if(e){const t=this.findAncestor(e,"joomla-tab"),i=this.findAncestor(t,"joomla-tab");if(i){const r=this.findAncestor(t,"section");i.showTab(r),this.show(e)}else this.showTab(e)}}t.checkView(t),window.addEventListener("resize",()=>{t.checkView(t)})}}disconnectedCallback(){const t=this.querySelector("ul");[].slice.call(t.querySelectorAll("a")).forEach(t=>{t.removeEventListener("click",this)}),t.removeEventListener("keydown",this)}createNavigation(t){if("ul"===this.firstElementChild.nodeName.toLowerCase())return;const e=document.createElement("ul");e.setAttribute("role","tablist");const i=t=>{t.preventDefault(),this.hasActive&&this.hideCurrent();const e=this.currentActive;this.dispatchCustomEvent("joomla.tab.show",t.target,this.querySelector(`#tab-${e}`)),t.target.setAttribute("active",""),t.target.setAttribute("aria-selected","true"),t.target.setAttribute("tabindex","0"),this.querySelector(t.target.hash).setAttribute("active",""),this.querySelector(t.target.hash).removeAttribute("aria-hidden"),this.currentActive=t.target.hash.substring(1),this.dispatchCustomEvent("joomla.tab.shown",t.target,this.querySelector(`#tab-${e}`)),this.saveState(`#tab-${t.target.hash.substring(1)}`)};t.forEach(t=>{if(!t.id)return;const r=t.hasAttribute("active"),s=document.createElement("li"),a=document.createElement("a");s.setAttribute("role","presentation"),a.setAttribute("role","tab"),a.setAttribute("aria-controls",t.id),a.setAttribute("aria-selected",r?"true":"false"),a.setAttribute("tabindex",r?"0":"-1"),a.setAttribute("href",`#${t.id}`),a.setAttribute("id",`tab-${t.id}`),a.innerHTML=t.getAttribute("name"),r&&a.setAttribute("active",""),a.addEventListener("click",i),s.appendChild(a),e.appendChild(s),t.setAttribute("aria-labelledby",`tab-${t.id}`),r||t.setAttribute("aria-hidden","true")}),this.insertAdjacentElement("afterbegin",e),this.addKeyListeners()}hideCurrent(){if(this.currentActive){const t=this.querySelector(`a[aria-controls="${this.currentActive}"]`);this.dispatchCustomEvent("joomla.tab.hide",t,this.querySelector(`#tab-${this.currentActive}`)),t.removeAttribute("active"),t.setAttribute("tabindex","-1"),this.querySelector(`#${this.currentActive}`).removeAttribute("active"),this.querySelector(`#${this.currentActive}`).setAttribute("aria-hidden","true"),t.removeAttribute("aria-selected"),this.dispatchCustomEvent("joomla.tab.hidden",t,this.querySelector(`#tab-${this.currentActive}`))}}showTab(t){document.querySelector(`#tab-${t.id}`).click()}show(t){t.click()}addKeyListeners(){this.querySelector("ul").addEventListener("keyup",t=>{const e=this.querySelector(`#tab-${this.currentActive}`),i=e.parentNode.previousElementSibling||e.parentNode.parentNode.lastElementChild,r=e.parentNode.nextElementSibling||e.parentNode.parentNode.firstElementChild;if(!t.metaKey&&!t.altKey&&-1!==this.tabs.indexOf(`#${document.activeElement.id}`))switch(t.keyCode){case 37:case 38:i.querySelector("a").click(),i.querySelector("a").focus(),t.preventDefault();break;case 39:case 40:r.querySelector("a").click(),r.querySelector("a").focus(),t.preventDefault()}})}getStorageKey(){return window.location.href.toString().split(window.location.host)[1].replace(/&return=[a-zA-Z0-9%]+/,"").split("#")[0]}saveState(t){const e=this.getStorageKey();sessionStorage.setItem(e,t)}checkView(t){const e=t,i=e.querySelector("ul"),r=[];if(document.body.getBoundingClientRect().width>920){if("tabs"===this.view)return;e.view="tabs";const t=[].slice.call(i.querySelectorAll("section"));for(let i=0,s=t.length;i<s;++i)t[i].parentNode.parentNode.parentNode===e&&r.push(t[i]);r.length&&r.forEach(t=>{e.appendChild(t)})}else{if("accordion"===this.view)return;e.view="accordion";const t=[].slice.call(e.querySelectorAll("section"));for(let i=0,s=t.length;i<s;++i)t[i].parentNode===e&&r.push(t[i]);r.length&&r.forEach(t=>{const i=e.querySelector(`a[aria-controls="${t.id}"]`);i.parentNode.parentNode===e.firstElementChild&&i.parentNode.appendChild(t)})}}findAncestor(t,e){let i=t;for(;i.nodeName.toLowerCase()!==e;){if(null===i.parentElement)return!1;i=i.parentElement}return i}dispatchCustomEvent(t,e,i){const r=new CustomEvent(t,{bubbles:!0,cancelable:!0});r.relatedTarget=i,e.dispatchEvent(r),e.removeEventListener(t,e)}});

No other release has this exact content. See every version of this file.