diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index e62d55e..e9dd24f 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:",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-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-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.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-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 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 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 v=document.createElement("span");v.id="mailgo-subject-value",p.appendChild(u),p.appendChild(v),l.appendChild(p);var f=document.createElement("p");f.id="mailgo-body";var C=document.createElement("span");C.className="mailgo-weight-500";var b=document.createTextNode("body ");C.appendChild(b);var E=document.createElement("span");E.id="mailgo-body-value",f.appendChild(C),f.appendChild(E),l.appendChild(f),o.appendChild(l);var y=document.createElement("a");y.id="mailgo-gmail",y.href="#mailgo-gmail",y.classList.add("mailgo-open"),y.classList.add("mailgo-gmail");var L=document.createTextNode("open in ");y.appendChild(L);var w=document.createElement("span");w.className="mailgo-weight-500";var x=document.createTextNode("Gmail");w.appendChild(x),y.appendChild(w),o.appendChild(y);var T=document.createElement("a");T.id="mailgo-outlook",T.href="#mailgo-outlook",T.classList.add("mailgo-open"),T.classList.add("mailgo-outlook");var k=document.createTextNode("open in ");T.appendChild(k);var N=document.createElement("span");N.className="mailgo-weight-500";var A=document.createTextNode("Outlook");N.appendChild(A),T.appendChild(N),o.appendChild(T);var M=document.createElement("a");M.id="mailgo-open",M.href="#mailgo-open",M.classList.add("mailgo-open"),M.classList.add("mailgo-default");var S=document.createElement("span");S.className="mailgo-weight-500";var I=document.createTextNode("open");S.appendChild(I);var R=document.createTextNode(" default");M.appendChild(S),M.appendChild(R),o.appendChild(M);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),o.appendChild(j);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 z=document.createTextNode("mailgo.js.org");U.appendChild(z),o.appendChild(U),document.body.appendChild(e),a.addEventListener("click",hideMailgo)},mailgoTelInit=function(){var e=document.createElement("div");e.style.display="none",e.id="mailgo-tel",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("a");l.id="mailgo-wa",l.href="#mailgo-wa",l.classList.add("mailgo-open"),l.classList.add("mailgo-wa");var n=document.createTextNode("open in ");l.appendChild(n);var i=document.createElement("span");i.className="mailgo-weight-500";var d=document.createTextNode("WhatsApp");i.appendChild(d),l.appendChild(i),o.appendChild(l);var c=document.createElement("a");c.id="mailgo-telegram",c.href="#mailgo-telegram",c.classList.add("mailgo-open"),c.classList.add("mailgo-telegram");var m=document.createTextNode("open in ");c.appendChild(m);var r=document.createElement("span");r.className="mailgo-weight-500";var s=document.createTextNode("Telegram");r.appendChild(s),c.appendChild(r),o.appendChild(c);var g=document.createElement("a");g.id="mailgo-open",g.href="#mailgo-open",g.classList.add("mailgo-open"),g.classList.add("mailgo-default");var p=document.createElement("span");p.className="mailgo-weight-500";var u=document.createTextNode("call");p.appendChild(u);var h=document.createTextNode(" default");g.appendChild(p),g.appendChild(h),o.appendChild(g);var v=document.createElement("a");v.id="mailgo-copy",v.href="#mailgo-copy",v.classList.add("mailgo-copy"),v.classList.add("mailgo-weight-500");var f=document.createTextNode("copy");v.appendChild(f),o.appendChild(v);var C=document.createElement("a");C.href="https://mailgo.js.org?ref=mailgo-modal",C.className="mailgo-by",C.target="_blank",C.rel="noopener noreferrer";var b=document.createTextNode("mailgo.js.org");C.appendChild(b),o.appendChild(C),document.body.appendChild(e),a.addEventListener("click",hideMailgo)},mailgoRender=function(e){var a="",o="",t="",l="",n="",i="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){o=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),a=new URL(e.href);var d=new URLSearchParams(a.search);t=d.get("cc"),l=d.get("bcc"),n=d.get("subject"),i=d.get("body")}else o=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),a=new URL(MAILTO+encodeURIComponent(o)),t=e.getAttribute("data-cc-address")+"@"+e.getAttribute("data-cc-domain"),l=e.getAttribute("data-bcc-address")+"@"+e.getAttribute("data-bcc-domain"),n=e.getAttribute("data-subject"),i=e.getAttribute("data-body");if(validateEmails(o.split(","))){t&&!validateEmails(t.split(","))&&(t=""),l&&!validateEmails(l.split(","))&&(l="");var c=getE("mailgo-title"),m=(getE("mailgo-details"),getE("mailgo-cc")),r=getE("mailgo-cc-value"),s=getE("mailgo-bcc"),g=getE("mailgo-bcc-value"),p=getE("mailgo-subject"),u=getE("mailgo-subject-value"),h=getE("mailgo-body"),v=getE("mailgo-body-value"),f=getE("mailgo-gmail"),C=getE("mailgo-outlook"),b=getE("mailgo-open"),E=getE("mailgo-copy");c.innerHTML=o.split(",").join("
"),t?(m.style.display="block",r.innerHTML=t.split(",").join("
")):m.style.display="none",l?(s.style.display="block",g.innerHTML=l.split(",").join("
")):s.style.display="none",n?(p.style.display="block",u.textContent=n):p.style.display="none",i?(h.style.display="block",v.textContent=i):h.style.display="none",f.addEventListener("click",function(){return actions.openGmail(o,t,l,n,i)}),C.addEventListener("click",function(){return actions.openOutlook(o,n,i)});var y=encodeEmail(o);b.addEventListener("click",function(){return actions.openDefault(y)}),E.addEventListener("click",function(){return actions.copy(o,E)}),showMailgo(),document.addEventListener("keydown",function(){return mailgoKeydown(o,t,l,n,i,y,E)})}},mailgoTelRender=function(e){var a="";e.href&&e.href.toLowerCase().startsWith(TEL)&&(a=decodeURIComponent(e.href.split("?")[0].split(TEL)[1].trim())),e.href&&e.href.toLowerCase().startsWith(CALLTO)&&(a=decodeURIComponent(e.href.split("?")[0].split(CALLTO)[1].trim()));var o=getE("mailgo-title"),t=getE("mailgo-wa"),l=getE("mailgo-telegram"),n=getE("mailgo-call"),i=getE("mailgo-copy");o.innerHTML=a,t.addEventListener("click",function(){return actions.openWhatsApp(a)}),l.addEventListener("click",function(){return actions.openTelegram(a)}),n.addEventListener("click",function(){return actions.callDefault(a)}),i.addEventListener("click",function(){return actions.copy(a,i)}),showMailgoTel()},actions={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){mailToEncoded(e)},openWhatsApp:function(e,a){var o="https://wa.me/"+e;window.open(o,"_blank")},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)},showMailgo=function(){return getE("mailgo").style.display="flex"},showMailgoTel=function(){return getE("mailgo-tel").style.display="flex"},hideMailgo=function(){return getE("mailgo").style.display="none"},mailgoIsShowing=function(){return"flex"===getE("mailgo").style.display},mailToEncoded=function(e){return window.location.href=MAILTO+atob(e)},encodeEmail=function(e){return btoa(e)},getE=function(e){return document.getElementById(e)},composedPath=function(e){for(var a=[];e;){if(a.push(e),"HTML"===e.tagName)return a.push(document),a.push(window),a;e=e.parentElement}},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"),t?(m.style.display="block",r.innerHTML=t.split(",").join("
")):m.style.display="none",l?(s.style.display="block",g.innerHTML=l.split(",").join("
")):s.style.display="none",n?(p.style.display="block",u.textContent=n):p.style.display="none",i?(h.style.display="block",v.textContent=i):h.style.display="none",f.addEventListener("click",function(){return actions.openGmail(o,t,l,n,i)}),C.addEventListener("click",function(){return actions.openOutlook(o,n,i)});var y=encodeEmail(o);b.addEventListener("click",function(){return actions.openDefault(y)}),E.addEventListener("click",function(){return actions.copy(o,E)}),showMailgo(),document.addEventListener("keydown",function(){return mailgoKeydown(o,t,l,n,i,y,E)})}},mailgoTelRender=function(e){var a="";e.href&&e.href.toLowerCase().startsWith(TEL)&&(a=decodeURIComponent(e.href.split("?")[0].split(TEL)[1].trim())),e.href&&e.href.toLowerCase().startsWith(CALLTO)&&(a=decodeURIComponent(e.href.split("?")[0].split(CALLTO)[1].trim()));var o=getE("mailgo-title"),t=getE("mailgo-wa"),l=getE("mailgo-telegram"),n=getE("mailgo-call"),i=getE("mailgo-copy");o.innerHTML=a,t.addEventListener("click",function(){return actions.openWhatsApp(a)}),l.addEventListener("click",function(){return actions.openTelegram(a)}),n.addEventListener("click",function(){return actions.callDefault(a)}),i.addEventListener("click",function(){return actions.copy(a,i)}),showMailgoTel()},actions={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){mailToEncoded(e)},openWhatsApp:function(e,a){var o="https://wa.me/"+e;window.open(o,"_blank")},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)},showMailgo=function(){return getE("mailgo").style.display="flex"},showMailgoTel=function(){return getE("mailgo-tel").style.display="flex"},hideMailgo=function(){return getE("mailgo").style.display="none"},mailgoIsShowing=function(){return"flex"===getE("mailgo").style.display},mailToEncoded=function(e){return window.location.href=MAILTO+atob(e)},encodeEmail=function(e){return btoa(e)},getE=function(e){return document.getElementById(e)},composedPath=function(e){for(var a=[];e;){if(a.push(e),"HTML"===e.tagName)return a.push(document),a.push(window),a;e=e.parentElement}},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"),o?(s.style.display="block",f.innerHTML=o.split(",").join("
")):s.style.display="none",n?(v.style.display="block",b.innerHTML=n.split(",").join("
")):v.style.display="none",d?(y.style.display="block",C.textContent=d):y.style.display="none",r?(x.style.display="block",w.textContent=r):x.style.display="none",E.addEventListener("click",(function(){return l.openGmail(t,o,n,d,r)})),k.addEventListener("click",(function(){return l.openOutlook(t,d,r)}));var T=g(t);L.addEventListener("click",(function(){return l.openDefault(T)})),N.addEventListener("click",(function(){return l.copy(t,N)})),c(),document.addEventListener("keydown",(function(){return i(t,o,n,d,r,T,N)}))}}(a)):function(e){return e.href&&(e.href.toLowerCase().startsWith("tel:")||e.href.toLowerCase().startsWith("callto:"))&&!e.classList.contains("no-mailgo")}(a)?(e.preventDefault(),void function(e){var a="";e.href&&e.href.toLowerCase().startsWith("tel:")&&(a=decodeURIComponent(e.href.split("?")[0].split("tel:")[1].trim())),e.href&&e.href.toLowerCase().startsWith("callto:")&&(a=decodeURIComponent(e.href.split("?")[0].split("callto:")[1].trim()));var t=u("mailgo-title"),o=u("mailgo-wa"),n=u("mailgo-telegram"),i=u("mailgo-call"),d=u("mailgo-copy");t.innerHTML=a,o.addEventListener("click",(function(){return l.openWhatsApp(a)})),n.addEventListener("click",(function(){return l.openTelegram(a)})),i.addEventListener("click",(function(){return l.callDefault(a)})),d.addEventListener("click",(function(){return l.copy(a,d)})),r()}(a)):void 0}))}}));var d=function(e){return/^(([^<>()[\]\\.,;:\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)},c=function(){return u("mailgo").style.display="flex"},r=function(){return u("mailgo-tel").style.display="flex"},m=function(){return u("mailgo").style.display="none"},p=function(){return"flex"===u("mailgo").style.display},s=function(e){return window.location.href="mailto:"+atob(e)},g=function(e){return btoa(e)},u=function(e){return document.getElementById(e)},f=function(e){for(var a=[];e;){if(a.push(e),"HTML"===e.tagName)return a.push(document),a.push(window),a;e=e.parentElement}},h=function(e){return e.every(d)},v=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 t=0"),o?(s.style.display="block",f.innerHTML=o.split(",").join("
")):s.style.display="none",n?(v.style.display="block",b.innerHTML=n.split(",").join("
")):v.style.display="none",d?(y.style.display="block",C.textContent=d):y.style.display="none",r?(x.style.display="block",w.textContent=r):x.style.display="none",E.addEventListener("click",(function(){return l.openGmail(t,o,n,d,r)})),k.addEventListener("click",(function(){return l.openOutlook(t,d,r)}));var T=g(t);L.addEventListener("click",(function(){return l.openDefault(T)})),N.addEventListener("click",(function(){return l.copy(t,N)})),c(),document.addEventListener("keydown",(function(){return i(t,o,n,d,r,T,N)}))}}(a)):function(e){return e.href&&(e.href.toLowerCase().startsWith("tel:")||e.href.toLowerCase().startsWith("callto:"))&&!e.classList.contains("no-mailgo")}(a)?(e.preventDefault(),void function(e){var a="";e.href&&e.href.toLowerCase().startsWith("tel:")&&(a=decodeURIComponent(e.href.split("?")[0].split("tel:")[1].trim())),e.href&&e.href.toLowerCase().startsWith("callto:")&&(a=decodeURIComponent(e.href.split("?")[0].split("callto:")[1].trim()));var t=u("mailgo-title"),o=u("mailgo-wa"),n=u("mailgo-telegram"),i=u("mailgo-call"),d=u("mailgo-copy");t.innerHTML=a,o.addEventListener("click",(function(){return l.openWhatsApp(a)})),n.addEventListener("click",(function(){return l.openTelegram(a)})),i.addEventListener("click",(function(){return l.callDefault(a)})),d.addEventListener("click",(function(){return l.copy(a,d)})),r()}(a)):void 0}))}}));var d=function(e){return/^(([^<>()[\]\\.,;:\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)},c=function(){return u("mailgo").style.display="flex"},r=function(){return u("mailgo-tel").style.display="flex"},m=function(){return u("mailgo").style.display="none"},p=function(){return"flex"===u("mailgo").style.display},s=function(e){return window.location.href="mailto:"+atob(e)},g=function(e){return btoa(e)},u=function(e){return document.getElementById(e)},f=function(e){for(var a=[];e;){if(a.push(e),"HTML"===e.tagName)return a.push(document),a.push(window),a;e=e.parentElement}},h=function(e){return e.every(d)},v=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 t=0 { // call default let call = document.createElement("a"); - call.id = "mailgo-open"; - call.href = "#mailgo-open"; + call.id = "mailgo-call"; + call.href = "#mailgo-call"; + call.classList.add("mailgo-open"); call.classList.add("mailgo-open"); - call.classList.add("mailgo-default"); let callSpan = document.createElement("span"); callSpan.className = "mailgo-weight-500"; let callSpanContent = document.createTextNode("call");