a lot of fix (outlook link)
This commit is contained in:
parent
3a2ae160bc
commit
51591eef7f
37
dist/mailgo.js
vendored
37
dist/mailgo.js
vendored
@ -233,7 +233,7 @@ var mailgoRender = function mailgoRender(mailgo) {
|
|||||||
showMailgo(); // listener keyDown
|
showMailgo(); // listener keyDown
|
||||||
|
|
||||||
mailgo.addEventListener("keydown", function () {
|
mailgo.addEventListener("keydown", function () {
|
||||||
return mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton);
|
return mailgoKeydown(mail, cc, bcc, subject, bodyMail, url, mailtoHref, encEmail, copyButton);
|
||||||
}, false);
|
}, false);
|
||||||
}; // actions
|
}; // actions
|
||||||
|
|
||||||
@ -245,8 +245,8 @@ var actions = {
|
|||||||
},
|
},
|
||||||
openOutlook: function openOutlook(mail, subject, bodyMail) {
|
openOutlook: function openOutlook(mail, subject, bodyMail) {
|
||||||
var outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail);
|
var outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail);
|
||||||
if (subject != "") outlookUrl = outlookUrl.concat("&subject=" + subject);
|
if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject);
|
||||||
if (bodyMail != "") outlookUrl = outlookUrl.concat("&body=" + bodyMail);
|
if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail);
|
||||||
window.open(outlookUrl, "_blank");
|
window.open(outlookUrl, "_blank");
|
||||||
},
|
},
|
||||||
openDefault: function openDefault(encEmail) {
|
openDefault: function openDefault(encEmail) {
|
||||||
@ -265,7 +265,7 @@ var isMailgo = function isMailgo(element) {
|
|||||||
return (// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
|
return (// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
|
||||||
element.href && element.href.toLowerCase().startsWith(MAILTO) && !element.classList.contains("no-mailgo") || // second case: the href=#mailgo
|
element.href && element.href.toLowerCase().startsWith(MAILTO) && !element.classList.contains("no-mailgo") || // second case: the href=#mailgo
|
||||||
element.href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo
|
element.href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo
|
||||||
element.classList.contains("mailgo")
|
element.classList && element.classList.contains("mailgo")
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -279,16 +279,17 @@ var isMailgo = function isMailgo(element) {
|
|||||||
|
|
||||||
var mailgoCheckRender = function mailgoCheckRender(event) {
|
var mailgoCheckRender = function mailgoCheckRender(event) {
|
||||||
// check if the id=mailgo exists in the body
|
// check if the id=mailgo exists in the body
|
||||||
if (!document.contains(getE("mailgo"))) return; // go in the event.path to find if the user has clicked on a mailgo element
|
if (!document.contains(getE("mailgo"))) return;
|
||||||
|
event.path.forEach(function (element) {
|
||||||
if (event.path.some(isMailgo)) {
|
// go in the event.path to find if the user has clicked on a mailgo element
|
||||||
// stop the normal execution of the element click
|
if (isMailgo(element)) {
|
||||||
event.preventDefault(); // render mailgo
|
// stop the normal execution of the element click
|
||||||
|
event.preventDefault(); // render mailgo
|
||||||
mailgoRender(e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
mailgoRender(element);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
@ -297,15 +298,7 @@ var mailgoCheckRender = function mailgoCheckRender(event) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
var mailgoKeydown = function mailgoKeydown(mail) {
|
var mailgoKeydown = function mailgoKeydown(mail, cc, bcc, subject, bodyMail, url, mailtoHref, encEmail, copyButton) {
|
||||||
var cc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
|
||||||
var bcc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
||||||
var bodyMail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
||||||
var subject = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
|
|
||||||
var url = arguments.length > 5 ? arguments[5] : undefined;
|
|
||||||
var mailtoHref = arguments.length > 6 ? arguments[6] : undefined;
|
|
||||||
var encEmail = arguments.length > 7 ? arguments[7] : undefined;
|
|
||||||
var copyButton = arguments.length > 8 ? arguments[8] : undefined;
|
|
||||||
// if mailgo is not showing do nothing
|
// if mailgo is not showing do nothing
|
||||||
if (!mailgoIsShowing()) return;
|
if (!mailgoIsShowing()) return;
|
||||||
|
|
||||||
|
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
@ -291,7 +291,18 @@ const mailgoRender = mailgo => {
|
|||||||
// listener keyDown
|
// listener keyDown
|
||||||
mailgo.addEventListener(
|
mailgo.addEventListener(
|
||||||
"keydown",
|
"keydown",
|
||||||
() => mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton),
|
() =>
|
||||||
|
mailgoKeydown(
|
||||||
|
mail,
|
||||||
|
cc,
|
||||||
|
bcc,
|
||||||
|
subject,
|
||||||
|
bodyMail,
|
||||||
|
url,
|
||||||
|
mailtoHref,
|
||||||
|
encEmail,
|
||||||
|
copyButton
|
||||||
|
),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@ -310,8 +321,8 @@ const actions = {
|
|||||||
let outlookUrl =
|
let outlookUrl =
|
||||||
"https://outlook.live.com/owa/?path=/mail/action/compose&to=" +
|
"https://outlook.live.com/owa/?path=/mail/action/compose&to=" +
|
||||||
encodeURIComponent(mail);
|
encodeURIComponent(mail);
|
||||||
if (subject != "") outlookUrl = outlookUrl.concat("&subject=" + subject);
|
if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject);
|
||||||
if (bodyMail != "") outlookUrl = outlookUrl.concat("&body=" + bodyMail);
|
if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail);
|
||||||
|
|
||||||
window.open(outlookUrl, "_blank");
|
window.open(outlookUrl, "_blank");
|
||||||
},
|
},
|
||||||
@ -336,7 +347,7 @@ const isMailgo = element =>
|
|||||||
// second case: the href=#mailgo
|
// second case: the href=#mailgo
|
||||||
(element.href && element.getAttribute("href").toLowerCase() === "#mailgo") ||
|
(element.href && element.getAttribute("href").toLowerCase() === "#mailgo") ||
|
||||||
// third case: the classList contains mailgo
|
// third case: the classList contains mailgo
|
||||||
element.classList.contains("mailgo");
|
(element.classList && element.classList.contains("mailgo"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mailgoCheckRender
|
* mailgoCheckRender
|
||||||
@ -349,16 +360,18 @@ const mailgoCheckRender = event => {
|
|||||||
// check if the id=mailgo exists in the body
|
// check if the id=mailgo exists in the body
|
||||||
if (!document.contains(getE("mailgo"))) return;
|
if (!document.contains(getE("mailgo"))) return;
|
||||||
|
|
||||||
// go in the event.path to find if the user has clicked on a mailgo element
|
event.path.forEach(element => {
|
||||||
if (event.path.some(isMailgo)) {
|
// go in the event.path to find if the user has clicked on a mailgo element
|
||||||
// stop the normal execution of the element click
|
if (isMailgo(element)) {
|
||||||
event.preventDefault();
|
// stop the normal execution of the element click
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
// render mailgo
|
// render mailgo
|
||||||
mailgoRender(e);
|
mailgoRender(element);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@ -369,10 +382,10 @@ const mailgoCheckRender = event => {
|
|||||||
*/
|
*/
|
||||||
const mailgoKeydown = (
|
const mailgoKeydown = (
|
||||||
mail,
|
mail,
|
||||||
cc = "",
|
cc,
|
||||||
bcc = "",
|
bcc,
|
||||||
bodyMail = "",
|
subject,
|
||||||
subject = "",
|
bodyMail,
|
||||||
url,
|
url,
|
||||||
mailtoHref,
|
mailtoHref,
|
||||||
encEmail,
|
encEmail,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user