4 lines
2.6 KiB
JavaScript
4 lines
2.6 KiB
JavaScript
|
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
|
||
|
const e=window.dsfr,t={HEADER:e.internals.ns.selector("header"),TOOLS_LINKS:e.internals.ns.selector("header__tools-links"),MENU_LINKS:e.internals.ns.selector("header__menu-links"),BUTTONS:`${e.internals.ns.selector("header__tools-links")} ${e.internals.ns.selector("btns-group")}, ${e.internals.ns.selector("header__tools-links")} ${e.internals.ns.selector("links-group")}`,MODALS:`${e.internals.ns.selector("header__search")}${e.internals.ns.selector("modal")}, ${e.internals.ns.selector("header__menu")}${e.internals.ns.selector("modal")}`};class s extends e.core.Instance{static get instanceClassName(){return"HeaderLinks"}init(){const s=this.queryParentSelector(t.HEADER);this.toolsLinks=s.querySelector(t.TOOLS_LINKS),this.menuLinks=s.querySelector(t.MENU_LINKS);const n="-mobile",a=this.toolsLinks.innerHTML.replace(/ +/g," "),r=this.menuLinks.innerHTML.replace(/ +/g," ");let i=a.match(/id="(.*?)"/gm)||[];i=i.map((e=>e.replace('id="',"").replace('"',"")));const o=a.match(/aria-controls="(.*?)"/gm);let l=a.replace(/id="(.*?)"/gm,'id="$1'+n+'"');if(o)for(const e of o){const t=e.replace('aria-controls="',"").replace('"',"");i.includes(t)&&(l=l.replace(`aria-controls="${t}"`,`aria-controls="${t+n}"`))}if(l!==r)switch(e.mode){case e.Modes.ANGULAR:case e.Modes.REACT:case e.Modes.VUE:this.warn(`header__tools-links content is different from header__menu-links content.\nAs you're using a dynamic framework, you should handle duplication of this content yourself, please refer to documentation:\n${e.header.doc}`);break;default:this.menuLinks.innerHTML=l}}}class n extends e.core.Instance{static get instanceClassName(){return"HeaderModal"}init(){this.isResizing=!0}resize(){this.isBreakpoint(e.core.Breakpoints.LG)?this.deactivateModal():this.activateModal()}activateModal(){const e=this.element.getInstance("Modal");e&&(e.isEnabled=!0,this.listenClick({capture:!0}))}deactivateModal(){const e=this.element.getInstance("Modal");e&&(e.conceal(),e.isEnabled=!1,this.unlistenClick({capture:!0}))}handleClick(t){if(t.target.matches("a, button")&&!t.target.matches("[aria-controls]")&&!t.target.matches(e.core.DisclosureSelector.PREVENT_CONCEAL)){this.element.getInstance("Modal").conceal()}}}e.header={HeaderLinks:s,HeaderModal:n,HeaderSelector:t,doc:"https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/en-tete"},e.internals.register(e.header.HeaderSelector.TOOLS_LINKS,e.header.HeaderLinks),e.internals.register(e.header.HeaderSelector.MODALS,e.header.HeaderModal);
|
||
|
//# sourceMappingURL=header.module.min.js.map
|