This commit is contained in:
Matteo Manzinello 2019-05-24 10:32:02 +02:00
parent 6d81e1debd
commit dab541edaa
3 changed files with 37 additions and 31 deletions

26
dist/mailgo.js vendored
View File

@ -265,20 +265,22 @@ var actions = {
*/
var mailgoCheckRender = function mailgoCheckRender(event) {
// the target element
var e = event.target; // 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 (e) {
if ( // first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
e.href && e.href.toLowerCase().startsWith(MAILTO) && !e.classList.contains("no-mailgo") || // second case: the href=#mailgo
e.href && e.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo
e.classList.contains("mailgo")) {
// stop the normal execution of the element click
event.preventDefault(); // render mailgo
if ( // first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
e.href && e.href.toLowerCase().startsWith(MAILTO) && !e.classList.contains("no-mailgo") || // second case: the href=#mailgo
e.href && e.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo
e.classList.contains("mailgo")) {
// stop the normal execution of the element click
event.preventDefault(); // render mailgo
mailgoRender(e);
}
mailgoRender(e);
return;
}
});
return;
};
/**
* mailgoKeydown

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -328,28 +328,32 @@ const actions = {
* );
*/
const mailgoCheckRender = event => {
// the target element
let e = event.target;
// check if the id=mailgo exists in the body
if (!document.contains(getE("mailgo"))) return;
if (
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
(e.href &&
e.href.toLowerCase().startsWith(MAILTO) &&
!e.classList.contains("no-mailgo")) ||
// second case: the href=#mailgo
(e.href && e.getAttribute("href").toLowerCase() === "#mailgo") ||
// third case: the classList contains mailgo
e.classList.contains("mailgo")
) {
// stop the normal execution of the element click
event.preventDefault();
// go in the event.path to find if the user has clicked on a mailgo element
event.path.forEach(e => {
if (
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
(e.href &&
e.href.toLowerCase().startsWith(MAILTO) &&
!e.classList.contains("no-mailgo")) ||
// second case: the href=#mailgo
(e.href && e.getAttribute("href").toLowerCase() === "#mailgo") ||
// third case: the classList contains mailgo
e.classList.contains("mailgo")
) {
// stop the normal execution of the element click
event.preventDefault();
// render mailgo
mailgoRender(e);
}
// render mailgo
mailgoRender(e);
return;
}
});
return;
};
/**