This commit is contained in:
2020-08-23 14:32:30 +02:00
parent 23d07f383e
commit 8b972c97a5
44 changed files with 563 additions and 1697 deletions

View File

@@ -321,7 +321,7 @@ var mailgoInit = function mailgoInit() {
var mailgoExists = !!document.getElementById("mailgo");
if (!mailgoExists) {
var _config3, _config4, _config5;
var _config3;
// modal
modalMailto = createElement();
@@ -439,12 +439,7 @@ var mailgoInit = function mailgoInit() {
copyMail.classList.add("m-copy");
copyMail.classList.add("w-500");
copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy));
modalContent.appendChild(copyMail); // 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" || ((_config5 = config) === null || _config5 === void 0 ? void 0 : _config5.showFooter) !== false) {
modalContent.appendChild(byElement());
} // add the modal at the end of the body
modalContent.appendChild(copyMail); // add the modal at the end of the body
document.body.appendChild(modalMailto); // every click outside the modal will hide the modal
@@ -455,7 +450,7 @@ var mailgoInit = function mailgoInit() {
var mailgoTelExists = !!document.getElementById("mailgo-tel");
if (!mailgoTelExists) {
var _config6, _config7, _config8;
var _config4;
// modal
modalTel = createElement();
@@ -466,7 +461,7 @@ var mailgoInit = function mailgoInit() {
modalTel.setAttribute("tabindex", "-1");
modalTel.setAttribute("aria-labelledby", "m-tel-title"); // if dark is in config
if ((_config6 = config) === null || _config6 === void 0 ? void 0 : _config6.dark) {
if ((_config4 = config) === null || _config4 === void 0 ? void 0 : _config4.dark) {
enableDarkMode(TEL_TYPE);
} else {
disableDarkMode(TEL_TYPE);
@@ -555,12 +550,7 @@ var mailgoInit = function mailgoInit() {
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 ((_config7 = config) === null || _config7 === void 0 ? void 0 : _config7.showFooter) === "undefined" || ((_config8 = config) === null || _config8 === void 0 ? void 0 : _config8.showFooter) !== false) {
_modalContent.appendChild(byElement());
} // add the modal at the end of the body
_modalContent.appendChild(copyTel); // add the modal at the end of the body
document.body.appendChild(modalTel); // every click outside the modal will hide the modal
@@ -578,14 +568,14 @@ var mailgoInit = function mailgoInit() {
function mailgoRender() {
var _config11;
var _config7;
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE;
var mailgoElement = arguments.length > 1 ? arguments[1] : undefined;
// mailgo mail
if (type === MAIL_TYPE) {
var _config9, _config10;
var _config5, _config6;
// if the element href=^"mailto:"
if (mailgoElement.href && mailgoElement.href.toLowerCase().startsWith(MAILTO)) {
@@ -612,7 +602,7 @@ function mailgoRender() {
bodyMail = mailgoElement.getAttribute("data-body");
}
if (typeof ((_config9 = config) === null || _config9 === void 0 ? void 0 : _config9.validateEmail) === "undefined" || ((_config10 = config) === null || _config10 === void 0 ? void 0 : _config10.validateEmail) === true) {
if (typeof ((_config5 = config) === null || _config5 === void 0 ? void 0 : _config5.validateEmail) === "undefined" || ((_config6 = config) === null || _config6 === void 0 ? void 0 : _config6.validateEmail) === true) {
// validate the email address
if (!validateEmails(mail.split(","))) return; // if cc, bcc are not valid cc, bcc = ""
@@ -680,7 +670,7 @@ function mailgoRender() {
} // if config.dark is set to true then all the modals will be in dark mode
if (!((_config11 = config) === null || _config11 === void 0 ? void 0 : _config11.dark)) {
if (!((_config7 = config) === null || _config7 === void 0 ? void 0 : _config7.dark)) {
// if the element contains dark as class enable dark mode
if (mailgoElement.classList.contains("dark")) {
enableDarkMode(type);
@@ -942,17 +932,6 @@ var hideMailgo = function hideMailgo() {
var mailgoIsShowing = function mailgoIsShowing() {
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE;
return getModalDisplay(type) === "flex";
};
var byElement = function byElement() {
// by
var by = createElement(aHTMLTag);
by.href = "https://mailgo.dev?ref=mailgo-modal";
by.className = "m-by";
by.target = "_blank";
by.rel = "noopener noreferrer";
by.appendChild(createTextNode("mailgo.dev"));
return by;
}; // create element
@@ -1117,15 +1096,15 @@ function mailgo(mailgoConfig) {
config = _objectSpread(_objectSpread({}, mailgoConfig), ((_window = window) === null || _window === void 0 ? void 0 : _window.mailgoConfig) || null); // if the window is defined...
if (window && typeof window !== "undefined") {
var _config12;
var _config8;
// add the style for mailgo
mailgoStyle(); // if is set an initEvent add the listener
if ((_config12 = config) === null || _config12 === void 0 ? void 0 : _config12.initEvent) {
var _config13;
if ((_config8 = config) === null || _config8 === void 0 ? void 0 : _config8.initEvent) {
var _config9;
if ((_config13 = config) === null || _config13 === void 0 ? void 0 : _config13.listenerOptions) {
if ((_config9 = config) === null || _config9 === void 0 ? void 0 : _config9.listenerOptions) {
// listener options specified
document.addEventListener(config.initEvent, function () {
mailgoInit();

File diff suppressed because one or more lines are too long