all buttons as let
This commit is contained in:
parent
6897c001ca
commit
bd9fbefb7b
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
162
src/mailgo.js
162
src/mailgo.js
@ -28,15 +28,20 @@
|
|||||||
telegramUsername = "",
|
telegramUsername = "",
|
||||||
skypeUsername = "";
|
skypeUsername = "";
|
||||||
|
|
||||||
|
// the DOM elements
|
||||||
|
let title,
|
||||||
|
titleTel,
|
||||||
|
detailCc,
|
||||||
|
detailBcc,
|
||||||
|
detailSubject,
|
||||||
|
detailBody,
|
||||||
|
ccValue,
|
||||||
|
bccValue,
|
||||||
|
subjectValue,
|
||||||
|
bodyValue;
|
||||||
|
|
||||||
// mailgo buttons
|
// mailgo buttons
|
||||||
let gmailButton,
|
let gmail, outlook, open, telegram, wa, skype, call, copyMail, copyTel;
|
||||||
outlookButton,
|
|
||||||
openButton,
|
|
||||||
telegramButton,
|
|
||||||
waButton,
|
|
||||||
skypeButton,
|
|
||||||
callButton,
|
|
||||||
copyButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mailgoInit
|
* mailgoInit
|
||||||
@ -62,7 +67,7 @@
|
|||||||
modal.appendChild(modalContent);
|
modal.appendChild(modalContent);
|
||||||
|
|
||||||
// title (email address)
|
// title (email address)
|
||||||
let title = document.createElement("strong");
|
title = document.createElement("strong");
|
||||||
title.id = "mailgo-title";
|
title.id = "mailgo-title";
|
||||||
title.className = "mailgo-title";
|
title.className = "mailgo-title";
|
||||||
modalContent.appendChild(title);
|
modalContent.appendChild(title);
|
||||||
@ -72,49 +77,49 @@
|
|||||||
details.id = "mailgo-details";
|
details.id = "mailgo-details";
|
||||||
details.className = "mailgo-details";
|
details.className = "mailgo-details";
|
||||||
|
|
||||||
let detailCc = document.createElement("p");
|
detailCc = document.createElement("p");
|
||||||
detailCc.id = "mailgo-cc";
|
detailCc.id = "mailgo-cc";
|
||||||
let ccSpan = document.createElement("span");
|
let ccSpan = document.createElement("span");
|
||||||
ccSpan.className = "mailgo-weight-500";
|
ccSpan.className = "mailgo-weight-500";
|
||||||
let ccContent = document.createTextNode("cc ");
|
let ccContent = document.createTextNode("cc ");
|
||||||
ccSpan.appendChild(ccContent);
|
ccSpan.appendChild(ccContent);
|
||||||
let ccValue = document.createElement("span");
|
ccValue = document.createElement("span");
|
||||||
ccValue.id = "mailgo-cc-value";
|
ccValue.id = "mailgo-cc-value";
|
||||||
detailCc.appendChild(ccSpan);
|
detailCc.appendChild(ccSpan);
|
||||||
detailCc.appendChild(ccValue);
|
detailCc.appendChild(ccValue);
|
||||||
details.appendChild(detailCc);
|
details.appendChild(detailCc);
|
||||||
|
|
||||||
let detailBcc = document.createElement("p");
|
detailBcc = document.createElement("p");
|
||||||
detailBcc.id = "mailgo-bcc";
|
detailBcc.id = "mailgo-bcc";
|
||||||
let bccSpan = document.createElement("span");
|
let bccSpan = document.createElement("span");
|
||||||
bccSpan.className = "mailgo-weight-500";
|
bccSpan.className = "mailgo-weight-500";
|
||||||
let bccContent = document.createTextNode("bcc ");
|
let bccContent = document.createTextNode("bcc ");
|
||||||
bccSpan.appendChild(bccContent);
|
bccSpan.appendChild(bccContent);
|
||||||
let bccValue = document.createElement("span");
|
bccValue = document.createElement("span");
|
||||||
bccValue.id = "mailgo-bcc-value";
|
bccValue.id = "mailgo-bcc-value";
|
||||||
detailBcc.appendChild(bccSpan);
|
detailBcc.appendChild(bccSpan);
|
||||||
detailBcc.appendChild(bccValue);
|
detailBcc.appendChild(bccValue);
|
||||||
details.appendChild(detailBcc);
|
details.appendChild(detailBcc);
|
||||||
|
|
||||||
let detailSubject = document.createElement("p");
|
detailSubject = document.createElement("p");
|
||||||
detailSubject.id = "mailgo-subject";
|
detailSubject.id = "mailgo-subject";
|
||||||
let subjectSpan = document.createElement("span");
|
let subjectSpan = document.createElement("span");
|
||||||
subjectSpan.className = "mailgo-weight-500";
|
subjectSpan.className = "mailgo-weight-500";
|
||||||
let subjectContent = document.createTextNode("subject ");
|
let subjectContent = document.createTextNode("subject ");
|
||||||
subjectSpan.appendChild(subjectContent);
|
subjectSpan.appendChild(subjectContent);
|
||||||
let subjectValue = document.createElement("span");
|
subjectValue = document.createElement("span");
|
||||||
subjectValue.id = "mailgo-subject-value";
|
subjectValue.id = "mailgo-subject-value";
|
||||||
detailSubject.appendChild(subjectSpan);
|
detailSubject.appendChild(subjectSpan);
|
||||||
detailSubject.appendChild(subjectValue);
|
detailSubject.appendChild(subjectValue);
|
||||||
details.appendChild(detailSubject);
|
details.appendChild(detailSubject);
|
||||||
|
|
||||||
let detailBody = document.createElement("p");
|
detailBody = document.createElement("p");
|
||||||
detailBody.id = "mailgo-body";
|
detailBody.id = "mailgo-body";
|
||||||
let bodySpan = document.createElement("span");
|
let bodySpan = document.createElement("span");
|
||||||
bodySpan.className = "mailgo-weight-500";
|
bodySpan.className = "mailgo-weight-500";
|
||||||
let bodyContent = document.createTextNode("body ");
|
let bodyContent = document.createTextNode("body ");
|
||||||
bodySpan.appendChild(bodyContent);
|
bodySpan.appendChild(bodyContent);
|
||||||
let bodyValue = document.createElement("span");
|
bodyValue = document.createElement("span");
|
||||||
bodyValue.id = "mailgo-body-value";
|
bodyValue.id = "mailgo-body-value";
|
||||||
detailBody.appendChild(bodySpan);
|
detailBody.appendChild(bodySpan);
|
||||||
detailBody.appendChild(bodyValue);
|
detailBody.appendChild(bodyValue);
|
||||||
@ -123,7 +128,7 @@
|
|||||||
modalContent.appendChild(details);
|
modalContent.appendChild(details);
|
||||||
|
|
||||||
// Gmail
|
// Gmail
|
||||||
let gmail = document.createElement("a");
|
gmail = document.createElement("a");
|
||||||
gmail.id = "mailgo-gmail";
|
gmail.id = "mailgo-gmail";
|
||||||
gmail.href = DEFAULT_BTN_HREF;
|
gmail.href = DEFAULT_BTN_HREF;
|
||||||
gmail.classList.add("mailgo-open");
|
gmail.classList.add("mailgo-open");
|
||||||
@ -139,7 +144,7 @@
|
|||||||
modalContent.appendChild(gmail);
|
modalContent.appendChild(gmail);
|
||||||
|
|
||||||
// Outlook
|
// Outlook
|
||||||
let outlook = document.createElement("a");
|
outlook = document.createElement("a");
|
||||||
outlook.id = "mailgo-outlook";
|
outlook.id = "mailgo-outlook";
|
||||||
outlook.href = DEFAULT_BTN_HREF;
|
outlook.href = DEFAULT_BTN_HREF;
|
||||||
outlook.classList.add("mailgo-open");
|
outlook.classList.add("mailgo-open");
|
||||||
@ -155,7 +160,7 @@
|
|||||||
modalContent.appendChild(outlook);
|
modalContent.appendChild(outlook);
|
||||||
|
|
||||||
// open default
|
// open default
|
||||||
let open = document.createElement("a");
|
open = document.createElement("a");
|
||||||
open.id = "mailgo-open";
|
open.id = "mailgo-open";
|
||||||
open.href = DEFAULT_BTN_HREF;
|
open.href = DEFAULT_BTN_HREF;
|
||||||
open.classList.add("mailgo-open");
|
open.classList.add("mailgo-open");
|
||||||
@ -171,15 +176,15 @@
|
|||||||
modalContent.appendChild(open);
|
modalContent.appendChild(open);
|
||||||
|
|
||||||
// copy
|
// copy
|
||||||
let copy = document.createElement("a");
|
copyMail = document.createElement("a");
|
||||||
copy.id = "mailgo-copy";
|
copyMail.id = "mailgo-copy";
|
||||||
copy.href = DEFAULT_BTN_HREF;
|
copyMail.href = DEFAULT_BTN_HREF;
|
||||||
copy.classList.add("mailgo-copy");
|
copyMail.classList.add("mailgo-copy");
|
||||||
copy.classList.add("mailgo-weight-500");
|
copyMail.classList.add("mailgo-weight-500");
|
||||||
let copyContent = document.createTextNode("copy");
|
let copyContent = document.createTextNode("copy");
|
||||||
copy.appendChild(copyContent);
|
copyMail.appendChild(copyContent);
|
||||||
|
|
||||||
modalContent.appendChild(copy);
|
modalContent.appendChild(copyMail);
|
||||||
|
|
||||||
// by
|
// by
|
||||||
let by = document.createElement("a");
|
let by = document.createElement("a");
|
||||||
@ -218,13 +223,13 @@
|
|||||||
modal.appendChild(modalContent);
|
modal.appendChild(modalContent);
|
||||||
|
|
||||||
// title (telephone number)
|
// title (telephone number)
|
||||||
let title = document.createElement("strong");
|
titleTel = document.createElement("strong");
|
||||||
title.id = "mailgo-tel-title";
|
titleTel.id = "mailgo-tel-title";
|
||||||
title.className = "mailgo-title";
|
titleTel.className = "mailgo-title";
|
||||||
modalContent.appendChild(title);
|
modalContent.appendChild(titleTel);
|
||||||
|
|
||||||
// Telegram
|
// Telegram
|
||||||
let telegram = document.createElement("a");
|
telegram = document.createElement("a");
|
||||||
telegram.id = "mailgo-telegram";
|
telegram.id = "mailgo-telegram";
|
||||||
telegram.href = DEFAULT_BTN_HREF;
|
telegram.href = DEFAULT_BTN_HREF;
|
||||||
telegram.classList.add("mailgo-open");
|
telegram.classList.add("mailgo-open");
|
||||||
@ -244,7 +249,7 @@
|
|||||||
modalContent.appendChild(telegram);
|
modalContent.appendChild(telegram);
|
||||||
|
|
||||||
// WhatsApp
|
// WhatsApp
|
||||||
let wa = document.createElement("a");
|
wa = document.createElement("a");
|
||||||
wa.id = "mailgo-wa";
|
wa.id = "mailgo-wa";
|
||||||
wa.href = DEFAULT_BTN_HREF;
|
wa.href = DEFAULT_BTN_HREF;
|
||||||
wa.classList.add("mailgo-open");
|
wa.classList.add("mailgo-open");
|
||||||
@ -260,7 +265,7 @@
|
|||||||
modalContent.appendChild(wa);
|
modalContent.appendChild(wa);
|
||||||
|
|
||||||
// Skype
|
// Skype
|
||||||
let skype = document.createElement("a");
|
skype = document.createElement("a");
|
||||||
skype.id = "mailgo-skype";
|
skype.id = "mailgo-skype";
|
||||||
skype.href = DEFAULT_BTN_HREF;
|
skype.href = DEFAULT_BTN_HREF;
|
||||||
skype.classList.add("mailgo-open");
|
skype.classList.add("mailgo-open");
|
||||||
@ -276,7 +281,7 @@
|
|||||||
modalContent.appendChild(skype);
|
modalContent.appendChild(skype);
|
||||||
|
|
||||||
// call default
|
// call default
|
||||||
let call = document.createElement("a");
|
call = document.createElement("a");
|
||||||
call.id = "mailgo-call";
|
call.id = "mailgo-call";
|
||||||
call.href = DEFAULT_BTN_HREF;
|
call.href = DEFAULT_BTN_HREF;
|
||||||
call.classList.add("mailgo-open");
|
call.classList.add("mailgo-open");
|
||||||
@ -292,15 +297,15 @@
|
|||||||
modalContent.appendChild(call);
|
modalContent.appendChild(call);
|
||||||
|
|
||||||
// copy
|
// copy
|
||||||
let copy = document.createElement("a");
|
let copyTel = document.createElement("a");
|
||||||
copy.id = "mailgo-tel-copy";
|
copyTel.id = "mailgo-tel-copy";
|
||||||
copy.href = DEFAULT_BTN_HREF;
|
copyTel.href = DEFAULT_BTN_HREF;
|
||||||
copy.classList.add("mailgo-copy");
|
copyTel.classList.add("mailgo-copy");
|
||||||
copy.classList.add("mailgo-weight-500");
|
copyTel.classList.add("mailgo-weight-500");
|
||||||
let copyContent = document.createTextNode("copy");
|
let copyContent = document.createTextNode("copy");
|
||||||
copy.appendChild(copyContent);
|
copyTel.appendChild(copyContent);
|
||||||
|
|
||||||
modalContent.appendChild(copy);
|
modalContent.appendChild(copyTel);
|
||||||
|
|
||||||
// by
|
// by
|
||||||
let by = document.createElement("a");
|
let by = document.createElement("a");
|
||||||
@ -381,57 +386,39 @@
|
|||||||
if (cc && !validateEmails(cc.split(","))) cc = "";
|
if (cc && !validateEmails(cc.split(","))) cc = "";
|
||||||
if (bcc && !validateEmails(bcc.split(","))) bcc = "";
|
if (bcc && !validateEmails(bcc.split(","))) bcc = "";
|
||||||
|
|
||||||
// information
|
|
||||||
let titleEl = getE("mailgo-title");
|
|
||||||
let detailsEl = getE("mailgo-details");
|
|
||||||
let ccEl = getE("mailgo-cc");
|
|
||||||
let ccValueEl = getE("mailgo-cc-value");
|
|
||||||
let bccEl = getE("mailgo-bcc");
|
|
||||||
let bccValueEl = getE("mailgo-bcc-value");
|
|
||||||
let subjectEl = getE("mailgo-subject");
|
|
||||||
let subjectValueEl = getE("mailgo-subject-value");
|
|
||||||
let bodyEl = getE("mailgo-body");
|
|
||||||
let bodyValueEl = getE("mailgo-body-value");
|
|
||||||
|
|
||||||
// action buttons
|
|
||||||
gmailButton = getE("mailgo-gmail");
|
|
||||||
outlookButton = getE("mailgo-outlook");
|
|
||||||
openButton = getE("mailgo-open");
|
|
||||||
copyButton = getE("mailgo-copy");
|
|
||||||
|
|
||||||
// the title of the modal (email address)
|
// the title of the modal (email address)
|
||||||
titleEl.innerHTML = mail.split(",").join("<br/>");
|
title.innerHTML = mail.split(",").join("<br/>");
|
||||||
|
|
||||||
// add the details if provided
|
// add the details if provided
|
||||||
cc
|
cc
|
||||||
? ((ccEl.style.display = "block"),
|
? ((detailCc.style.display = "block"),
|
||||||
(ccValueEl.innerHTML = cc.split(",").join("<br/>")))
|
(ccValue.innerHTML = cc.split(",").join("<br/>")))
|
||||||
: (ccEl.style.display = "none");
|
: (detailCc.style.display = "none");
|
||||||
|
|
||||||
bcc
|
bcc
|
||||||
? ((bccEl.style.display = "block"),
|
? ((detailBcc.style.display = "block"),
|
||||||
(bccValueEl.innerHTML = bcc.split(",").join("<br/>")))
|
(bccValue.innerHTML = bcc.split(",").join("<br/>")))
|
||||||
: (bccEl.style.display = "none");
|
: (detailBcc.style.display = "none");
|
||||||
|
|
||||||
subject
|
subject
|
||||||
? ((subjectEl.style.display = "block"),
|
? ((detailSubject.style.display = "block"),
|
||||||
(subjectValueEl.textContent = subject))
|
(subjectValue.textContent = subject))
|
||||||
: (subjectEl.style.display = "none");
|
: (detailSubject.style.display = "none");
|
||||||
|
|
||||||
bodyMail
|
bodyMail
|
||||||
? ((bodyEl.style.display = "block"),
|
? ((detailBody.style.display = "block"),
|
||||||
(bodyValueEl.textContent = bodyMail))
|
(bodyValue.textContent = bodyMail))
|
||||||
: (bodyEl.style.display = "none");
|
: (detailBody.style.display = "none");
|
||||||
|
|
||||||
// add the actions
|
// add the actions
|
||||||
gmailButton.addEventListener("click", openGmail);
|
gmail.addEventListener("click", openGmail);
|
||||||
|
|
||||||
outlookButton.addEventListener("click", openOutlook);
|
outlook.addEventListener("click", openOutlook);
|
||||||
|
|
||||||
encEmail = encodeEmail(mail);
|
encEmail = encodeEmail(mail);
|
||||||
openButton.addEventListener("click", openDefault);
|
open.addEventListener("click", openDefault);
|
||||||
|
|
||||||
copyButton.addEventListener("click", () => copy(mail || tel));
|
copyMail.addEventListener("click", () => copy(mail));
|
||||||
}
|
}
|
||||||
// mailgo tel
|
// mailgo tel
|
||||||
if (type === TEL_TYPE) {
|
if (type === TEL_TYPE) {
|
||||||
@ -455,7 +442,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// information
|
// information
|
||||||
let titleEl = getE("mailgo-tel-title");
|
// let titleEl = getE("mailgo-tel-title");
|
||||||
|
|
||||||
// Telegram username
|
// Telegram username
|
||||||
if (mailgo.hasAttribute("data-telegram")) {
|
if (mailgo.hasAttribute("data-telegram")) {
|
||||||
@ -467,29 +454,22 @@
|
|||||||
skypeUsername = mailgo.getAttribute("data-skype");
|
skypeUsername = mailgo.getAttribute("data-skype");
|
||||||
}
|
}
|
||||||
|
|
||||||
// actions
|
|
||||||
telegramButton = getE("mailgo-telegram");
|
|
||||||
waButton = getE("mailgo-wa");
|
|
||||||
skypeButton = getE("mailgo-skype");
|
|
||||||
callButton = getE("mailgo-call");
|
|
||||||
copyButton = getE("mailgo-tel-copy");
|
|
||||||
|
|
||||||
// the title of the modal (tel)
|
// the title of the modal (tel)
|
||||||
titleEl.innerHTML = tel;
|
titleTel.innerHTML = tel;
|
||||||
|
|
||||||
// add the actions to buttons
|
// add the actions to buttons
|
||||||
waButton.addEventListener("click", openWhatsApp);
|
wa.addEventListener("click", openWhatsApp);
|
||||||
|
|
||||||
if (telegramUsername) {
|
if (telegramUsername) {
|
||||||
setDisplay("mailgo-telegram", "block");
|
setDisplay("mailgo-telegram", "block");
|
||||||
telegramButton.addEventListener("click", openTelegram);
|
telegram.addEventListener("click", openTelegram);
|
||||||
}
|
}
|
||||||
|
|
||||||
skypeButton.addEventListener("click", openSkype);
|
skype.addEventListener("click", openSkype);
|
||||||
|
|
||||||
callButton.addEventListener("click", callDefault);
|
call.addEventListener("click", callDefault);
|
||||||
|
|
||||||
copyButton.addEventListener("click", () => copy(tel));
|
copyTel.addEventListener("click", () => copy(tel));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show the mailgo
|
// show the mailgo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user