new build

This commit is contained in:
Matteo Manzinello committed 2020-04-25 14:38:57 +02:00
1 parent 43a6ccc91f
commit 1379cd7114
3 files changed
+54 -44

No files matched your search

+1 -1
View File
@@ -1 +1 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mailgo=t():e.mailgo=t()}(window,(function(){return function(e){var t={};function o(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,a){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(a,n,function(t){return e[t]}.bind(null,n));return a},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";o.r(t);const a="javascript:void(0);",n="span";let l,i,d,s,m,c,r,p,b,u,h,f,g,x,w,y,C,k,v,L,z="",j="",A="",E="",N="",S="",R="",U="",I="",M="";const _=()=>{{let e=X();e.style.display="none",e.id="mailgo",e.classList.add("m-modal");let t=X();t.className="m-modal-back",e.appendChild(t);let o=X();o.className="m-modal-content",e.appendChild(o),i=X("strong"),i.id="m-title",i.className="m-title",o.appendChild(i);let l=X();l.id="m-details",l.className="m-details",s=X("p"),s.id="m-cc";let d=X(n);d.className="w-500",d.appendChild(Y("cc ")),p=X(n),p.id="m-cc-value",s.appendChild(d),s.appendChild(p),l.appendChild(s),m=X("p"),m.id="m-bcc";let w=X(n);w.className="w-500",w.appendChild(Y("bcc ")),b=X(n),b.id="m-bcc-value",m.appendChild(w),m.appendChild(b),l.appendChild(m),c=X("p"),c.id="m-subject";let y=X(n);y.className="w-500",y.appendChild(Y("subject ")),u=X(n),u.id="m-subject-value",c.appendChild(y),c.appendChild(u),l.appendChild(c),r=X("p"),r.id="m-body";let C=X(n);C.className="w-500",C.appendChild(Y("body ")),h=X(n),h.id="m-body-value",r.appendChild(C),r.appendChild(h),l.appendChild(r),o.appendChild(l),f=X("a"),f.id="m-gmail",f.href=a,f.classList.add("m-open"),f.classList.add("m-gmail"),f.appendChild(Y("open in "));let k=X(n);k.className="w-500",k.appendChild(Y("Gmail")),f.appendChild(k),o.appendChild(f),g=X("a"),g.id="m-outlook",g.href=a,g.classList.add("m-open"),g.classList.add("m-outlook"),g.appendChild(Y("open in "));let L=X(n);L.className="w-500",L.appendChild(Y("Outlook")),g.appendChild(L),o.appendChild(g),x=X("a"),x.id="m-open",x.href=a,x.classList.add("m-open"),x.classList.add("m-default");let z=X(n);z.className="w-500",z.appendChild(Y("open")),x.appendChild(z),x.appendChild(Y(" default")),o.appendChild(x),v=X("a"),v.id="m-copy",v.href=a,v.classList.add("m-copy"),v.classList.add("w-500"),v.appendChild(Y("copy")),o.appendChild(v),o.appendChild(V()),document.body.appendChild(e),t.addEventListener("click",K)}{let e=X();e.style.display="none",e.id="mailgo-tel",e.classList.add("m-modal");let t=X();t.className="m-modal-back",e.appendChild(t);let o=X();o.className="m-modal-content",e.appendChild(o),d=X("strong"),d.id="m-tel-title",d.className="m-title",o.appendChild(d),w=X("a"),w.id="m-tg",w.href=a,w.classList.add("m-open"),w.classList.add("m-tg"),w.style.display="none",w.appendChild(Y("open in "));let l=X(n);l.className="w-500",l.appendChild(Y("Telegram")),w.appendChild(l),o.appendChild(w),y=X("a"),y.id="m-wa",y.href=a,y.classList.add("m-open"),y.classList.add("m-wa"),y.appendChild(Y("open in "));let i=X(n);i.className="w-500",i.appendChild(Y("WhatsApp")),y.appendChild(i),o.appendChild(y),C=X("a"),C.id="m-skype",C.href=a,C.classList.add("m-open"),C.classList.add("m-skype"),C.appendChild(Y("open in "));let s=X(n);s.className="w-500",s.appendChild(Y("Skype")),C.appendChild(s),o.appendChild(C),k=X("a"),k.id="m-call",k.href=a,k.classList.add("m-open"),k.classList.add("m-default");let m=X(n);m.className="w-500",m.appendChild(Y("call")),k.appendChild(m),k.appendChild(Y(" as default")),o.appendChild(k),L=X("a"),L.id="m-tel-copy",L.href=a,L.classList.add("m-copy"),L.classList.add("w-500"),L.appendChild(Y("copy")),o.appendChild(L),o.appendChild(V()),document.body.appendChild(e),t.addEventListener("click",K)}},T=(e="mail",t)=>{if("mail"===e){if(t.href&&t.href.toLowerCase().startsWith("mailto:")){z=decodeURIComponent(t.href.split("?")[0].split("mailto:")[1].trim()),l=new URL(t.href);let e=l.searchParams;A=e.get("cc"),E=e.get("bcc"),N=e.get("subject"),S=e.get("body")}else z=t.getAttribute("data-address")+"@"+t.getAttribute("data-domain"),l=new URL("mailto:"+encodeURIComponent(z)),A=t.getAttribute("data-cc-address")+"@"+t.getAttribute("data-cc-domain"),E=t.getAttribute("data-bcc-address")+"@"+t.getAttribute("data-bcc-domain"),N=t.getAttribute("data-subject"),S=t.getAttribute("data-body"Line truncated
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mailgo=t():e.mailgo=t()}(window,(function(){return function(e){var t={};function o(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,a){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(a,n,function(t){return e[t]}.bind(null,n));return a},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";o.r(t);const a="javascript:void(0);",n="span";let l,i,d,s,m,c,r,p,b,u,h,g,f,x,w,y,C,k,v,L,z="",j="",A="",E="",N="",S="",R="",U="",I="",M="";const _=()=>{{let e=X();e.style.display="none",e.id="mailgo",e.classList.add("m-modal");let t=X();t.className="m-modal-back",e.appendChild(t);let o=X();o.className="m-modal-content",e.appendChild(o),i=X("strong"),i.id="m-title",i.className="m-title",o.appendChild(i);let l=X();l.id="m-details",l.className="m-details",s=X("p"),s.id="m-cc";let d=X(n);d.className="w-500",d.appendChild(Y("cc ")),p=X(n),p.id="m-cc-value",s.appendChild(d),s.appendChild(p),l.appendChild(s),m=X("p"),m.id="m-bcc";let w=X(n);w.className="w-500",w.appendChild(Y("bcc ")),b=X(n),b.id="m-bcc-value",m.appendChild(w),m.appendChild(b),l.appendChild(m),c=X("p"),c.id="m-subject";let y=X(n);y.className="w-500",y.appendChild(Y("subject ")),u=X(n),u.id="m-subject-value",c.appendChild(y),c.appendChild(u),l.appendChild(c),r=X("p"),r.id="m-body";let C=X(n);C.className="w-500",C.appendChild(Y("body ")),h=X(n),h.id="m-body-value",r.appendChild(C),r.appendChild(h),l.appendChild(r),o.appendChild(l),g=X("a"),g.id="m-gmail",g.href=a,g.classList.add("m-open"),g.classList.add("m-gmail"),g.appendChild(Y("open in "));let k=X(n);k.className="w-500",k.appendChild(Y("Gmail")),g.appendChild(k),o.appendChild(g),f=X("a"),f.id="m-outlook",f.href=a,f.classList.add("m-open"),f.classList.add("m-outlook"),f.appendChild(Y("open in "));let L=X(n);L.className="w-500",L.appendChild(Y("Outlook")),f.appendChild(L),o.appendChild(f),x=X("a"),x.id="m-open",x.href=a,x.classList.add("m-open"),x.classList.add("m-default");let z=X(n);z.className="w-500",z.appendChild(Y("open")),x.appendChild(z),x.appendChild(Y(" default")),o.appendChild(x),v=X("a"),v.id="m-copy",v.href=a,v.classList.add("m-copy"),v.classList.add("w-500"),v.appendChild(Y("copy")),o.appendChild(v),o.appendChild(V()),document.body.appendChild(e),t.addEventListener("click",K)}{let e=X();e.style.display="none",e.id="mailgo-tel",e.classList.add("m-modal");let t=X();t.className="m-modal-back",e.appendChild(t);let o=X();o.className="m-modal-content",e.appendChild(o),d=X("strong"),d.id="m-tel-title",d.className="m-title",o.appendChild(d),w=X("a"),w.id="m-tg",w.href=a,w.classList.add("m-open"),w.classList.add("m-tg"),w.style.display="none",w.appendChild(Y("open in "));let l=X(n);l.className="w-500",l.appendChild(Y("Telegram")),w.appendChild(l),o.appendChild(w),y=X("a"),y.id="m-wa",y.href=a,y.classList.add("m-open"),y.classList.add("m-wa"),y.appendChild(Y("open in "));let i=X(n);i.className="w-500",i.appendChild(Y("WhatsApp")),y.appendChild(i),o.appendChild(y),C=X("a"),C.id="m-skype",C.href=a,C.classList.add("m-open"),C.classList.add("m-skype"),C.appendChild(Y("open in "));let s=X(n);s.className="w-500",s.appendChild(Y("Skype")),C.appendChild(s),o.appendChild(C),k=X("a"),k.id="m-call",k.href=a,k.classList.add("m-open"),k.classList.add("m-default");let m=X(n);m.className="w-500",m.appendChild(Y("call")),k.appendChild(m),k.appendChild(Y(" as default")),o.appendChild(k),L=X("a"),L.id="m-tel-copy",L.href=a,L.classList.add("m-copy"),L.classList.add("w-500"),L.appendChild(Y("copy")),o.appendChild(L),o.appendChild(V()),document.body.appendChild(e),t.addEventListener("click",K)}},T=(e="mail",t)=>{if("mail"===e){if(t.href&&t.href.toLowerCase().startsWith("mailto:")){z=decodeURIComponent(t.href.split("?")[0].split("mailto:")[1].trim()),l=new URL(t.href);let e=l.searchParams;A=e.get("cc"),E=e.get("bcc"),N=e.get("subject"),S=e.get("body")}else z=t.getAttribute("data-address")+"@"+t.getAttribute("data-domain"),l=new URL("mailto:"+encodeURIComponent(z)),A=t.getAttribute("data-cc-address")+"@"+t.getAttribute("data-cc-domain"),E=t.getAttribute("data-bcc-address")+"@"+t.getAttribute("data-bcc-domain"),N=t.getAttribute("data-subject"),S=t.getAttribute("data-body"Line truncated
+10 -7
View File
@@ -474,32 +474,32 @@ const mailgoCheckRender = (event) => {
return;
// if a mailgo is already showing do nothing
if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE))
return;
return false;
// the path of the event
let path = (event.composedPath && event.composedPath()) ||
composedPath(event.target);
if (path) {
path.forEach((element) => {
if (element instanceof HTMLDocument || element instanceof Window)
return;
return false;
// go in the event.path to find if the user has clicked on a mailgo element
if (isMailgo(element, MAIL_TYPE)) {
// stop the normal execution of the element click
event.preventDefault();
// render mailgo
mailgoRender(MAIL_TYPE, element);
return;
return true;
}
if (isMailgo(element, TEL_TYPE)) {
// stop the normal execution of the element click
event.preventDefault();
// render mailgo
mailgoRender(TEL_TYPE, element);
return;
return true;
}
});
}
return;
return false;
};
/**
* mailgoKeydown
@@ -568,13 +568,14 @@ const showMailgo = (type = MAIL_TYPE) => {
// show mailgo type mail
if (type === MAIL_TYPE) {
setDisplay("mailgo", "flex");
return;
return true;
}
// show mailgo type tel
if (type === TEL_TYPE) {
setDisplay("mailgo-tel", "flex");
return;
return true;
}
return false;
};
// hide the modal
const hideMailgo = () => {
@@ -649,7 +650,9 @@ const copyToClipboard = (str) => {
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
return true;
}
return false;
};
const mailgoStyle = () => {
// mailgo style
+43 -36
View File
@@ -299,7 +299,7 @@ const mailgoInit = (): void => {
* mailgoRender
* function to render a mailgo (mail or tel)
*/
const mailgoRender = (type = MAIL_TYPE, mailgo: any) => {
const mailgoRender = (type = MAIL_TYPE, mailgo: any): void => {
// mailgo mail
if (type === MAIL_TYPE) {
// if the element href=^"mailto:"
@@ -438,7 +438,7 @@ const mailgoRender = (type = MAIL_TYPE, mailgo: any) => {
};
// actions
const openGmail = () => {
const openGmail = (): void => {
// Gmail url
let gmailUrl =
"https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" +
@@ -457,7 +457,7 @@ const openGmail = () => {
hideMailgo();
};
const openOutlook = () => {
const openOutlook = (): void => {
// Outlook url
let outlookUrl =
"https://outlook.live.com/owa/?path=/mail/action/compose&to=" +
@@ -474,12 +474,12 @@ const openOutlook = () => {
hideMailgo();
};
const openDefault = () => {
const openDefault = (): void => {
mailToEncoded(encEmail);
hideMailgo();
};
const openTelegram = () => {
const openTelegram = (): void => {
// Telegram url
let tgUrl = "https://t.me/" + telegramUsername;
@@ -490,7 +490,7 @@ const openTelegram = () => {
hideMailgo();
};
const openSkype = () => {
const openSkype = (): void => {
let skype = skypeUsername !== "" ? skypeUsername : tel;
// Telegram url
@@ -503,7 +503,7 @@ const openSkype = () => {
hideMailgo();
};
const openWhatsApp = () => {
const openWhatsApp = (): void => {
// WhatsApp url
let waUrl = "https://wa.me/" + tel;
@@ -517,13 +517,13 @@ const openWhatsApp = () => {
hideMailgo();
};
const callDefault = () => {
const callDefault = (): void => {
let callUrl = "tel:" + tel;
window.open(callUrl);
hideMailgo();
};
const copy = (content: string) => {
const copy = (content: string): void => {
copyToClipboard(content);
let activeCopy: HTMLElement;
// the correct copyButton (mail or tel)
@@ -537,7 +537,7 @@ const copy = (content: string) => {
};
// function that returns if an element is a mailgo
const isMailgo = (element: HTMLElement, type: string = MAIL_TYPE) => {
const isMailgo = (element: HTMLElement, type: string = MAIL_TYPE): boolean => {
let href: string = (element as HTMLLinkElement).href;
// mailgo type mail
@@ -591,7 +591,7 @@ const isMailgo = (element: HTMLElement, type: string = MAIL_TYPE) => {
* 'a[href^="callto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
* );
*/
const mailgoCheckRender = (event: Event) => {
const mailgoCheckRender = (event: Event): boolean => {
// check if the id=mailgo exists in the body
if (
!document.contains(getE("mailgo")) ||
@@ -600,7 +600,7 @@ const mailgoCheckRender = (event: Event) => {
return;
// if a mailgo is already showing do nothing
if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) return;
if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) return false;
// the path of the event
let path =
@@ -609,7 +609,8 @@ const mailgoCheckRender = (event: Event) => {
if (path) {
path.forEach((element: HTMLElement) => {
if (element instanceof HTMLDocument || element instanceof Window) return;
if (element instanceof HTMLDocument || element instanceof Window)
return false;
// go in the event.path to find if the user has clicked on a mailgo element
if (isMailgo(element, MAIL_TYPE)) {
@@ -619,7 +620,7 @@ const mailgoCheckRender = (event: Event) => {
// render mailgo
mailgoRender(MAIL_TYPE, element);
return;
return true;
}
if (isMailgo(element, TEL_TYPE)) {
// stop the normal execution of the element click
@@ -628,19 +629,19 @@ const mailgoCheckRender = (event: Event) => {
// render mailgo
mailgoRender(TEL_TYPE, element);
return;
return true;
}
});
}
return;
return false;
};
/**
* mailgoKeydown
* function to manage the keydown event when the modal is showing
*/
const mailgoKeydown = (event: KeyboardEvent) => {
const mailgoKeydown = (event: KeyboardEvent): void => {
// if mailgo is showing
if (mailgoIsShowing(MAIL_TYPE)) {
switch (event.keyCode) {
@@ -699,21 +700,22 @@ const mailgoKeydown = (event: KeyboardEvent) => {
};
// show the modal
const showMailgo = (type = MAIL_TYPE) => {
const showMailgo = (type = MAIL_TYPE): boolean => {
// show mailgo type mail
if (type === MAIL_TYPE) {
setDisplay("mailgo", "flex");
return;
return true;
}
// show mailgo type tel
if (type === TEL_TYPE) {
setDisplay("mailgo-tel", "flex");
return;
return true;
}
return false;
};
// hide the modal
const hideMailgo = () => {
const hideMailgo = (): void => {
setDisplay("mailgo", "none");
setDisplay("mailgo-tel", "none");
@@ -722,7 +724,7 @@ const hideMailgo = () => {
};
// is the mailgo modal hidden?
const mailgoIsShowing = (type = MAIL_TYPE) => {
const mailgoIsShowing = (type = MAIL_TYPE): boolean => {
return type === MAIL_TYPE
? getDisplay("mailgo") === "flex"
: type === TEL_TYPE
@@ -730,7 +732,7 @@ const mailgoIsShowing = (type = MAIL_TYPE) => {
: false;
};
const byElement = () => {
const byElement = (): HTMLLinkElement => {
// by
let by: HTMLLinkElement = <HTMLLinkElement>createElement("a");
by.href = "https://mailgo.js.org?ref=mailgo-modal";
@@ -743,31 +745,34 @@ const byElement = () => {
};
// create element
const createElement = (element: string = "div") =>
const createElement = (element: string = "div"): HTMLElement =>
document.createElement(element);
// create text node
const createTextNode = (element: string) => document.createTextNode(element);
const createTextNode = (element: string): Text =>
document.createTextNode(element);
// decrypt email
const mailToEncoded = (encoded: string) =>
const mailToEncoded = (encoded: string): string =>
(window.location.href = MAILTO + atob(encoded));
// encode email
const encodeEmail = (email: string) => btoa(email);
const encodeEmail = (email: string): string => btoa(email);
// getE shorthand
const getE = (id: string) => document.getElementById(id);
const getE = (id: string): HTMLElement => document.getElementById(id);
// get display value
const getDisplay = (id: string) => getE(id).style.display;
const getDisplay = (id: string): string => getE(id).style.display;
// get display value
const setDisplay = (id: string, value: string) =>
const setDisplay = (id: string, value: string): string =>
(getE(id).style.display = value);
// custom composedPath if path or event.composedPath() are not defined
const composedPath = (el: HTMLElement) => {
const composedPath = (
el: HTMLElement
): (HTMLElement | Document | (Window & typeof globalThis))[] => {
let path = [];
while (el) {
@@ -784,16 +789,16 @@ const composedPath = (el: HTMLElement) => {
};
// validate a single email with regex
const validateEmail = (email: string) =>
const validateEmail = (email: string): boolean =>
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
email
);
// validate an array of emails
const validateEmails = (arr: string[]) => arr.every(validateEmail);
const validateEmails = (arr: string[]): boolean => arr.every(validateEmail);
// copy of a string
const copyToClipboard = (str: string) => {
const copyToClipboard = (str: string): boolean => {
let el: HTMLInputElement = <HTMLInputElement>createElement("textarea");
el.value = str;
el.setAttribute("readonly", "");
@@ -810,10 +815,12 @@ const copyToClipboard = (str: string) => {
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
return true;
}
return false;
};
const mailgoStyle = () => {
const mailgoStyle = (): void => {
// mailgo style
let mailgoCSS: HTMLStyleElement = <HTMLStyleElement>createElement("style");
mailgoCSS.id = "mailgo-style";
@@ -823,7 +830,7 @@ const mailgoStyle = () => {
};
// mailgo
const mailgo = (mailgoConfig?: any) => {
const mailgo = (mailgoConfig?: any): void => {
// if the window is defined...
if (window && typeof window !== "undefined") {
// add the style for mailgo