diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index 348e60b..07ceaea 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -"use strict";var V="0.6.10",MAILTO="mailto:",TEL="tel:",CALLTO="callto:",MAIL_TYPE="mail",TEL_TYPE="tel",url="",mail="",encEmail="",cc="",bcc="",subject="",bodyMail="",tel="",msg="",mailgoCSS=document.createElement("style");mailgoCSS.id="mailgo-style",mailgoCSS.type="text/css";var mailgoCSSContent=document.createTextNode('.mailgo-modal{position:fixed;top:0;right:0;bottom:0;left:0;justify-content:center;align-items:center;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.mailgo-modal a,.mailgo-modal p,.mailgo-modal span,.mailgo-modal strong{margin:0;padding:0;font-size:100%;line-height:1;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"}.mailgo-modal strong{font-weight:700}.mailgo-modal .mailgo-modal-background{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.mailgo-modal .mailgo-modal-content{position:relative;z-index:10002;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;border-radius:5px;box-shadow:0 3px 8px 0 rgba(32,35,42,.12);color:#4a4a4a;display:block;overflow:auto;padding:20px}.mailgo-modal .mailgo-modal-content:hover{opacity:1;box-shadow:0 18px 30px 0 rgba(32,35,42,.23)}.mailgo-modal .mailgo-modal-content .mailgo-title{display:block;margin-bottom:5px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.mailgo-modal .mailgo-modal-content .mailgo-details{margin-bottom:10px}.mailgo-modal .mailgo-modal-content .mailgo-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.mailgo-modal .mailgo-modal-content a{display:block;padding:10px;color:#4a4a4a;border-radius:5px;text-decoration:none}.mailgo-modal .mailgo-modal-content a.mailgo-gmail{color:#d44638}.mailgo-modal .mailgo-modal-content a.mailgo-outlook{color:#0072c6}.mailgo-modal .mailgo-modal-content a.mailgo-wa{color:#00bfa5}.mailgo-modal .mailgo-modal-content a.mailgo-telegram{color:#08c}.mailgo-modal .mailgo-modal-content a.mailgo-copy{padding:16px 10px;font-size:16px}.mailgo-modal .mailgo-modal-content a.mailgo-copy:hover,.mailgo-modal .mailgo-modal-content a.mailgo-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.mailgo-modal .mailgo-modal-content a.mailgo-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.mailgo-modal .mailgo-modal-content a.mailgo-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.mailgo-modal .mailgo-modal-content a.mailgo-telegram:hover{background-color:rgba(0,114,198,.08);color:#08c}.mailgo-modal .mailgo-modal-content a.mailgo-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.mailgo-modal .mailgo-modal-content a.mailgo-by{display:block;font-size:8px;margin-top:1rem;padding:0;color:#4a4a4a;opacity:.5}.mailgo-modal .mailgo-modal-content a.mailgo-by:hover{opacity:1}.mailgo-modal .mailgo-modal-content .mailgo-weight-500{font-weight:500}');mailgoCSS.appendChild(mailgoCSSContent),document.head.appendChild(mailgoCSS);var mailgoInit=function(){var e=document.createElement("div");e.style.display="none",e.id="mailgo",e.classList.add("mailgo-modal");var a=document.createElement("div");a.className="mailgo-modal-background",e.appendChild(a);var o=document.createElement("div");o.className="mailgo-modal-content",e.appendChild(o);var t=document.createElement("strong");t.id="mailgo-title",t.className="mailgo-title",o.appendChild(t);var l=document.createElement("div");l.id="mailgo-details",l.className="mailgo-details";var i=document.createElement("p");i.id="mailgo-cc";var n=document.createElement("span");n.className="mailgo-weight-500";var d=document.createTextNode("cc ");n.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",i.appendChild(n),i.appendChild(c),l.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),l.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 b=document.createElement("span");b.id="mailgo-subject-value",p.appendChild(u),p.appendChild(b),l.appendChild(p);var v=document.createElement("p");v.id="mailgo-body";var f=document.createElement("span");f.className="mailgo-weight-500";var E=document.createTextNode("body ");f.appendChild(E);var y=document.createElement("span");y.id="mailgo-body-value",v.appendChild(f),v.appendChild(y),l.appendChild(v),o.appendChild(l);var C=document.createElement("a");C.id="mailgo-gmail",C.href="#mailgo-gmail",C.classList.add("mailgo-open"),C.classList.add("mailgo-gmail");var L=document.createTextNode("open in ");C.appendChild(L);var T=document.createElement("span");T.className="mailgo-weight-500";var w=document.createTextNode("Gmail");T.appendChild(w),C.appendChild(T),o.appendChild(C);var x=document.createElement("a");x.id="mailgo-outlook",x.href="#mailgo-outlook",x.classList.add("mailgo-open"),x.classList.add("mailgo-outlook");var k=document.createTextNode("open in ");x.appendChild(k);var M=document.createElement("span");M.className="mailgo-weight-500";var N=document.createTextNode("Outlook");M.appendChild(N),x.appendChild(M),o.appendChild(x);var A=document.createElement("a");A.id="mailgo-open",A.href="#mailgo-open",A.classList.add("mailgo-open"),A.classList.add("mailgo-default");var j=document.createElement("span");j.className="mailgo-weight-500";var I=document.createTextNode("open");j.appendChild(I);var S=document.createTextNode(" default");A.appendChild(j),A.appendChild(S),o.appendChild(A);var R=document.createElement("a");R.id="mailgo-copy",R.href="#mailgo-copy",R.classList.add("mailgo-copy"),R.classList.add("mailgo-weight-500");var _=document.createTextNode("copy");R.appendChild(_),o.appendChild(R);var P=document.createElement("a");P.href="https://mailgo.js.org?ref=mailgo-modal",P.className="mailgo-by",P.target="_blank",P.rel="noopener noreferrer";var O=document.createTextNode("mailgo.js.org");P.appendChild(O),o.appendChild(P),document.body.appendChild(e),a.addEventListener("click",hideMailgo);var D=document.createElement("div");D.style.display="none",D.id="mailgo-tel",D.classList.add("mailgo-modal");var U=document.createElement("div");U.className="mailgo-modal-background",D.appendChild(U);var Y=document.createElement("div");Y.className="mailgo-modal-content",D.appendChild(Y);var z=document.createElement("strong");z.id="mailgo-tel-title",z.className="mailgo-title",Y.appendChild(z);var W=document.createElement("a");W.id="mailgo-telegram",W.href="#mailgo-telegram",W.classList.add("mailgo-open"),W.classList.add("mailgo-telegram");var H=document.createTextNode("open in ");W.appendChild(H);var G=document.createElement("span");G.className="mailgo-weight-500";var B=document.createTextNode("Telegram");G.appendChild(B),W.appendChild(G),Y.appendChild(W);var K=document.createElement("a");K.id="mailgo-wa",K.href="#mailgo-wa",K.classList.add("mailgo-open"),K.classList.add("mailgo-wa");var Z=document.createTextNode("open in ");K.appendChild(Z);var F=document.createElement("span");F.className="mailgo-weight-500";var V=document.createTextNode("WhatsApp");F.appendChild(V),K.appendChild(F),Y.appendChild(K);var $=document.createElement("a");$.id="mailgo-call",$.href="#mailgo-call",$.classList.add("mailgo-open"),$.classList.add("mailgo-default");var q=document.createElement("span");q.className="mailgo-weight-500";var J=document.createTextNode("call");q.appendChild(J);var Q=document.createTextNode(" as default");$.appendChild(q),$.appendChild(Q),Y.appendChild($);var X=document.createElement("a");X.id="mailgo-tel-copy",X.href="#mailgo-copy",X.classList.add("mailgo-copy"),X.classList.add("mailgo-weight-500");var ee=document.createTextNode("copy");X.appendChild(ee),Y.appendChild(X);var ae=document.createElement("a");ae.href="https://mailgo.js.org?ref=mailgo-modal",ae.className="mailgo-by",ae.target="_blank",ae.rel="noopener noreferrer";var oe=document.createTextNode("mailgo.js.org");ae.appendChild(oe),Y.appendChild(ae),document.body.appendChild(D),U.addEventListener("click",hideMailgo)},mailgoRender=function(e,a){var o=0"),cc?(n.style.display="block",d.innerHTML=cc.split(",").join("
")):n.style.display="none",bcc?(c.style.display="block",m.innerHTML=bcc.split(",").join("
")):c.style.display="none",subject?(r.style.display="block",s.textContent=subject):r.style.display="none",bodyMail?(g.style.display="block",p.textContent=bodyMail):g.style.display="none",u.addEventListener("click",function(){return actions.openGmail(mail,cc,bcc,subject,bodyMail)}),h.addEventListener("click",function(){return actions.openOutlook(mail,subject,bodyMail)}),encEmail=encodeEmail(mail),b.addEventListener("click",function(){return actions.openDefault(encEmail)}),v.addEventListener("click",function(){return actions.copy(mail,v)})}if(o===TEL_TYPE){t.href&&t.href.toLowerCase().startsWith(TEL)&&(tel=decodeURIComponent(t.href.split("?")[0].split(TEL)[1].trim())),t.href&&t.href.toLowerCase().startsWith(CALLTO)&&(tel=decodeURIComponent(t.href.split("?")[0].split(CALLTO)[1].trim()));var f=getE("mailgo-tel-title"),E=getE("mailgo-wa"),y=getE("mailgo-telegram"),C=getE("mailgo-call"),L=getE("mailgo-tel-copy");f.innerHTML=tel,E.addEventListener("click",function(){return actions.openWhatsApp(tel)}),y.addEventListener("click",function(){return actions.openTelegram(tel)}),C.addEventListener("click",function(){return actions.callDefault(tel)}),L.addEventListener("click",function(){return actions.copy(tel,L)})}showMailgo(o),document.addEventListener("keydown",mailgoKeydown)},actions={openGmail:function(e,a,o,t,l){var i="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(e);a&&(i=i.concat("&cc="+encodeURIComponent(a))),o&&(i=i.concat("&bcc="+encodeURIComponent(o))),t&&(i=i.concat("&subject="+t)),l&&(i=i.concat("&body="+l)),window.open(i,"_blank")},openOutlook:function(e,a,o){var t="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(e);a&&(t=t.concat("&subject="+a)),o&&(t=t.concat("&body="+o)),window.open(t,"_blank")},openDefault:function(e){mailToEncoded(e)},openTelegram:function(e,a){var o="tg://msg?text="+(1()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},validateEmails=function(e){return e.every(validateEmail)},cleanTel=function(e){return e},copyToClipboard=function(e){var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a);var o=0"),cc?(n.style.display="block",d.innerHTML=cc.split(",").join("
")):n.style.display="none",bcc?(c.style.display="block",m.innerHTML=bcc.split(",").join("
")):c.style.display="none",subject?(r.style.display="block",s.textContent=subject):r.style.display="none",bodyMail?(g.style.display="block",p.textContent=bodyMail):g.style.display="none",gmailButton.addEventListener("click",function(){return actions.openGmail()}),outlookButton.addEventListener("click",function(){return actions.openOutlook()}),encEmail=encodeEmail(mail),openButton.addEventListener("click",function(){return actions.openDefault()}),copyButton.addEventListener("click",function(){return actions.copy()})}if(o===TEL_TYPE){t.href&&t.href.toLowerCase().startsWith(TEL)?tel=decodeURIComponent(t.href.split("?")[0].split(TEL)[1].trim()):t.href&&t.href.toLowerCase().startsWith(CALLTO)?tel=decodeURIComponent(t.href.split("?")[0].split(CALLTO)[1].trim()):t.hasAttribute("data-tel")&&(tel=t.getAttribute("data-tel"),msg=t.getAttribute("data-msg"));var u=getE("mailgo-tel-title");waButton=getE("mailgo-wa"),telegramButton=getE("mailgo-telegram"),callButton=getE("mailgo-call"),copyButton=getE("mailgo-tel-copy"),u.innerHTML=tel,waButton.addEventListener("click",function(){return actions.openWhatsApp()}),telegramButton.addEventListener("click",function(){return actions.openTelegram()}),callButton.addEventListener("click",function(){return actions.callDefault()}),copyButton.addEventListener("click",function(){return actions.copy(tel)})}showMailgo(o),document.addEventListener("keydown",mailgoKeydown)},actions={openGmail:function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(mail);cc&&(e=e.concat("&cc="+encodeURIComponent(cc))),bcc&&(e=e.concat("&bcc="+encodeURIComponent(bcc))),subject&&(e=e.concat("&subject="+subject)),bodyMail&&(e=e.concat("&body="+bodyMail)),window.open(e,"_blank")},openOutlook:function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(mail);subject&&(e=e.concat("&subject="+subject)),bodyMail&&(e=e.concat("&body="+bodyMail)),window.open(e,"_blank")},openDefault:function(){mailToEncoded(encEmail)},openTelegram:function(){var e="tg://msg?text="+msg+"&to="+tel;window.open(e,"_blank")},openWhatsApp:function(){var e="https://wa.me/"+tel;window.open(e,"_blank")},callDefault:function(){var e="tel:"+tel;window.open(e)},copy:function(e){copyToClipboard(e),(copyButton=mailgoIsShowing(MAIL_TYPE)?getE("mailgo-copy"):getE("mailgo-tel-copy")).textContent="copied",setTimeout(function(){return copyButton.textContent="copy"},999)}},isMailgo=function(e){return e.href&&e.href.toLowerCase().startsWith(MAILTO)&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(e.href&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))},isMailgoTel=function(e){return e.href&&(e.href.toLowerCase().startsWith(TEL)||e.href.toLowerCase().startsWith(CALLTO))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&e.href&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")},mailgoCheckRender=function(a){if(document.contains(getE("mailgo"))&&document.contains(getE("mailgo-tel"))){var e=a.path||a.composedPath&&a.composedPath()||composedPath(a.target);e&&e.forEach(function(e){if(console.log(e),!(e instanceof HTMLDocument||e instanceof Window))return isMailgo(e)?(a.preventDefault(),void mailgoRender(MAIL_TYPE,e)):isMailgoTel(e)?(a.preventDefault(),void mailgoRender(TEL_TYPE,e)):void 0})}},mailgoKeydown=function(e){if(console.log(e),mailgoIsShowing(MAIL_TYPE))switch(console.log("son qui"),e.keyCode){case 27:hideMailgo();break;case 71:actions.openGmail();break;case 79:actions.openOutlook();break;case 32:case 13:actions.openDefault();break;case 67:actions.copy(mail);break;default:return}else if(mailgoIsShowing(TEL_TYPE))switch(e.keyCode){case 27:hideMailgo();break;case 71:actions.openGmail();break;case 79:actions.openOutlook();break;case 32:case 13:actions.openDefault();break;case 67:actions.copy(tel);break;default:return}};document.addEventListener("DOMContentLoaded",mailgoInit),document.addEventListener("click",mailgoCheckRender);var showMailgo=function(e){setDisplay((0()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},validateEmails=function(e){return e.every(validateEmail)},cleanTel=function(e){return e},copyToClipboard=function(e){var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a);var o=0"),c?(y.style.display="block",C.innerHTML=c.split(",").join("
")):y.style.display="none",m?(x.style.display="block",E.innerHTML=m.split(",").join("
")):x.style.display="none",r?(L.style.display="block",N.textContent=r):L.style.display="none",p?(T.style.display="block",A.textContent=p):T.style.display="none",R.addEventListener("click",(function(){return f.openGmail(i,c,m,r,p)})),S.addEventListener("click",(function(){return f.openOutlook(i,r,p)})),d=w(i),U.addEventListener("click",(function(){return f.openDefault(d)})),O.addEventListener("click",(function(){return f.copy(i,O)}))}if("tel"===o){g.href&&g.href.toLowerCase().startsWith(l)&&(s=decodeURIComponent(g.href.split("?")[0].split(l)[1].trim())),g.href&&g.href.toLowerCase().startsWith("callto:")&&(s=decodeURIComponent(g.href.split("?")[0].split("callto:")[1].trim()));var I=k("mailgo-tel-title"),_=k("mailgo-wa"),z=k("mailgo-telegram"),M=k("mailgo-call"),D=k("mailgo-tel-copy");I.innerHTML=s,_.addEventListener("click",(function(){return f.openWhatsApp(s)})),z.addEventListener("click",(function(){return f.openTelegram(s)})),M.addEventListener("click",(function(){return f.callDefault(s)})),D.addEventListener("click",(function(){return f.copy(s,D)}))}b(o),document.addEventListener("keydown",v)},f={openGmail:function(e,a,o,t,l){var n="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(e);a&&(n=n.concat("&cc="+encodeURIComponent(a))),o&&(n=n.concat("&bcc="+encodeURIComponent(o))),t&&(n=n.concat("&subject="+t)),l&&(n=n.concat("&body="+l)),window.open(n,"_blank")},openOutlook:function(e,a,o){var t="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(e);a&&(t=t.concat("&subject="+a)),o&&(t=t.concat("&body="+o)),window.open(t,"_blank")},openDefault:function(e){x(e)},openTelegram:function(e,a){var o="tg://msg?text="+(1()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},j=function(e){return e.every(T)},A=function(e){var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a);var o=0"),f?(T.style.display="block",j.innerHTML=f.split(",").join("
")):T.style.display="none",h?(A.style.display="block",U.innerHTML=h.split(",").join("
")):A.style.display="none",v?(O.style.display="block",I.textContent=v):O.style.display="none",b?(M.style.display="block",z.textContent=b):M.style.display="none",t.addEventListener("click",(function(){return E.openGmail()})),l.addEventListener("click",(function(){return E.openOutlook()})),u=R(g),n.addEventListener("click",(function(){return E.openDefault()})),m.addEventListener("click",(function(){return E.copy()}))}if("tel"===o){x.href&&x.href.toLowerCase().startsWith(s)?y=decodeURIComponent(x.href.split("?")[0].split(s)[1].trim()):x.href&&x.href.toLowerCase().startsWith("callto:")?y=decodeURIComponent(x.href.split("?")[0].split("callto:")[1].trim()):x.hasAttribute("data-tel")&&(y=x.getAttribute("data-tel"),C=x.getAttribute("data-msg"));var D=S("mailgo-tel-title");i=S("mailgo-wa"),d=S("mailgo-telegram"),c=S("mailgo-call"),m=S("mailgo-tel-copy"),D.innerHTML=y,i.addEventListener("click",(function(){return E.openWhatsApp()})),d.addEventListener("click",(function(){return E.openTelegram()})),c.addEventListener("click",(function(){return E.callDefault()})),m.addEventListener("click",(function(){return E.copy(y)}))}N(o),document.addEventListener("keydown",L)},E={openGmail:function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(g);f&&(e=e.concat("&cc="+encodeURIComponent(f))),h&&(e=e.concat("&bcc="+encodeURIComponent(h))),v&&(e=e.concat("&subject="+v)),b&&(e=e.concat("&body="+b)),window.open(e,"_blank")},openOutlook:function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(g);v&&(e=e.concat("&subject="+v)),b&&(e=e.concat("&body="+b)),window.open(e,"_blank")},openDefault:function(){A(u)},openTelegram:function(){var e="tg://msg?text="+C+"&to="+y;window.open(e,"_blank")},openWhatsApp:function(){var e="https://wa.me/"+y;window.open(e,"_blank")},callDefault:function(){var e="tel:"+y;window.open(e)},copy:function(e){z(e),(m=j("mail")?S("mailgo-copy"):S("mailgo-tel-copy")).textContent="copied",setTimeout((function(){return m.textContent="copy"}),999)}},L=function(e){if(console.log(e),j("mail"))switch(console.log("son qui"),e.keyCode){case 27:T();break;case 71:E.openGmail();break;case 79:E.openOutlook();break;case 32:case 13:E.openDefault();break;case 67:E.copy(g);break;default:return}else if(j("tel"))switch(e.keyCode){case 27:T();break;case 71:E.openGmail();break;case 79:E.openOutlook();break;case 32:case 13:E.openDefault();break;case 67:E.copy(y);break;default:return}};document.addEventListener("DOMContentLoaded",(function(){var e=document.createElement("div");e.style.display="none",e.id="mailgo",e.classList.add("mailgo-modal");var a=document.createElement("div");a.className="mailgo-modal-background",e.appendChild(a);var o=document.createElement("div");o.className="mailgo-modal-content",e.appendChild(o);var t=document.createElement("strong");t.id="mailgo-title",t.className="mailgo-title",o.appendChild(t);var l=document.createElement("div");l.id="mailgo-details",l.className="mailgo-details";var n=document.createElement("p");n.id="mailgo-cc";var i=document.createElement("span");i.className="mailgo-weight-500";var d=document.createTextNode("cc ");i.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",n.appendChild(i),n.appendChild(c),l.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 p=document.createElement("span");p.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(p),l.appendChild(m);var g=document.createElement("p");g.id="mailgo-subject";var u=document.createElement("span");u.className="mailgo-weight-500";var f=document.createTextNode("subject ");u.appendChild(f);var h=document.createElement("span");h.id="mailgo-subject-value",g.appendChild(u),g.appendChild(h),l.appendChild(g);var v=document.createElement("p");v.id="mailgo-body";var b=document.createElement("span");b.className="mailgo-weight-500";var y=document.createTextNode("body ");b.appendChild(y);var C=document.createElement("span");C.id="mailgo-body-value",v.appendChild(b),v.appendChild(C),l.appendChild(v),o.appendChild(l);var x=document.createElement("a");x.id="mailgo-gmail",x.href="#mailgo-gmail",x.classList.add("mailgo-open"),x.classList.add("mailgo-gmail");var w=document.createTextNode("open in ");x.appendChild(w);var k=document.createElement("span");k.className="mailgo-weight-500";var E=document.createTextNode("Gmail");k.appendChild(E),x.appendChild(k),o.appendChild(x);var L=document.createElement("a");L.id="mailgo-outlook",L.href="#mailgo-outlook",L.classList.add("mailgo-open"),L.classList.add("mailgo-outlook");var N=document.createTextNode("open in ");L.appendChild(N);var j=document.createElement("span");j.className="mailgo-weight-500";var A=document.createTextNode("Outlook");j.appendChild(A),L.appendChild(j),o.appendChild(L);var R=document.createElement("a");R.id="mailgo-open",R.href="#mailgo-open",R.classList.add("mailgo-open"),R.classList.add("mailgo-default");var S=document.createElement("span");S.className="mailgo-weight-500";var U=document.createTextNode("open");S.appendChild(U);var O=document.createTextNode(" default");R.appendChild(S),R.appendChild(O),o.appendChild(R);var I=document.createElement("a");I.id="mailgo-copy",I.href="#mailgo-copy",I.classList.add("mailgo-copy"),I.classList.add("mailgo-weight-500");var M=document.createTextNode("copy");I.appendChild(M),o.appendChild(I);var _=document.createElement("a");_.href="https://mailgo.js.org?ref=mailgo-modal",_.className="mailgo-by",_.target="_blank",_.rel="noopener noreferrer";var z=document.createTextNode("mailgo.js.org");_.appendChild(z),o.appendChild(_),document.body.appendChild(e),a.addEventListener("click",T);var D=document.createElement("div");D.style.display="none",D.id="mailgo-tel",D.classList.add("mailgo-modal");var W=document.createElement("div");W.className="mailgo-modal-background",D.appendChild(W);var P=document.createElement("div");P.className="mailgo-modal-content",D.appendChild(P);var H=document.createElement("strong");H.id="mailgo-tel-title",H.className="mailgo-title",P.appendChild(H);var G=document.createElement("a");G.id="mailgo-telegram",G.href="#mailgo-telegram",G.classList.add("mailgo-open"),G.classList.add("mailgo-telegram");var B=document.createTextNode("open in ");G.appendChild(B);var Z=document.createElement("span");Z.className="mailgo-weight-500";var q=document.createTextNode("Telegram");Z.appendChild(q),G.appendChild(Z),P.appendChild(G);var F=document.createElement("a");F.id="mailgo-wa",F.href="#mailgo-wa",F.classList.add("mailgo-open"),F.classList.add("mailgo-wa");var $=document.createTextNode("open in ");F.appendChild($);var J=document.createElement("span");J.className="mailgo-weight-500";var K=document.createTextNode("WhatsApp");J.appendChild(K),F.appendChild(J),P.appendChild(F);var Q=document.createElement("a");Q.id="mailgo-call",Q.href="#mailgo-call",Q.classList.add("mailgo-open"),Q.classList.add("mailgo-default");var V=document.createElement("span");V.className="mailgo-weight-500";var X=document.createTextNode("call");V.appendChild(X);var Y=document.createTextNode(" as default");Q.appendChild(V),Q.appendChild(Y),P.appendChild(Q);var ee=document.createElement("a");ee.id="mailgo-tel-copy",ee.href="#mailgo-copy",ee.classList.add("mailgo-copy"),ee.classList.add("mailgo-weight-500");var ae=document.createTextNode("copy");ee.appendChild(ae),P.appendChild(ee);var oe=document.createElement("a");oe.href="https://mailgo.js.org?ref=mailgo-modal",oe.className="mailgo-by",oe.target="_blank",oe.rel="noopener noreferrer";var te=document.createTextNode("mailgo.js.org");oe.appendChild(te),P.appendChild(oe),document.body.appendChild(D),W.addEventListener("click",T)})),document.addEventListener("click",(function(e){if(document.contains(S("mailgo"))&&document.contains(S("mailgo-tel"))){var a=e.path||e.composedPath&&e.composedPath()||I(e.target);a&&a.forEach((function(a){if(console.log(a),!(a instanceof HTMLDocument||a instanceof Window))return function(e){return e.href&&e.href.toLowerCase().startsWith(r)&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(e.href&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))}(a)?(e.preventDefault(),void k("mail",a)):function(e){return e.href&&(e.href.toLowerCase().startsWith(s)||e.href.toLowerCase().startsWith("callto:"))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&e.href&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")}(a)?(e.preventDefault(),void k("tel",a)):void 0}))}}));var N=function(e){O("tel"===(0()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},_=function(e){return e.every(M)},z=function(e){var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a);var o=0 { let bodyValueEl = getE("mailgo-body-value"); // actions - let gmailButton = getE("mailgo-gmail"); - let outlookButton = getE("mailgo-outlook"); - let openButton = getE("mailgo-open"); - let copyButton = getE("mailgo-copy"); + gmailButton = getE("mailgo-gmail"); + outlookButton = getE("mailgo-outlook"); + openButton = getE("mailgo-open"); + copyButton = getE("mailgo-copy"); // the title of the modal (email address) titleEl.innerHTML = mail.split(",").join("
"); @@ -391,18 +404,14 @@ const mailgoRender = (type = MAIL_TYPE, mailgo) => { : (bodyEl.style.display = "none"); // add the actions - gmailButton.addEventListener("click", () => - actions.openGmail(mail, cc, bcc, subject, bodyMail) - ); + gmailButton.addEventListener("click", () => actions.openGmail()); - outlookButton.addEventListener("click", () => - actions.openOutlook(mail, subject, bodyMail) - ); + outlookButton.addEventListener("click", () => actions.openOutlook()); encEmail = encodeEmail(mail); - openButton.addEventListener("click", () => actions.openDefault(encEmail)); + openButton.addEventListener("click", () => actions.openDefault()); - copyButton.addEventListener("click", () => actions.copy(mail, copyButton)); + copyButton.addEventListener("click", () => actions.copy()); } // mailgo tel if (type === TEL_TYPE) { @@ -429,22 +438,22 @@ const mailgoRender = (type = MAIL_TYPE, mailgo) => { let titleEl = getE("mailgo-tel-title"); // actions - let waButton = getE("mailgo-wa"); - let telegramButton = getE("mailgo-telegram"); - let callButton = getE("mailgo-call"); - let copyButton = getE("mailgo-tel-copy"); + waButton = getE("mailgo-wa"); + telegramButton = getE("mailgo-telegram"); + callButton = getE("mailgo-call"); + copyButton = getE("mailgo-tel-copy"); // the title of the modal (tel) titleEl.innerHTML = tel; // add the actions - waButton.addEventListener("click", () => actions.openWhatsApp(tel)); + waButton.addEventListener("click", () => actions.openWhatsApp()); - telegramButton.addEventListener("click", () => actions.openTelegram(tel)); + telegramButton.addEventListener("click", () => actions.openTelegram()); - callButton.addEventListener("click", () => actions.callDefault(tel)); + callButton.addEventListener("click", () => actions.callDefault()); - copyButton.addEventListener("click", () => actions.copy(tel, copyButton)); + copyButton.addEventListener("click", () => actions.copy(tel)); } // show the mailgo @@ -456,7 +465,7 @@ const mailgoRender = (type = MAIL_TYPE, mailgo) => { // actions const actions = { - openGmail: (mail, cc, bcc, subject, bodyMail) => { + openGmail: () => { let gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + encodeURIComponent(mail); @@ -469,7 +478,7 @@ const actions = { window.open(gmailUrl, "_blank"); }, - openOutlook: (mail, subject, bodyMail) => { + openOutlook: () => { let outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail); @@ -479,27 +488,30 @@ const actions = { window.open(outlookUrl, "_blank"); }, - openDefault: encEmail => { + openDefault: () => { mailToEncoded(encEmail); }, - openTelegram: (tel, msg = "") => { + openTelegram: () => { let tgUrl = "tg://msg?text=" + msg + "&to=" + tel; window.open(tgUrl, "_blank"); }, - openWhatsApp: (tel, msg = "") => { + openWhatsApp: () => { let waUrl = "https://wa.me/" + tel; window.open(waUrl, "_blank"); }, - callDefault: tel => { + callDefault: () => { let callUrl = "tel:" + tel; window.open(callUrl); }, - copy: (content, copyButton) => { + copy: content => { copyToClipboard(content); + mailgoIsShowing(MAIL_TYPE) + ? (copyButton = getE("mailgo-copy")) + : (copyButton = getE("mailgo-tel-copy")); copyButton.textContent = "copied"; setTimeout(() => (copyButton.textContent = "copy"), 999); } @@ -558,6 +570,9 @@ const mailgoCheckRender = event => { if (path) { path.forEach(element => { + console.log(element); + if (element instanceof HTMLDocument || element instanceof Window) return; + // 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 @@ -587,9 +602,11 @@ const mailgoCheckRender = event => { * mailgoKeydown * function to manage the keydown event when the modal is showing */ -const mailgoKeydown = () => { +const mailgoKeydown = event => { + console.log(event); // if mailgo is showing if (mailgoIsShowing(MAIL_TYPE)) { + console.log("son qui"); switch (event.keyCode) { case 27: // Escape @@ -597,20 +614,20 @@ const mailgoKeydown = () => { break; case 71: // g -> open GMail - actions.openGmail(mail, cc, bcc, subject, bodyMail); + actions.openGmail(); break; case 79: // o -> open Outlook - actions.openOutlook(mail, subject, bodyMail); + actions.openOutlook(); break; case 32: case 13: // spacebar or enter -> open default - actions.openDefault(encEmail); + actions.openDefault(); break; case 67: // c -> copy - actions.copy(mail, copyButton); + actions.copy(mail); break; default: return; @@ -623,20 +640,20 @@ const mailgoKeydown = () => { break; case 71: // g -> open GMail - actions.openGmail(mail, cc, bcc, subject, bodyMail); + actions.openGmail(); break; case 79: // o -> open Outlook - actions.openOutlook(mail, subject, bodyMail); + actions.openOutlook(); break; case 32: case 13: // spacebar or enter -> open default - actions.openDefault(encEmail); + actions.openDefault(); break; case 67: // c -> copy - actions.copy(tel, copyButton); + actions.copy(tel); break; default: return; @@ -669,9 +686,12 @@ const hideMailgo = () => { // is the mailgo modal hidden? const mailgoIsShowing = (type = MAIL_TYPE) => { - type === TEL_TYPE - ? getDisplay("mailgo-tel") === "flex" - : getDisplay("mailgo") === "flex"; + if (type === MAIL_TYPE) { + return getDisplay("mailgo") === "flex"; + } else if (type === TEL_TYPE) { + return getDisplay("mailgo-tel") === "flex"; + } + return false; }; // decrypt email