go on with typescript, support for ssr and configuration
This commit is contained in:
parent
50b3a5ff2e
commit
d696299389
2
index.d.ts
vendored
2
index.d.ts
vendored
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
export as namespace Mailgo;
|
export as namespace Mailgo;
|
||||||
|
|
||||||
export function mailgo(mailgoConfig: any | undefined): void;
|
export function mailgo(mailgoConfig?: any): void;
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
import { mailgoDOMContentLoaded } from "../mailgo";
|
import { mailgoDOMContentLoaded } from "../mailgo";
|
||||||
mailgoDOMContentLoaded();
|
|
||||||
|
mailgoDOMContentLoaded({ initEvent: "DOMContentLoaded" });
|
||||||
|
@ -823,28 +823,18 @@ const mailgoStyle = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// start default mailgo
|
// start default mailgo
|
||||||
export const mailgoDOMContentLoaded = () => {
|
export const mailgo = (mailgoConfig?: any) => {
|
||||||
// if the window is defined...
|
// if the window is defined...
|
||||||
if (window && typeof window !== "undefined") {
|
if (window && typeof window !== "undefined") {
|
||||||
// add the style for mailgo
|
// add the style for mailgo
|
||||||
mailgoStyle();
|
mailgoStyle();
|
||||||
|
|
||||||
// DOMContentLoaded -> mailgoInit (creates the modals)
|
// if is set an initEvent add the listener
|
||||||
document.addEventListener("DOMContentLoaded", mailgoInit);
|
if (mailgoConfig.initEvent) {
|
||||||
|
document.addEventListener(mailgoConfig.initEvent, mailgoInit);
|
||||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
} else {
|
||||||
document.addEventListener("click", mailgoCheckRender);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const mailgo = () => {
|
|
||||||
// if the window is defined...
|
|
||||||
if (window && typeof window !== "undefined") {
|
|
||||||
// add the style for mailgo
|
|
||||||
mailgoStyle();
|
|
||||||
|
|
||||||
// mailgo init
|
|
||||||
mailgoInit();
|
mailgoInit();
|
||||||
|
}
|
||||||
|
|
||||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||||
document.addEventListener("click", mailgoCheckRender);
|
document.addEventListener("click", mailgoCheckRender);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user