changed gmail and outlook, now open new tab

This commit is contained in:
Matteo Manzinello committed 2019-05-20 17:54:45 +02:00
1 parent 7f6879bfd6
commit 2a34df709f
3 files changed
+118 -22

No files matched your search

+52 -8
View File
@@ -84,6 +84,7 @@ var mailgoInit = function mailgoInit() {
var gmail = document.createElement("a");
gmail.id = "mailgo-gmail";
gmail.href = "#mailgo-gmail";
gmail.classList.add("mailgo-open");
gmail.classList.add("mailgo-gmail");
var gmailContent = document.createTextNode("open in ");
@@ -97,6 +98,7 @@ var mailgoInit = function mailgoInit() {
var outlook = document.createElement("a");
outlook.id = "mailgo-outlook";
outlook.href = "#mailgo-outlook";
outlook.classList.add("mailgo-open");
outlook.classList.add("mailgo-outlook");
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";
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);
outlookButton.href = "https://outlook.office.com/owa/?rru=compose&to=" + encodeURIComponent(mail) + url.search.replace(/^[$]/, "&");
gmailButton.addEventListener("click", function () {
openGmailAction(mailtoHref);
}, false);
outlookButton.addEventListener("click", function () {
openOutlookAction(mail, url);
}, false);
var encEmail = encodeEmail(mail);
openButton.addEventListener("click", function () {
mailToEncoded(encEmail);
openDefaultAction(encEmail);
}, false);
copyButton.addEventListener("click", function (event) {
copyToClipboard(mail);
copyButton.textContent = "copied";
setTimeout(function () {
copyButton.textContent = "copy";
}, 999);
copyAction(mail, copyButton);
}, false); // show the mailgo
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
@@ -269,6 +292,27 @@ var mailgoKeydown = function mailgoKeydown(event) {
hideMailgo();
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:
return;
}
+1 -1
View File
@@ -1 +1 @@
"use strict";var V="0.3.3",MAILTO="mailto:",mailgoCSS=document.createElement("link");mailgoCSS.rel="stylesheet",mailgoCSS.type="text/css",mailgoCSS.href="https://unpkg.com/mailgo@"+V+"/dist/mailgo.min.css",document.head.appendChild(mailgoCSS);var mailgoInit=function(){var e=document.createElement("div");e.id="mailgo",e.classList.add("mailgo-modal"),e.style.display="none";var t=document.createElement("div");t.className="mailgo-modal-background",e.appendChild(t);var a=document.createElement("div");a.className="mailgo-modal-content",e.appendChild(a);var o=document.createElement("strong");o.id="mailgo-title",o.className="mailgo-title",a.appendChild(o);var d=document.createElement("div");d.id="mailgo-details",d.className="mailgo-details";var n=document.createElement("p");n.id="mailgo-cc";var l=document.createElement("span");l.className="mailgo-weight-500";var i=document.createTextNode("cc ");l.appendChild(i);var c=document.createElement("span");c.id="mailgo-cc-value",n.appendChild(l),n.appendChild(c),d.appendChild(n);var m=document.createElement("p");m.id="mailgo-bcc";var r=document.createElement("span");r.className="mailgo-weight-500";var s=document.createTextNode("bcc ");r.appendChild(s);var g=document.createElement("span");g.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(g),d.appendChild(m);var p=document.createElement("p");p.id="mailgo-subject";var u=document.createElement("span");u.className="mailgo-weight-500";var h=document.createTextNode("subject");u.appendChild(h);var v=document.createElement("span");v.id="mailgo-subject-value",p.appendChild(u),p.appendChild(v),d.appendChild(p);var C=document.createElement("p");C.id="mailgo-body";var E=document.createElement("span");E.className="mailgo-weight-500";var y=document.createTextNode("body ");E.appendChild(y);var b=document.createElement("span");b.id="mailgo-body-value",C.appendChild(E),C.appendChild(b),d.appendChild(C),a.appendChild(d);var f=document.createElement("a");f.id="mailgo-gmail",f.classList.add("mailgo-open"),f.classList.add("mailgo-gmail");var L=document.createTextNode("open in ");f.appendChild(L);var w=document.createElement("span");w.className="mailgo-weight-500";var x=document.createTextNode("Gmail");w.appendChild(x),f.appendChild(w),a.appendChild(f);var N=document.createElement("a");N.id="mailgo-outlook",N.classList.add("mailgo-open"),N.classList.add("mailgo-outlook");var k=document.createTextNode("open in ");N.appendChild(k);var T=document.createElement("span");T.className="mailgo-weight-500";var A=document.createTextNode("Outlook");T.appendChild(A),N.appendChild(T),a.appendChild(N);var S=document.createElement("a");S.id="mailgo-open",S.href="#mailgo-open",S.classList.add("mailgo-open"),S.classList.add("mailgo-default");var R=document.createElement("span");R.className="mailgo-weight-500";var I=document.createTextNode("open");R.appendChild(I);var M=document.createTextNode(" default");S.appendChild(R),S.appendChild(M),a.appendChild(S);var j=document.createElement("a");j.id="mailgo-copy",j.href="#mailgo-copy",j.classList.add("mailgo-copy"),j.classList.add("mailgo-weight-500");var O=document.createTextNode("copy");j.appendChild(O),a.appendChild(j);var U=document.createElement("a");U.href="https://mailgo.js.org",U.className="mailgo-by",U.target="_blank",U.rel="noopener noreferrer";var K=document.createTextNode("mailgo.js.org");U.appendChild(K),a.appendChild(U),document.body.appendChild(e),t.addEventListener("click",hideMailgo,!1)},mailgoRender=function(e){var t="",a="",o="",d="",n="",l="",i="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){t=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),o=e.href,a=new URL(o);var c=new URLSearchParams(a.search);d=c.get("cc"),n=c.get("bcc"),l=c.get("subject"),i=c.get("body")}else t=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),o=MAILTO+encodeURIComponent(t),a=new URL(o),d=e.getAttribute("data-cc-address")+"@"+e.getAttribute("data-cc-domain"),n=e.getAttribute("data-bcc-address")+"@"+e.getAttribute("data-bcc-domain"),l=e.getAttribute("data-subject"),i=e.getAttribute("data-body");if(validateEmail(t)){validateEmail(d)||(d=""),validateEmail(n)||(n="");var m=getE("mailgo-title"),r=(getE("mailgo-details"),getE("mailgo-cc")),s=getE("mailgo-cc-value"),g=getE("mailgo-bcc"),p=getE("mailgo-bcc-value"),u=getE("mailgo-subject"),h=getE("mailgo-subject-value"),v=getE("mailgo-body"),C=getE("mailgo-body-value"),E=getE("mailgo-gmail"),y=getE("mailgo-outlook"),b=getE("mailgo-open"),f=getE("mailgo-copy");m.textContent=t,d?(r.style.display="block",s.textContent=d):r.style.display="none",n?(g.style.display="block",p.textContent=n):g.style.display="none",l?(u.style.display="block",h.textContent=l):u.style.display="none",i?(v.style.display="block",C.textContent=i):v.style.display="none",E.href="https://mail.google.com/mail?extsrc=mailto&url="+encodeURIComponent(o),y.href="https://outlook.office.com/owa/?rru=compose&to="+encodeURIComponent(t)+a.search.replace(/^[$]/,"&");var L=encodeEmail(t);bLine truncated
"use strict";var V="0.3.3",MAILTO="mailto:",mailgoCSS=document.createElement("link");mailgoCSS.rel="stylesheet",mailgoCSS.type="text/css",mailgoCSS.href="https://unpkg.com/mailgo@"+V+"/dist/mailgo.min.css",document.head.appendChild(mailgoCSS);var mailgoInit=function(){var e=document.createElement("div");e.id="mailgo",e.classList.add("mailgo-modal"),e.style.display="none";var t=document.createElement("div");t.className="mailgo-modal-background",e.appendChild(t);var a=document.createElement("div");a.className="mailgo-modal-content",e.appendChild(a);var o=document.createElement("strong");o.id="mailgo-title",o.className="mailgo-title",a.appendChild(o);var n=document.createElement("div");n.id="mailgo-details",n.className="mailgo-details";var i=document.createElement("p");i.id="mailgo-cc";var d=document.createElement("span");d.className="mailgo-weight-500";var l=document.createTextNode("cc ");d.appendChild(l);var c=document.createElement("span");c.id="mailgo-cc-value",i.appendChild(d),i.appendChild(c),n.appendChild(i);var m=document.createElement("p");m.id="mailgo-bcc";var r=document.createElement("span");r.className="mailgo-weight-500";var s=document.createTextNode("bcc ");r.appendChild(s);var p=document.createElement("span");p.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(p),n.appendChild(m);var g=document.createElement("p");g.id="mailgo-subject";var u=document.createElement("span");u.className="mailgo-weight-500";var h=document.createTextNode("subject");u.appendChild(h);var v=document.createElement("span");v.id="mailgo-subject-value",g.appendChild(u),g.appendChild(v),n.appendChild(g);var C=document.createElement("p");C.id="mailgo-body";var E=document.createElement("span");E.className="mailgo-weight-500";var y=document.createTextNode("body ");E.appendChild(y);var b=document.createElement("span");b.id="mailgo-body-value",C.appendChild(E),C.appendChild(b),n.appendChild(C),a.appendChild(n);var f=document.createElement("a");f.id="mailgo-gmail",f.href="#mailgo-gmail",f.classList.add("mailgo-open"),f.classList.add("mailgo-gmail");var L=document.createTextNode("open in ");f.appendChild(L);var k=document.createElement("span");k.className="mailgo-weight-500";var w=document.createTextNode("Gmail");k.appendChild(w),f.appendChild(k),a.appendChild(f);var A=document.createElement("a");A.id="mailgo-outlook",A.href="#mailgo-outlook",A.classList.add("mailgo-open"),A.classList.add("mailgo-outlook");var x=document.createTextNode("open in ");A.appendChild(x);var N=document.createElement("span");N.className="mailgo-weight-500";var T=document.createTextNode("Outlook");N.appendChild(T),A.appendChild(N),a.appendChild(A);var S=document.createElement("a");S.id="mailgo-open",S.href="#mailgo-open",S.classList.add("mailgo-open"),S.classList.add("mailgo-default");var R=document.createElement("span");R.className="mailgo-weight-500";var I=document.createTextNode("open");R.appendChild(I);var M=document.createTextNode(" default");S.appendChild(R),S.appendChild(M),a.appendChild(S);var O=document.createElement("a");O.id="mailgo-copy",O.href="#mailgo-copy",O.classList.add("mailgo-copy"),O.classList.add("mailgo-weight-500");var j=document.createTextNode("copy");O.appendChild(j),a.appendChild(O);var U=document.createElement("a");U.href="https://mailgo.js.org",U.className="mailgo-by",U.target="_blank",U.rel="noopener noreferrer";var D=document.createTextNode("mailgo.js.org");U.appendChild(D),a.appendChild(U),document.body.appendChild(e),t.addEventListener("click",hideMailgo,!1)},mailgoRender=function(e){var t="",a="",o="",n="",i="",d="",l="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){t=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),o=e.href,a=new URL(o);var c=new URLSearchParams(a.search);n=c.get("cc"),i=c.get("bcc"),d=c.get("subject"),l=c.get("body")}else t=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),o=MAILTO+encodeURIComponent(t),a=new URL(o),n=e.getAttribute("data-cc-address")+"@"+e.getAttribute("data-cc-domain"),i=e.getAttribute("data-bcc-address")+"@"+e.getAttribute("data-bcc-domain"),d=e.getAttribute("data-subject"),l=e.getAttribute("data-body");if(validateEmail(t)){validateEmail(n)||(n=""),validateEmail(i)||(i="");var m=getE("mailgo-title"),r=(getE("mailgo-details"),getE("mailgo-cc")),s=getE("mailgo-cc-value"),p=getE("mailgo-bcc"),g=getE("mailgo-bcc-value"),u=getE("mailgo-subject"),h=getE("mailgo-subject-value"),v=getE("mailgo-body"),C=getE("mailgo-body-value"),E=getE("mailgo-gmail"),y=getE("mailgo-outlook"),b=getE("mailgo-open"),f=getE("mailgo-copy");m.textContent=t,n?(r.style.display="block",s.textContent=n):r.style.display="none",i?(p.style.display="block",g.textContent=i):p.style.display="none",d?(u.style.display="block",h.textContent=d):u.style.display="none",l?(v.style.display="block",C.textContent=l):v.style.display="none",E.addEventListener("click",function(){openGmailAction(o)},!1),y.addEventListener("click",function(){openOutlookAction(t,a)},!1);var L=encodeEmail(t);b.addEventLiLine truncated
+65 -13
View File
@@ -93,6 +93,7 @@ const mailgoInit = () => {
// Gmail
let gmail = document.createElement("a");
gmail.id = "mailgo-gmail";
gmail.href = "#mailgo-gmail";
gmail.classList.add("mailgo-open");
gmail.classList.add("mailgo-gmail");
let gmailContent = document.createTextNode("open in ");
@@ -108,6 +109,7 @@ const mailgoInit = () => {
// Outlook
let outlook = document.createElement("a");
outlook.id = "mailgo-outlook";
outlook.href = "#mailgo-outlook";
outlook.classList.add("mailgo-open");
outlook.classList.add("mailgo-outlook");
let outlookContent = document.createTextNode("open in ");
@@ -272,20 +274,27 @@ const mailgoRender = mailgo => {
: (bodyEl.style.display = "none");
// add the actions
gmailButton.href =
"https://mail.google.com/mail?extsrc=mailto&url=" +
encodeURIComponent(mailtoHref);
gmailButton.addEventListener(
"click",
() => {
openGmailAction(mailtoHref);
},
false
);
outlookButton.href =
"https://outlook.office.com/owa/?rru=compose&to=" +
encodeURIComponent(mail) +
url.search.replace(/^[$]/, "&");
outlookButton.addEventListener(
"click",
() => {
openOutlookAction(mail, url);
},
false
);
let encEmail = encodeEmail(mail);
openButton.addEventListener(
"click",
() => {
mailToEncoded(encEmail);
openDefaultAction(encEmail);
},
false
);
@@ -293,11 +302,7 @@ const mailgoRender = mailgo => {
copyButton.addEventListener(
"click",
event => {
copyToClipboard(mail);
copyButton.textContent = "copied";
setTimeout(() => {
copyButton.textContent = "copy";
}, 999);
copyAction(mail, copyButton);
},
false
);
@@ -306,6 +311,36 @@ const mailgoRender = mailgo => {
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
* function to check if an element is mailgo-enabled or not referencing to the old
@@ -350,6 +385,23 @@ const mailgoKeydown = event => {
// Escape
hideMailgo();
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:
return;
}