This commit is contained in:
Matteo Manzinello 2019-05-13 12:11:06 +02:00
parent e07aad3a8a
commit 1f3510122f
2 changed files with 24 additions and 9 deletions

31
dist/mailgo.js vendored
View File

@ -2,11 +2,11 @@ const V = "0.3.0";
const MAILTO = "mailto:"; const MAILTO = "mailto:";
// mailgo style // mailgo style
const styleSheet = document.createElement("link"); const mailgoCSS = document.createElement("link");
styleSheet.rel = "stylesheet"; mailgoCSS.rel = "stylesheet";
styleSheet.type = "text/css"; mailgoCSS.type = "text/css";
styleSheet.href = "https://unpkg.com/mailgo@" + V + "/dist/mailgo.min.css"; mailgoCSS.href = "https://unpkg.com/mailgo@" + V + "/dist/mailgo.min.css";
document.head.appendChild(styleSheet); document.head.appendChild(mailgoCSS);
/** /**
* mailgoInit * mailgoInit
@ -194,18 +194,33 @@ mailgoRender = mailgo => {
bodyMail = urlParams.get("body"); bodyMail = urlParams.get("body");
} else { } else {
// if the element href="#mailgo" or class="mailgo" // if the element href="#mailgo" or class="mailgo"
// email = data-address + @ + data-domain // mail = data-address + @ + data-domain
mail = mail =
mailgo.getAttribute("data-address") + mailgo.getAttribute("data-address") +
"@" + "@" +
mailgo.getAttribute("data-domain"); mailgo.getAttribute("data-domain");
mailtoHref = MAILTO + encodeURIComponent(mail); mailtoHref = MAILTO + encodeURIComponent(mail);
url = new URL(mailtoHref); url = new URL(mailtoHref);
// cc = data-cc-address + @ + data-cc-domain
cc =
mailgo.getAttribute("data-cc-address") +
"@" +
mailgo.getAttribute("data-cc-domain");
// subject = data-subject
subject = mailgo.getAttribute("data-subject");
// body = data-body
bodyMail = mailgo.getAttribute("data-body");
} }
// validate the email address // validate the email address
if (!validateEmail(mail)) return; if (!validateEmail(mail)) return;
// if cc is not valid cc = ""
if (!validateEmail(cc)) cc = "";
// information // information
titleEl = getE("mailgo-title"); titleEl = getE("mailgo-title");
detailsEl = getE("mailgo-details"); detailsEl = getE("mailgo-details");
@ -344,13 +359,13 @@ validateEmail = email => {
// copy of a string // copy of a string
copyToClipboard = str => { copyToClipboard = str => {
const el = document.createElement("textarea"); let el = document.createElement("textarea");
el.value = str; el.value = str;
el.setAttribute("readonly", ""); el.setAttribute("readonly", "");
el.style.position = "absolute"; el.style.position = "absolute";
el.style.left = "-9999px"; el.style.left = "-9999px";
document.body.appendChild(el); document.body.appendChild(el);
const selected = let selected =
document.getSelection().rangeCount > 0 document.getSelection().rangeCount > 0
? document.getSelection().getRangeAt(0) ? document.getSelection().getRangeAt(0)
: false; : false;

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long