a lot of fix (outlook link)

This commit is contained in:
Matteo Manzinello committed 2019-05-24 21:18:40 +02:00
1 parent 3a2ae160bc
commit 51591eef7f
3 files changed
+45 -39

No files matched your search

+15 -22
View File
@@ -233,7 +233,7 @@ var mailgoRender = function mailgoRender(mailgo) {
showMailgo(); // listener keyDown
mailgo.addEventListener("keydown", function () {
return mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton);
return mailgoKeydown(mail, cc, bcc, subject, bodyMail, url, mailtoHref, encEmail, copyButton);
}, false);
}; // actions
@@ -245,8 +245,8 @@ var actions = {
},
openOutlook: function openOutlook(mail, subject, bodyMail) {
var outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail);
if (subject != "") outlookUrl = outlookUrl.concat("&subject=" + subject);
if (bodyMail != "") outlookUrl = outlookUrl.concat("&body=" + bodyMail);
if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject);
if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail);
window.open(outlookUrl, "_blank");
},
openDefault: function openDefault(encEmail) {
@@ -265,7 +265,7 @@ var isMailgo = function isMailgo(element) {
return (// first case: it is an <a> element with "mailto:..." in href and no no-mailgo in classList
element.href && element.href.toLowerCase().startsWith(MAILTO) && !element.classList.contains("no-mailgo") || // second case: the href=#mailgo
element.href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo
element.classList.contains("mailgo")
element.classList && element.classList.contains("mailgo")
);
};
/**
@@ -279,16 +279,17 @@ var isMailgo = function isMailgo(element) {
var mailgoCheckRender = function mailgoCheckRender(event) {
// 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 (event.path.some(isMailgo)) {
// stop the normal execution of the element click
event.preventDefault(); // render mailgo
mailgoRender(e);
return;
}
if (!document.contains(getE("mailgo"))) return;
event.path.forEach(function (element) {
// go in the event.path to find if the user has clicked on a mailgo element
if (isMailgo(element)) {
// stop the normal execution of the element click
event.preventDefault(); // render mailgo
mailgoRender(element);
return;
}
});
return;
};
/**
@@ -297,15 +298,7 @@ var mailgoCheckRender = function mailgoCheckRender(event) {
*/
var mailgoKeydown = function mailgoKeydown(mail) {
var cc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
var bcc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
var bodyMail = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
var subject = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : "";
var url = arguments.length > 5 ? arguments[5] : undefined;
var mailtoHref = arguments.length > 6 ? arguments[6] : undefined;
var encEmail = arguments.length > 7 ? arguments[7] : undefined;
var copyButton = arguments.length > 8 ? arguments[8] : undefined;
var mailgoKeydown = function mailgoKeydown(mail, cc, bcc, subject, bodyMail, url, mailtoHref, encEmail, copyButton) {
// if mailgo is not showing do nothing
if (!mailgoIsShowing()) return;
+1 -1
View File
@@ -1 +1 @@
"use strict";var V="0.4.7",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 l=document.createElement("span");l.className="mailgo-weight-500";var d=document.createTextNode("cc ");l.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",i.appendChild(l),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 g=document.createElement("span");g.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(g),n.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),n.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),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 k=document.createTextNode("open in ");f.appendChild(k);var L=document.createElement("span");L.className="mailgo-weight-500";var w=document.createTextNode("Gmail");L.appendChild(w),f.appendChild(L),a.appendChild(f);var x=document.createElement("a");x.id="mailgo-outlook",x.href="#mailgo-outlook",x.classList.add("mailgo-open"),x.classList.add("mailgo-outlook");var N=document.createTextNode("open in ");x.appendChild(N);var T=document.createElement("span");T.className="mailgo-weight-500";var A=document.createTextNode("Outlook");T.appendChild(A),x.appendChild(T),a.appendChild(x);var S=document.createElement("a");S.id="mailgo-open",S.href="#mailgo-open",S.classList.add("mailgo-open"),S.classList.add("mailgo-default");var I=document.createElement("span");I.className="mailgo-weight-500";var M=document.createTextNode("open");I.appendChild(M);var R=document.createTextNode(" default");S.appendChild(I),S.appendChild(R),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?ref=mailgo-modal",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)},mailgoRender=function(e){var t="",a="",o="",n="",i="",l="",d="";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"),l=c.get("subject"),d=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"),l=e.getAttribute("data-subject"),d=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"),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,n?(r.style.display="block",s.textContent=n):r.style.display="none",i?(g.style.display="block",p.textContent=i):g.style.display="none",l?(u.style.display="block",h.textContent=l):u.style.display="none",d?(v.style.display="block",C.textContent=d):v.style.display="none",E.addEventListener("click",function(){return actions.openGmail(o)}),y.addEventListener("click",function(){return actions.openOutlook(t,l,d)});var Line truncated
"use strict";var V="0.4.7",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 l=document.createElement("span");l.className="mailgo-weight-500";var d=document.createTextNode("cc ");l.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",i.appendChild(l),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 k=document.createTextNode("open in ");f.appendChild(k);var L=document.createElement("span");L.className="mailgo-weight-500";var w=document.createTextNode("Gmail");L.appendChild(w),f.appendChild(L),a.appendChild(f);var x=document.createElement("a");x.id="mailgo-outlook",x.href="#mailgo-outlook",x.classList.add("mailgo-open"),x.classList.add("mailgo-outlook");var N=document.createTextNode("open in ");x.appendChild(N);var T=document.createElement("span");T.className="mailgo-weight-500";var A=document.createTextNode("Outlook");T.appendChild(A),x.appendChild(T),a.appendChild(x);var S=document.createElement("a");S.id="mailgo-open",S.href="#mailgo-open",S.classList.add("mailgo-open"),S.classList.add("mailgo-default");var I=document.createElement("span");I.className="mailgo-weight-500";var M=document.createTextNode("open");I.appendChild(M);var R=document.createTextNode(" default");S.appendChild(I),S.appendChild(R),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?ref=mailgo-modal",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)},mailgoRender=function(e){var t="",a="",o="",n="",i="",l="",d="";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"),l=c.get("subject"),d=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"),l=e.getAttribute("data-subject"),d=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",l?(u.style.display="block",h.textContent=l):u.style.display="none",d?(v.style.display="block",C.textContent=d):v.style.display="none",E.addEventListener("click",function(){return actions.openGmail(o)}),y.addEventListener("click",function(){return actions.openOutlook(t,l,d)});var Line truncated
+29 -16
View File
@@ -291,7 +291,18 @@ const mailgoRender = mailgo => {
// listener keyDown
mailgo.addEventListener(
"keydown",
() => mailgoKeydown(mail, url, mailtoHref, encEmail, copyButton),
() =>
mailgoKeydown(
mail,
cc,
bcc,
subject,
bodyMail,
url,
mailtoHref,
encEmail,
copyButton
),
false
);
};
@@ -310,8 +321,8 @@ const actions = {
let outlookUrl =
"https://outlook.live.com/owa/?path=/mail/action/compose&to=" +
encodeURIComponent(mail);
if (subject != "") outlookUrl = outlookUrl.concat("&subject=" + subject);
if (bodyMail != "") outlookUrl = outlookUrl.concat("&body=" + bodyMail);
if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject);
if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail);
window.open(outlookUrl, "_blank");
},
@@ -336,7 +347,7 @@ const isMailgo = element =>
// second case: the href=#mailgo
(element.href && element.getAttribute("href").toLowerCase() === "#mailgo") ||
// third case: the classList contains mailgo
element.classList.contains("mailgo");
(element.classList && element.classList.contains("mailgo"));
/**
* mailgoCheckRender
@@ -349,16 +360,18 @@ const mailgoCheckRender = event => {
// 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 (event.path.some(isMailgo)) {
// stop the normal execution of the element click
event.preventDefault();
event.path.forEach(element => {
// go in the event.path to find if the user has clicked on a mailgo element
if (isMailgo(element)) {
// stop the normal execution of the element click
event.preventDefault();
// render mailgo
mailgoRender(e);
// render mailgo
mailgoRender(element);
return;
}
return;
}
});
return;
};
@@ -369,10 +382,10 @@ const mailgoCheckRender = event => {
*/
const mailgoKeydown = (
mail,
cc = "",
bcc = "",
bodyMail = "",
subject = "",
cc,
bcc,
subject,
bodyMail,
url,
mailtoHref,
encEmail,