UNPKG

@govbr-ds/core

Version:

Padrão Digital de Governo

2 lines 2.86 kB
!function t(e,s){"object"==typeof exports&&"object"==typeof module?module.exports=s():"function"==typeof define&&define.amd?define("core",[],s):"object"==typeof exports?exports.core=s():e.core=s()}(self,()=>(()=>{var t=()=>{},e,s=()=>{};(()=>{class t{constructor(t,e){this.name=t,this.component=e,this._setUp(),this._setBehavior()}_setUp(){this.list=this.component.querySelector(".br-list.horizontal")}_setBehavior(){this._setCollapseBehavior(),window.onresize=function(){window.matchMedia("(min-width: 992px)").matches?window.document.querySelectorAll(".br-footer .br-list:not(.horizontal)").forEach(t=>{t.style.display="block"}):(window.document.querySelectorAll(".br-footer .br-list:not(.horizontal)").forEach(t=>{t.style.display="none"}),window.document.querySelectorAll(".br-footer i").forEach(t=>{t.classList.remove("fa-angle-up"),t.classList.add("fa-angle-down")}))}}_setCollapseBehavior(){this.britems=[],this.list&&(this.list.querySelectorAll(".br-list").forEach(t=>{window.matchMedia("(max-width: 992px)").matches&&(t.style.display="none")}),this.list.querySelectorAll(".br-item").forEach(t=>{t.addEventListener("click",t=>{window.matchMedia("(max-width: 992px)").matches&&this._showList(t)}),this.britems.push(t)}),this.list.querySelectorAll(".br-item").forEach(t=>{t.addEventListener("keydown",t=>{13===t.keyCode&&window.matchMedia("(max-width: 992px)").matches&&this._showList(t)}),this.britems.push(t)}))}_showList(t){parent=t.target.parentElement,parent=parent.classList.contains("col-2")?t.target.parentElement:t.target.parentElement.parentElement,parent=parent.classList.contains("col-2")?parent:t.target.parentElement.parentElement.parentElement,this._closeAllColumns(parent),parent.querySelectorAll(".br-list ").forEach(e=>{e.style.display="block"===e.style.display?"none":"block";const s=parent.querySelector("i");"block"===e.style.display?this._iconAngleUP(s):this._iconAngleDOWN(s),this._setAriaAttributes(e,t)})}_closeAllColumns(t){this.component.querySelectorAll(".br-list:not(.horizontal)").forEach(e=>{t!==e.parentElement&&(e.style.display="none",this.component.querySelectorAll(".header i").forEach(t=>{this._iconAngleDOWN(t)}))})}_iconAngleUP(t){t.classList.remove("fa-angle-down"),t.classList.add("fa-angle-up")}_iconAngleDOWN(t){t.classList.remove("fa-angle-up"),t.classList.add("fa-angle-down")}_setAriaAttributes(t,e){const s=undefined;this.list.querySelectorAll(".br-item").forEach(()=>{const s=`list-${Math.floor(1e4*Math.random())}`,o="block"===t.style.display,{parentElement:i}=e.target;i.setAttribute("id",s),i.setAttribute("data-visible",o),i.setAttribute("aria-expanded",o),i.setAttribute("aria-label",o?"expandido":"recolhido"),i.setAttribute("aria-controls",s),i.setAttribute("data-group","group1"),i.setAttribute("data-target",s)})}}var e=null})(),t();var o={};return s(),o})()); //# sourceMappingURL=footer.min.js.map