@govbr-ds/core
Version:
Padrão Digital de Governo
2 lines • 1.93 kB
JavaScript
!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,o){this.name=e,this.component=t,this.component.setAttribute("id",`card${o}`),this._setBehavior()}_setBehavior(){this._setFlipBehavior(),this._setDragBehavior(),this._setDisableBehavior(),this._collpaseBehavior()}_collpaseBehavior(){this.component.querySelectorAll('[data-toggle="collapse"]').forEach(e=>{const t=undefined,o=undefined;new Collapse({iconToHide:"fa-chevron-up",iconToShow:"fa-chevron-down",trigger:e,useIcons:!0}).setBehavior()})}_setDisableBehavior(){if(this.component.classList.contains("disabled")){this.component.setAttribute("aria-hidden","true");const e=this.component.querySelectorAll("button"),t=this.component.querySelectorAll("input"),o=this.component.querySelectorAll("select"),s=this.component.querySelectorAll("textarea");for(const t of e)t.setAttribute("disabled","disabled");for(const e of t)e.setAttribute("disabled","disabled");for(const e of o)e.setAttribute("disabled","disabled");for(const e of s)e.setAttribute("disabled","disabled")}}_setFlipBehavior(){for(const e of this.component.querySelectorAll("button.flip"))e.addEventListener("click",()=>{"off"===this.component.getAttribute("flipped")?this.component.setAttribute("flipped","on"):this.component.setAttribute("flipped","off")})}_setDragBehavior(){for(const e of this.component.querySelectorAll("img"))e.setAttribute("draggable","false");for(const e of this.component.querySelectorAll("a"))e.setAttribute("draggable","false");this.component.addEventListener("dragstart",e=>{e.stopPropagation(),e.dataTransfer.setData("text/plain",this.component.getAttribute("id")),e.dropEffect="move"})}}var t=null})(),e();var s={};return o(),s})());
//# sourceMappingURL=card.min.js.map