From e3483cec6ecb385da66f0a4de880bf6bb0e79959 Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Mon, 6 May 2019 18:53:52 +0200 Subject: [PATCH] miglioramenti css --- src/mailgo.js | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/mailgo.js b/src/mailgo.js index 10f9e5f..31c4ea9 100644 --- a/src/mailgo.js +++ b/src/mailgo.js @@ -1,20 +1,14 @@ function mailgoInit() { const styles = ` - .mailgo { - all: initial; - * { - all: unset; - } - } .mailgo-title { display: block; margin-bottom: 5px; } .mailgo-details { - font-size: 12px; margin-bottom: 10px; } .mailgo-details p { + font-size: 12px; margin-top: 3px; margin-bottom: 3px; } @@ -102,23 +96,37 @@ function mailgoInit() { // attivo mailgo su tutti gli elementi mailgos.forEach(function(mailgo, index) { - let mail = mailgo.href - .split("?")[0] - .split("mailto:")[1] - .trim(); + let mail = "", + cc = "", + bcc = "", + subject = "", + bodyMail = ""; - let url = new URL(mailgo.href); - let urlParams = new URLSearchParams(url.search); + // caso in cui applico mailgo ad un con mailto: + if (mailgo.href.includes("mailto:")) { + mail = mailgo.href + .split("?")[0] + .split("mailto:")[1] + .trim(); - let cc = urlParams.get("cc"); - let bcc = urlParams.get("bcc"); - let subject = urlParams.get("subject"); - let bodyMail = urlParams.get("body"); + let url = new URL(mailgo.href); + let urlParams = new URLSearchParams(url.search); + + cc = urlParams.get("cc"); + bcc = urlParams.get("bcc"); + subject = urlParams.get("subject"); + bodyMail = urlParams.get("body"); + } else { + // caso in cui applico mailgo ad con class="mailgo" + mail = + mailgo.getAttribute("data-address") + + "@" + + mailgo.getAttribute("data-domain"); + } if (!validateEmail(mail)) return; let modal = document.createElement("div"); - modal.classList.add("mailgo"); modal.classList.add("mailgo-modal"); modal.setAttribute("data-index", index);