%PDF- %PDF-
Direktori : /var/www/projetos/romanian.ongrace.com/wp-content/plugins/otter-blocks/build/blocks/ |
Current File : /var/www/projetos/romanian.ongrace.com/wp-content/plugins/otter-blocks/build/blocks/popup.js |
!function(){"use strict";var e;e=()=>{const e=document.querySelectorAll(".wp-block-themeisle-blocks-popup");e.length&&e.forEach((e=>new class{constructor(e){this.element=e,this.happened=!1,this.storageKey="otter-popup-dismiss";const{dismiss:t,anchor:n}=e.dataset;if(this.isItemDismissed()&&t&&!n&&!Boolean(window.themeisleGutenberg.isPreview))return!1;this.init()}init(){this.bindOpen(),this.bindClose()}openModal(){this.element.classList.add("active"),this.happened=!0}closeModal(){this.element.classList.remove("active"),this.dismissModal()}dismissModal(){const{dismiss:e,anchor:t}=this.element.dataset,{id:n}=this.element;if(!e||!n||t)return!1;const s=new Date,i=JSON.parse(localStorage.getItem(this.storageKey))||[];if(i.some((e=>e.modalID===n)))return!1;const o=864e5*e,r={expiry:s.getTime()+o,modalID:n};localStorage.setItem(this.storageKey,JSON.stringify([...i,r]))}isItemDismissed(){const{id:e}=this.element,t=JSON.parse(localStorage.getItem(this.storageKey))||[],n=t.filter((t=>t.modalID===e));if(0===n.length)return!1;const s=n[0],i=new Date;if(s.expiry>i.getTime())return!0;const o=t.filter((e=>e!==n[0]));return localStorage.setItem(this.storageKey,JSON.stringify(o)),!1}bindOpen(){const{open:e}=this.element.dataset;switch(e){case"onClick":this.bindAnchors();break;case"onScroll":this.bindOpenAfterScroll();break;case"onExit":this.bindExitIntent();break;default:this.bindOnLoad()}}bindAnchors(){const{anchor:e}=this.element.dataset;if(!e)return!1;document.querySelectorAll(`a[href='#${e}']`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),this.openModal()}))}))}bindOpenAfterScroll(){window.document.addEventListener("scroll",(()=>{if(this.happened)return!1;const{offset:e}=this.element.dataset;if(parseInt(e)>=parseInt(this.getScrolledPercent()))return!1;this.openModal()}))}bindOnLoad(){const{time:e}=this.element.dataset;setTimeout((()=>{this.openModal()}),1e3*e)}bindExitIntent(){document.body.addEventListener("mouseleave",(e=>{if(this.happened)return!1;0>e.clientY&&this.openModal()}))}getScrolledPercent(){const e=document.documentElement,{body:t}=document,n="scrollTop",s="scrollHeight";return(e[n]||t[n])/((e[s]||t[s])-e.clientHeight)*100}bindClose(){this.bindCloseButtons(),this.bindAnchorClose(),this.bindOverlayClosing()}bindAnchorClose(){const{anchorclose:e}=this.element.dataset;if(!e)return!1;document.querySelectorAll(`a[href='#${e}']`).forEach((e=>{e.addEventListener("click",(e=>{e.preventDefault(),this.closeModal()}))}))}bindCloseButtons(){this.element.querySelectorAll(".otter-popup__modal_header .components-button").forEach((e=>{e.addEventListener("click",(()=>{this.closeModal()}))}))}bindOverlayClosing(){const{outside:e}=this.element.dataset;if(!e)return!1;this.element.querySelector(".otter-popup__modal_wrap_overlay").addEventListener("click",(()=>{this.closeModal()}))}}(e)))},"undefined"!=typeof document&&("complete"!==document.readyState&&"interactive"!==document.readyState?document.addEventListener("DOMContentLoaded",e):e())}();