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