@iris.interactive/handcook 8.0.5 → 8.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,4 +11,4 @@
11
11
  * @author Lucas ROCHE
12
12
  * @date 01/02/2022 11:01
13
13
  * @copyright Copyright (c) 2002-2022 IRIS Interactive, Inc. (http://www.iris-interactive.fr)
14
- */import{Fancybox as t}from"@fancyapps/ui";import e from"../../enumerators/element.enum";import"@fancyapps/ui/dist/fancybox.css";import"./modal.component.scss";export class HcModal{showEvent;hideEvent;options={};constructor(o=e.modal,s={}){for(let n of(this.createEvent(),document.querySelectorAll(o))){this.initOptions(),Object.assign(this.options,s),this.options.src=""!==this.options.src?this.options.src:n.hasAttribute("href")?n.getAttribute("href"):n.hasAttribute("data-src")?n.dataset.src:"",this.options.parentEl=null!==this.options.parentEl?document.querySelector(this.options.parentEl):n.hasAttribute("data-hc-modal-parent")?document.querySelector(n.getAttribute("data-hc-modal-parent")):"",this.options.autoFocus=!!n.hasAttribute("data-hc-modal-autofocus");let o=`${e.modal}[${n.hasAttribute("data-src")?"data-src":"href"}="${this.options.src}"]`;t.bind(o,Object.assign(this.options,{on:{done:()=>{document.dispatchEvent(this.showEvent)},closing:()=>{document.dispatchEvent(this.hideEvent),document.activeElement?.blur()}}}))}for(let t of document.querySelectorAll(e.modalClose))t.addEventListener("click",t=>{t.preventDefault();let e=""===t.currentTarget.dataset.hcModalClose||t.currentTarget.dataset.hcModalClose;HcModal.close(e)})}static show(e){t.show([e])}static close(e){t.close(e)}initOptions(){this.options={src:"",type:"inline",parentEl:null}}createEvent(){this.showEvent=new Event("show.hc.modal"),this.hideEvent=new Event("hide.hc.modal")}}let hc_modal=(t,e)=>new HcModal(t,e);export default hc_modal;
14
+ */import{Fancybox as t}from"@fancyapps/ui";import e from"../../enumerators/element.enum";import"@fancyapps/ui/dist/fancybox.css";import"./modal.component.scss";export class HcModal{options={};constructor(t=e.modal,o={}){this.initOptions(),this.initElements(t,o)}initOptions(){this.options={src:"",type:"inline",parentEl:null,autoFocus:!1}}initElements(o,s){for(let n of document.querySelectorAll(o)){this.initOptions(),Object.assign(this.options,s),this.options.src=""!==this.options.src?this.options.src:n.hasAttribute("href")?n.getAttribute("href"):n.hasAttribute("data-src")?n.dataset.src:"",this.options.parentEl=null!==this.options.parentEl?document.querySelector(this.options.parentEl):n.hasAttribute("data-hc-modal-parent")?document.querySelector(n.getAttribute("data-hc-modal-parent")):null,this.options.autoFocus=!!n.hasAttribute("data-hc-modal-autofocus");let o=`${e.modal}[${n.hasAttribute("data-src")?"data-src":"href"}="${this.options.src}"]`;t.bind(o,this.bindFancyboxEvents(this.options))}for(let t of document.querySelectorAll(e.modalClose))t.addEventListener("click",t=>{t.preventDefault();let e=""===t.currentTarget.dataset.hcModalClose||t.currentTarget.dataset.hcModalClose;HcModal.close(e)})}bindFancyboxEvents(t={}){return Object.assign({},t,{on:HcModal.fancyboxEventHandlers()})}static show(e){t.show([e],{on:HcModal.fancyboxEventHandlers()})}static close(e){t.close(e),document.dispatchEvent(HcModal.hideEvent())}static showEvent(t={}){return new CustomEvent("show.hc.modal",{detail:t})}static hideEvent(t={}){return new CustomEvent("hide.hc.modal",{detail:t})}static fancyboxEventHandlers(){return{done:t=>{let e=t.getSlide()||{};document.dispatchEvent(HcModal.showEvent({src:e.src,type:e.type}))},closing:t=>{let e=t.getSlide()||{};document.dispatchEvent(HcModal.hideEvent({src:e.src,type:e.type})),document.activeElement?.blur()}}}}let hc_modal=(t,e)=>new HcModal(t,e);export default hc_modal;