added more check on isMailgo

This commit is contained in:
Matteo Manzinello 2019-09-16 23:34:57 +02:00
parent bf1484a2a0
commit 153ced3b9b

View File

@ -497,8 +497,8 @@ const actions = {
window.open(callUrl); window.open(callUrl);
}, },
copy: (mail, copyButton) => { copy: (content, copyButton) => {
copyToClipboard(mail); copyToClipboard(content);
copyButton.textContent = "copied"; copyButton.textContent = "copied";
setTimeout(() => (copyButton.textContent = "copy"), 999); setTimeout(() => (copyButton.textContent = "copy"), 999);
} }
@ -510,18 +510,26 @@ const isMailgo = element =>
(element.href && (element.href &&
element.href.toLowerCase().startsWith(MAILTO) && element.href.toLowerCase().startsWith(MAILTO) &&
!element.classList.contains("no-mailgo")) || !element.classList.contains("no-mailgo")) ||
// second case: the href=#mailgo (element.hasAttribute("data-address") &&
(element.href && element.getAttribute("href").toLowerCase() === "#mailgo") || // second case: the href=#mailgo
// third case: the classList contains mailgo ((element.href &&
(element.classList && element.classList.contains("mailgo")); element.getAttribute("href").toLowerCase() === "#mailgo") ||
// third case: the classList contains mailgo
(element.classList && element.classList.contains("mailgo"))));
// function that returns if an element is a mailgo-tel // function that returns if an element is a mailgo-tel
const isMailgoTel = element => const isMailgoTel = element =>
// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList // first case: it is an <a> element with "tel:..." or "callto:..." in href and no no-mailgo in classList
element.href && (element.href &&
(element.href.toLowerCase().startsWith(TEL) || (element.href.toLowerCase().startsWith(TEL) ||
element.href.toLowerCase().startsWith(CALLTO)) && element.href.toLowerCase().startsWith(CALLTO)) &&
!element.classList.contains("no-mailgo"); !element.classList.contains("no-mailgo")) ||
((element.hasAttribute("data-tel") &&
// second case: the href=#mailgo
(element.href &&
element.getAttribute("href").toLowerCase() === "#mailgo")) ||
// third case: the classList contains mailgo
(element.classList && element.classList.contains("mailgo")));
/** /**
* mailgoCheckRender * mailgoCheckRender
@ -607,6 +615,31 @@ const mailgoKeydown = () => {
return; return;
} }
} else if (mailgoIsShowing(TEL_TYPE)) { } else if (mailgoIsShowing(TEL_TYPE)) {
switch (event.keyCode) {
case 27:
// Escape
hideMailgo();
break;
case 71:
// g -> open GMail
actions.openGmail(mail, cc, bcc, subject, bodyMail);
break;
case 79:
// o -> open Outlook
actions.openOutlook(mail, subject, bodyMail);
break;
case 32:
case 13:
// spacebar or enter -> open default
actions.openDefault(encEmail);
break;
case 67:
// c -> copy
actions.copy(tel, copyButton);
break;
default:
return;
}
} }
return; return;
}; };