better arrow functions
This commit is contained in:
parent
fa9cdd3864
commit
a321258ba5
36
dist/mailgo.js
vendored
36
dist/mailgo.js
vendored
@ -144,7 +144,7 @@ var mailgoInit = function mailgoInit() {
|
||||
|
||||
document.body.appendChild(modal); // every click outside the modal will hide the modal
|
||||
|
||||
modalBackground.addEventListener("click", hideMailgo, false);
|
||||
modalBackground.addEventListener("click", hideMailgo);
|
||||
};
|
||||
/**
|
||||
* mailgoRender
|
||||
@ -217,42 +217,42 @@ var mailgoRender = function mailgoRender(mailgo) {
|
||||
bodyMail ? (bodyEl.style.display = "block", bodyValueEl.textContent = bodyMail) : bodyEl.style.display = "none"; // add the actions
|
||||
|
||||
gmailButton.addEventListener("click", function () {
|
||||
actions.openGmail(mailtoHref);
|
||||
}, false);
|
||||
return actions.openGmail(mailtoHref);
|
||||
});
|
||||
outlookButton.addEventListener("click", function () {
|
||||
actions.openOutlook(mail, url);
|
||||
}, false);
|
||||
return actions.openOutlook(mail, url);
|
||||
});
|
||||
var encEmail = encodeEmail(mail);
|
||||
openButton.addEventListener("click", function () {
|
||||
actions.openDefault(encEmail);
|
||||
}, false);
|
||||
copyButton.addEventListener("click", function (event) {
|
||||
actions.copy(mail, copyButton);
|
||||
}, false); // show the mailgo
|
||||
return actions.openDefault(encEmail);
|
||||
});
|
||||
copyButton.addEventListener("click", function () {
|
||||
return actions.copy(mail, copyButton);
|
||||
}); // show the mailgo
|
||||
|
||||
showMailgo(); // listener keyDown
|
||||
|
||||
mailgo.addEventListener("keydown", function () {
|
||||
mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton);
|
||||
return mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton);
|
||||
}, false);
|
||||
}; // actions
|
||||
|
||||
|
||||
var actions = {
|
||||
openGmail: function openGmail(mailtoHref) {
|
||||
window.open("https://mail.google.com/mail?extsrc=mailto&url=" + encodeURIComponent(mailtoHref), "_blank");
|
||||
return window.open("https://mail.google.com/mail?extsrc=mailto&url=" + encodeURIComponent(mailtoHref), "_blank");
|
||||
},
|
||||
openOutlook: function openOutlook(mail, url) {
|
||||
window.open("https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&"), "_blank");
|
||||
return window.open("https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&"), "_blank");
|
||||
},
|
||||
openDefault: function openDefault(encEmail) {
|
||||
mailToEncoded(encEmail);
|
||||
return mailToEncoded(encEmail);
|
||||
},
|
||||
copy: function copy(mail, copyButton) {
|
||||
copyToClipboard(mail);
|
||||
copyButton.textContent = "copied";
|
||||
var timeout = setTimeout(function () {
|
||||
copyButton.textContent = "copy";
|
||||
setTimeout(function () {
|
||||
return copyButton.textContent = "copy";
|
||||
}, 999);
|
||||
}
|
||||
};
|
||||
@ -325,9 +325,9 @@ var mailgoKeydown = function mailgoKeydown(mail, url, mailtoHref, encEmail, copy
|
||||
}; // DOMContentLoaded -> mailgoInit (creates the modal)
|
||||
|
||||
|
||||
document.addEventListener("DOMContentLoaded", mailgoInit, false); // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("DOMContentLoaded", mailgoInit); // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
|
||||
document.addEventListener("click", mailgoCheckRender, true); // validate the email with regex
|
||||
document.addEventListener("click", mailgoCheckRender); // validate the email with regex
|
||||
|
||||
var validateEmail = function validateEmail(email) {
|
||||
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||
|
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
@ -164,7 +164,7 @@ const mailgoInit = () => {
|
||||
document.body.appendChild(modal);
|
||||
|
||||
// every click outside the modal will hide the modal
|
||||
modalBackground.addEventListener("click", hideMailgo, false);
|
||||
modalBackground.addEventListener("click", hideMailgo);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -274,38 +274,14 @@ const mailgoRender = mailgo => {
|
||||
: (bodyEl.style.display = "none");
|
||||
|
||||
// add the actions
|
||||
gmailButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
actions.openGmail(mailtoHref);
|
||||
},
|
||||
false
|
||||
);
|
||||
gmailButton.addEventListener("click", () => actions.openGmail(mailtoHref));
|
||||
|
||||
outlookButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
actions.openOutlook(mail, url);
|
||||
},
|
||||
false
|
||||
);
|
||||
outlookButton.addEventListener("click", () => actions.openOutlook(mail, url));
|
||||
|
||||
let encEmail = encodeEmail(mail);
|
||||
openButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
actions.openDefault(encEmail);
|
||||
},
|
||||
false
|
||||
);
|
||||
openButton.addEventListener("click", () => actions.openDefault(encEmail));
|
||||
|
||||
copyButton.addEventListener(
|
||||
"click",
|
||||
event => {
|
||||
actions.copy(mail, copyButton);
|
||||
},
|
||||
false
|
||||
);
|
||||
copyButton.addEventListener("click", () => actions.copy(mail, copyButton));
|
||||
|
||||
// show the mailgo
|
||||
showMailgo();
|
||||
@ -313,42 +289,34 @@ const mailgoRender = mailgo => {
|
||||
// listener keyDown
|
||||
mailgo.addEventListener(
|
||||
"keydown",
|
||||
() => {
|
||||
mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton);
|
||||
},
|
||||
() => mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton),
|
||||
false
|
||||
);
|
||||
};
|
||||
|
||||
// actions
|
||||
const actions = {
|
||||
openGmail: mailtoHref => {
|
||||
openGmail: mailtoHref =>
|
||||
window.open(
|
||||
"https://mail.google.com/mail?extsrc=mailto&url=" +
|
||||
encodeURIComponent(mailtoHref),
|
||||
"_blank"
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
openOutlook: (mail, url) => {
|
||||
openOutlook: (mail, url) =>
|
||||
window.open(
|
||||
"https://outlook.office.com/owa/?rru=compose&to=" +
|
||||
encodeURIComponent(mail) +
|
||||
url.search.replace(/^[$]/, "&"),
|
||||
"_blank"
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
openDefault: encEmail => {
|
||||
mailToEncoded(encEmail);
|
||||
},
|
||||
openDefault: encEmail => mailToEncoded(encEmail),
|
||||
|
||||
copy: (mail, copyButton) => {
|
||||
copyToClipboard(mail);
|
||||
copyButton.textContent = "copied";
|
||||
let timeout = setTimeout(() => {
|
||||
copyButton.textContent = "copy";
|
||||
}, 999);
|
||||
setTimeout(() => (copyButton.textContent = "copy"), 999);
|
||||
}
|
||||
};
|
||||
|
||||
@ -420,10 +388,10 @@ const mailgoKeydown = (mail, url, mailtoHref, encEmail, copyButton) => {
|
||||
};
|
||||
|
||||
// DOMContentLoaded -> mailgoInit (creates the modal)
|
||||
document.addEventListener("DOMContentLoaded", mailgoInit, false);
|
||||
document.addEventListener("DOMContentLoaded", mailgoInit);
|
||||
|
||||
// event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered
|
||||
document.addEventListener("click", mailgoCheckRender, true);
|
||||
document.addEventListener("click", mailgoCheckRender);
|
||||
|
||||
// validate the email with regex
|
||||
const validateEmail = email => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user