check-render in init
This commit is contained in:
parent
bde3262e3d
commit
301ef64611
File diff suppressed because one or more lines are too long
12
mailgo.js
12
mailgo.js
|
@ -21,7 +21,7 @@ let gmail, outlook, open, telegram, wa, skype, call, copyMail, copyTel;
|
|||
* mailgoInit
|
||||
* the function that creates the mailgo elements in DOM
|
||||
*/
|
||||
const mailgoInit = () => {
|
||||
const mailgoInit = (mailgoConfig) => {
|
||||
// mailgo mail
|
||||
{
|
||||
// modal
|
||||
|
@ -221,6 +221,8 @@ const mailgoInit = () => {
|
|||
// every click outside the modal will hide the modal
|
||||
modalBackground.addEventListener("click", hideMailgo);
|
||||
}
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("click", mailgoCheckRender);
|
||||
};
|
||||
/**
|
||||
* mailgoRender
|
||||
|
@ -670,13 +672,13 @@ const mailgo = (mailgoConfig) => {
|
|||
mailgoStyle();
|
||||
// if is set an initEvent add the listener
|
||||
if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) {
|
||||
document.addEventListener(mailgoConfig.initEvent, mailgoInit);
|
||||
document.addEventListener(mailgoConfig.initEvent, () => {
|
||||
mailgoInit(mailgoConfig);
|
||||
});
|
||||
}
|
||||
else {
|
||||
mailgoInit();
|
||||
mailgoInit(mailgoConfig);
|
||||
}
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("click", mailgoCheckRender);
|
||||
}
|
||||
};
|
||||
export default mailgo;
|
||||
|
|
|
@ -57,7 +57,7 @@ let gmail: HTMLLinkElement,
|
|||
* mailgoInit
|
||||
* the function that creates the mailgo elements in DOM
|
||||
*/
|
||||
const mailgoInit = (): void => {
|
||||
const mailgoInit = (mailgoConfig?: MailgoConfig): void => {
|
||||
// mailgo mail
|
||||
{
|
||||
// modal
|
||||
|
@ -295,6 +295,9 @@ const mailgoInit = (): void => {
|
|||
// every click outside the modal will hide the modal
|
||||
modalBackground.addEventListener("click", hideMailgo);
|
||||
}
|
||||
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("click", mailgoCheckRender);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -840,13 +843,12 @@ const mailgo = (mailgoConfig?: MailgoConfig): void => {
|
|||
|
||||
// if is set an initEvent add the listener
|
||||
if (mailgoConfig?.initEvent) {
|
||||
document.addEventListener(mailgoConfig.initEvent, mailgoInit);
|
||||
document.addEventListener(mailgoConfig.initEvent, () => {
|
||||
mailgoInit(mailgoConfig);
|
||||
});
|
||||
} else {
|
||||
mailgoInit();
|
||||
mailgoInit(mailgoConfig);
|
||||
}
|
||||
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("click", mailgoCheckRender);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue