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 function mailgo(mailgoConfig: any | undefined): void;
|
||||
export function mailgo(mailgoConfig?: any): void;
|
||||
|
@ -1,2 +1,3 @@
|
||||
import { mailgoDOMContentLoaded } from "../mailgo";
|
||||
mailgoDOMContentLoaded();
|
||||
|
||||
mailgoDOMContentLoaded({ initEvent: "DOMContentLoaded" });
|
||||
|
@ -823,28 +823,18 @@ const mailgoStyle = () => {
|
||||
};
|
||||
|
||||
// start default mailgo
|
||||
export const mailgoDOMContentLoaded = () => {
|
||||
export const mailgo = (mailgoConfig?: any) => {
|
||||
// if the window is defined...
|
||||
if (window && typeof window !== "undefined") {
|
||||
// add the style for mailgo
|
||||
mailgoStyle();
|
||||
|
||||
// DOMContentLoaded -> mailgoInit (creates the modals)
|
||||
document.addEventListener("DOMContentLoaded", mailgoInit);
|
||||
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
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
|
||||
// if is set an initEvent add the listener
|
||||
if (mailgoConfig.initEvent) {
|
||||
document.addEventListener(mailgoConfig.initEvent, mailgoInit);
|
||||
} else {
|
||||
mailgoInit();
|
||||
}
|
||||
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("click", mailgoCheckRender);
|
||||
|
Loading…
x
Reference in New Issue
Block a user