changed gmail and outlook, now open new tab
This commit is contained in:
parent
7f6879bfd6
commit
2a34df709f
60
dist/mailgo.js
vendored
60
dist/mailgo.js
vendored
@ -84,6 +84,7 @@ var mailgoInit = function mailgoInit() {
|
|||||||
|
|
||||||
var gmail = document.createElement("a");
|
var gmail = document.createElement("a");
|
||||||
gmail.id = "mailgo-gmail";
|
gmail.id = "mailgo-gmail";
|
||||||
|
gmail.href = "#mailgo-gmail";
|
||||||
gmail.classList.add("mailgo-open");
|
gmail.classList.add("mailgo-open");
|
||||||
gmail.classList.add("mailgo-gmail");
|
gmail.classList.add("mailgo-gmail");
|
||||||
var gmailContent = document.createTextNode("open in ");
|
var gmailContent = document.createTextNode("open in ");
|
||||||
@ -97,6 +98,7 @@ var mailgoInit = function mailgoInit() {
|
|||||||
|
|
||||||
var outlook = document.createElement("a");
|
var outlook = document.createElement("a");
|
||||||
outlook.id = "mailgo-outlook";
|
outlook.id = "mailgo-outlook";
|
||||||
|
outlook.href = "#mailgo-outlook";
|
||||||
outlook.classList.add("mailgo-open");
|
outlook.classList.add("mailgo-open");
|
||||||
outlook.classList.add("mailgo-outlook");
|
outlook.classList.add("mailgo-outlook");
|
||||||
var outlookContent = document.createTextNode("open in ");
|
var outlookContent = document.createTextNode("open in ");
|
||||||
@ -214,21 +216,42 @@ var mailgoRender = function mailgoRender(mailgo) {
|
|||||||
subject ? (subjectEl.style.display = "block", subjectValueEl.textContent = subject) : subjectEl.style.display = "none";
|
subject ? (subjectEl.style.display = "block", subjectValueEl.textContent = subject) : subjectEl.style.display = "none";
|
||||||
bodyMail ? (bodyEl.style.display = "block", bodyValueEl.textContent = bodyMail) : bodyEl.style.display = "none"; // add the actions
|
bodyMail ? (bodyEl.style.display = "block", bodyValueEl.textContent = bodyMail) : bodyEl.style.display = "none"; // add the actions
|
||||||
|
|
||||||
gmailButton.href = "https://mail.google.com/mail?extsrc=mailto&url=" + encodeURIComponent(mailtoHref);
|
gmailButton.addEventListener("click", function () {
|
||||||
outlookButton.href = "https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&");
|
openGmailAction(mailtoHref);
|
||||||
|
}, false);
|
||||||
|
outlookButton.addEventListener("click", function () {
|
||||||
|
openOutlookAction(mail, url);
|
||||||
|
}, false);
|
||||||
var encEmail = encodeEmail(mail);
|
var encEmail = encodeEmail(mail);
|
||||||
openButton.addEventListener("click", function () {
|
openButton.addEventListener("click", function () {
|
||||||
mailToEncoded(encEmail);
|
openDefaultAction(encEmail);
|
||||||
}, false);
|
}, false);
|
||||||
copyButton.addEventListener("click", function (event) {
|
copyButton.addEventListener("click", function (event) {
|
||||||
copyToClipboard(mail);
|
copyAction(mail, copyButton);
|
||||||
copyButton.textContent = "copied";
|
|
||||||
setTimeout(function () {
|
|
||||||
copyButton.textContent = "copy";
|
|
||||||
}, 999);
|
|
||||||
}, false); // show the mailgo
|
}, false); // show the mailgo
|
||||||
|
|
||||||
showMailgo();
|
showMailgo();
|
||||||
|
}; // actions
|
||||||
|
|
||||||
|
|
||||||
|
var openGmailAction = function openGmailAction(mailtoHref) {
|
||||||
|
window.open("https://mail.google.com/mail?extsrc=mailto&url=" + encodeURIComponent(mailtoHref), "_blank");
|
||||||
|
};
|
||||||
|
|
||||||
|
var openOutlookAction = function openOutlookAction(mail, url) {
|
||||||
|
window.open("https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&"), "_blank");
|
||||||
|
};
|
||||||
|
|
||||||
|
var openDefaultAction = function openDefaultAction(encEmail) {
|
||||||
|
mailToEncoded(encEmail);
|
||||||
|
};
|
||||||
|
|
||||||
|
var copyAction = function copyAction(mail, copyButton) {
|
||||||
|
copyToClipboard(mail);
|
||||||
|
copyButton.textContent = "copied";
|
||||||
|
var timeout = setTimeout(function () {
|
||||||
|
copyButton.textContent = "copy";
|
||||||
|
}, 999);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* mailgoCheckRender
|
* mailgoCheckRender
|
||||||
@ -269,6 +292,27 @@ var mailgoKeydown = function mailgoKeydown(event) {
|
|||||||
hideMailgo();
|
hideMailgo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 71:
|
||||||
|
// g -> open GMail
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 79:
|
||||||
|
// o -> open Outlook
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 32:
|
||||||
|
case 13:
|
||||||
|
// spacebar or enter -> open default
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 67:
|
||||||
|
// c -> copy
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
2
dist/mailgo.min.js
vendored
2
dist/mailgo.min.js
vendored
File diff suppressed because one or more lines are too long
@ -93,6 +93,7 @@ const mailgoInit = () => {
|
|||||||
// Gmail
|
// Gmail
|
||||||
let gmail = document.createElement("a");
|
let gmail = document.createElement("a");
|
||||||
gmail.id = "mailgo-gmail";
|
gmail.id = "mailgo-gmail";
|
||||||
|
gmail.href = "#mailgo-gmail";
|
||||||
gmail.classList.add("mailgo-open");
|
gmail.classList.add("mailgo-open");
|
||||||
gmail.classList.add("mailgo-gmail");
|
gmail.classList.add("mailgo-gmail");
|
||||||
let gmailContent = document.createTextNode("open in ");
|
let gmailContent = document.createTextNode("open in ");
|
||||||
@ -108,6 +109,7 @@ const mailgoInit = () => {
|
|||||||
// Outlook
|
// Outlook
|
||||||
let outlook = document.createElement("a");
|
let outlook = document.createElement("a");
|
||||||
outlook.id = "mailgo-outlook";
|
outlook.id = "mailgo-outlook";
|
||||||
|
outlook.href = "#mailgo-outlook";
|
||||||
outlook.classList.add("mailgo-open");
|
outlook.classList.add("mailgo-open");
|
||||||
outlook.classList.add("mailgo-outlook");
|
outlook.classList.add("mailgo-outlook");
|
||||||
let outlookContent = document.createTextNode("open in ");
|
let outlookContent = document.createTextNode("open in ");
|
||||||
@ -272,20 +274,27 @@ const mailgoRender = mailgo => {
|
|||||||
: (bodyEl.style.display = "none");
|
: (bodyEl.style.display = "none");
|
||||||
|
|
||||||
// add the actions
|
// add the actions
|
||||||
gmailButton.href =
|
gmailButton.addEventListener(
|
||||||
"https://mail.google.com/mail?extsrc=mailto&url=" +
|
"click",
|
||||||
encodeURIComponent(mailtoHref);
|
() => {
|
||||||
|
openGmailAction(mailtoHref);
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
outlookButton.href =
|
outlookButton.addEventListener(
|
||||||
"https://outlook.office.com/owa/?rru=compose&to=" +
|
"click",
|
||||||
encodeURIComponent(mail) +
|
() => {
|
||||||
url.search.replace(/^[$]/, "&");
|
openOutlookAction(mail, url);
|
||||||
|
},
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
let encEmail = encodeEmail(mail);
|
let encEmail = encodeEmail(mail);
|
||||||
openButton.addEventListener(
|
openButton.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
() => {
|
() => {
|
||||||
mailToEncoded(encEmail);
|
openDefaultAction(encEmail);
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -293,11 +302,7 @@ const mailgoRender = mailgo => {
|
|||||||
copyButton.addEventListener(
|
copyButton.addEventListener(
|
||||||
"click",
|
"click",
|
||||||
event => {
|
event => {
|
||||||
copyToClipboard(mail);
|
copyAction(mail, copyButton);
|
||||||
copyButton.textContent = "copied";
|
|
||||||
setTimeout(() => {
|
|
||||||
copyButton.textContent = "copy";
|
|
||||||
}, 999);
|
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -306,6 +311,36 @@ const mailgoRender = mailgo => {
|
|||||||
showMailgo();
|
showMailgo();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// actions
|
||||||
|
let openGmailAction = 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"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
let openDefaultAction = encEmail => {
|
||||||
|
mailToEncoded(encEmail);
|
||||||
|
};
|
||||||
|
|
||||||
|
let copyAction = (mail, copyButton) => {
|
||||||
|
copyToClipboard(mail);
|
||||||
|
copyButton.textContent = "copied";
|
||||||
|
let timeout = setTimeout(() => {
|
||||||
|
copyButton.textContent = "copy";
|
||||||
|
}, 999);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mailgoCheckRender
|
* mailgoCheckRender
|
||||||
* function to check if an element is mailgo-enabled or not referencing to the old
|
* function to check if an element is mailgo-enabled or not referencing to the old
|
||||||
@ -350,6 +385,23 @@ const mailgoKeydown = event => {
|
|||||||
// Escape
|
// Escape
|
||||||
hideMailgo();
|
hideMailgo();
|
||||||
break;
|
break;
|
||||||
|
case 71:
|
||||||
|
// g -> open GMail
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
case 79:
|
||||||
|
// o -> open Outlook
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
case 13:
|
||||||
|
// spacebar or enter -> open default
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
|
case 67:
|
||||||
|
// c -> copy
|
||||||
|
hideMailgo();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user