self-invoking functions
This commit is contained in:
parent
e43f387097
commit
b0ec8a49cf
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,8 +1,6 @@
|
|||||||
|
(() => {
|
||||||
const V = "MAILGO_VERSION";
|
const V = "MAILGO_VERSION";
|
||||||
|
|
||||||
// window exists
|
|
||||||
const windowExists = () => window && typeof window !== "undefined";
|
|
||||||
|
|
||||||
// links
|
// links
|
||||||
const MAILTO = "mailto:";
|
const MAILTO = "mailto:";
|
||||||
const TEL = "tel:";
|
const TEL = "tel:";
|
||||||
@ -40,16 +38,6 @@ let gmailButton,
|
|||||||
callButton,
|
callButton,
|
||||||
copyButton;
|
copyButton;
|
||||||
|
|
||||||
if (windowExists()) {
|
|
||||||
// mailgo style (gulp)
|
|
||||||
let mailgoCSS = document.createElement("style");
|
|
||||||
mailgoCSS.id = "mailgo-style";
|
|
||||||
mailgoCSS.type = "text/css";
|
|
||||||
let mailgoCSSContent = document.createTextNode(`MAILGO_STYLE`);
|
|
||||||
mailgoCSS.appendChild(mailgoCSSContent);
|
|
||||||
document.head.appendChild(mailgoCSS);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mailgoInit
|
* mailgoInit
|
||||||
* the function that creates the mailgo elements in DOM
|
* the function that creates the mailgo elements in DOM
|
||||||
@ -430,7 +418,8 @@ const mailgoRender = (type = MAIL_TYPE, mailgo) => {
|
|||||||
: (subjectEl.style.display = "none");
|
: (subjectEl.style.display = "none");
|
||||||
|
|
||||||
bodyMail
|
bodyMail
|
||||||
? ((bodyEl.style.display = "block"), (bodyValueEl.textContent = bodyMail))
|
? ((bodyEl.style.display = "block"),
|
||||||
|
(bodyValueEl.textContent = bodyMail))
|
||||||
: (bodyEl.style.display = "none");
|
: (bodyEl.style.display = "none");
|
||||||
|
|
||||||
// add the actions
|
// add the actions
|
||||||
@ -674,7 +663,8 @@ const mailgoCheckRender = event => {
|
|||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
path.forEach(element => {
|
path.forEach(element => {
|
||||||
if (element instanceof HTMLDocument || element instanceof Window) return;
|
if (element instanceof HTMLDocument || element instanceof Window)
|
||||||
|
return;
|
||||||
|
|
||||||
// go in the event.path to find if the user has clicked on a mailgo element
|
// go in the event.path to find if the user has clicked on a mailgo element
|
||||||
if (isMailgo(element, MAIL_TYPE)) {
|
if (isMailgo(element, MAIL_TYPE)) {
|
||||||
@ -763,15 +753,6 @@ const mailgoKeydown = event => {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// if the window object exists...
|
|
||||||
if (windowExists()) {
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// show the modal
|
// show the modal
|
||||||
const showMailgo = (type = MAIL_TYPE) => {
|
const showMailgo = (type = MAIL_TYPE) => {
|
||||||
// show mailgo type mail
|
// show mailgo type mail
|
||||||
@ -805,6 +786,9 @@ const mailgoIsShowing = (type = MAIL_TYPE) => {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// window exists
|
||||||
|
const windowExists = () => window && typeof window !== "undefined";
|
||||||
|
|
||||||
// decrypt email
|
// decrypt email
|
||||||
const mailToEncoded = encoded =>
|
const mailToEncoded = encoded =>
|
||||||
(window.location.href = MAILTO + atob(encoded));
|
(window.location.href = MAILTO + atob(encoded));
|
||||||
@ -867,3 +851,24 @@ const copyToClipboard = str => {
|
|||||||
document.getSelection().addRange(selected);
|
document.getSelection().addRange(selected);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// start mailgo
|
||||||
|
(() => {
|
||||||
|
// if the window object exists...
|
||||||
|
if (windowExists()) {
|
||||||
|
// mailgo style (gulp)
|
||||||
|
let mailgoCSS = document.createElement("style");
|
||||||
|
mailgoCSS.id = "mailgo-style";
|
||||||
|
mailgoCSS.type = "text/css";
|
||||||
|
let mailgoCSSContent = document.createTextNode(`MAILGO_STYLE`);
|
||||||
|
mailgoCSS.appendChild(mailgoCSSContent);
|
||||||
|
document.head.appendChild(mailgoCSS);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user