mailgo
Version:
a new concept of mailto and tel links
1,212 lines (913 loc) • 64.1 kB
JavaScript
/******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 91:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
// Imports
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(476);
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(function(i){return i[1]});
// Module
___CSS_LOADER_EXPORT___.push([module.id, ".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:16.5px;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:#20232a;opacity:.8}.m-modal .m-modal-content{position:relative;z-index:10002;box-sizing:content-box;text-align:center;overflow:hidden;min-width:200px;max-width:240px;background-color:#fff;opacity:.95;border-radius:20px;box-shadow:0 3px 20px rgba(32,35,42,.5);border:3px solid #333;color:#4a4a4a;display:flex;flex-direction:column;overflow:auto;padding:24px;transition:.5s box-shadow}.m-modal .m-modal-content:hover,.m-modal .m-modal-content:focus,.m-modal .m-modal-content:active{opacity:1}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:pre-line;text-overflow:ellipsis;line-height:1.2em}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{white-space:pre-line;font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{cursor:pointer;padding:10px;color:#4a4a4a;border-radius:20px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#c0372a}.m-modal .m-modal-content a.m-gmail:hover,.m-modal .m-modal-content a.m-gmail:focus,.m-modal .m-modal-content a.m-gmail:active{background-color:rgba(192,55,42,.08);color:#c0372a}.m-modal .m-modal-content a.m-outlook{color:#0967aa}.m-modal .m-modal-content a.m-outlook:hover,.m-modal .m-modal-content a.m-outlook:focus,.m-modal .m-modal-content a.m-outlook:active{background-color:rgba(9,103,170,.08);color:#0967aa}.m-modal .m-modal-content a.m-yahoo{color:#4a00a0}.m-modal .m-modal-content a.m-yahoo:hover,.m-modal .m-modal-content a.m-yahoo:focus,.m-modal .m-modal-content a.m-yahoo:active{background-color:rgba(74,0,160,.08);color:#4a00a0}.m-modal .m-modal-content a.m-tg{color:#086da0}.m-modal .m-modal-content a.m-tg:hover,.m-modal .m-modal-content a.m-tg:focus,.m-modal .m-modal-content a.m-tg:active{background-color:rgba(8,109,160,.08);color:#086da0}.m-modal .m-modal-content a.m-wa{color:#067466}.m-modal .m-modal-content a.m-wa:hover,.m-modal .m-modal-content a.m-wa:focus,.m-modal .m-modal-content a.m-wa:active{background-color:rgba(6,116,102,.08);color:#067466}.m-modal .m-modal-content a.m-skype{color:#076d92}.m-modal .m-modal-content a.m-skype:hover,.m-modal .m-modal-content a.m-skype:focus,.m-modal .m-modal-content a.m-skype:active{background-color:rgba(7,109,146,.08);color:#076d92}.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-default:focus,.m-modal .m-modal-content a.m-default:active,.m-modal .m-modal-content a.m-copy:hover,.m-modal .m-modal-content a.m-copy:focus,.m-modal .m-modal-content a.m-copy:active{background-color:rgba(0,0,0,.08);color:#4a4a4a}.m-modal .m-modal-content a.m-custom-action{color:#0b790b}.m-modal .m-modal-content a.m-custom-action:hover,.m-modal .m-modal-content a.m-custom-action:focus,.m-modal .m-modal-content a.m-custom-action:active{background-color:rgba(11,121,11,.08);color:#0b790b}.m-modal .m-modal-content a.m-by{font-size:12px;margin-top:.8rem;padding:5px;color:#4a4a4a}.m-modal .m-modal-content a.m-by:hover,.m-modal .m-modal-content a.m-by:focus,.m-modal .m-modal-content a.m-by:active{color:#3d3d3d}.m-modal .m-modal-content .w-500{font-weight:500}.m-modal.m-dark .m-modal-content{background-color:#20232a}.m-modal.m-dark .m-modal-content,.m-modal.m-dark .m-modal-content p,.m-modal.m-dark .m-modal-content p span,.m-modal.m-dark .m-modal-content strong{color:#fff}.m-modal.m-dark .m-modal-content a{color:#eaeaea}.m-modal.m-dark .m-modal-content a:not(.m-by):hover,.m-modal.m-dark .m-modal-content a:not(.m-by):focus,.m-modal.m-dark .m-modal-content a:not(.m-by):active{background-color:rgba(134,134,134,.08);color:#eaeaea}.m-modal.m-dark .m-modal-content a.m-gmail{color:#e07d73}.m-modal.m-dark .m-modal-content a.m-gmail:hover,.m-modal.m-dark .m-modal-content a.m-gmail:focus,.m-modal.m-dark .m-modal-content a.m-gmail:active{background-color:rgba(224,125,115,.08);color:#e07d73}.m-modal.m-dark .m-modal-content a.m-outlook{color:#4c9cd7}.m-modal.m-dark .m-modal-content a.m-outlook:hover,.m-modal.m-dark .m-modal-content a.m-outlook:focus,.m-modal.m-dark .m-modal-content a.m-outlook:active{background-color:rgba(76,156,215,.08);color:#4c9cd7}.m-modal.m-dark .m-modal-content a.m-yahoo{color:#ac88d3}.m-modal.m-dark .m-modal-content a.m-yahoo:hover,.m-modal.m-dark .m-modal-content a.m-yahoo:focus,.m-modal.m-dark .m-modal-content a.m-yahoo:active{background-color:rgba(172,136,211,.08);color:#ac88d3}.m-modal.m-dark .m-modal-content a.m-tg{color:#4cabdb}.m-modal.m-dark .m-modal-content a.m-tg:hover,.m-modal.m-dark .m-modal-content a.m-tg:focus,.m-modal.m-dark .m-modal-content a.m-tg:active{background-color:rgba(76,171,219,.08);color:#4cabdb}.m-modal.m-dark .m-modal-content a.m-wa{color:#4cd2c0}.m-modal.m-dark .m-modal-content a.m-wa:hover,.m-modal.m-dark .m-modal-content a.m-wa:focus,.m-modal.m-dark .m-modal-content a.m-wa:active{background-color:rgba(76,210,192,.08);color:#4cd2c0}.m-modal.m-dark .m-modal-content a.m-skype{color:#4cc7f4}.m-modal.m-dark .m-modal-content a.m-skype:hover,.m-modal.m-dark .m-modal-content a.m-skype:focus,.m-modal.m-dark .m-modal-content a.m-skype:active{background-color:rgba(76,199,244,.08);color:#4cc7f4}.m-modal.m-dark .m-modal-content a.m-custom-action{color:#b0ecb0}.m-modal.m-dark .m-modal-content a.m-custom-action:hover,.m-modal.m-dark .m-modal-content a.m-custom-action:focus,.m-modal.m-dark .m-modal-content a.m-custom-action:active{background-color:rgba(176,236,176,.08);color:#b0ecb0}.m-modal.m-dark .m-modal-content a.m-by:hover,.m-modal.m-dark .m-modal-content a.m-by:focus,.m-modal.m-dark .m-modal-content a.m-by:active{color:#fff}", ""]);
// Exports
module.exports = ___CSS_LOADER_EXPORT___;
/***/ }),
/***/ 476:
/***/ (function(module) {
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
// eslint-disable-next-line func-names
module.exports = function (cssWithMappingToString) {
var list = []; // return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item);
if (item[2]) {
return "@media ".concat(item[2], " {").concat(content, "}");
}
return content;
}).join("");
}; // import a list of modules into the list
// eslint-disable-next-line func-names
list.i = function (modules, mediaQuery, dedupe) {
if (typeof modules === "string") {
// eslint-disable-next-line no-param-reassign
modules = [[null, modules, ""]];
}
var alreadyImportedModules = {};
if (dedupe) {
for (var i = 0; i < this.length; i++) {
// eslint-disable-next-line prefer-destructuring
var id = this[i][0];
if (id != null) {
alreadyImportedModules[id] = true;
}
}
}
for (var _i = 0; _i < modules.length; _i++) {
var item = [].concat(modules[_i]);
if (dedupe && alreadyImportedModules[item[0]]) {
// eslint-disable-next-line no-continue
continue;
}
if (mediaQuery) {
if (!item[2]) {
item[2] = mediaQuery;
} else {
item[2] = "".concat(mediaQuery, " and ").concat(item[2]);
}
}
list.push(item);
}
};
return list;
};
/***/ }),
/***/ 801:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
var result = __webpack_require__(91);
if (typeof result === "string") {
module.exports = result;
} else {
module.exports = result.toString();
}
/***/ }),
/***/ 474:
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
;// CONCATENATED MODULE: ../src/constants.ts
// links
var MAILTO = "mailto:";
var MAILGO = "mailgo:";
var TEL = "tel:";
var CALLTO = "callto:";
var SMS = "sms:"; // deep linking
var outlookDeepLink = "ms-outlook://"; // no mailgo class
var NO_MAILGO = "no-mailgo"; // responsive settings
var DESKTOP = "desktop";
var MOBILE = "mobile"; // mailgo modal types
var MAILGO_MAIL = "mailgo";
var MAILGO_TEL = "mailgo-tel";
var MAILGO_SMS = "mailgo-sms"; // mailgo installation types
var CLASSIC = "classic";
var LESS_SPAM = "less-spam"; // useful html tags
var spanHTMLTag = "span";
var aHTMLTag = "a";
var pHTMLTag = "p"; // default lang
var defaultLang = "en"; // useful regexp
var notNumber = new RegExp("[^0-9/]", "gi");
var leadingZeros = new RegExp("^0+", "gi"); // custom action
var customActionTextMaxLength = 20;
;// CONCATENATED MODULE: ../src/utils.ts
// 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);
}; // validate a single tel with regex
var validateTel = function validateTel(tel) {
return /^[+]{0,1}[\s0-9]*[(]{0,1}[0-9]{1,4}[)]{0,1}[-\s\./0-9]*[p]{0,1}[\s0-9]*$/.test(tel);
}; // copy of a string
var copyToClipboard = function copyToClipboard(str) {
var el = document.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;
}; // set focus loop within modal
var setFocusLoop = function setFocusLoop(ref) {
var modal = ref;
modal.querySelector(".m-modal-content a:last-of-type").addEventListener("keydown", leaveLastLink);
modal.querySelector(".m-modal-content a:first-of-type").addEventListener("keydown", leaveFirstLink);
};
var leaveLastLink = function leaveLastLink(e) {
// going back to the first link to force looping
if (e.code === "Tab" && e.shiftKey === false) {
e.preventDefault();
e.target.closest("div").querySelector("a:first-of-type").focus();
}
};
var leaveFirstLink = function leaveFirstLink(e) {
// going back to the first link to force looping
if (e.code === "Tab" && e.shiftKey === true) {
e.preventDefault();
e.target.closest("div").querySelector("a:last-of-type").focus();
}
};
var truncate = function truncate(text, maxLength) {
return text && text.length > maxLength ? text.substr(0, maxLength - 1) + "..." : text;
};
;// CONCATENATED MODULE: ../i18n/languages.json
var languages_namespaceObject = JSON.parse('["en","it","es","de","fr","pt","nl","ru","sv","no","dk","is","zh","ja","cs"]');
;// CONCATENATED MODULE: ../i18n/translations.json
var translations_namespaceObject = JSON.parse('{"en":{"open_in_":"open in ","cc_":"cc ","bcc_":"bcc ","subject_":"subject ","body_":"body ","gmail":"Gmail","outlook":"Outlook","yahoo":"Yahoo Mail","telegram":"Telegram","whatsapp":"WhatsApp","skype":"Skype","call":"call","open":"open","_default":" default","_as_default":" as default","copy":"copy","copied":"copied"},"it":{"open_in_":"apri con ","bcc_":"ccn ","subject_":"oggetto ","body_":"testo ","call":"chiama","open":"apri","_default":" ","_as_default":" ","copy":"copia","copied":"copiato"},"es":{"open_in_":"abrir con ","bcc_":"cco ","subject_":"asunto ","body_":"cuerpo ","call":"llamar","open":"abrir","_default":" predefinido","_as_default":" por defecto","copy":"copiar","copied":"copiado"},"de":{"open_in_":"Öffnen in ","subject_":"Betreff ","body_":"Nachricht ","call":"Anrufen","open":"Öffnen","_default":" mit Standard","_as_default":" mit Standard","copy":"kopieren","copied":"kopiert"},"pt":{"open_in_":"abrir com ","bcc_":"cco ","subject_":"assunto ","body_":"corpo ","call":"ligar","open":"abrir","_default":" padrão","_as_default":" por padrão","copy":"copiar","copied":"copiado"},"fr":{"open_in_":"Ouvrir dans ","bcc_":"cci ","subject_":"sujet ","body_":"contenu ","call":"Appeler","open":"Ouvrir","_default":" par défaut","_as_default":" par défaut","copy":"Copier","copied":"copié"},"nl":{"subject_":"onderwerp ","body_":"bericht ","call":"bellen","open":"openen","_default":" standaard","_as_default":" als standaard","copy":"kopiëren"},"ru":{"open_in_":"открыть в ","subject_":"тема ","body_":"тело ","call":"позвонить","open":"открыть","_default":" по умолчанию","_as_default":" по умолчанию","copy":"скопировать"},"sv":{"open_in_":"öppna i ","subject_":"ämne ","body_":"meddelandetext ","call":"ring","open":"öppna","_default":" förval","_as_default":" som förval","copy":"kopiera","copied":"kopierad"},"no":{"open_in_":"åpne i ","subject_":"emne ","call":"ringe","open":"åpne","_as_default":" som standard","copy":"kopiere","copied":"kopiert"},"dk":{"open_in_":"åpne i ","subject_":"emne ","call":"ringe op","open":"åben","_as_default":" som standard","copy":"kopi","copied":"kopieret"},"is":{"open_in_":"opið inn ","subject_":"viðfangsefni ","body_":"líkami ","call":"hringja","open":"opið","_default":" sjálfgefið","_as_default":" sem sjálfgefið","copy":"afrita","copied":"afritað"},"zh":{"open_in_":"開啟 ","cc_":"副本 ","bcc_":"密件副本 ","subject_":"主旨 ","body_":"內文 ","call":"通話","open":"開啟","_default":" 預設","_as_default":" 預設","copy":"複製","copied":"已複製"},"ja":{"open_in_":"開く ","subject_":"主題 ","body_":"本文 ","call":"通話 ","open":"開く ","_default":" 標準のアプリ","_as_default":" 標準のアプリ","copy":"リンクをコピー","copied":"コピーしました"},"cs":{"open_in_":"otevřít v ","cc_":"kopie ","subject_":"předmět ","body_":"zpráva ","call":"volat","open":"otevřít","_default":" výchozí","_as_default":" s výchozím nastavením","copy":"kopírovat","copied":"zkopírováno"}}');
;// CONCATENATED MODULE: ../src/mobile-detect.ts
var userAgent = function userAgent() {
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
return "mobile";
}
return "desktop";
};
;// CONCATENATED MODULE: ../src/mailgo.ts
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
// polyfill
// import { mailgoPolyfill } from "./polyfill";
// constants
// utils
// i18n for mailgo
// mobile detect
// mailgo scss, with toString (https://github.com/webpack-contrib/css-loader#tostring)
var mailgoCSS = __webpack_require__(801).toString(); // default language
var lang = defaultLang; // default strings
var defaultStrings = translations_namespaceObject[defaultLang]; // translation strings
var strings; // global mailgo config object
var config; // config to check if the client is mobile or desktop
var isMobile = false; // default config attributes
var mailtoEnabled = true;
var telEnabled = true;
var smsEnabled = false;
var desktopEnabled = true;
var mobileEnabled = true;
var validateEmailConfig = true;
var validateTelConfig = true;
var showFooterConfig = true;
var loadCSSConfig = true; // activeMailgoType
var activeMailgoType; // modals global object
var modalMailto, modalTel; // mailgo general variables
var url, href, lessSpamHref; // mailgo mail variables
var mail, cc, bcc, subject, bodyMail; // mailgo mail custom action variables
var customActionText, customActionTitle, customActionUrl; // mailgo tel variables
var tel, msg, telegramUsername, skypeUsername; // the DOM elements
var title, titleTel, detailCc, detailBcc, detailSubject, detailBody, detailMsg, ccValue, bccValue, subjectValue, bodyValue, msgValue, activatedLink; // mailgo buttons (actions)
var gmail, outlook, yahoo, mailgo_open, telegram, wa, skype, call, copyMail, copyTel, customAction;
/**
* mailgoInit
* the function that creates the mailgo elements in DOM
*/
var mailgoInit = function mailgoInit() {
// set the boolean for mobile/desktop
isMobile = userAgent() === MOBILE; // responsive settings
{
var _config, _config2;
if (typeof ((_config = config) === null || _config === void 0 ? void 0 : _config.desktop) !== "undefined") {
desktopEnabled = config.desktop; // if it is a desktop and desktop is not enabled no init mailgo
if (!isMobile && !desktopEnabled) {
return;
}
}
if (typeof ((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.mobile) !== "undefined") {
mobileEnabled = config.mobile; // if it is a mobile and mobile is not enabled no init mailgo
if (isMobile && !mobileEnabled) {
return;
}
}
} // set the mailgo language
mailgoSetLanguage(); // mailgo, if mailgo not already exists
var mailgoExists = !!document.getElementById(MAILGO_MAIL); // if mailgo is enabled for mailto and it not exists in DOM
if (mailtoEnabled && !mailgoExists) {
var _config3, _config4;
// modal
modalMailto = createElement();
modalMailto.style.display = "none";
modalMailto.id = MAILGO_MAIL;
modalMailto.classList.add("m-modal");
modalMailto.setAttribute("role", "dialog");
modalMailto.setAttribute("tabindex", "-1");
modalMailto.setAttribute("aria-labelledby", "m-title"); // if dark is in config
if ((_config3 = config) !== null && _config3 !== void 0 && _config3.dark) {
enableDarkMode();
} else {
disableDarkMode();
} // background
var modalBackground = createElement();
modalBackground.className = "m-modal-back";
modalMailto.appendChild(modalBackground); // modal content
var modalContent = createElement();
modalContent.className = "m-modal-content";
modalMailto.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(pHTMLTag);
detailCc.id = "m-cc";
var ccSpan = createElement(spanHTMLTag);
ccSpan.className = "w-500";
ccSpan.appendChild(createTextNode(strings.cc_ || defaultStrings.cc_));
ccValue = createElement(spanHTMLTag);
ccValue.id = "m-cc-value";
detailCc.appendChild(ccSpan);
detailCc.appendChild(ccValue);
details.appendChild(detailCc);
detailBcc = createElement(pHTMLTag);
detailBcc.id = "m-bcc";
var bccSpan = createElement(spanHTMLTag);
bccSpan.className = "w-500";
bccSpan.appendChild(createTextNode(strings.bcc_ || defaultStrings.bcc_));
bccValue = createElement(spanHTMLTag);
bccValue.id = "m-bcc-value";
detailBcc.appendChild(bccSpan);
detailBcc.appendChild(bccValue);
details.appendChild(detailBcc);
detailSubject = createElement(pHTMLTag);
detailSubject.id = "m-subject";
var subjectSpan = createElement(spanHTMLTag);
subjectSpan.className = "w-500";
subjectSpan.appendChild(createTextNode(strings.subject_ || defaultStrings.subject_));
subjectValue = createElement(spanHTMLTag);
subjectValue.id = "m-subject-value";
detailSubject.appendChild(subjectSpan);
detailSubject.appendChild(subjectValue);
details.appendChild(detailSubject);
detailBody = createElement(pHTMLTag);
detailBody.id = "m-body";
var bodySpan = createElement(spanHTMLTag);
bodySpan.className = "w-500";
bodySpan.appendChild(createTextNode(strings.body_ || defaultStrings.body_));
bodyValue = createElement(spanHTMLTag);
bodyValue.id = "m-body-value";
detailBody.appendChild(bodySpan);
detailBody.appendChild(bodyValue);
details.appendChild(detailBody);
modalContent.appendChild(details); // Gmail
gmail = createElement(aHTMLTag);
gmail.id = "m-gmail";
gmail.href = "#mailgo-gmail";
gmail.classList.add("m-open");
gmail.classList.add("m-gmail");
gmail.appendChild(createTextNode(strings.open_in_ || defaultStrings.open_in_));
var gmailSpan = createElement(spanHTMLTag);
gmailSpan.className = "w-500";
gmailSpan.appendChild(createTextNode(strings.gmail || defaultStrings.gmail));
gmail.appendChild(gmailSpan);
if (mailgoConfigAttributeEnabled("action", "gmail")) {
modalContent.appendChild(gmail);
} // Outlook
outlook = createElement(aHTMLTag);
outlook.id = "m-outlook";
outlook.href = "#mailgo-outlook";
outlook.classList.add("m-open");
outlook.classList.add("m-outlook");
outlook.appendChild(createTextNode(strings.open_in_ || defaultStrings.open_in_));
var outlookSpan = createElement(spanHTMLTag);
outlookSpan.className = "w-500";
outlookSpan.appendChild(createTextNode(strings.outlook || defaultStrings.outlook));
outlook.appendChild(outlookSpan);
if (mailgoConfigAttributeEnabled("action", "outlook")) {
modalContent.appendChild(outlook);
} // Outlook
yahoo = createElement(aHTMLTag);
yahoo.id = "m-yahoo";
yahoo.href = "#mailgo-yahoo";
yahoo.classList.add("m-open");
yahoo.classList.add("m-yahoo");
yahoo.appendChild(createTextNode(strings.open_in_ || defaultStrings.open_in_));
var yahooSpan = createElement(spanHTMLTag);
yahooSpan.className = "w-500";
yahooSpan.appendChild(createTextNode(strings.yahoo || defaultStrings.yahoo));
yahoo.appendChild(yahooSpan);
if (mailgoConfigAttributeEnabled("action", "yahoo")) {
modalContent.appendChild(yahoo);
} // open default
mailgo_open = createElement(aHTMLTag);
mailgo_open.id = "m-open";
mailgo_open.href = "#mailgo-open";
mailgo_open.classList.add("m-open");
mailgo_open.classList.add("m-default");
var openSpan = createElement(spanHTMLTag);
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(aHTMLTag);
copyMail.id = "m-copy";
copyMail.href = "#mailgo-copy";
copyMail.classList.add("m-copy");
copyMail.classList.add("w-500");
copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy));
modalContent.appendChild(copyMail); // custom action
customAction = createElement(aHTMLTag);
customAction.id = "m-custom-action";
customAction.href = "#mailgo-custom-action";
customAction.classList.add("m-open");
customAction.classList.add("m-custom-action");
if (mailgoConfigAttributeEnabled("action", "custom")) {
modalContent.appendChild(customAction);
} // hide mailgo.dev in footer only if showFooter is defined and equal to false
if (typeof ((_config4 = config) === null || _config4 === void 0 ? void 0 : _config4.showFooter) !== "undefined") {
showFooterConfig = config.showFooter;
}
if (showFooterConfig) {
modalContent.appendChild(byElement());
} // add the modal at the end of the body
document.body.appendChild(modalMailto); // every click outside the modal will hide the modal
modalBackground.addEventListener("click", hideMailgo);
} // mailgo tel, if mailgo-tel not already exists
var mailgoTelExists = !!document.getElementById(MAILGO_TEL); // if mailgo is enabled for tel/callto and it not exists in DOM
if (telEnabled && !mailgoTelExists) {
var _config5, _config6;
// modal
modalTel = createElement();
modalTel.style.display = "none";
modalTel.id = MAILGO_TEL;
modalTel.classList.add("m-modal");
modalTel.setAttribute("role", "dialog");
modalTel.setAttribute("tabindex", "-1");
modalTel.setAttribute("aria-labelledby", "m-tel-title"); // if dark is in config
if ((_config5 = config) !== null && _config5 !== void 0 && _config5.dark) {
enableDarkMode();
} else {
disableDarkMode();
} // background
var _modalBackground = createElement();
_modalBackground.className = "m-modal-back";
modalTel.appendChild(_modalBackground); // modal content
var _modalContent = createElement();
_modalContent.className = "m-modal-content";
modalTel.appendChild(_modalContent); // title (telephone number)
titleTel = createElement("strong");
titleTel.id = "m-tel-title";
titleTel.className = "m-title";
_modalContent.appendChild(titleTel); // details
var detailsTel = createElement();
detailsTel.id = "m-tel-details";
detailsTel.className = "m-details";
detailMsg = createElement(pHTMLTag);
detailMsg.id = "m-msg";
var msgSpan = createElement(spanHTMLTag);
msgSpan.className = "w-500";
msgSpan.appendChild(createTextNode(strings.body_ || defaultStrings.body_));
msgValue = createElement(spanHTMLTag);
msgValue.id = "m-msg-value";
detailMsg.appendChild(msgSpan);
detailMsg.appendChild(msgValue);
detailsTel.appendChild(detailMsg);
_modalContent.appendChild(detailsTel); // Telegram
telegram = createElement(aHTMLTag);
telegram.id = "m-tg";
telegram.href = "#mailgo-telegram";
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(spanHTMLTag);
telegramSpan.className = "w-500";
telegramSpan.appendChild(createTextNode(strings.telegram || defaultStrings.telegram));
telegram.appendChild(telegramSpan);
if (mailgoConfigAttributeEnabled("action", "telegram")) {
_modalContent.appendChild(telegram);
} // WhatsApp
wa = createElement(aHTMLTag);
wa.id = "m-wa";
wa.href = "#mailgo-whatsapp";
wa.classList.add("m-open");
wa.classList.add("m-wa");
wa.appendChild(createTextNode(strings.open_in_ || defaultStrings.open_in_));
var waSpan = createElement(spanHTMLTag);
waSpan.className = "w-500";
waSpan.appendChild(createTextNode(strings.whatsapp || defaultStrings.whatsapp));
wa.appendChild(waSpan);
if (mailgoConfigAttributeEnabled("action", "whatsapp")) {
_modalContent.appendChild(wa);
} // Skype
skype = createElement(aHTMLTag);
skype.id = "m-skype";
skype.href = "#mailgo-skype";
skype.classList.add("m-open");
skype.classList.add("m-skype");
skype.appendChild(createTextNode(strings.open_in_ || defaultStrings.open_in_));
var skypeSpan = createElement(spanHTMLTag);
skypeSpan.className = "w-500";
skypeSpan.appendChild(createTextNode(strings.skype || defaultStrings.skype));
skype.appendChild(skypeSpan);
if (mailgoConfigAttributeEnabled("action", "skype")) {
_modalContent.appendChild(skype);
} // call default
call = createElement(aHTMLTag);
call.id = "m-call";
call.href = "#mailgo-open";
call.classList.add("m-open");
call.classList.add("m-default");
var callSpan = createElement(spanHTMLTag);
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(aHTMLTag);
copyTel.id = "m-tel-copy";
copyTel.href = "#mailgo-copy";
copyTel.classList.add("m-copy");
copyTel.classList.add("w-500");
copyTel.appendChild(createTextNode(strings.copy || defaultStrings.copy));
_modalContent.appendChild(copyTel); // hide mailgo.dev in footer only if showFooter is defined and equal to false
if (typeof ((_config6 = config) === null || _config6 === void 0 ? void 0 : _config6.showFooter) !== "undefined") {
showFooterConfig = config.showFooter;
}
if (showFooterConfig) {
_modalContent.appendChild(byElement());
} // add the modal at the end of the body
document.body.appendChild(modalTel); // 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", mailgoClickListener);
};
/**
* mailgoClickListener
* function to check if an element is mailgo-enabled or not referencing to
* mail:
* document.querySelectorAll(
* 'a[href^="mailto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
* );
* tel:
* document.querySelectorAll(
* 'a[href^="tel:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
* );
* or
* document.querySelectorAll(
* 'a[href^="callto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
* );
* or
* document.querySelectorAll(
* 'a[href^="sms:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo'
* );
*/
function mailgoClickListener(event) {
// check if the mailgo HTML exists in the body
if (!document.body.contains(modalMailto) && !document.body.contains(modalTel)) {
return false;
} // if a mailgo is already showing do nothing
if (mailgoIsShowing()) {
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 here only if one of the mailgo modals are enabled
if (mailtoEnabled || telEnabled || smsEnabled) {
var localMailgoType = getMailgoTypeByElement(element); // go on if the localMailgoType is not null
if (localMailgoType) {
var _activeMailgoType;
// set the active mailgo type
activeMailgoType = localMailgoType;
var activeMailgoModalType = (_activeMailgoType = activeMailgoType) === null || _activeMailgoType === void 0 ? void 0 : _activeMailgoType.type;
if (activeMailgoModalType) {
// check if the setting is enabled and if so go with pre-render
if (mailtoEnabled && activeMailgoModalType === MAILGO_MAIL || telEnabled && activeMailgoModalType === MAILGO_TEL || smsEnabled && activeMailgoModalType === MAILGO_SMS) {
// stop the normal execution of the element click
event.preventDefault(); // render mailgo
mailgoPreRender(element);
return true;
}
}
}
}
});
}
return false;
}
/**
* mailgoPreRender
* function to pre-render a mailgo, it helps populating elements needed by modal
*/
function mailgoPreRender(mailgoElementOrUrl) {
var _activeMailgoType2, _activeMailgoType3, _config9;
var mailgoElement; // get the type and installation from current mailgo type
var type = (_activeMailgoType2 = activeMailgoType) === null || _activeMailgoType2 === void 0 ? void 0 : _activeMailgoType2.type;
var installation = (_activeMailgoType3 = activeMailgoType) === null || _activeMailgoType3 === void 0 ? void 0 : _activeMailgoType3.installation; // if type is not defined return
if (!type) return false;
if (typeof mailgoElementOrUrl === "string") {
// if the parameter is a string it is the url
href = mailgoElementOrUrl;
} else {
// if the paramenter is an HTMLLinkElement get the href attribute and the element
href = mailgoElementOrUrl.getAttribute("href");
mailgoElement = mailgoElementOrUrl;
} // mailgo mail
if (type === MAILGO_MAIL) {
var _config7;
// if the installation is classic
if (installation === CLASSIC) {
if (validateUrl(href, MAILTO)) {
mail = decodeURIComponent(href.split("?")[0].split(MAILTO)[1].trim());
} else if (validateUrl(href, MAILGO)) {
mail = decodeURIComponent(href.split("?")[0].split(MAILGO)[1].trim());
}
try {
url = new URL(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");
} catch (error) {
console.log(error);
}
} else if (installation === LESS_SPAM) {
// if the installation is less-spam
// mail = data-address + @ + data-domain
mail = mailgoElement.getAttribute("data-address") && mailgoElement.getAttribute("data-domain") ? mailgoElement.getAttribute("data-address") + "@" + mailgoElement.getAttribute("data-domain") : null;
try {
url = new URL(MAILTO + encodeURIComponent(mail));
} catch (error) {
console.log(error);
}
var parameters = []; // cc = data-cc-address + @ + data-cc-domain
cc = mailgoElement.getAttribute("data-cc-address") ? mailgoElement.getAttribute("data-cc-address") + "@" + mailgoElement.getAttribute("data-cc-domain") : null; // if cc is defined add it to parameters
if (cc) parameters.push("cc=" + cc); // bcc = data-bcc-address + @ + data-bcc-domain
bcc = mailgoElement.getAttribute("data-bcc-address") ? mailgoElement.getAttribute("data-bcc-address") + "@" + mailgoElement.getAttribute("data-bcc-domain") : null; // if bcc is defined add it to parameters
if (bcc) parameters.push("bcc=" + bcc); // subject = data-subject
subject = mailgoElement.getAttribute("data-subject"); // if subject is defined add it to parameters
if (subject) parameters.push("subject=" + subject); // body = data-body
bodyMail = mailgoElement.getAttribute("data-body"); // if body is defined add it to parameters
if (bodyMail) parameters.push("body=" + bodyMail); // set the lessSpamHref
lessSpamHref = buildLessSpamHref(MAILTO + encodeURIComponent(mail), parameters);
} // set custom action text, title and url
customActionText = "";
customActionTitle = "";
customActionUrl = "";
if (mailgoConfigAttributeEnabled("action", "custom") && mailgoElement) {
var _mailgoElement$getAtt, _mailgoElement$getAtt2;
customActionText = (_mailgoElement$getAtt = mailgoElement.getAttribute("data-custom-action-text")) !== null && _mailgoElement$getAtt !== void 0 ? _mailgoElement$getAtt : customActionText;
if (customActionText) {
customActionTitle = customActionText;
customActionText = truncate(customActionText, customActionTextMaxLength);
}
customActionUrl = (_mailgoElement$getAtt2 = mailgoElement.getAttribute("data-custom-action-url")) !== null && _mailgoElement$getAtt2 !== void 0 ? _mailgoElement$getAtt2 : customActionUrl;
} // if is in config use it
if (typeof ((_config7 = config) === null || _config7 === void 0 ? void 0 : _config7.validateEmail) !== "undefined") {
validateEmailConfig = config.validateEmail;
}
if (validateEmailConfig) {
// validate the email address
if (!validateEmails(mail.split(","))) {
return false;
} // if cc, bcc are not valid cc, bcc = ""
if (cc && !validateEmails(cc.split(","))) cc = "";
if (bcc && !validateEmails(bcc.split(","))) bcc = "";
}
} // mailgo tel
else if (type === MAILGO_TEL) {
var _config8;
if (installation === CLASSIC) {
if (validateUrl(href, TEL)) {
tel = decodeURIComponent(href.split("?")[0].split(TEL)[1].trim());
} else if (validateUrl(href, CALLTO)) {
tel = decodeURIComponent(href.split("?")[0].split(CALLTO)[1].trim());
} else if (validateUrl(href, SMS)) {
tel = decodeURIComponent(href.split("?")[0].split(SMS)[1].trim());
}
try {
url = new URL(href);
var _urlParams = url.searchParams; // optional parameters for the phone number
msg = _urlParams.get("body");
} catch (error) {
console.log(error);
}
} else if (installation == LESS_SPAM) {
tel = mailgoElement.getAttribute("data-tel");
msg = mailgoElement.getAttribute("data-msg");
try {
url = new URL(TEL + encodeURIComponent(tel));
} catch (error) {
console.log(error);
}
var _parameters = []; // if msg is defined add it to parameters
if (msg) _parameters.push("body=" + msg); // set the lessSpamHref
lessSpamHref = buildLessSpamHref(TEL + encodeURIComponent(tel), _parameters);
} // if is in config use it
if (typeof ((_config8 = config) === null || _config8 === void 0 ? void 0 : _config8.validateTel) !== "undefined") {
validateTelConfig = config.validateTel;
} // validate the phone number
if (validateTelConfig) {
if (!validateTel(tel)) return false;
} // Telegram username
if (mailgoElement && mailgoElement.hasAttribute("data-telegram")) {
telegramUsername = mailgoElement.getAttribute("data-telegram");
} else {
telegramUsername = null;
} // Telegram username
if (mailgoElement && mailgoElement.hasAttribute("data-skype")) {
skypeUsername = mailgoElement.getAttribute("data-skype");
} else {
skypeUsername = null;
}
} // if dark is in config or contained in the element
if ((_config9 = config) !== null && _config9 !== void 0 && _config9.dark || mailgoElement.classList.contains("dark")) {
enableDarkMode();
} else {
disableDarkMode();
} // render mailgo
mailgoRender();
return true;
}
/**
* mailgoDirectRender
* function to render a mailgo directly from a URL
*/
function mailgoDirectRender(directUrl) {
// start mailgo
mailgo();
if (validateUrl(directUrl, MAILTO) || validateUrl(directUrl, MAILGO)) {
activeMailgoType = {
type: MAILGO_MAIL,
installation: CLASSIC
};
return mailgoPreRender(directUrl);
} else if (validateUrl(directUrl, TEL) || validateUrl(directUrl, CALLTO) || validateUrl(directUrl, SMS)) {
activeMailgoType = {
type: MAILGO_TEL,
installation: CLASSIC
};
return mailgoPreRender(directUrl);
}
return false;
}
/**
* mailgoRender
* function to render a mailgo (mail or tel)
*/
function mailgoRender() {
var _activeMailgoType4;
// get the type from current mailgo type
var type = (_activeMailgoType4 = activeMailgoType) === null || _activeMailgoType4 === void 0 ? void 0 : _activeMailgoType4.type; // if type is not defined return
if (!type) return false; // mailgo mail
if (type === MAILGO_MAIL) {
// the title of the modal (email address)
title.textContent = mail.split(",").join("\n"); // add the details if provided
if (mailgoConfigAttributeEnabled("detail", "cc") && cc) {
detailCc.style.display = "block";
ccValue.textContent = cc.split(",").join("\n");
} else {
detailCc.style.display = "none";
}
if (mailgoConfigAttributeEnabled("detail", "bcc") && bcc) {
detailBcc.style.display = "block";
bccValue.textContent = bcc.split(",").join("\n");
} else {
detailBcc.style.display = "none";
}
if (mailgoConfigAttributeEnabled("detail", "subject") && subject) {
detailSubject.style.display = "block";
subjectValue.textContent = subject;
} else {
detailSubject.style.display = "none";
}
if (mailgoConfigAttributeEnabled("detail", "body") && bodyMail) {
detailBody.style.display = "block";
bodyValue.textContent = bodyMail;
} else {
detailBody.style.display = "none";
} // custom action text, title and visibility
customAction.textContent = customActionText;
customAction.title = customActionTitle;
customAction.style.display = customActionText ? "block" : "none"; // add the actions
gmail.addEventListener("click", openGmail);
outlook.addEventListener("click", openOutlook);
yahoo.addEventListener("click", openYahooMail);
mailgo_open.addEventListener("click", openDefault);
copyMail.addEventListener("click", copy);
customAction.addEventListener("click", openCustomAction);
} // mailgo tel
else if (type === MAILGO_TEL) {
// the title of the modal (tel)
titleTel.textContent = tel;
if (mailgoConfigAttributeEnabled("detail", "msg") && msg) {
detailMsg.style.display = "block";
msgValue.textContent = msg;
} else {
detailMsg.style.display = "none";
} // add the actions to buttons
wa.addEventListener("click", openWhatsApp); // telegram must be shown only if data-telegram is provided
if (telegramUsername) {
document.getElementById("m-tg").style.display = "block";
telegram.addEventListener("click", openTelegram);
} else {
document.getElementById("m-tg").style.display = "none";
}
skype.addEventListener("click", openSkype);
call.addEventListener("click", openDefault);
copyTel.addEventListener("click", copy);
} // show the mailgo
showMailgo(type); // add listener keyDown
document.addEventListener("keydown", mailgoKeydown);
return true;
} // actions
var openGmail = function openGmail(event) {
var _activeMailgoType5;
event.preventDefault();
var urlString;
var installation = (_activeMailgoType5 = activeMailgoType) === null || _activeMailgoType5 === void 0 ? void 0 : _activeMailgoType5.installation;
if (installation === CLASSIC) {
try {
urlString = url.toString();
} catch (e) {
urlString = href;
}
} else if (installation === LESS_SPAM) {
urlString = lessSpamHref;
} // Gmail url
var gmailUrl = "https://mail.google.com/mail/?extsrc=mailto&url=" + encodeURIComponent(urlString); // open the link
window.open(gmailUrl, "_blank", "noopener, noreferrer"); // hide the modal
hideMailgo();
};
var openOutlook = function openOutlook(event) {
var _config10;
event.preventDefault(); // Outlook starting url
var startingOutlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to="; // let the user to decide to open Office365 Outlook instead of the classic outlook.live.com
if ((_config10 = config) !== null && _config10 !== void 0 && _config10.office365) {
startingOutlookUrl = "https://outlook.office365.com/owa/?path=/mail/action/compose&to=";
} // Outlook url
var outlookUrl = startingOutlookUrl + encodeURIComponent(mail); // the details if provided
if (subject) {
outlookUrl = outlookUrl.concat("&subject=" + encodeURIComponent(subject));
}
if (bodyMail) {
outlookUrl = outlookUrl.concat("&body=" + encodeURIComponent(bodyMail));
} // open the link
window.open(outlookUrl, "_blank", "noopener, noreferrer"); // hide the modal
hideMailgo();
};
var openYahooMail = function openYahooMail(event) {
event.preventDefault(); // Yahoo url
var yahooUrl = "https://compose.mail.yahoo.com/?to=" + mail; // the details if provided
if (subject) {
yahooUrl = yahooUrl.concat("&subject=" + encodeURIComponent(subject));
}
if (bodyMail) {
yahooUrl = yahooUrl.concat("&body=" + encodeURIComponent(bodyMail));
} // open the link
window.open(yahooUrl, "_blank", "noopener, noreferrer"); // hide the modal
hideMailgo();
};
var openTelegram = function openTelegram(event) {
event.preventDefault(); // check if telegramUsername exists
if (telegramUsername) {
// Telegram url
var tgUrl = "https://t.me/" + encodeURIComponent(telegramUsername); // open the url
window.open(tgUrl, "_blank", "noopener, noreferrer"); // hide the modal
hideMailgo();
}
};
var openSkype = function openSkype(event) {
event.preventDefault();
var skype = skypeUsername || tel; // Telegram url
var skypeUrl = "skype:" + encodeURIComponent(skype); // open the url
window.open(skypeUrl, "_blank", "noopener, noreferrer"); // hide the modal
hideMailgo();
};
var openWhatsApp = function openWhatsApp(event) {
event.preventDefault(); // WhatsApp API doesn't work with non number digits and leading 0s: https://faq.whatsapp.com/general/chats/how-to-use-click-to-chat/
var whatappTel = tel.replace(notNumber, "").replace(leadingZeros, ""); // WhatsApp url
var waUrl = "https://wa.me/" + encodeURIComponent(whatappTel); // the details if provided
if (msg) {
waUrl = waUrl.concat("?text=" + encodeURIComponent(msg));
} // open the url
window.open(waUrl, "_blank", "noopener, noreferrer"); // hide the modal
hideMailgo();
};
var openDefault = function openDefault(event) {
var _activeMailgoType6;
event.preventDefault();
var installation = (_activeMailgoType6 = activeMailgoType) === null || _activeMailgoType6 === void 0 ? void 0 : _activeMailgoType6.installation; // if the installation is classic the browser can follow the default behaviour
if (installation === CLASSIC) {
window.location.href = href;
} else if (installation === LESS_SPAM) {
// if the installation is less-spam use the built less-spam href
window.location.href = lessSpamHref;
}
hideMailgo();
};
var copy = function copy(event) {
event.preventDefault(); // the correct copyButton (mail or tel)
if (mailgoIsShowing()) {
var _activeMailgoType7;
var activeCopy;
var type = (_activeMailgoType7 = activeMailgoType) === null || _activeMailgoType7 === void 0 ? void 0 : _activeMailgoType7.type;
if (type === MAILGO_MAIL) {
// in case it is showing mail modal copy email address
copyToClipboard(mail);
activeCopy = copyMail;
} else {
// in case it is showing tel modal copy phone number
copyToClipboard(tel);
activeCopy = copyTel;
}
activeCopy.textContent = strings.copied || defaultStrings.copied;
setTimeout(function () {
activeCopy.textContent = strings.copy || defaultStrings.copy; // hide after the timeout
hideMailgo();
}, 999);
}
};
var openCustomAction = function openCustomAction(event) {
event === null || event === void 0 ? void 0 : event.preventDefault();
if (customActionUrl) {
var customActionUrlEncoded = encodeURI(customActionUrl);
window.open(customActionUrlEncoded, "_blank", "noopener, noreferrer");
}
hideMailgo();
}; // function to find if a link is a mailto, tel, callto or sms
var validateUrl = function validateUrl(url) {
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MAILTO;
var regexValidate = new RegExp("^" + type + "((.)+)", "gi");
return regexValidate.test(url);
}; // function that returns if an element is a mailgo
function getMailgoTypeByElement(element) {
var _element$classList, _element$classList2, _element$classList3;
var linkElement = element;
if (!linkElement.getAttribute) {
return null;
}
var elementHref = linkElement.getAttribute("href"); // return null if there is no-mailgo in class
if ((_element$classList = element.classList) !== null && _element$classList !== void 0 && _element$classList.contains(NO_MAILGO)) {
return null;
} // the case of classic type of mailgo, like a href=mailto:... or a href=tel:... and the class=mailgo with a useful href
if (elementHref || (_element$classList2 = element.classList) !== null && _element$classList2 !== void 0 && _element$classList2.contains("mailgo")) {
if (validateUrl(elementHref, MAILTO) || validateUrl(elementHref, MAILGO)) {
// a mailto: or mailgo:
return {
type: MAILGO_MAIL,
installation: CLASSIC
};
} else if (validateUrl(elementHref, TEL) || validateUrl(elementHref, CALLTO)) {
// a tel: or callto:
return {
type: MAILGO_TEL,
installation: CLASSIC
};
} else if (validateUrl(elementHref, SMS)) {
// a sms:
return {
type: MAILGO_SMS,
installation: CLASSIC
};
}
}
if (elementHref === "#mailgo" || (_element$classList3 = element.classList) !== null && _element$classList3 !== void 0 && _element$classList3.contains("mailgo")) {
// less-spam installation of mailgo, check to the attributes
if (element.hasAttribute("data-address") && element.hasAttribute("data-domain")