From c0568f05ae84c2eb059a059667a1b1bb21217f28 Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Wed, 1 Jul 2020 14:48:18 +0200 Subject: [PATCH] removed ts-loader for babel-loader --- dist/mailgo.js | 1396 +++++++++++++++++++++++--------------------- dist/mailgo.min.js | 2 +- lib/mailgo.js | 1396 +++++++++++++++++++++++--------------------- src/mailgo.ts | 2 +- webpack.config.js | 11 +- 5 files changed, 1465 insertions(+), 1342 deletions(-) diff --git a/dist/mailgo.js b/dist/mailgo.js index eaeabbf..5c3b03b 100644 --- a/dist/mailgo.js +++ b/dist/mailgo.js @@ -228,481 +228,497 @@ __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ../src/mailgo.ts // i18n for mailgo -const i18n = __webpack_require__(0); -// mailgo css -const mailgoCSS = __webpack_require__(1).toString(); -// default lang -const DEFAULT_LANG = "en"; -// links -const MAILTO = "mailto:"; -const TEL = "tel:"; -const CALLTO = "callto:"; -// mailgo types -const MAIL_TYPE = "mail"; -const TEL_TYPE = "tel"; -// default href for links -const DEFAULT_BTN_HREF = "javascript:void(0);"; -// html tags -const span = "span"; -// mailgo variables -let url, mail = "", encEmail = "", cc = "", bcc = "", subject = "", bodyMail = ""; -// mailgo tel variables -let tel = "", msg = "", telegramUsername = "", skypeUsername = ""; -// the DOM elements -let title, titleTel, detailCc, detailBcc, detailSubject, detailBody, ccValue, bccValue, subjectValue, bodyValue; -// mailgo buttons (actions) -let gmail, outlook, mailgo_open, telegram, wa, skype, call, copyMail, copyTel; +var i18n = __webpack_require__(0); // mailgo css + + +var mailgoCSS = __webpack_require__(1).toString(); // default lang + + +var DEFAULT_LANG = "en"; // links + +var MAILTO = "mailto:"; +var TEL = "tel:"; +var CALLTO = "callto:"; // mailgo types + +var MAIL_TYPE = "mail"; +var TEL_TYPE = "tel"; // default href for links + +var DEFAULT_BTN_HREF = "javascript:void(0);"; // html tags + +var span = "span"; // mailgo variables + +var url, + mail = "", + encEmail = "", + cc = "", + bcc = "", + subject = "", + bodyMail = ""; // mailgo tel variables + +var tel = "", + msg = "", + telegramUsername = "", + skypeUsername = ""; // the DOM elements + +var title, titleTel, detailCc, detailBcc, detailSubject, detailBody, ccValue, bccValue, subjectValue, bodyValue; // mailgo buttons (actions) + +var gmail, outlook, mailgo_open, telegram, wa, skype, call, copyMail, copyTel; /** * mailgoInit * the function that creates the mailgo elements in DOM */ -const mailgoInit = (mailgoConfig) => { - // default language - let lang = DEFAULT_LANG; - // translations - let translations = i18n.translations; - // if a default language is defined use it - if ((mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.defaultLang) && - i18n.languages.includes(mailgoConfig.defaultLang)) { - lang = mailgoConfig.defaultLang; - } - // if is defined use it! - if (!(mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.forceLang) && document.documentElement.lang) { - lang = document.documentElement.lang; - } - // strings - let defaultStrings = translations[DEFAULT_LANG]; - let strings = translations[lang]; - // mailgo mail - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo"; - modal.classList.add("m-modal"); - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - // title (email address) - title = createElement("strong"); - title.id = "m-title"; - title.className = "m-title"; - modalContent.appendChild(title); - // details - let details = createElement(); - details.id = "m-details"; - details.className = "m-details"; - detailCc = createElement("p"); - detailCc.id = "m-cc"; - let ccSpan = createElement(span); - ccSpan.className = "w-500"; - ccSpan.appendChild(createTextNode(strings.cc || defaultStrings.cc)); - ccValue = createElement(span); - ccValue.id = "m-cc-value"; - detailCc.appendChild(ccSpan); - detailCc.appendChild(ccValue); - details.appendChild(detailCc); - detailBcc = createElement("p"); - detailBcc.id = "m-bcc"; - let bccSpan = createElement(span); - bccSpan.className = "w-500"; - bccSpan.appendChild(createTextNode(strings.bcc || defaultStrings.bcc)); - bccValue = createElement(span); - bccValue.id = "m-bcc-value"; - detailBcc.appendChild(bccSpan); - detailBcc.appendChild(bccValue); - details.appendChild(detailBcc); - detailSubject = createElement("p"); - detailSubject.id = "m-subject"; - let subjectSpan = createElement(span); - subjectSpan.className = "w-500"; - subjectSpan.appendChild(createTextNode(strings.subject || defaultStrings.subject)); - subjectValue = createElement(span); - subjectValue.id = "m-subject-value"; - detailSubject.appendChild(subjectSpan); - detailSubject.appendChild(subjectValue); - details.appendChild(detailSubject); - detailBody = createElement("p"); - detailBody.id = "m-body"; - let bodySpan = createElement(span); - bodySpan.className = "w-500"; - bodySpan.appendChild(createTextNode(strings.body || defaultStrings.body)); - bodyValue = createElement(span); - bodyValue.id = "m-body-value"; - detailBody.appendChild(bodySpan); - detailBody.appendChild(bodyValue); - details.appendChild(detailBody); - modalContent.appendChild(details); - // Gmail - gmail = createElement("a"); - gmail.id = "m-gmail"; - gmail.href = DEFAULT_BTN_HREF; - gmail.classList.add("m-open"); - gmail.classList.add("m-gmail"); - gmail.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let gmailSpan = createElement(span); - gmailSpan.className = "w-500"; - gmailSpan.appendChild(createTextNode(strings.gmail || defaultStrings.gmail)); - gmail.appendChild(gmailSpan); - modalContent.appendChild(gmail); - // Outlook - outlook = createElement("a"); - outlook.id = "m-outlook"; - outlook.href = DEFAULT_BTN_HREF; - outlook.classList.add("m-open"); - outlook.classList.add("m-outlook"); - outlook.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let outlookSpan = createElement(span); - outlookSpan.className = "w-500"; - outlookSpan.appendChild(createTextNode(strings.outlook || defaultStrings.outlook)); - outlook.appendChild(outlookSpan); - modalContent.appendChild(outlook); - // open default - mailgo_open = createElement("a"); - mailgo_open.id = "m-open"; - mailgo_open.href = DEFAULT_BTN_HREF; - mailgo_open.classList.add("m-open"); - mailgo_open.classList.add("m-default"); - let openSpan = createElement(span); - openSpan.className = "w-500"; - openSpan.appendChild(createTextNode(strings.open || defaultStrings.open)); - mailgo_open.appendChild(openSpan); - mailgo_open.appendChild(createTextNode(strings._default || defaultStrings._default)); - modalContent.appendChild(mailgo_open); - // copy - copyMail = createElement("a"); - copyMail.id = "m-copy"; - copyMail.href = DEFAULT_BTN_HREF; - copyMail.classList.add("m-copy"); - copyMail.classList.add("w-500"); - copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy)); - modalContent.appendChild(copyMail); - modalContent.appendChild(byElement()); - // add the modal at the end of the body - document.body.appendChild(modal); - // every click outside the modal will hide the modal - modalBackground.addEventListener("click", hideMailgo); - } - // mailgo tel - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo-tel"; - modal.classList.add("m-modal"); - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - // title (telephone number) - titleTel = createElement("strong"); - titleTel.id = "m-tel-title"; - titleTel.className = "m-title"; - modalContent.appendChild(titleTel); - // Telegram - telegram = createElement("a"); - telegram.id = "m-tg"; - telegram.href = DEFAULT_BTN_HREF; - telegram.classList.add("m-open"); - telegram.classList.add("m-tg"); - // by default not display - telegram.style.display = "none"; - telegram.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let telegramSpan = createElement(span); - telegramSpan.className = "w-500"; - telegramSpan.appendChild(createTextNode(strings.telegram || defaultStrings.telegram)); - telegram.appendChild(telegramSpan); - modalContent.appendChild(telegram); - // WhatsApp - wa = createElement("a"); - wa.id = "m-wa"; - wa.href = DEFAULT_BTN_HREF; - wa.classList.add("m-open"); - wa.classList.add("m-wa"); - wa.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let waSpan = createElement(span); - waSpan.className = "w-500"; - waSpan.appendChild(createTextNode(strings.whatsapp || defaultStrings.whatsapp)); - wa.appendChild(waSpan); - modalContent.appendChild(wa); - // Skype - skype = createElement("a"); - skype.id = "m-skype"; - skype.href = DEFAULT_BTN_HREF; - skype.classList.add("m-open"); - skype.classList.add("m-skype"); - skype.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let skypeSpan = createElement(span); - skypeSpan.className = "w-500"; - skypeSpan.appendChild(createTextNode(strings.skype || defaultStrings.skype)); - skype.appendChild(skypeSpan); - modalContent.appendChild(skype); - // call default - call = createElement("a"); - call.id = "m-call"; - call.href = DEFAULT_BTN_HREF; - call.classList.add("m-open"); - call.classList.add("m-default"); - let callSpan = createElement(span); - callSpan.className = "w-500"; - callSpan.appendChild(createTextNode(strings.call || defaultStrings.call)); - call.appendChild(callSpan); - call.appendChild(createTextNode(strings._as_default || defaultStrings._as_default)); - modalContent.appendChild(call); - // copy - copyTel = createElement("a"); - copyTel.id = "m-tel-copy"; - copyTel.href = DEFAULT_BTN_HREF; - copyTel.classList.add("m-copy"); - copyTel.classList.add("w-500"); - copyTel.appendChild(createTextNode(strings.copy || defaultStrings.copy)); - modalContent.appendChild(copyTel); - modalContent.appendChild(byElement()); - // add the modal at the end of the body - document.body.appendChild(modal); - // 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); + +var mailgoInit = function mailgoInit(mailgoConfig) { + // default language + var lang = DEFAULT_LANG; // translations + + var translations = i18n.translations; // if a default language is defined use it + + if ((mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.defaultLang) && i18n.languages.includes(mailgoConfig.defaultLang)) { + lang = mailgoConfig.defaultLang; + } // if is defined use it! + + + if (!(mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.forceLang) && document.documentElement.lang) { + lang = document.documentElement.lang; + } // strings + + + var defaultStrings = translations[DEFAULT_LANG]; + var strings = translations[lang]; // mailgo mail + + { + // modal + var modal = createElement(); + modal.style.display = "none"; + modal.id = "mailgo"; + modal.classList.add("m-modal"); // background + + var modalBackground = createElement(); + modalBackground.className = "m-modal-back"; + modal.appendChild(modalBackground); // modal content + + var modalContent = createElement(); + modalContent.className = "m-modal-content"; + modal.appendChild(modalContent); // title (email address) + + title = createElement("strong"); + title.id = "m-title"; + title.className = "m-title"; + modalContent.appendChild(title); // details + + var details = createElement(); + details.id = "m-details"; + details.className = "m-details"; + detailCc = createElement("p"); + detailCc.id = "m-cc"; + var ccSpan = createElement(span); + ccSpan.className = "w-500"; + ccSpan.appendChild(createTextNode(strings.cc || defaultStrings.cc)); + ccValue = createElement(span); + ccValue.id = "m-cc-value"; + detailCc.appendChild(ccSpan); + detailCc.appendChild(ccValue); + details.appendChild(detailCc); + detailBcc = createElement("p"); + detailBcc.id = "m-bcc"; + var bccSpan = createElement(span); + bccSpan.className = "w-500"; + bccSpan.appendChild(createTextNode(strings.bcc || defaultStrings.bcc)); + bccValue = createElement(span); + bccValue.id = "m-bcc-value"; + detailBcc.appendChild(bccSpan); + detailBcc.appendChild(bccValue); + details.appendChild(detailBcc); + detailSubject = createElement("p"); + detailSubject.id = "m-subject"; + var subjectSpan = createElement(span); + subjectSpan.className = "w-500"; + subjectSpan.appendChild(createTextNode(strings.subject || defaultStrings.subject)); + subjectValue = createElement(span); + subjectValue.id = "m-subject-value"; + detailSubject.appendChild(subjectSpan); + detailSubject.appendChild(subjectValue); + details.appendChild(detailSubject); + detailBody = createElement("p"); + detailBody.id = "m-body"; + var bodySpan = createElement(span); + bodySpan.className = "w-500"; + bodySpan.appendChild(createTextNode(strings.body || defaultStrings.body)); + bodyValue = createElement(span); + bodyValue.id = "m-body-value"; + detailBody.appendChild(bodySpan); + detailBody.appendChild(bodyValue); + details.appendChild(detailBody); + modalContent.appendChild(details); // Gmail + + gmail = createElement("a"); + gmail.id = "m-gmail"; + gmail.href = DEFAULT_BTN_HREF; + gmail.classList.add("m-open"); + gmail.classList.add("m-gmail"); + gmail.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var gmailSpan = createElement(span); + gmailSpan.className = "w-500"; + gmailSpan.appendChild(createTextNode(strings.gmail || defaultStrings.gmail)); + gmail.appendChild(gmailSpan); + modalContent.appendChild(gmail); // Outlook + + outlook = createElement("a"); + outlook.id = "m-outlook"; + outlook.href = DEFAULT_BTN_HREF; + outlook.classList.add("m-open"); + outlook.classList.add("m-outlook"); + outlook.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var outlookSpan = createElement(span); + outlookSpan.className = "w-500"; + outlookSpan.appendChild(createTextNode(strings.outlook || defaultStrings.outlook)); + outlook.appendChild(outlookSpan); + modalContent.appendChild(outlook); // open default + + mailgo_open = createElement("a"); + mailgo_open.id = "m-open"; + mailgo_open.href = DEFAULT_BTN_HREF; + mailgo_open.classList.add("m-open"); + mailgo_open.classList.add("m-default"); + var openSpan = createElement(span); + openSpan.className = "w-500"; + openSpan.appendChild(createTextNode(strings.open || defaultStrings.open)); + mailgo_open.appendChild(openSpan); + mailgo_open.appendChild(createTextNode(strings._default || defaultStrings._default)); + modalContent.appendChild(mailgo_open); // copy + + copyMail = createElement("a"); + copyMail.id = "m-copy"; + copyMail.href = DEFAULT_BTN_HREF; + copyMail.classList.add("m-copy"); + copyMail.classList.add("w-500"); + copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy)); + modalContent.appendChild(copyMail); + modalContent.appendChild(byElement()); // add the modal at the end of the body + + document.body.appendChild(modal); // every click outside the modal will hide the modal + + modalBackground.addEventListener("click", hideMailgo); + } // mailgo tel + + { + // modal + var _modal = createElement(); + + _modal.style.display = "none"; + _modal.id = "mailgo-tel"; + + _modal.classList.add("m-modal"); // background + + + var _modalBackground = createElement(); + + _modalBackground.className = "m-modal-back"; + + _modal.appendChild(_modalBackground); // modal content + + + var _modalContent = createElement(); + + _modalContent.className = "m-modal-content"; + + _modal.appendChild(_modalContent); // title (telephone number) + + + titleTel = createElement("strong"); + titleTel.id = "m-tel-title"; + titleTel.className = "m-title"; + + _modalContent.appendChild(titleTel); // Telegram + + + telegram = createElement("a"); + telegram.id = "m-tg"; + telegram.href = DEFAULT_BTN_HREF; + telegram.classList.add("m-open"); + telegram.classList.add("m-tg"); // by default not display + + telegram.style.display = "none"; + telegram.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var telegramSpan = createElement(span); + telegramSpan.className = "w-500"; + telegramSpan.appendChild(createTextNode(strings.telegram || defaultStrings.telegram)); + telegram.appendChild(telegramSpan); + + _modalContent.appendChild(telegram); // WhatsApp + + + wa = createElement("a"); + wa.id = "m-wa"; + wa.href = DEFAULT_BTN_HREF; + wa.classList.add("m-open"); + wa.classList.add("m-wa"); + wa.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var waSpan = createElement(span); + waSpan.className = "w-500"; + waSpan.appendChild(createTextNode(strings.whatsapp || defaultStrings.whatsapp)); + wa.appendChild(waSpan); + + _modalContent.appendChild(wa); // Skype + + + skype = createElement("a"); + skype.id = "m-skype"; + skype.href = DEFAULT_BTN_HREF; + skype.classList.add("m-open"); + skype.classList.add("m-skype"); + skype.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var skypeSpan = createElement(span); + skypeSpan.className = "w-500"; + skypeSpan.appendChild(createTextNode(strings.skype || defaultStrings.skype)); + skype.appendChild(skypeSpan); + + _modalContent.appendChild(skype); // call default + + + call = createElement("a"); + call.id = "m-call"; + call.href = DEFAULT_BTN_HREF; + call.classList.add("m-open"); + call.classList.add("m-default"); + var callSpan = createElement(span); + callSpan.className = "w-500"; + callSpan.appendChild(createTextNode(strings.call || defaultStrings.call)); + call.appendChild(callSpan); + call.appendChild(createTextNode(strings._as_default || defaultStrings._as_default)); + + _modalContent.appendChild(call); // copy + + + copyTel = createElement("a"); + copyTel.id = "m-tel-copy"; + copyTel.href = DEFAULT_BTN_HREF; + copyTel.classList.add("m-copy"); + copyTel.classList.add("w-500"); + copyTel.appendChild(createTextNode(strings.copy || defaultStrings.copy)); + + _modalContent.appendChild(copyTel); + + _modalContent.appendChild(byElement()); // add the modal at the end of the body + + + document.body.appendChild(_modal); // 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 * function to render a mailgo (mail or tel) */ -const mailgoRender = (type = MAIL_TYPE, mailgo) => { - // mailgo mail - if (type === MAIL_TYPE) { - // if the element href=^"mailto:" - if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { - mail = decodeURIComponent(mailgo.href.split("?")[0].split(MAILTO)[1].trim()); - url = new URL(mailgo.href); - let urlParams = url.searchParams; - // optional parameters for the email - cc = urlParams.get("cc"); - bcc = urlParams.get("bcc"); - subject = urlParams.get("subject"); - bodyMail = urlParams.get("body"); - } - else { - // if the element href="#mailgo" or class="mailgo" - // mail = data-address + @ + data-domain - mail = - mailgo.getAttribute("data-address") + - "@" + - mailgo.getAttribute("data-domain"); - url = new URL(MAILTO + encodeURIComponent(mail)); - // cc = data-cc-address + @ + data-cc-domain - cc = - mailgo.getAttribute("data-cc-address") + - "@" + - mailgo.getAttribute("data-cc-domain"); - // bcc = data-bcc-address + @ + data-bcc-domain - bcc = - mailgo.getAttribute("data-bcc-address") + - "@" + - mailgo.getAttribute("data-bcc-domain"); - // subject = data-subject - subject = mailgo.getAttribute("data-subject"); - // body = data-body - bodyMail = mailgo.getAttribute("data-body"); - } - // validate the email address - if (!validateEmails(mail.split(","))) - return; - // if cc, bcc is not valid cc, bcc = "" - if (cc && !validateEmails(cc.split(","))) - cc = ""; - if (bcc && !validateEmails(bcc.split(","))) - bcc = ""; - // the title of the modal (email address) - title.innerHTML = mail.split(",").join("
"); - // add the details if provided - cc - ? ((detailCc.style.display = "block"), - (ccValue.innerHTML = cc.split(",").join("
"))) - : (detailCc.style.display = "none"); - bcc - ? ((detailBcc.style.display = "block"), - (bccValue.innerHTML = bcc.split(",").join("
"))) - : (detailBcc.style.display = "none"); - subject - ? ((detailSubject.style.display = "block"), - (subjectValue.textContent = subject)) - : (detailSubject.style.display = "none"); - bodyMail - ? ((detailBody.style.display = "block"), - (bodyValue.textContent = bodyMail)) - : (detailBody.style.display = "none"); - // add the actions - gmail.addEventListener("click", openGmail); - outlook.addEventListener("click", openOutlook); - encEmail = encodeEmail(mail); - mailgo_open.addEventListener("click", openDefault); - copyMail.addEventListener("click", () => copy(mail)); + + +var mailgoRender = function mailgoRender() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + var mailgo = arguments.length > 1 ? arguments[1] : undefined; + + // mailgo mail + if (type === MAIL_TYPE) { + // if the element href=^"mailto:" + if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { + mail = decodeURIComponent(mailgo.href.split("?")[0].split(MAILTO)[1].trim()); + url = new URL(mailgo.href); + var urlParams = url.searchParams; // optional parameters for the email + + cc = urlParams.get("cc"); + bcc = urlParams.get("bcc"); + subject = urlParams.get("subject"); + bodyMail = urlParams.get("body"); + } else { + // if the element href="#mailgo" or class="mailgo" + // mail = data-address + @ + data-domain + mail = mailgo.getAttribute("data-address") + "@" + mailgo.getAttribute("data-domain"); + url = new URL(MAILTO + encodeURIComponent(mail)); // cc = data-cc-address + @ + data-cc-domain + + cc = mailgo.getAttribute("data-cc-address") + "@" + mailgo.getAttribute("data-cc-domain"); // bcc = data-bcc-address + @ + data-bcc-domain + + bcc = mailgo.getAttribute("data-bcc-address") + "@" + mailgo.getAttribute("data-bcc-domain"); // subject = data-subject + + subject = mailgo.getAttribute("data-subject"); // body = data-body + + bodyMail = mailgo.getAttribute("data-body"); + } // validate the email address + + + if (!validateEmails(mail.split(","))) return; // if cc, bcc is not valid cc, bcc = "" + + if (cc && !validateEmails(cc.split(","))) cc = ""; + if (bcc && !validateEmails(bcc.split(","))) bcc = ""; // the title of the modal (email address) + + title.innerHTML = mail.split(",").join("
"); // add the details if provided + + cc ? (detailCc.style.display = "block", ccValue.innerHTML = cc.split(",").join("
")) : detailCc.style.display = "none"; + bcc ? (detailBcc.style.display = "block", bccValue.innerHTML = bcc.split(",").join("
")) : detailBcc.style.display = "none"; + subject ? (detailSubject.style.display = "block", subjectValue.textContent = subject) : detailSubject.style.display = "none"; + bodyMail ? (detailBody.style.display = "block", bodyValue.textContent = bodyMail) : detailBody.style.display = "none"; // add the actions + + gmail.addEventListener("click", openGmail); + outlook.addEventListener("click", openOutlook); + encEmail = encodeEmail(mail); + mailgo_open.addEventListener("click", openDefault); + copyMail.addEventListener("click", function () { + return copy(mail); + }); + } // mailgo tel + + + if (type === TEL_TYPE) { + if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { + tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); + } else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { + tel = decodeURIComponent(mailgo.href.split("?")[0].split(CALLTO)[1].trim()); + } else if (mailgo.hasAttribute("data-tel")) { + tel = mailgo.getAttribute("data-tel"); + msg = mailgo.getAttribute("data-msg"); + } // information + // let titleEl = getE("m-tel-title"); + // Telegram username + + + if (mailgo.hasAttribute("data-telegram")) { + telegramUsername = mailgo.getAttribute("data-telegram"); + } // Telegram username + + + if (mailgo.hasAttribute("data-skype")) { + skypeUsername = mailgo.getAttribute("data-skype"); + } // the title of the modal (tel) + + + titleTel.innerHTML = tel; // add the actions to buttons + + wa.addEventListener("click", openWhatsApp); + + if (telegramUsername) { + setDisplay("m-tg", "block"); + telegram.addEventListener("click", openTelegram); } - // mailgo tel - if (type === TEL_TYPE) { - if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); - } - else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(CALLTO)[1].trim()); - } - else if (mailgo.hasAttribute("data-tel")) { - tel = mailgo.getAttribute("data-tel"); - msg = mailgo.getAttribute("data-msg"); - } - // information - // let titleEl = getE("m-tel-title"); - // Telegram username - if (mailgo.hasAttribute("data-telegram")) { - telegramUsername = mailgo.getAttribute("data-telegram"); - } - // Telegram username - if (mailgo.hasAttribute("data-skype")) { - skypeUsername = mailgo.getAttribute("data-skype"); - } - // the title of the modal (tel) - titleTel.innerHTML = tel; - // add the actions to buttons - wa.addEventListener("click", openWhatsApp); - if (telegramUsername) { - setDisplay("m-tg", "block"); - telegram.addEventListener("click", openTelegram); - } - skype.addEventListener("click", openSkype); - call.addEventListener("click", callDefault); - copyTel.addEventListener("click", () => copy(tel)); - } - // show the mailgo - showMailgo(type); - // add listener keyDown - document.addEventListener("keydown", mailgoKeydown); + + skype.addEventListener("click", openSkype); + call.addEventListener("click", callDefault); + copyTel.addEventListener("click", function () { + return copy(tel); + }); + } // show the mailgo + + + showMailgo(type); // add listener keyDown + + document.addEventListener("keydown", mailgoKeydown); +}; // actions + + +var openGmail = function openGmail() { + // Gmail url + var gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + encodeURIComponent(mail); // the details if provided + + if (cc) gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); + if (bcc) gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); + if (subject) gmailUrl = gmailUrl.concat("&subject=" + subject); + if (bodyMail) gmailUrl = gmailUrl.concat("&body=" + bodyMail); // open the link + + window.open(gmailUrl, "_blank"); // hide the modal + + hideMailgo(); }; -// actions -const openGmail = () => { - // Gmail url - let gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + - encodeURIComponent(mail); - // the details if provided - if (cc) - gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); - if (bcc) - gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); - if (subject) - gmailUrl = gmailUrl.concat("&subject=" + subject); - if (bodyMail) - gmailUrl = gmailUrl.concat("&body=" + bodyMail); - // open the link - window.open(gmailUrl, "_blank"); - // hide the modal + +var openOutlook = function openOutlook() { + // Outlook url + var outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail); // the details if provided + + if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject); + if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail); // open the link + + window.open(outlookUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openDefault = function openDefault() { + mailToEncoded(encEmail); + hideMailgo(); +}; + +var openTelegram = function openTelegram() { + // Telegram url + var tgUrl = "https://t.me/" + telegramUsername; // open the url + + window.open(tgUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openSkype = function openSkype() { + var skype = skypeUsername !== "" ? skypeUsername : tel; // Telegram url + + var skypeUrl = "skype:" + skype; // open the url + + window.open(skypeUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openWhatsApp = function openWhatsApp() { + // WhatsApp url + var waUrl = "https://wa.me/" + tel; // the details if provided + + if (msg) waUrl + "?text=" + msg; // open the url + + window.open(waUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var callDefault = function callDefault() { + var callUrl = "tel:" + tel; + window.open(callUrl); + hideMailgo(); +}; + +var copy = function copy(content) { + copyToClipboard(content); + var activeCopy; // the correct copyButton (mail or tel) + + mailgoIsShowing(MAIL_TYPE) ? activeCopy = copyMail : activeCopy = copyTel; + activeCopy.textContent = "copied"; + setTimeout(function () { + activeCopy.textContent = "copy"; // hide after the timeout + hideMailgo(); -}; -const openOutlook = () => { - // Outlook url - let outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + - encodeURIComponent(mail); - // the details if provided - if (subject) - outlookUrl = outlookUrl.concat("&subject=" + subject); - if (bodyMail) - outlookUrl = outlookUrl.concat("&body=" + bodyMail); - // open the link - window.open(outlookUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openDefault = () => { - mailToEncoded(encEmail); - hideMailgo(); -}; -const openTelegram = () => { - // Telegram url - let tgUrl = "https://t.me/" + telegramUsername; - // open the url - window.open(tgUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openSkype = () => { - let skype = skypeUsername !== "" ? skypeUsername : tel; - // Telegram url - let skypeUrl = "skype:" + skype; - // open the url - window.open(skypeUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openWhatsApp = () => { - // WhatsApp url - let waUrl = "https://wa.me/" + tel; - // the details if provided - if (msg) - waUrl + "?text=" + msg; - // open the url - window.open(waUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const callDefault = (event) => { - let callUrl = "tel:" + tel; - window.open(callUrl); - hideMailgo(); -}; -const copy = (content) => { - copyToClipboard(content); - let activeCopy; - // the correct copyButton (mail or tel) - mailgoIsShowing(MAIL_TYPE) ? (activeCopy = copyMail) : (activeCopy = copyTel); - activeCopy.textContent = "copied"; - setTimeout(() => { - activeCopy.textContent = "copy"; - // hide after the timeout - hideMailgo(); - }, 999); -}; -// function that returns if an element is a mailgo -const isMailgo = (element, type = MAIL_TYPE) => { - let href = element.href; - // mailgo type mail - if (type === MAIL_TYPE) { - return ( - // first case: it is an element with "mailto:..." in href and no no-mailgo in classList - (href && - href.toLowerCase().startsWith(MAILTO) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-address") && - // second case: the href=#mailgo - ((href && element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo"))))); - } - // mailgo type tel - if (type === TEL_TYPE) { - return ( - // first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList - (href && - (href.toLowerCase().startsWith(TEL) || - href.toLowerCase().startsWith(CALLTO)) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-tel") && - // second case: the href=#mailgo - href && - element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo"))); - } - return false; + }, 999); +}; // function that returns if an element is a mailgo + + +var isMailgo = function isMailgo(element) { + var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MAIL_TYPE; + var href = element.href; // mailgo type mail + + if (type === MAIL_TYPE) { + return (// first case: it is an element with "mailto:..." in href and no no-mailgo in classList + href && href.toLowerCase().startsWith(MAILTO) && !element.classList.contains("no-mailgo") || element.hasAttribute("data-address") && ( // second case: the href=#mailgo + href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo + element.classList && element.classList.contains("mailgo")) + ); + } // mailgo type tel + + + if (type === TEL_TYPE) { + return (// first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList + href && (href.toLowerCase().startsWith(TEL) || href.toLowerCase().startsWith(CALLTO)) && !element.classList.contains("no-mailgo") || element.hasAttribute("data-tel") && // second case: the href=#mailgo + href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo + element.classList && element.classList.contains("mailgo") + ); + } + + return false; }; /** * mailgoCheckRender @@ -720,220 +736,270 @@ const isMailgo = (element, type = MAIL_TYPE) => { * 'a[href^="callto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo' * ); */ -const mailgoCheckRender = (event) => { - // check if the id=mailgo exists in the body - if (!document.contains(getE("mailgo")) || - !document.contains(getE("mailgo-tel"))) - return; - // if a mailgo is already showing do nothing - if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) - 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 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 true; - } - if (isMailgo(element, TEL_TYPE)) { - // stop the normal execution of the element click - event.preventDefault(); - // render mailgo - mailgoRender(TEL_TYPE, element); - return true; - } - }); - } - return false; + + +var mailgoCheckRender = function mailgoCheckRender(event) { + // check if the id=mailgo exists in the body + if (!document.contains(getE("mailgo")) || !document.contains(getE("mailgo-tel"))) return; // if a mailgo is already showing do nothing + + if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) return false; // the path of the event + + var path = event.composedPath && event.composedPath() || composedPath(event.target); + + if (path) { + path.forEach(function (element) { + 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)) { + // stop the normal execution of the element click + event.preventDefault(); // render mailgo + + mailgoRender(MAIL_TYPE, element); + return true; + } + + if (isMailgo(element, TEL_TYPE)) { + // stop the normal execution of the element click + event.preventDefault(); // render mailgo + + mailgoRender(TEL_TYPE, element); + return true; + } + }); + } + + return false; }; /** * mailgoKeydown * function to manage the keydown event when the modal is showing */ -const mailgoKeydown = (event) => { - // if mailgo is showing - if (mailgoIsShowing(MAIL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 71: - // g -> open GMail - openGmail(); - break; - case 79: - // o -> open Outlook - openOutlook(); - break; - case 32: - case 13: - // spacebar or enter -> open default - openDefault(); - break; - case 67: - // c -> copy - copy(mail); - break; - default: - return; - } + + +var mailgoKeydown = function mailgoKeydown(event) { + // if mailgo is showing + if (mailgoIsShowing(MAIL_TYPE)) { + switch (event.keyCode) { + case 27: + // Escape + hideMailgo(); + break; + + case 71: + // g -> open GMail + openGmail(); + break; + + case 79: + // o -> open Outlook + openOutlook(); + break; + + case 32: + case 13: + // spacebar or enter -> open default + openDefault(); + break; + + case 67: + // c -> copy + copy(mail); + break; + + default: + return; } - else if (mailgoIsShowing(TEL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 84: - // t -> open Telegram - openTelegram(); - break; - case 87: - // w -> open WhatsApp - openWhatsApp(); - break; - case 32: - case 13: - // spacebar or enter -> call default - callDefault(); - break; - case 67: - // c -> copy - copy(tel); - break; - default: - return; - } + } else if (mailgoIsShowing(TEL_TYPE)) { + switch (event.keyCode) { + case 27: + // Escape + hideMailgo(); + break; + + case 84: + // t -> open Telegram + openTelegram(); + break; + + case 87: + // w -> open WhatsApp + openWhatsApp(); + break; + + case 32: + case 13: + // spacebar or enter -> call default + callDefault(); + break; + + case 67: + // c -> copy + copy(tel); + break; + + default: + return; } - return; + } + + return; +}; // show the modal + + +var showMailgo = function showMailgo() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + + // show mailgo type mail + if (type === MAIL_TYPE) { + setDisplay("mailgo", "flex"); + return true; + } // show mailgo type tel + + + if (type === TEL_TYPE) { + setDisplay("mailgo-tel", "flex"); + return true; + } + + return false; +}; // hide the modal + + +var hideMailgo = function hideMailgo() { + setDisplay("mailgo", "none"); + setDisplay("mailgo-tel", "none"); // remove listener keyDown + + document.removeEventListener("keydown", mailgoKeydown); +}; // is the mailgo modal hidden? + + +var mailgoIsShowing = function mailgoIsShowing() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + return type === MAIL_TYPE ? getDisplay("mailgo") === "flex" : type === TEL_TYPE ? getDisplay("mailgo-tel") === "flex" : false; }; -// show the modal -const showMailgo = (type = MAIL_TYPE) => { - // show mailgo type mail - if (type === MAIL_TYPE) { - setDisplay("mailgo", "flex"); - return true; + +var byElement = function byElement() { + // by + var by = createElement("a"); + by.href = "https://mailgo.js.org?ref=mailgo-modal"; + by.className = "m-by"; + by.target = "_blank"; + by.rel = "noopener noreferrer"; + by.appendChild(createTextNode("mailgo.js.org")); + return by; +}; // create element + + +var createElement = function createElement() { + var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "div"; + return document.createElement(element); +}; // create text node + + +var createTextNode = function createTextNode(element) { + return document.createTextNode(element); +}; // decrypt email + + +var mailToEncoded = function mailToEncoded(encoded) { + return window.location.href = MAILTO + atob(encoded); +}; // encode email + + +var encodeEmail = function encodeEmail(email) { + return btoa(email); +}; // getE shorthand + + +var getE = function getE(id) { + return document.getElementById(id); +}; // get display value + + +var getDisplay = function getDisplay(id) { + return getE(id).style.display; +}; // get display value + + +var setDisplay = function setDisplay(id, value) { + return getE(id).style.display = value; +}; // custom composedPath if path or event.composedPath() are not defined + + +var composedPath = function composedPath(el) { + var path = []; + + while (el) { + path.push(el); + + if (el.tagName === "HTML") { + path.push(document); + path.push(window); + return path; } - // show mailgo type tel - if (type === TEL_TYPE) { - setDisplay("mailgo-tel", "flex"); - return true; - } - return false; -}; -// hide the modal -const hideMailgo = () => { - setDisplay("mailgo", "none"); - setDisplay("mailgo-tel", "none"); - // remove listener keyDown - document.removeEventListener("keydown", mailgoKeydown); -}; -// is the mailgo modal hidden? -const mailgoIsShowing = (type = MAIL_TYPE) => { - return type === MAIL_TYPE - ? getDisplay("mailgo") === "flex" - : type === TEL_TYPE - ? getDisplay("mailgo-tel") === "flex" - : false; -}; -const byElement = () => { - // by - let by = createElement("a"); - by.href = "https://mailgo.js.org?ref=mailgo-modal"; - by.className = "m-by"; - by.target = "_blank"; - by.rel = "noopener noreferrer"; - by.appendChild(createTextNode("mailgo.js.org")); - return by; -}; -// create element -const createElement = (element = "div") => document.createElement(element); -// create text node -const createTextNode = (element) => document.createTextNode(element); -// decrypt email -const mailToEncoded = (encoded) => (window.location.href = MAILTO + atob(encoded)); -// encode email -const encodeEmail = (email) => btoa(email); -// getE shorthand -const getE = (id) => document.getElementById(id); -// get display value -const getDisplay = (id) => getE(id).style.display; -// get display value -const setDisplay = (id, value) => (getE(id).style.display = value); -// custom composedPath if path or event.composedPath() are not defined -const composedPath = (el) => { - let path = []; - while (el) { - path.push(el); - if (el.tagName === "HTML") { - path.push(document); - path.push(window); - return path; - } - el = el.parentElement; - } -}; -// validate a single email with regex -const validateEmail = (email) => /^(([^<>()[\]\\.,;:\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) => arr.every(validateEmail); -// copy of a string -const copyToClipboard = (str) => { - let el = createElement("textarea"); - el.value = str; - el.setAttribute("readonly", ""); - el.style.position = "absolute"; - el.style.left = "-9999px"; - document.body.appendChild(el); - let selected = document.getSelection().rangeCount > 0 - ? document.getSelection().getRangeAt(0) - : false; - el.select(); - document.execCommand("copy"); - document.body.removeChild(el); - if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); - return true; - } - return false; -}; -const mailgoStyle = () => { - // mailgo style - let mailgoCSSElement = createElement("style"); - mailgoCSSElement.id = "mailgo-style"; - mailgoCSSElement.type = "text/css"; - mailgoCSSElement.appendChild(createTextNode(mailgoCSS)); - document.head.appendChild(mailgoCSSElement); -}; -// mailgo -const mailgo = (mailgoConfig) => { - // if the window is defined... - if (window && typeof window !== "undefined") { - // add the style for mailgo - mailgoStyle(); - // if is set an initEvent add the listener - if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) { - document.addEventListener(mailgoConfig.initEvent, () => { - mailgoInit(mailgoConfig); - }); - } - else { - mailgoInit(mailgoConfig); - } + + el = el.parentElement; + } +}; // validate a single email with regex + + +var validateEmail = function validateEmail(email) { + return /^(([^<>()[\]\\.,;:\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 + + +var validateEmails = function validateEmails(arr) { + return arr.every(validateEmail); +}; // copy of a string + + +var copyToClipboard = function copyToClipboard(str) { + var el = createElement("textarea"); + el.value = str; + el.setAttribute("readonly", ""); + el.style.position = "absolute"; + el.style.left = "-9999px"; + document.body.appendChild(el); + var selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; + el.select(); + document.execCommand("copy"); + document.body.removeChild(el); + + if (selected) { + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); + return true; + } + + return false; +}; + +var mailgoStyle = function mailgoStyle() { + // mailgo style + var mailgoCSSElement = createElement("style"); + mailgoCSSElement.id = "mailgo-style"; + mailgoCSSElement.type = "text/css"; + mailgoCSSElement.appendChild(createTextNode(mailgoCSS)); + document.head.appendChild(mailgoCSSElement); +}; // mailgo + + +var mailgo = function mailgo(mailgoConfig) { + // if the window is defined... + if (window && typeof window !== "undefined") { + // add the style for mailgo + mailgoStyle(); // if is set an initEvent add the listener + + if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) { + document.addEventListener(mailgoConfig.initEvent, function () { + mailgoInit(mailgoConfig); + }); + } else { + mailgoInit(mailgoConfig); } + } }; /* harmony default export */ var src_mailgo = (mailgo); - // CONCATENATED MODULE: ./mailgo.dist.ts // webpack > dist/mailgo.min.js diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index 0452d26..cf714f4 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -window.mailgo=function(e){var t={};function a(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,a),n.l=!0,n.exports}return a.m=e,a.c=t,a.d=function(e,t,o){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(a.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)a.d(o,n,function(t){return e[t]}.bind(null,n));return o},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=4)}([function(e){e.exports=JSON.parse('{"languages":["en","it"],"translations":{"en":{"open_in":"open in ","cc_":"cc ","bcc_":"bcc ","subject_":"subject ","body_":"body ","gmail":"Gmail","outlook":"Outlook","telegram":"Telegram","whatsapp":"WhatsApp","skype":"Skype","call":"call","open":"open","_default":" default","_as_default":" as default","copy":"copy"},"it":{"open_in":"apri con ","cc":"cc ","bcc":"ccn ","subject":"oggetto ","body":"testo ","gmail":"Gmail","outlook":"Outlook","telegram":"Telegram","whatsapp":"WhatsApp","skype":"Skype","call":"chiama","open":"apri","_default":" ","_as_default":" ","copy":"copia"}}}')},function(e,t,a){var o=a(2);e.exports="string"==typeof o?o:o.toString()},function(e,t,a){(t=a(3)(!1)).push([e.i,'.m-modal{position:fixed;top:0;right:0;bottom:0;left:0;justify-content:center;align-items:center;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal p,.m-modal span,.m-modal strong,.m-modal a{margin:0;padding:0;font-size:100%;line-height:1;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,0.75);opacity:0.8}.m-modal .m-modal-content{position:relative;z-index:10002;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:0.97;border-radius:8px;box-shadow:0px 3px 20px rgba(32,35,42,0.5);color:#4a4a4a;display:flex;flex-direction:column;overflow:auto;padding:20px;transition:0.5s box-shadow}.m-modal .m-modal-content:hover{opacity:1;box-shadow:0px 7px 20px rgba(32,35,42,0.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,0.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,0.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,0.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,0.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,0.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-default:hover,.m-modal .m-modal-content a.m-copy:hover{background-color:rgba(0,0,0,0.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:0.8rem;padding:5px;color:#4a4a4a;opacity:0.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}\n',""]),e.exports=t},function(e,t,a){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var a=function(e,t){var a=e[1]||"",o=e[3];if(!o)return a;if(t&&"function"==typeof btoa){var n=(d=o,i=btoa(unescape(encodeURIComponent(JSON.stringify(d)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),"/*# ".concat(c," */")),l=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[a].concat(l).concat([n]).join("\n")}var d,i,c;return[a].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(a,"}"):a})).join("")},t.i=function(e,a,o){"string"==typeof e&&(e=[[null,e,""]]);var n={};if(o)for(var l=0;l{let t="en",a=o.translations;(null==e?void 0:e.defaultLang)&&o.languages.includes(e.defaultLang)&&(t=e.defaultLang),!(null==e?void 0:e.forceLang)&&document.documentElement.lang&&(t=document.documentElement.lang);let n=a.en,i=a[t];{let e=ee();e.style.display="none",e.id="mailgo",e.classList.add("m-modal");let t=ee();t.className="m-modal-back",e.appendChild(t);let a=ee();a.className="m-modal-content",e.appendChild(a),c=ee("strong"),c.id="m-title",c.className="m-title",a.appendChild(c);let o=ee();o.id="m-details",o.className="m-details",m=ee("p"),m.id="m-cc";let s=ee(d);s.className="w-500",s.appendChild(te(i.cc||n.cc)),h=ee(d),h.id="m-cc-value",m.appendChild(s),m.appendChild(h),o.appendChild(m),p=ee("p"),p.id="m-bcc";let k=ee(d);k.className="w-500",k.appendChild(te(i.bcc||n.bcc)),g=ee(d),g.id="m-bcc-value",p.appendChild(k),p.appendChild(g),o.appendChild(p),r=ee("p"),r.id="m-subject";let v=ee(d);v.className="w-500",v.appendChild(te(i.subject||n.subject)),f=ee(d),f.id="m-subject-value",r.appendChild(v),r.appendChild(f),o.appendChild(r),u=ee("p"),u.id="m-body";let L=ee(d);L.className="w-500",L.appendChild(te(i.body||n.body)),b=ee(d),b.id="m-body-value",u.appendChild(L),u.appendChild(b),o.appendChild(u),a.appendChild(o),y=ee("a"),y.id="m-gmail",y.href=l,y.classList.add("m-open"),y.classList.add("m-gmail"),y.appendChild(te(i.open_in||n.open_in));let x=ee(d);x.className="w-500",x.appendChild(te(i.gmail||n.gmail)),y.appendChild(x),a.appendChild(y),C=ee("a"),C.id="m-outlook",C.href=l,C.classList.add("m-open"),C.classList.add("m-outlook"),C.appendChild(te(i.open_in||n.open_in));let j=ee(d);j.className="w-500",j.appendChild(te(i.outlook||n.outlook)),C.appendChild(j),a.appendChild(C),w=ee("a"),w.id="m-open",w.href=l,w.classList.add("m-open"),w.classList.add("m-default");let A=ee(d);A.className="w-500",A.appendChild(te(i.open||n.open)),w.appendChild(A),w.appendChild(te(i._default||n._default)),a.appendChild(w),_=ee("a"),_.id="m-copy",_.href=l,_.classList.add("m-copy"),_.classList.add("w-500"),_.appendChild(te(i.copy||n.copy)),a.appendChild(_),a.appendChild(Y()),document.body.appendChild(e),t.addEventListener("click",V)}{let e=ee();e.style.display="none",e.id="mailgo-tel",e.classList.add("m-modal");let t=ee();t.className="m-modal-back",e.appendChild(t);let a=ee();a.className="m-modal-content",e.appendChild(a),s=ee("strong"),s.id="m-tel-title",s.className="m-title",a.appendChild(s),k=ee("a"),k.id="m-tg",k.href=l,k.classList.add("m-open"),k.classList.add("m-tg"),k.style.display="none",k.appendChild(te(i.open_in||n.open_in));let o=ee(d);o.className="w-500",o.appendChild(te(i.telegram||n.telegram)),k.appendChild(o),a.appendChild(k),v=ee("a"),v.id="m-wa",v.href=l,v.classList.add("m-open"),v.classList.add("m-wa"),v.appendChild(te(i.open_in||n.open_in));let c=ee(d);c.className="w-500",c.appendChild(te(i.whatsapp||n.whatsapp)),v.appendChild(c),a.appendChild(v),L=ee("a"),L.id="m-skype",L.href=l,L.classList.add("m-open"),L.classList.add("m-skype"),L.appendChild(te(i.open_in||n.open_in));let m=ee(d);m.className="w-500",m.appendChild(te(i.skype||n.skype)),L.appendChild(m),a.appendChild(L),x=ee("a"),x.id="m-call",x.href=l,x.classList.add("m-open"),x.classList.add("m-default");let p=ee(d);p.className="w-500",p.appendChild(te(i.call||n.call)),x.appendChild(p),x.appendChild(te(i._as_default||n._as_default)),a.appendChild(x),j=ee("a"),j.id="m-tel-copy",j.href=l,j.classList.add("m-copy"),j.classList.add("w-500"),j.appendChild(te(i.copy||n.copy)),a.appendChild(j),a.appendChild(Y()),document.body.appendChild(e),t.addEventListener("click",V)}document.addEventListener("click",q)},W=(e="mail",t)=>{if("mail"===e){if(t.href&&t.href.toLowerCase().startsWith("mailto:")){A=decodeURIComponent(t.href.split("?")[0].split("mailto:")[1].trim()),i=new URL(t.href);let e=i.searchParams;N=e.get("cc"),S=e.get("bcc"),R=e.get("subject"),U=e.get("body")}else A=t.getAttribute("data-address")+"@"+t.getAttribute("data-domain"),i=new URL("mailto:"+encodeURIComponent(A)),N=t.getAttribute("data-cc-address")+"@"+t.getAttribute("data-cc-domain"),S=t.getAttribute("data-bcc-address")+"@"+t.getAttribute("data-bcc-domain"),R=t.getAttribute("data-subject"),U=t.getAttribute("data-body");if(!se(A.split(",")))return;N&&!se(N.split(","))&&(N=""),S&&!se(S.split(","))&&(S=""),c.innerHTML=A.split(",").join("
"),N?(m.style.display="block",h.innerHTML=N.split(",").join("
")):m.style.display="none",S?(p.style.display="block",g.innerHTML=S.split(",").join("
")):p.style.display="none",R?(r.style.display="block",f.textContent=R):r.style.display="none",U?(u.style.display="block",b.textContent=U):u.style.display="none",y.addEventListener("click",P),C.addEventListener("click",H),E=oe(A),w.addEventListener("click",D),_.addEventListener("click",()=>F(A))}"tel"===e&&(t.href&&t.href.toLowerCase().startsWith("tel:")?I=decodeURIComponent(t.href.split("?")[0].split("tel:")[1].trim()):t.href&&t.href.toLowerCase().startsWith("callto:")?I=decodeURIComponent(t.href.split("?")[0].split("callto:")[1].trim()):t.hasAttribute("data-tel")&&(I=t.getAttribute("data-tel"),M=t.getAttribute("data-msg")),t.hasAttribute("data-telegram")&&(z=t.getAttribute("data-telegram")),t.hasAttribute("data-skype")&&(O=t.getAttribute("data-skype")),s.innerHTML=I,v.addEventListener("click",J),z&&(de("m-tg","block"),k.addEventListener("click",B)),L.addEventListener("click",G),x.addEventListener("click",Z),j.addEventListener("click",()=>F(I))),Q(e),document.addEventListener("keydown",K)},P=()=>{let e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(A);N&&(e=e.concat("&cc="+encodeURIComponent(N))),S&&(e=e.concat("&bcc="+encodeURIComponent(S))),R&&(e=e.concat("&subject="+R)),U&&(e=e.concat("&body="+U)),window.open(e,"_blank"),V()},H=()=>{let e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(A);R&&(e=e.concat("&subject="+R)),U&&(e=e.concat("&body="+U)),window.open(e,"_blank"),V()},D=()=>{ae(E),V()},B=()=>{let e="https://t.me/"+z;window.open(e,"_blank"),V()},G=()=>{let e="skype:"+(""!==O?O:I);window.open(e,"_blank"),V()},J=()=>{let e="https://wa.me/"+I;window.open(e,"_blank"),V()},Z=e=>{let t="tel:"+I;window.open(t),V()},F=e=>{let t;me(e),t=X("mail")?_:j,t.textContent="copied",setTimeout(()=>{t.textContent="copy",V()},999)},$=(e,t="mail")=>{let a=e.href;return"mail"===t?a&&a.toLowerCase().startsWith("mailto:")&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(a&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")):"tel"===t&&(a&&(a.toLowerCase().startsWith("tel:")||a.toLowerCase().startsWith("callto:"))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&a&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))},q=e=>{if(!document.contains(ne("mailgo"))||!document.contains(ne("mailgo-tel")))return;if(X("mail")||X("tel"))return!1;let t=e.composedPath&&e.composedPath()||ie(e.target);return t&&t.forEach(t=>!(t instanceof HTMLDocument||t instanceof Window)&&($(t,"mail")?(e.preventDefault(),W("mail",t),!0):$(t,"tel")?(e.preventDefault(),W("tel",t),!0):void 0)),!1},K=e=>{if(X("mail"))switch(e.keyCode){case 27:V();break;case 71:P();break;case 79:H();break;case 32:case 13:D();break;case 67:F(A);break;default:return}else if(X("tel"))switch(e.keyCode){case 27:V();break;case 84:B();break;case 87:J();break;case 32:case 13:Z();break;case 67:F(I);break;default:return}},Q=(e="mail")=>"mail"===e?(de("mailgo","flex"),!0):"tel"===e&&(de("mailgo-tel","flex"),!0),V=()=>{de("mailgo","none"),de("mailgo-tel","none"),document.removeEventListener("keydown",K)},X=(e="mail")=>"mail"===e?"flex"===le("mailgo"):"tel"===e&&"flex"===le("mailgo-tel"),Y=()=>{let e=ee("a");return e.href="https://mailgo.js.org?ref=mailgo-modal",e.className="m-by",e.target="_blank",e.rel="noopener noreferrer",e.appendChild(te("mailgo.js.org")),e},ee=(e="div")=>document.createElement(e),te=e=>document.createTextNode(e),ae=e=>window.location.href="mailto:"+atob(e),oe=e=>btoa(e),ne=e=>document.getElementById(e),le=e=>ne(e).style.display,de=(e,t)=>ne(e).style.display=t,ie=e=>{let t=[];for(;e;){if(t.push(e),"HTML"===e.tagName)return t.push(document),t.push(window),t;e=e.parentElement}},ce=e=>/^(([^<>()[\]\\.,;:\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(e),se=e=>e.every(ce),me=e=>{let t=ee("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);let a=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);return t.select(),document.execCommand("copy"),document.body.removeChild(t),!!a&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(a),!0)};var pe=e=>{window&&"undefined"!=typeof window&&((()=>{let e=ee("style");e.id="mailgo-style",e.type="text/css",e.appendChild(te(n)),document.head.appendChild(e)})(),(null==e?void 0:e.initEvent)?document.addEventListener(e.initEvent,()=>{T(e)}):T(e))};pe({initEvent:"DOMContentLoaded"})}]); \ No newline at end of file +window.mailgo=function(e){var t={};function a(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,a),o.l=!0,o.exports}return a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)a.d(n,o,function(t){return e[t]}.bind(null,o));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=4)}([function(e){e.exports=JSON.parse('{"languages":["en","it"],"translations":{"en":{"open_in":"open in ","cc_":"cc ","bcc_":"bcc ","subject_":"subject ","body_":"body ","gmail":"Gmail","outlook":"Outlook","telegram":"Telegram","whatsapp":"WhatsApp","skype":"Skype","call":"call","open":"open","_default":" default","_as_default":" as default","copy":"copy"},"it":{"open_in":"apri con ","cc":"cc ","bcc":"ccn ","subject":"oggetto ","body":"testo ","gmail":"Gmail","outlook":"Outlook","telegram":"Telegram","whatsapp":"WhatsApp","skype":"Skype","call":"chiama","open":"apri","_default":" ","_as_default":" ","copy":"copia"}}}')},function(e,t,a){var n=a(2);e.exports="string"==typeof n?n:n.toString()},function(e,t,a){(t=a(3)(!1)).push([e.i,'.m-modal{position:fixed;top:0;right:0;bottom:0;left:0;justify-content:center;align-items:center;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal p,.m-modal span,.m-modal strong,.m-modal a{margin:0;padding:0;font-size:100%;line-height:1;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,0.75);opacity:0.8}.m-modal .m-modal-content{position:relative;z-index:10002;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:0.97;border-radius:8px;box-shadow:0px 3px 20px rgba(32,35,42,0.5);color:#4a4a4a;display:flex;flex-direction:column;overflow:auto;padding:20px;transition:0.5s box-shadow}.m-modal .m-modal-content:hover{opacity:1;box-shadow:0px 7px 20px rgba(32,35,42,0.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,0.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,0.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,0.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,0.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,0.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-default:hover,.m-modal .m-modal-content a.m-copy:hover{background-color:rgba(0,0,0,0.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:0.8rem;padding:5px;color:#4a4a4a;opacity:0.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}\n',""]),e.exports=t},function(e,t,a){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var a=function(e,t){var a=e[1]||"",n=e[3];if(!n)return a;if(t&&"function"==typeof btoa){var o=(d=n,l=btoa(unescape(encodeURIComponent(JSON.stringify(d)))),c="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(l),"/*# ".concat(c," */")),i=n.sources.map((function(e){return"/*# sourceURL=".concat(n.sourceRoot||"").concat(e," */")}));return[a].concat(i).concat([o]).join("\n")}var d,l,c;return[a].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(a,"}"):a})).join("")},t.i=function(e,a,n){"string"==typeof e&&(e=[[null,e,""]]);var o={};if(n)for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:"mail",t=arguments.length>1?arguments[1]:void 0;if("mail"===e){if(t.href&&t.href.toLowerCase().startsWith(x)){N=decodeURIComponent(t.href.split("?")[0].split(x)[1].trim());var a=new URL(t.href).searchParams;R=a.get("cc"),U=a.get("bcc"),I=a.get("subject"),M=a.get("body")}else N=t.getAttribute("data-address")+"@"+t.getAttribute("data-domain"),new URL(x+encodeURIComponent(N)),R=t.getAttribute("data-cc-address")+"@"+t.getAttribute("data-cc-domain"),U=t.getAttribute("data-bcc-address")+"@"+t.getAttribute("data-bcc-domain"),I=t.getAttribute("data-subject"),M=t.getAttribute("data-body");if(!se(N.split(",")))return;R&&!se(R.split(","))&&(R=""),U&&!se(U.split(","))&&(U=""),n.innerHTML=N.split(",").join("
"),R?(i.style.display="block",r.innerHTML=R.split(",").join("
")):i.style.display="none",U?(d.style.display="block",s.innerHTML=U.split(",").join("
")):d.style.display="none",I?(l.style.display="block",m.textContent=I):l.style.display="none",M?(c.style.display="block",p.textContent=M):c.style.display="none",u.addEventListener("click",H),f.addEventListener("click",D),S=oe(N),h.addEventListener("click",B),C.addEventListener("click",(function(){return $(N)}))}"tel"===e&&(t.href&&t.href.toLowerCase().startsWith(_)?z=decodeURIComponent(t.href.split("?")[0].split(_)[1].trim()):t.href&&t.href.toLowerCase().startsWith(j)?z=decodeURIComponent(t.href.split("?")[0].split(j)[1].trim()):t.hasAttribute("data-tel")&&(z=t.getAttribute("data-tel"),t.getAttribute("data-msg")),t.hasAttribute("data-telegram")&&(O=t.getAttribute("data-telegram")),t.hasAttribute("data-skype")&&(T=t.getAttribute("data-skype")),o.innerHTML=z,b.addEventListener("click",Z),O&&(le("m-tg","block"),g.addEventListener("click",G)),v.addEventListener("click",J),y.addEventListener("click",F),w.addEventListener("click",(function(){return $(z)}))),V(e),document.addEventListener("keydown",Q)},H=function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(N);R&&(e=e.concat("&cc="+encodeURIComponent(R))),U&&(e=e.concat("&bcc="+encodeURIComponent(U))),I&&(e=e.concat("&subject="+I)),M&&(e=e.concat("&body="+M)),window.open(e,"_blank"),X()},D=function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(N);I&&(e=e.concat("&subject="+I)),M&&(e=e.concat("&body="+M)),window.open(e,"_blank"),X()},B=function(){ne(S),X()},G=function(){var e="https://t.me/"+O;window.open(e,"_blank"),X()},J=function(){var e="skype:"+(""!==T?T:z);window.open(e,"_blank"),X()},Z=function(){var e="https://wa.me/"+z;window.open(e,"_blank"),X()},F=function(){var e="tel:"+z;window.open(e),X()},$=function(e){var t;me(e),(t=Y("mail")?C:w).textContent="copied",setTimeout((function(){t.textContent="copy",X()}),999)},q=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"mail",a=e.href;return"mail"===t?a&&a.toLowerCase().startsWith(x)&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(a&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")):"tel"===t&&(a&&(a.toLowerCase().startsWith(_)||a.toLowerCase().startsWith(j))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&a&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))},K=function(e){if(document.contains(ie("mailgo"))&&document.contains(ie("mailgo-tel"))){if(Y("mail")||Y("tel"))return!1;var t=e.composedPath&&e.composedPath()||ce(e.target);return t&&t.forEach((function(t){return!(t instanceof HTMLDocument||t instanceof Window)&&(q(t,"mail")?(e.preventDefault(),P("mail",t),!0):q(t,"tel")?(e.preventDefault(),P("tel",t),!0):void 0)})),!1}},Q=function(e){if(Y("mail"))switch(e.keyCode){case 27:X();break;case 71:H();break;case 79:D();break;case 32:case 13:B();break;case 67:$(N);break;default:return}else if(Y("tel"))switch(e.keyCode){case 27:X();break;case 84:G();break;case 87:Z();break;case 32:case 13:F();break;case 67:$(z);break;default:return}},V=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"mail";return"mail"===e?(le("mailgo","flex"),!0):"tel"===e&&(le("mailgo-tel","flex"),!0)},X=function(){le("mailgo","none"),le("mailgo-tel","none"),document.removeEventListener("keydown",Q)},Y=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"mail";return"mail"===e?"flex"===de("mailgo"):"tel"===e&&"flex"===de("mailgo-tel")},ee=function(){var e=te("a");return e.href="https://mailgo.js.org?ref=mailgo-modal",e.className="m-by",e.target="_blank",e.rel="noopener noreferrer",e.appendChild(ae("mailgo.js.org")),e},te=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div";return document.createElement(e)},ae=function(e){return document.createTextNode(e)},ne=function(e){return window.location.href=x+atob(e)},oe=function(e){return btoa(e)},ie=function(e){return document.getElementById(e)},de=function(e){return ie(e).style.display},le=function(e,t){return ie(e).style.display=t},ce=function(e){for(var t=[];e;){if(t.push(e),"HTML"===e.tagName)return t.push(document),t.push(window),t;e=e.parentElement}},re=function(e){return/^(([^<>()[\]\\.,;:\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(e)},se=function(e){return e.every(re)},me=function(e){var t=te("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);var a=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);return t.select(),document.execCommand("copy"),document.body.removeChild(t),!!a&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(a),!0)},pe=function(e){var t;window&&"undefined"!=typeof window&&((t=te("style")).id="mailgo-style",t.type="text/css",t.appendChild(ae(L)),document.head.appendChild(t),(null==e?void 0:e.initEvent)?document.addEventListener(e.initEvent,(function(){W(e)})):W(e))};pe({initEvent:"DOMContentLoaded"})}]); \ No newline at end of file diff --git a/lib/mailgo.js b/lib/mailgo.js index 0e90744..4c5372b 100644 --- a/lib/mailgo.js +++ b/lib/mailgo.js @@ -237,481 +237,497 @@ __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ../src/mailgo.ts // i18n for mailgo -const i18n = __webpack_require__(0); -// mailgo css -const mailgoCSS = __webpack_require__(1).toString(); -// default lang -const DEFAULT_LANG = "en"; -// links -const MAILTO = "mailto:"; -const TEL = "tel:"; -const CALLTO = "callto:"; -// mailgo types -const MAIL_TYPE = "mail"; -const TEL_TYPE = "tel"; -// default href for links -const DEFAULT_BTN_HREF = "javascript:void(0);"; -// html tags -const span = "span"; -// mailgo variables -let url, mail = "", encEmail = "", cc = "", bcc = "", subject = "", bodyMail = ""; -// mailgo tel variables -let tel = "", msg = "", telegramUsername = "", skypeUsername = ""; -// the DOM elements -let title, titleTel, detailCc, detailBcc, detailSubject, detailBody, ccValue, bccValue, subjectValue, bodyValue; -// mailgo buttons (actions) -let gmail, outlook, mailgo_open, telegram, wa, skype, call, copyMail, copyTel; +var i18n = __webpack_require__(0); // mailgo css + + +var mailgoCSS = __webpack_require__(1).toString(); // default lang + + +var DEFAULT_LANG = "en"; // links + +var MAILTO = "mailto:"; +var TEL = "tel:"; +var CALLTO = "callto:"; // mailgo types + +var MAIL_TYPE = "mail"; +var TEL_TYPE = "tel"; // default href for links + +var DEFAULT_BTN_HREF = "javascript:void(0);"; // html tags + +var span = "span"; // mailgo variables + +var url, + mail = "", + encEmail = "", + cc = "", + bcc = "", + subject = "", + bodyMail = ""; // mailgo tel variables + +var tel = "", + msg = "", + telegramUsername = "", + skypeUsername = ""; // the DOM elements + +var title, titleTel, detailCc, detailBcc, detailSubject, detailBody, ccValue, bccValue, subjectValue, bodyValue; // mailgo buttons (actions) + +var gmail, outlook, mailgo_open, telegram, wa, skype, call, copyMail, copyTel; /** * mailgoInit * the function that creates the mailgo elements in DOM */ -const mailgoInit = (mailgoConfig) => { - // default language - let lang = DEFAULT_LANG; - // translations - let translations = i18n.translations; - // if a default language is defined use it - if ((mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.defaultLang) && - i18n.languages.includes(mailgoConfig.defaultLang)) { - lang = mailgoConfig.defaultLang; - } - // if is defined use it! - if (!(mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.forceLang) && document.documentElement.lang) { - lang = document.documentElement.lang; - } - // strings - let defaultStrings = translations[DEFAULT_LANG]; - let strings = translations[lang]; - // mailgo mail - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo"; - modal.classList.add("m-modal"); - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - // title (email address) - title = createElement("strong"); - title.id = "m-title"; - title.className = "m-title"; - modalContent.appendChild(title); - // details - let details = createElement(); - details.id = "m-details"; - details.className = "m-details"; - detailCc = createElement("p"); - detailCc.id = "m-cc"; - let ccSpan = createElement(span); - ccSpan.className = "w-500"; - ccSpan.appendChild(createTextNode(strings.cc || defaultStrings.cc)); - ccValue = createElement(span); - ccValue.id = "m-cc-value"; - detailCc.appendChild(ccSpan); - detailCc.appendChild(ccValue); - details.appendChild(detailCc); - detailBcc = createElement("p"); - detailBcc.id = "m-bcc"; - let bccSpan = createElement(span); - bccSpan.className = "w-500"; - bccSpan.appendChild(createTextNode(strings.bcc || defaultStrings.bcc)); - bccValue = createElement(span); - bccValue.id = "m-bcc-value"; - detailBcc.appendChild(bccSpan); - detailBcc.appendChild(bccValue); - details.appendChild(detailBcc); - detailSubject = createElement("p"); - detailSubject.id = "m-subject"; - let subjectSpan = createElement(span); - subjectSpan.className = "w-500"; - subjectSpan.appendChild(createTextNode(strings.subject || defaultStrings.subject)); - subjectValue = createElement(span); - subjectValue.id = "m-subject-value"; - detailSubject.appendChild(subjectSpan); - detailSubject.appendChild(subjectValue); - details.appendChild(detailSubject); - detailBody = createElement("p"); - detailBody.id = "m-body"; - let bodySpan = createElement(span); - bodySpan.className = "w-500"; - bodySpan.appendChild(createTextNode(strings.body || defaultStrings.body)); - bodyValue = createElement(span); - bodyValue.id = "m-body-value"; - detailBody.appendChild(bodySpan); - detailBody.appendChild(bodyValue); - details.appendChild(detailBody); - modalContent.appendChild(details); - // Gmail - gmail = createElement("a"); - gmail.id = "m-gmail"; - gmail.href = DEFAULT_BTN_HREF; - gmail.classList.add("m-open"); - gmail.classList.add("m-gmail"); - gmail.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let gmailSpan = createElement(span); - gmailSpan.className = "w-500"; - gmailSpan.appendChild(createTextNode(strings.gmail || defaultStrings.gmail)); - gmail.appendChild(gmailSpan); - modalContent.appendChild(gmail); - // Outlook - outlook = createElement("a"); - outlook.id = "m-outlook"; - outlook.href = DEFAULT_BTN_HREF; - outlook.classList.add("m-open"); - outlook.classList.add("m-outlook"); - outlook.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let outlookSpan = createElement(span); - outlookSpan.className = "w-500"; - outlookSpan.appendChild(createTextNode(strings.outlook || defaultStrings.outlook)); - outlook.appendChild(outlookSpan); - modalContent.appendChild(outlook); - // open default - mailgo_open = createElement("a"); - mailgo_open.id = "m-open"; - mailgo_open.href = DEFAULT_BTN_HREF; - mailgo_open.classList.add("m-open"); - mailgo_open.classList.add("m-default"); - let openSpan = createElement(span); - openSpan.className = "w-500"; - openSpan.appendChild(createTextNode(strings.open || defaultStrings.open)); - mailgo_open.appendChild(openSpan); - mailgo_open.appendChild(createTextNode(strings._default || defaultStrings._default)); - modalContent.appendChild(mailgo_open); - // copy - copyMail = createElement("a"); - copyMail.id = "m-copy"; - copyMail.href = DEFAULT_BTN_HREF; - copyMail.classList.add("m-copy"); - copyMail.classList.add("w-500"); - copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy)); - modalContent.appendChild(copyMail); - modalContent.appendChild(byElement()); - // add the modal at the end of the body - document.body.appendChild(modal); - // every click outside the modal will hide the modal - modalBackground.addEventListener("click", hideMailgo); - } - // mailgo tel - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo-tel"; - modal.classList.add("m-modal"); - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - // title (telephone number) - titleTel = createElement("strong"); - titleTel.id = "m-tel-title"; - titleTel.className = "m-title"; - modalContent.appendChild(titleTel); - // Telegram - telegram = createElement("a"); - telegram.id = "m-tg"; - telegram.href = DEFAULT_BTN_HREF; - telegram.classList.add("m-open"); - telegram.classList.add("m-tg"); - // by default not display - telegram.style.display = "none"; - telegram.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let telegramSpan = createElement(span); - telegramSpan.className = "w-500"; - telegramSpan.appendChild(createTextNode(strings.telegram || defaultStrings.telegram)); - telegram.appendChild(telegramSpan); - modalContent.appendChild(telegram); - // WhatsApp - wa = createElement("a"); - wa.id = "m-wa"; - wa.href = DEFAULT_BTN_HREF; - wa.classList.add("m-open"); - wa.classList.add("m-wa"); - wa.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let waSpan = createElement(span); - waSpan.className = "w-500"; - waSpan.appendChild(createTextNode(strings.whatsapp || defaultStrings.whatsapp)); - wa.appendChild(waSpan); - modalContent.appendChild(wa); - // Skype - skype = createElement("a"); - skype.id = "m-skype"; - skype.href = DEFAULT_BTN_HREF; - skype.classList.add("m-open"); - skype.classList.add("m-skype"); - skype.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); - let skypeSpan = createElement(span); - skypeSpan.className = "w-500"; - skypeSpan.appendChild(createTextNode(strings.skype || defaultStrings.skype)); - skype.appendChild(skypeSpan); - modalContent.appendChild(skype); - // call default - call = createElement("a"); - call.id = "m-call"; - call.href = DEFAULT_BTN_HREF; - call.classList.add("m-open"); - call.classList.add("m-default"); - let callSpan = createElement(span); - callSpan.className = "w-500"; - callSpan.appendChild(createTextNode(strings.call || defaultStrings.call)); - call.appendChild(callSpan); - call.appendChild(createTextNode(strings._as_default || defaultStrings._as_default)); - modalContent.appendChild(call); - // copy - copyTel = createElement("a"); - copyTel.id = "m-tel-copy"; - copyTel.href = DEFAULT_BTN_HREF; - copyTel.classList.add("m-copy"); - copyTel.classList.add("w-500"); - copyTel.appendChild(createTextNode(strings.copy || defaultStrings.copy)); - modalContent.appendChild(copyTel); - modalContent.appendChild(byElement()); - // add the modal at the end of the body - document.body.appendChild(modal); - // 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); + +var mailgoInit = function mailgoInit(mailgoConfig) { + // default language + var lang = DEFAULT_LANG; // translations + + var translations = i18n.translations; // if a default language is defined use it + + if ((mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.defaultLang) && i18n.languages.includes(mailgoConfig.defaultLang)) { + lang = mailgoConfig.defaultLang; + } // if is defined use it! + + + if (!(mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.forceLang) && document.documentElement.lang) { + lang = document.documentElement.lang; + } // strings + + + var defaultStrings = translations[DEFAULT_LANG]; + var strings = translations[lang]; // mailgo mail + + { + // modal + var modal = createElement(); + modal.style.display = "none"; + modal.id = "mailgo"; + modal.classList.add("m-modal"); // background + + var modalBackground = createElement(); + modalBackground.className = "m-modal-back"; + modal.appendChild(modalBackground); // modal content + + var modalContent = createElement(); + modalContent.className = "m-modal-content"; + modal.appendChild(modalContent); // title (email address) + + title = createElement("strong"); + title.id = "m-title"; + title.className = "m-title"; + modalContent.appendChild(title); // details + + var details = createElement(); + details.id = "m-details"; + details.className = "m-details"; + detailCc = createElement("p"); + detailCc.id = "m-cc"; + var ccSpan = createElement(span); + ccSpan.className = "w-500"; + ccSpan.appendChild(createTextNode(strings.cc || defaultStrings.cc)); + ccValue = createElement(span); + ccValue.id = "m-cc-value"; + detailCc.appendChild(ccSpan); + detailCc.appendChild(ccValue); + details.appendChild(detailCc); + detailBcc = createElement("p"); + detailBcc.id = "m-bcc"; + var bccSpan = createElement(span); + bccSpan.className = "w-500"; + bccSpan.appendChild(createTextNode(strings.bcc || defaultStrings.bcc)); + bccValue = createElement(span); + bccValue.id = "m-bcc-value"; + detailBcc.appendChild(bccSpan); + detailBcc.appendChild(bccValue); + details.appendChild(detailBcc); + detailSubject = createElement("p"); + detailSubject.id = "m-subject"; + var subjectSpan = createElement(span); + subjectSpan.className = "w-500"; + subjectSpan.appendChild(createTextNode(strings.subject || defaultStrings.subject)); + subjectValue = createElement(span); + subjectValue.id = "m-subject-value"; + detailSubject.appendChild(subjectSpan); + detailSubject.appendChild(subjectValue); + details.appendChild(detailSubject); + detailBody = createElement("p"); + detailBody.id = "m-body"; + var bodySpan = createElement(span); + bodySpan.className = "w-500"; + bodySpan.appendChild(createTextNode(strings.body || defaultStrings.body)); + bodyValue = createElement(span); + bodyValue.id = "m-body-value"; + detailBody.appendChild(bodySpan); + detailBody.appendChild(bodyValue); + details.appendChild(detailBody); + modalContent.appendChild(details); // Gmail + + gmail = createElement("a"); + gmail.id = "m-gmail"; + gmail.href = DEFAULT_BTN_HREF; + gmail.classList.add("m-open"); + gmail.classList.add("m-gmail"); + gmail.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var gmailSpan = createElement(span); + gmailSpan.className = "w-500"; + gmailSpan.appendChild(createTextNode(strings.gmail || defaultStrings.gmail)); + gmail.appendChild(gmailSpan); + modalContent.appendChild(gmail); // Outlook + + outlook = createElement("a"); + outlook.id = "m-outlook"; + outlook.href = DEFAULT_BTN_HREF; + outlook.classList.add("m-open"); + outlook.classList.add("m-outlook"); + outlook.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var outlookSpan = createElement(span); + outlookSpan.className = "w-500"; + outlookSpan.appendChild(createTextNode(strings.outlook || defaultStrings.outlook)); + outlook.appendChild(outlookSpan); + modalContent.appendChild(outlook); // open default + + mailgo_open = createElement("a"); + mailgo_open.id = "m-open"; + mailgo_open.href = DEFAULT_BTN_HREF; + mailgo_open.classList.add("m-open"); + mailgo_open.classList.add("m-default"); + var openSpan = createElement(span); + openSpan.className = "w-500"; + openSpan.appendChild(createTextNode(strings.open || defaultStrings.open)); + mailgo_open.appendChild(openSpan); + mailgo_open.appendChild(createTextNode(strings._default || defaultStrings._default)); + modalContent.appendChild(mailgo_open); // copy + + copyMail = createElement("a"); + copyMail.id = "m-copy"; + copyMail.href = DEFAULT_BTN_HREF; + copyMail.classList.add("m-copy"); + copyMail.classList.add("w-500"); + copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy)); + modalContent.appendChild(copyMail); + modalContent.appendChild(byElement()); // add the modal at the end of the body + + document.body.appendChild(modal); // every click outside the modal will hide the modal + + modalBackground.addEventListener("click", hideMailgo); + } // mailgo tel + + { + // modal + var _modal = createElement(); + + _modal.style.display = "none"; + _modal.id = "mailgo-tel"; + + _modal.classList.add("m-modal"); // background + + + var _modalBackground = createElement(); + + _modalBackground.className = "m-modal-back"; + + _modal.appendChild(_modalBackground); // modal content + + + var _modalContent = createElement(); + + _modalContent.className = "m-modal-content"; + + _modal.appendChild(_modalContent); // title (telephone number) + + + titleTel = createElement("strong"); + titleTel.id = "m-tel-title"; + titleTel.className = "m-title"; + + _modalContent.appendChild(titleTel); // Telegram + + + telegram = createElement("a"); + telegram.id = "m-tg"; + telegram.href = DEFAULT_BTN_HREF; + telegram.classList.add("m-open"); + telegram.classList.add("m-tg"); // by default not display + + telegram.style.display = "none"; + telegram.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var telegramSpan = createElement(span); + telegramSpan.className = "w-500"; + telegramSpan.appendChild(createTextNode(strings.telegram || defaultStrings.telegram)); + telegram.appendChild(telegramSpan); + + _modalContent.appendChild(telegram); // WhatsApp + + + wa = createElement("a"); + wa.id = "m-wa"; + wa.href = DEFAULT_BTN_HREF; + wa.classList.add("m-open"); + wa.classList.add("m-wa"); + wa.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var waSpan = createElement(span); + waSpan.className = "w-500"; + waSpan.appendChild(createTextNode(strings.whatsapp || defaultStrings.whatsapp)); + wa.appendChild(waSpan); + + _modalContent.appendChild(wa); // Skype + + + skype = createElement("a"); + skype.id = "m-skype"; + skype.href = DEFAULT_BTN_HREF; + skype.classList.add("m-open"); + skype.classList.add("m-skype"); + skype.appendChild(createTextNode(strings.open_in || defaultStrings.open_in)); + var skypeSpan = createElement(span); + skypeSpan.className = "w-500"; + skypeSpan.appendChild(createTextNode(strings.skype || defaultStrings.skype)); + skype.appendChild(skypeSpan); + + _modalContent.appendChild(skype); // call default + + + call = createElement("a"); + call.id = "m-call"; + call.href = DEFAULT_BTN_HREF; + call.classList.add("m-open"); + call.classList.add("m-default"); + var callSpan = createElement(span); + callSpan.className = "w-500"; + callSpan.appendChild(createTextNode(strings.call || defaultStrings.call)); + call.appendChild(callSpan); + call.appendChild(createTextNode(strings._as_default || defaultStrings._as_default)); + + _modalContent.appendChild(call); // copy + + + copyTel = createElement("a"); + copyTel.id = "m-tel-copy"; + copyTel.href = DEFAULT_BTN_HREF; + copyTel.classList.add("m-copy"); + copyTel.classList.add("w-500"); + copyTel.appendChild(createTextNode(strings.copy || defaultStrings.copy)); + + _modalContent.appendChild(copyTel); + + _modalContent.appendChild(byElement()); // add the modal at the end of the body + + + document.body.appendChild(_modal); // 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 * function to render a mailgo (mail or tel) */ -const mailgoRender = (type = MAIL_TYPE, mailgo) => { - // mailgo mail - if (type === MAIL_TYPE) { - // if the element href=^"mailto:" - if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { - mail = decodeURIComponent(mailgo.href.split("?")[0].split(MAILTO)[1].trim()); - url = new URL(mailgo.href); - let urlParams = url.searchParams; - // optional parameters for the email - cc = urlParams.get("cc"); - bcc = urlParams.get("bcc"); - subject = urlParams.get("subject"); - bodyMail = urlParams.get("body"); - } - else { - // if the element href="#mailgo" or class="mailgo" - // mail = data-address + @ + data-domain - mail = - mailgo.getAttribute("data-address") + - "@" + - mailgo.getAttribute("data-domain"); - url = new URL(MAILTO + encodeURIComponent(mail)); - // cc = data-cc-address + @ + data-cc-domain - cc = - mailgo.getAttribute("data-cc-address") + - "@" + - mailgo.getAttribute("data-cc-domain"); - // bcc = data-bcc-address + @ + data-bcc-domain - bcc = - mailgo.getAttribute("data-bcc-address") + - "@" + - mailgo.getAttribute("data-bcc-domain"); - // subject = data-subject - subject = mailgo.getAttribute("data-subject"); - // body = data-body - bodyMail = mailgo.getAttribute("data-body"); - } - // validate the email address - if (!validateEmails(mail.split(","))) - return; - // if cc, bcc is not valid cc, bcc = "" - if (cc && !validateEmails(cc.split(","))) - cc = ""; - if (bcc && !validateEmails(bcc.split(","))) - bcc = ""; - // the title of the modal (email address) - title.innerHTML = mail.split(",").join("
"); - // add the details if provided - cc - ? ((detailCc.style.display = "block"), - (ccValue.innerHTML = cc.split(",").join("
"))) - : (detailCc.style.display = "none"); - bcc - ? ((detailBcc.style.display = "block"), - (bccValue.innerHTML = bcc.split(",").join("
"))) - : (detailBcc.style.display = "none"); - subject - ? ((detailSubject.style.display = "block"), - (subjectValue.textContent = subject)) - : (detailSubject.style.display = "none"); - bodyMail - ? ((detailBody.style.display = "block"), - (bodyValue.textContent = bodyMail)) - : (detailBody.style.display = "none"); - // add the actions - gmail.addEventListener("click", openGmail); - outlook.addEventListener("click", openOutlook); - encEmail = encodeEmail(mail); - mailgo_open.addEventListener("click", openDefault); - copyMail.addEventListener("click", () => copy(mail)); + + +var mailgoRender = function mailgoRender() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + var mailgo = arguments.length > 1 ? arguments[1] : undefined; + + // mailgo mail + if (type === MAIL_TYPE) { + // if the element href=^"mailto:" + if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { + mail = decodeURIComponent(mailgo.href.split("?")[0].split(MAILTO)[1].trim()); + url = new URL(mailgo.href); + var urlParams = url.searchParams; // optional parameters for the email + + cc = urlParams.get("cc"); + bcc = urlParams.get("bcc"); + subject = urlParams.get("subject"); + bodyMail = urlParams.get("body"); + } else { + // if the element href="#mailgo" or class="mailgo" + // mail = data-address + @ + data-domain + mail = mailgo.getAttribute("data-address") + "@" + mailgo.getAttribute("data-domain"); + url = new URL(MAILTO + encodeURIComponent(mail)); // cc = data-cc-address + @ + data-cc-domain + + cc = mailgo.getAttribute("data-cc-address") + "@" + mailgo.getAttribute("data-cc-domain"); // bcc = data-bcc-address + @ + data-bcc-domain + + bcc = mailgo.getAttribute("data-bcc-address") + "@" + mailgo.getAttribute("data-bcc-domain"); // subject = data-subject + + subject = mailgo.getAttribute("data-subject"); // body = data-body + + bodyMail = mailgo.getAttribute("data-body"); + } // validate the email address + + + if (!validateEmails(mail.split(","))) return; // if cc, bcc is not valid cc, bcc = "" + + if (cc && !validateEmails(cc.split(","))) cc = ""; + if (bcc && !validateEmails(bcc.split(","))) bcc = ""; // the title of the modal (email address) + + title.innerHTML = mail.split(",").join("
"); // add the details if provided + + cc ? (detailCc.style.display = "block", ccValue.innerHTML = cc.split(",").join("
")) : detailCc.style.display = "none"; + bcc ? (detailBcc.style.display = "block", bccValue.innerHTML = bcc.split(",").join("
")) : detailBcc.style.display = "none"; + subject ? (detailSubject.style.display = "block", subjectValue.textContent = subject) : detailSubject.style.display = "none"; + bodyMail ? (detailBody.style.display = "block", bodyValue.textContent = bodyMail) : detailBody.style.display = "none"; // add the actions + + gmail.addEventListener("click", openGmail); + outlook.addEventListener("click", openOutlook); + encEmail = encodeEmail(mail); + mailgo_open.addEventListener("click", openDefault); + copyMail.addEventListener("click", function () { + return copy(mail); + }); + } // mailgo tel + + + if (type === TEL_TYPE) { + if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { + tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); + } else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { + tel = decodeURIComponent(mailgo.href.split("?")[0].split(CALLTO)[1].trim()); + } else if (mailgo.hasAttribute("data-tel")) { + tel = mailgo.getAttribute("data-tel"); + msg = mailgo.getAttribute("data-msg"); + } // information + // let titleEl = getE("m-tel-title"); + // Telegram username + + + if (mailgo.hasAttribute("data-telegram")) { + telegramUsername = mailgo.getAttribute("data-telegram"); + } // Telegram username + + + if (mailgo.hasAttribute("data-skype")) { + skypeUsername = mailgo.getAttribute("data-skype"); + } // the title of the modal (tel) + + + titleTel.innerHTML = tel; // add the actions to buttons + + wa.addEventListener("click", openWhatsApp); + + if (telegramUsername) { + setDisplay("m-tg", "block"); + telegram.addEventListener("click", openTelegram); } - // mailgo tel - if (type === TEL_TYPE) { - if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); - } - else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(CALLTO)[1].trim()); - } - else if (mailgo.hasAttribute("data-tel")) { - tel = mailgo.getAttribute("data-tel"); - msg = mailgo.getAttribute("data-msg"); - } - // information - // let titleEl = getE("m-tel-title"); - // Telegram username - if (mailgo.hasAttribute("data-telegram")) { - telegramUsername = mailgo.getAttribute("data-telegram"); - } - // Telegram username - if (mailgo.hasAttribute("data-skype")) { - skypeUsername = mailgo.getAttribute("data-skype"); - } - // the title of the modal (tel) - titleTel.innerHTML = tel; - // add the actions to buttons - wa.addEventListener("click", openWhatsApp); - if (telegramUsername) { - setDisplay("m-tg", "block"); - telegram.addEventListener("click", openTelegram); - } - skype.addEventListener("click", openSkype); - call.addEventListener("click", callDefault); - copyTel.addEventListener("click", () => copy(tel)); - } - // show the mailgo - showMailgo(type); - // add listener keyDown - document.addEventListener("keydown", mailgoKeydown); + + skype.addEventListener("click", openSkype); + call.addEventListener("click", callDefault); + copyTel.addEventListener("click", function () { + return copy(tel); + }); + } // show the mailgo + + + showMailgo(type); // add listener keyDown + + document.addEventListener("keydown", mailgoKeydown); +}; // actions + + +var openGmail = function openGmail() { + // Gmail url + var gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + encodeURIComponent(mail); // the details if provided + + if (cc) gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); + if (bcc) gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); + if (subject) gmailUrl = gmailUrl.concat("&subject=" + subject); + if (bodyMail) gmailUrl = gmailUrl.concat("&body=" + bodyMail); // open the link + + window.open(gmailUrl, "_blank"); // hide the modal + + hideMailgo(); }; -// actions -const openGmail = () => { - // Gmail url - let gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + - encodeURIComponent(mail); - // the details if provided - if (cc) - gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); - if (bcc) - gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); - if (subject) - gmailUrl = gmailUrl.concat("&subject=" + subject); - if (bodyMail) - gmailUrl = gmailUrl.concat("&body=" + bodyMail); - // open the link - window.open(gmailUrl, "_blank"); - // hide the modal + +var openOutlook = function openOutlook() { + // Outlook url + var outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail); // the details if provided + + if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject); + if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail); // open the link + + window.open(outlookUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openDefault = function openDefault() { + mailToEncoded(encEmail); + hideMailgo(); +}; + +var openTelegram = function openTelegram() { + // Telegram url + var tgUrl = "https://t.me/" + telegramUsername; // open the url + + window.open(tgUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openSkype = function openSkype() { + var skype = skypeUsername !== "" ? skypeUsername : tel; // Telegram url + + var skypeUrl = "skype:" + skype; // open the url + + window.open(skypeUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openWhatsApp = function openWhatsApp() { + // WhatsApp url + var waUrl = "https://wa.me/" + tel; // the details if provided + + if (msg) waUrl + "?text=" + msg; // open the url + + window.open(waUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var callDefault = function callDefault() { + var callUrl = "tel:" + tel; + window.open(callUrl); + hideMailgo(); +}; + +var copy = function copy(content) { + copyToClipboard(content); + var activeCopy; // the correct copyButton (mail or tel) + + mailgoIsShowing(MAIL_TYPE) ? activeCopy = copyMail : activeCopy = copyTel; + activeCopy.textContent = "copied"; + setTimeout(function () { + activeCopy.textContent = "copy"; // hide after the timeout + hideMailgo(); -}; -const openOutlook = () => { - // Outlook url - let outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + - encodeURIComponent(mail); - // the details if provided - if (subject) - outlookUrl = outlookUrl.concat("&subject=" + subject); - if (bodyMail) - outlookUrl = outlookUrl.concat("&body=" + bodyMail); - // open the link - window.open(outlookUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openDefault = () => { - mailToEncoded(encEmail); - hideMailgo(); -}; -const openTelegram = () => { - // Telegram url - let tgUrl = "https://t.me/" + telegramUsername; - // open the url - window.open(tgUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openSkype = () => { - let skype = skypeUsername !== "" ? skypeUsername : tel; - // Telegram url - let skypeUrl = "skype:" + skype; - // open the url - window.open(skypeUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openWhatsApp = () => { - // WhatsApp url - let waUrl = "https://wa.me/" + tel; - // the details if provided - if (msg) - waUrl + "?text=" + msg; - // open the url - window.open(waUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const callDefault = (event) => { - let callUrl = "tel:" + tel; - window.open(callUrl); - hideMailgo(); -}; -const copy = (content) => { - copyToClipboard(content); - let activeCopy; - // the correct copyButton (mail or tel) - mailgoIsShowing(MAIL_TYPE) ? (activeCopy = copyMail) : (activeCopy = copyTel); - activeCopy.textContent = "copied"; - setTimeout(() => { - activeCopy.textContent = "copy"; - // hide after the timeout - hideMailgo(); - }, 999); -}; -// function that returns if an element is a mailgo -const isMailgo = (element, type = MAIL_TYPE) => { - let href = element.href; - // mailgo type mail - if (type === MAIL_TYPE) { - return ( - // first case: it is an
element with "mailto:..." in href and no no-mailgo in classList - (href && - href.toLowerCase().startsWith(MAILTO) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-address") && - // second case: the href=#mailgo - ((href && element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo"))))); - } - // mailgo type tel - if (type === TEL_TYPE) { - return ( - // first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList - (href && - (href.toLowerCase().startsWith(TEL) || - href.toLowerCase().startsWith(CALLTO)) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-tel") && - // second case: the href=#mailgo - href && - element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo"))); - } - return false; + }, 999); +}; // function that returns if an element is a mailgo + + +var isMailgo = function isMailgo(element) { + var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MAIL_TYPE; + var href = element.href; // mailgo type mail + + if (type === MAIL_TYPE) { + return (// first case: it is an element with "mailto:..." in href and no no-mailgo in classList + href && href.toLowerCase().startsWith(MAILTO) && !element.classList.contains("no-mailgo") || element.hasAttribute("data-address") && ( // second case: the href=#mailgo + href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo + element.classList && element.classList.contains("mailgo")) + ); + } // mailgo type tel + + + if (type === TEL_TYPE) { + return (// first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList + href && (href.toLowerCase().startsWith(TEL) || href.toLowerCase().startsWith(CALLTO)) && !element.classList.contains("no-mailgo") || element.hasAttribute("data-tel") && // second case: the href=#mailgo + href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo + element.classList && element.classList.contains("mailgo") + ); + } + + return false; }; /** * mailgoCheckRender @@ -729,220 +745,270 @@ const isMailgo = (element, type = MAIL_TYPE) => { * 'a[href^="callto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo' * ); */ -const mailgoCheckRender = (event) => { - // check if the id=mailgo exists in the body - if (!document.contains(getE("mailgo")) || - !document.contains(getE("mailgo-tel"))) - return; - // if a mailgo is already showing do nothing - if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) - 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 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 true; - } - if (isMailgo(element, TEL_TYPE)) { - // stop the normal execution of the element click - event.preventDefault(); - // render mailgo - mailgoRender(TEL_TYPE, element); - return true; - } - }); - } - return false; + + +var mailgoCheckRender = function mailgoCheckRender(event) { + // check if the id=mailgo exists in the body + if (!document.contains(getE("mailgo")) || !document.contains(getE("mailgo-tel"))) return; // if a mailgo is already showing do nothing + + if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) return false; // the path of the event + + var path = event.composedPath && event.composedPath() || composedPath(event.target); + + if (path) { + path.forEach(function (element) { + 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)) { + // stop the normal execution of the element click + event.preventDefault(); // render mailgo + + mailgoRender(MAIL_TYPE, element); + return true; + } + + if (isMailgo(element, TEL_TYPE)) { + // stop the normal execution of the element click + event.preventDefault(); // render mailgo + + mailgoRender(TEL_TYPE, element); + return true; + } + }); + } + + return false; }; /** * mailgoKeydown * function to manage the keydown event when the modal is showing */ -const mailgoKeydown = (event) => { - // if mailgo is showing - if (mailgoIsShowing(MAIL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 71: - // g -> open GMail - openGmail(); - break; - case 79: - // o -> open Outlook - openOutlook(); - break; - case 32: - case 13: - // spacebar or enter -> open default - openDefault(); - break; - case 67: - // c -> copy - copy(mail); - break; - default: - return; - } + + +var mailgoKeydown = function mailgoKeydown(event) { + // if mailgo is showing + if (mailgoIsShowing(MAIL_TYPE)) { + switch (event.keyCode) { + case 27: + // Escape + hideMailgo(); + break; + + case 71: + // g -> open GMail + openGmail(); + break; + + case 79: + // o -> open Outlook + openOutlook(); + break; + + case 32: + case 13: + // spacebar or enter -> open default + openDefault(); + break; + + case 67: + // c -> copy + copy(mail); + break; + + default: + return; } - else if (mailgoIsShowing(TEL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 84: - // t -> open Telegram - openTelegram(); - break; - case 87: - // w -> open WhatsApp - openWhatsApp(); - break; - case 32: - case 13: - // spacebar or enter -> call default - callDefault(); - break; - case 67: - // c -> copy - copy(tel); - break; - default: - return; - } + } else if (mailgoIsShowing(TEL_TYPE)) { + switch (event.keyCode) { + case 27: + // Escape + hideMailgo(); + break; + + case 84: + // t -> open Telegram + openTelegram(); + break; + + case 87: + // w -> open WhatsApp + openWhatsApp(); + break; + + case 32: + case 13: + // spacebar or enter -> call default + callDefault(); + break; + + case 67: + // c -> copy + copy(tel); + break; + + default: + return; } - return; + } + + return; +}; // show the modal + + +var showMailgo = function showMailgo() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + + // show mailgo type mail + if (type === MAIL_TYPE) { + setDisplay("mailgo", "flex"); + return true; + } // show mailgo type tel + + + if (type === TEL_TYPE) { + setDisplay("mailgo-tel", "flex"); + return true; + } + + return false; +}; // hide the modal + + +var hideMailgo = function hideMailgo() { + setDisplay("mailgo", "none"); + setDisplay("mailgo-tel", "none"); // remove listener keyDown + + document.removeEventListener("keydown", mailgoKeydown); +}; // is the mailgo modal hidden? + + +var mailgoIsShowing = function mailgoIsShowing() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + return type === MAIL_TYPE ? getDisplay("mailgo") === "flex" : type === TEL_TYPE ? getDisplay("mailgo-tel") === "flex" : false; }; -// show the modal -const showMailgo = (type = MAIL_TYPE) => { - // show mailgo type mail - if (type === MAIL_TYPE) { - setDisplay("mailgo", "flex"); - return true; + +var byElement = function byElement() { + // by + var by = createElement("a"); + by.href = "https://mailgo.js.org?ref=mailgo-modal"; + by.className = "m-by"; + by.target = "_blank"; + by.rel = "noopener noreferrer"; + by.appendChild(createTextNode("mailgo.js.org")); + return by; +}; // create element + + +var createElement = function createElement() { + var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "div"; + return document.createElement(element); +}; // create text node + + +var createTextNode = function createTextNode(element) { + return document.createTextNode(element); +}; // decrypt email + + +var mailToEncoded = function mailToEncoded(encoded) { + return window.location.href = MAILTO + atob(encoded); +}; // encode email + + +var encodeEmail = function encodeEmail(email) { + return btoa(email); +}; // getE shorthand + + +var getE = function getE(id) { + return document.getElementById(id); +}; // get display value + + +var getDisplay = function getDisplay(id) { + return getE(id).style.display; +}; // get display value + + +var setDisplay = function setDisplay(id, value) { + return getE(id).style.display = value; +}; // custom composedPath if path or event.composedPath() are not defined + + +var composedPath = function composedPath(el) { + var path = []; + + while (el) { + path.push(el); + + if (el.tagName === "HTML") { + path.push(document); + path.push(window); + return path; } - // show mailgo type tel - if (type === TEL_TYPE) { - setDisplay("mailgo-tel", "flex"); - return true; - } - return false; -}; -// hide the modal -const hideMailgo = () => { - setDisplay("mailgo", "none"); - setDisplay("mailgo-tel", "none"); - // remove listener keyDown - document.removeEventListener("keydown", mailgoKeydown); -}; -// is the mailgo modal hidden? -const mailgoIsShowing = (type = MAIL_TYPE) => { - return type === MAIL_TYPE - ? getDisplay("mailgo") === "flex" - : type === TEL_TYPE - ? getDisplay("mailgo-tel") === "flex" - : false; -}; -const byElement = () => { - // by - let by = createElement("a"); - by.href = "https://mailgo.js.org?ref=mailgo-modal"; - by.className = "m-by"; - by.target = "_blank"; - by.rel = "noopener noreferrer"; - by.appendChild(createTextNode("mailgo.js.org")); - return by; -}; -// create element -const createElement = (element = "div") => document.createElement(element); -// create text node -const createTextNode = (element) => document.createTextNode(element); -// decrypt email -const mailToEncoded = (encoded) => (window.location.href = MAILTO + atob(encoded)); -// encode email -const encodeEmail = (email) => btoa(email); -// getE shorthand -const getE = (id) => document.getElementById(id); -// get display value -const getDisplay = (id) => getE(id).style.display; -// get display value -const setDisplay = (id, value) => (getE(id).style.display = value); -// custom composedPath if path or event.composedPath() are not defined -const composedPath = (el) => { - let path = []; - while (el) { - path.push(el); - if (el.tagName === "HTML") { - path.push(document); - path.push(window); - return path; - } - el = el.parentElement; - } -}; -// validate a single email with regex -const validateEmail = (email) => /^(([^<>()[\]\\.,;:\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) => arr.every(validateEmail); -// copy of a string -const copyToClipboard = (str) => { - let el = createElement("textarea"); - el.value = str; - el.setAttribute("readonly", ""); - el.style.position = "absolute"; - el.style.left = "-9999px"; - document.body.appendChild(el); - let selected = document.getSelection().rangeCount > 0 - ? document.getSelection().getRangeAt(0) - : false; - el.select(); - document.execCommand("copy"); - document.body.removeChild(el); - if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); - return true; - } - return false; -}; -const mailgoStyle = () => { - // mailgo style - let mailgoCSSElement = createElement("style"); - mailgoCSSElement.id = "mailgo-style"; - mailgoCSSElement.type = "text/css"; - mailgoCSSElement.appendChild(createTextNode(mailgoCSS)); - document.head.appendChild(mailgoCSSElement); -}; -// mailgo -const mailgo = (mailgoConfig) => { - // if the window is defined... - if (window && typeof window !== "undefined") { - // add the style for mailgo - mailgoStyle(); - // if is set an initEvent add the listener - if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) { - document.addEventListener(mailgoConfig.initEvent, () => { - mailgoInit(mailgoConfig); - }); - } - else { - mailgoInit(mailgoConfig); - } + + el = el.parentElement; + } +}; // validate a single email with regex + + +var validateEmail = function validateEmail(email) { + return /^(([^<>()[\]\\.,;:\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 + + +var validateEmails = function validateEmails(arr) { + return arr.every(validateEmail); +}; // copy of a string + + +var copyToClipboard = function copyToClipboard(str) { + var el = createElement("textarea"); + el.value = str; + el.setAttribute("readonly", ""); + el.style.position = "absolute"; + el.style.left = "-9999px"; + document.body.appendChild(el); + var selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; + el.select(); + document.execCommand("copy"); + document.body.removeChild(el); + + if (selected) { + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); + return true; + } + + return false; +}; + +var mailgoStyle = function mailgoStyle() { + // mailgo style + var mailgoCSSElement = createElement("style"); + mailgoCSSElement.id = "mailgo-style"; + mailgoCSSElement.type = "text/css"; + mailgoCSSElement.appendChild(createTextNode(mailgoCSS)); + document.head.appendChild(mailgoCSSElement); +}; // mailgo + + +var mailgo = function mailgo(mailgoConfig) { + // if the window is defined... + if (window && typeof window !== "undefined") { + // add the style for mailgo + mailgoStyle(); // if is set an initEvent add the listener + + if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) { + document.addEventListener(mailgoConfig.initEvent, function () { + mailgoInit(mailgoConfig); + }); + } else { + mailgoInit(mailgoConfig); } + } }; /* harmony default export */ var src_mailgo = (mailgo); - // CONCATENATED MODULE: ./mailgo.lib.ts // webpack > lib/mailgo.js diff --git a/src/mailgo.ts b/src/mailgo.ts index a50c3d0..0f8254a 100644 --- a/src/mailgo.ts +++ b/src/mailgo.ts @@ -578,7 +578,7 @@ const openWhatsApp = (): void => { hideMailgo(); }; -const callDefault = (event?: any): void => { +const callDefault = () => { let callUrl = "tel:" + tel; window.open(callUrl); hideMailgo(); diff --git a/webpack.config.js b/webpack.config.js index d999986..058c59c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,19 +1,10 @@ const path = require("path"); -const { presets } = require("./babel.config"); const mailgoRules = [ { test: /\.tsx?$/, include: path.resolve(__dirname, "./src/"), - use: [ - "ts-loader", - /*{ - loader: "babel-loader", - options: { - presets: presets, - }, - },*/ - ], + use: ["babel-loader"], exclude: /node_modules/, }, {