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

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long