actions object
This commit is contained in:
@@ -277,7 +277,7 @@ const mailgoRender = mailgo => {
|
||||
gmailButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
openGmailAction(mailtoHref);
|
||||
actions.openGmail(mailtoHref);
|
||||
},
|
||||
false
|
||||
);
|
||||
@@ -285,7 +285,7 @@ const mailgoRender = mailgo => {
|
||||
outlookButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
openOutlookAction(mail, url);
|
||||
actions.openOutlook(mail, url);
|
||||
},
|
||||
false
|
||||
);
|
||||
@@ -294,7 +294,7 @@ const mailgoRender = mailgo => {
|
||||
openButton.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
openDefaultAction(encEmail);
|
||||
actions.openDefault(encEmail);
|
||||
},
|
||||
false
|
||||
);
|
||||
@@ -302,7 +302,7 @@ const mailgoRender = mailgo => {
|
||||
copyButton.addEventListener(
|
||||
"click",
|
||||
event => {
|
||||
copyAction(mail, copyButton);
|
||||
actions.copy(mail, copyButton);
|
||||
},
|
||||
false
|
||||
);
|
||||
@@ -321,33 +321,35 @@ const mailgoRender = mailgo => {
|
||||
};
|
||||
|
||||
// actions
|
||||
let openGmailAction = mailtoHref => {
|
||||
window.open(
|
||||
"https://mail.google.com/mail?extsrc=mailto&url=" +
|
||||
encodeURIComponent(mailtoHref),
|
||||
"_blank"
|
||||
);
|
||||
};
|
||||
const actions = {
|
||||
openGmail: mailtoHref => {
|
||||
window.open(
|
||||
"https://mail.google.com/mail?extsrc=mailto&url=" +
|
||||
encodeURIComponent(mailtoHref),
|
||||
"_blank"
|
||||
);
|
||||
},
|
||||
|
||||
let openOutlookAction = (mail, url) => {
|
||||
window.open(
|
||||
"https://outlook.office.com/owa/?rru=compose&to=" +
|
||||
encodeURIComponent(mail) +
|
||||
url.search.replace(/^[$]/, "&"),
|
||||
"_blank"
|
||||
);
|
||||
};
|
||||
openOutlook: (mail, url) => {
|
||||
window.open(
|
||||
"https://outlook.office.com/owa/?rru=compose&to=" +
|
||||
encodeURIComponent(mail) +
|
||||
url.search.replace(/^[$]/, "&"),
|
||||
"_blank"
|
||||
);
|
||||
},
|
||||
|
||||
let openDefaultAction = encEmail => {
|
||||
mailToEncoded(encEmail);
|
||||
};
|
||||
openDefault: encEmail => {
|
||||
mailToEncoded(encEmail);
|
||||
},
|
||||
|
||||
let copyAction = (mail, copyButton) => {
|
||||
copyToClipboard(mail);
|
||||
copyButton.textContent = "copied";
|
||||
let timeout = setTimeout(() => {
|
||||
copyButton.textContent = "copy";
|
||||
}, 999);
|
||||
copy: (mail, copyButton) => {
|
||||
copyToClipboard(mail);
|
||||
copyButton.textContent = "copied";
|
||||
let timeout = setTimeout(() => {
|
||||
copyButton.textContent = "copy";
|
||||
}, 999);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -398,20 +400,20 @@ const mailgoKeydown = (mail, url, mailtoHref, encEmail, copyButton) => {
|
||||
break;
|
||||
case 71:
|
||||
// g -> open GMail
|
||||
openGmailAction(mailtoHref);
|
||||
actions.openGmail(mailtoHref);
|
||||
break;
|
||||
case 79:
|
||||
// o -> open Outlook
|
||||
openOutlookAction(mail, url);
|
||||
actions.openOutlook(mail, url);
|
||||
break;
|
||||
case 32:
|
||||
case 13:
|
||||
// spacebar or enter -> open default
|
||||
openDefaultAction(encEmail);
|
||||
actions.openDefault(encEmail);
|
||||
break;
|
||||
case 67:
|
||||
// c -> copy
|
||||
copyAction(mail, copyButton);
|
||||
actions.copy(mail, copyButton);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user