UNPKG

@govbr-ds/core

Version:

Padrão Digital de Governo

2 lines 1.38 kB
!function e(t,o){"object"==typeof exports&&"object"==typeof module?module.exports=o():"function"==typeof define&&define.amd?define("core",[],o):"object"==typeof exports?exports.core=o():t.core=o()}(self,(()=>(()=>{var e=()=>{},t,o=()=>{};(()=>{class e{constructor(e,t){this.name=e,this.component=t,this._setBehavior()}_setBehavior(){for(const e of this.component.querySelectorAll("button.header"))e.addEventListener("click",(e=>{this._collapse(e),this._changeIcon(e)}))}_collapse(e){if(this.component.hasAttribute("single"))for(const t of this.component.querySelectorAll(".item"))t===e.currentTarget.parentNode?t.hasAttribute("active")?t.removeAttribute("active"):t.setAttribute("active",""):t.hasAttribute("active")&&t.removeAttribute("active");else for(const t of this.component.querySelectorAll(".item"))t===e.currentTarget.parentNode&&(t.hasAttribute("active")?t.removeAttribute("active"):t.setAttribute("active",""))}_changeIcon(){for(const e of this.component.querySelectorAll(".item"))if(e.hasAttribute("active"))for(const t of e.querySelectorAll(".icon"))t.children[0].classList.remove("fa-angle-down"),t.children[0].classList.add("fa-angle-up");else for(const t of e.querySelectorAll(".icon"))t.children[0].classList.remove("fa-angle-up"),t.children[0].classList.add("fa-angle-down")}}var t=null})(),e();var r={};return o(),r})())); //# sourceMappingURL=accordion.min.js.map