diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..62e2b3d --- /dev/null +++ b/babel.config.js @@ -0,0 +1,7 @@ +const presets = [ + ["@babel/env", {}], + ["@babel/preset-flow", {}], + "@babel/preset-typescript", +]; + +module.exports = { presets }; diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index 43d0ee6..9845164 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mailgo=t():e.mailgo=t()}(window,(function(){return function(e){var t={};function o(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,a){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(a,n,function(t){return e[t]}.bind(null,n));return a},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=0)}([function(e,t,o){"use strict";o.r(t);const a="javascript:void(0);",n="span";let l,i,d,s,m,c,r,p,b,u,h,g,f,x,w,y,C,k,v,L,z="",j="",A="",E="",N="",S="",R="",U="",I="",M="";const _=()=>{{let e=X();e.style.display="none",e.id="mailgo",e.classList.add("m-modal");let t=X();t.className="m-modal-back",e.appendChild(t);let o=X();o.className="m-modal-content",e.appendChild(o),i=X("strong"),i.id="m-title",i.className="m-title",o.appendChild(i);let l=X();l.id="m-details",l.className="m-details",s=X("p"),s.id="m-cc";let d=X(n);d.className="w-500",d.appendChild(Y("cc ")),p=X(n),p.id="m-cc-value",s.appendChild(d),s.appendChild(p),l.appendChild(s),m=X("p"),m.id="m-bcc";let w=X(n);w.className="w-500",w.appendChild(Y("bcc ")),b=X(n),b.id="m-bcc-value",m.appendChild(w),m.appendChild(b),l.appendChild(m),c=X("p"),c.id="m-subject";let y=X(n);y.className="w-500",y.appendChild(Y("subject ")),u=X(n),u.id="m-subject-value",c.appendChild(y),c.appendChild(u),l.appendChild(c),r=X("p"),r.id="m-body";let C=X(n);C.className="w-500",C.appendChild(Y("body ")),h=X(n),h.id="m-body-value",r.appendChild(C),r.appendChild(h),l.appendChild(r),o.appendChild(l),g=X("a"),g.id="m-gmail",g.href=a,g.classList.add("m-open"),g.classList.add("m-gmail"),g.appendChild(Y("open in "));let k=X(n);k.className="w-500",k.appendChild(Y("Gmail")),g.appendChild(k),o.appendChild(g),f=X("a"),f.id="m-outlook",f.href=a,f.classList.add("m-open"),f.classList.add("m-outlook"),f.appendChild(Y("open in "));let L=X(n);L.className="w-500",L.appendChild(Y("Outlook")),f.appendChild(L),o.appendChild(f),x=X("a"),x.id="m-open",x.href=a,x.classList.add("m-open"),x.classList.add("m-default");let z=X(n);z.className="w-500",z.appendChild(Y("open")),x.appendChild(z),x.appendChild(Y(" default")),o.appendChild(x),v=X("a"),v.id="m-copy",v.href=a,v.classList.add("m-copy"),v.classList.add("w-500"),v.appendChild(Y("copy")),o.appendChild(v),o.appendChild(V()),document.body.appendChild(e),t.addEventListener("click",K)}{let e=X();e.style.display="none",e.id="mailgo-tel",e.classList.add("m-modal");let t=X();t.className="m-modal-back",e.appendChild(t);let o=X();o.className="m-modal-content",e.appendChild(o),d=X("strong"),d.id="m-tel-title",d.className="m-title",o.appendChild(d),w=X("a"),w.id="m-tg",w.href=a,w.classList.add("m-open"),w.classList.add("m-tg"),w.style.display="none",w.appendChild(Y("open in "));let l=X(n);l.className="w-500",l.appendChild(Y("Telegram")),w.appendChild(l),o.appendChild(w),y=X("a"),y.id="m-wa",y.href=a,y.classList.add("m-open"),y.classList.add("m-wa"),y.appendChild(Y("open in "));let i=X(n);i.className="w-500",i.appendChild(Y("WhatsApp")),y.appendChild(i),o.appendChild(y),C=X("a"),C.id="m-skype",C.href=a,C.classList.add("m-open"),C.classList.add("m-skype"),C.appendChild(Y("open in "));let s=X(n);s.className="w-500",s.appendChild(Y("Skype")),C.appendChild(s),o.appendChild(C),k=X("a"),k.id="m-call",k.href=a,k.classList.add("m-open"),k.classList.add("m-default");let m=X(n);m.className="w-500",m.appendChild(Y("call")),k.appendChild(m),k.appendChild(Y(" as default")),o.appendChild(k),L=X("a"),L.id="m-tel-copy",L.href=a,L.classList.add("m-copy"),L.classList.add("w-500"),L.appendChild(Y("copy")),o.appendChild(L),o.appendChild(V()),document.body.appendChild(e),t.addEventListener("click",K)}},T=(e="mail",t)=>{if("mail"===e){if(t.href&&t.href.toLowerCase().startsWith("mailto:")){z=decodeURIComponent(t.href.split("?")[0].split("mailto:")[1].trim()),l=new URL(t.href);let e=l.searchParams;A=e.get("cc"),E=e.get("bcc"),N=e.get("subject"),S=e.get("body")}else z=t.getAttribute("data-address")+"@"+t.getAttribute("data-domain"),l=new URL("mailto:"+encodeURIComponent(z)),A=t.getAttribute("data-cc-address")+"@"+t.getAttribute("data-cc-domain"),E=t.getAttribute("data-bcc-address")+"@"+t.getAttribute("data-bcc-domain"),N=t.getAttribute("data-subject"),S=t.getAttribute("data-body");if(!de(z.split(",")))return;A&&!de(A.split(","))&&(A=""),E&&!de(E.split(","))&&(E=""),i.innerHTML=z.split(",").join("
"),A?(s.style.display="block",p.innerHTML=A.split(",").join("
")):s.style.display="none",E?(m.style.display="block",b.innerHTML=E.split(",").join("
")):m.style.display="none",N?(c.style.display="block",u.textContent=N):c.style.display="none",S?(r.style.display="block",h.textContent=S):r.style.display="none",g.addEventListener("click",O),f.addEventListener("click",P),j=te(z),x.addEventListener("click",W),v.addEventListener("click",()=>F(z))}"tel"===e&&(t.href&&t.href.toLowerCase().startsWith("tel:")?R=decodeURIComponent(t.href.split("?")[0].split("tel:")[1].trim()):t.href&&t.href.toLowerCase().startsWith("callto:")?R=decodeURIComponent(t.href.split("?")[0].split("callto:")[1].trim()):t.hasAttribute("data-tel")&&(R=t.getAttribute("data-tel"),U=t.getAttribute("data-msg")),t.hasAttribute("data-telegram")&&(I=t.getAttribute("data-telegram")),t.hasAttribute("data-skype")&&(M=t.getAttribute("data-skype")),d.innerHTML=R,y.addEventListener("click",B),I&&(ne("m-tg","block"),w.addEventListener("click",H)),C.addEventListener("click",D),k.addEventListener("click",Z),L.addEventListener("click",()=>F(R))),J(e),document.addEventListener("keydown",q)},O=()=>{let e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(z);A&&(e=e.concat("&cc="+encodeURIComponent(A))),E&&(e=e.concat("&bcc="+encodeURIComponent(E))),N&&(e=e.concat("&subject="+N)),S&&(e=e.concat("&body="+S)),window.open(e,"_blank"),K()},P=()=>{let e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(z);N&&(e=e.concat("&subject="+N)),S&&(e=e.concat("&body="+S)),window.open(e,"_blank"),K()},W=()=>{ee(j),K()},H=()=>{let e="https://t.me/"+I;window.open(e,"_blank"),K()},D=()=>{let e="skype:"+(""!==M?M:R);window.open(e,"_blank"),K()},B=()=>{let e="https://wa.me/"+R;window.open(e,"_blank"),K()},Z=()=>{let e="tel:"+R;window.open(e),K()},F=e=>{let t;se(e),t=Q("mail")?v:L,t.textContent="copied",setTimeout(()=>{t.textContent="copy",K()},999)},G=(e,t="mail")=>{let o=e.href;return"mail"===t?o&&o.toLowerCase().startsWith("mailto:")&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(o&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")):"tel"===t&&(o&&(o.toLowerCase().startsWith("tel:")||o.toLowerCase().startsWith("callto:"))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&o&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))},$=e=>{if(!document.contains(oe("mailgo"))||!document.contains(oe("mailgo-tel")))return;if(Q("mail")||Q("tel"))return!1;let t=e.composedPath&&e.composedPath()||le(e.target);return t&&t.forEach(t=>!(t instanceof HTMLDocument||t instanceof Window)&&(G(t,"mail")?(e.preventDefault(),T("mail",t),!0):G(t,"tel")?(e.preventDefault(),T("tel",t),!0):void 0)),!1},q=e=>{if(Q("mail"))switch(e.keyCode){case 27:K();break;case 71:O();break;case 79:P();break;case 32:case 13:W();break;case 67:F(z);break;default:return}else if(Q("tel"))switch(e.keyCode){case 27:K();break;case 84:H();break;case 87:B();break;case 32:case 13:Z();break;case 67:F(R);break;default:return}},J=(e="mail")=>"mail"===e?(ne("mailgo","flex"),!0):"tel"===e&&(ne("mailgo-tel","flex"),!0),K=()=>{ne("mailgo","none"),ne("mailgo-tel","none"),document.removeEventListener("keydown",q)},Q=(e="mail")=>"mail"===e?"flex"===ae("mailgo"):"tel"===e&&"flex"===ae("mailgo-tel"),V=()=>{let e=X("a");return e.href="https://mailgo.js.org?ref=mailgo-modal",e.className="m-by",e.target="_blank",e.rel="noopener noreferrer",e.appendChild(Y("mailgo.js.org")),e},X=(e="div")=>document.createElement(e),Y=e=>document.createTextNode(e),ee=e=>window.location.href="mailto:"+atob(e),te=e=>btoa(e),oe=e=>document.getElementById(e),ae=e=>oe(e).style.display,ne=(e,t)=>oe(e).style.display=t,le=e=>{let t=[];for(;e;){if(t.push(e),"HTML"===e.tagName)return t.push(document),t.push(window),t;e=e.parentElement}},ie=e=>/^(([^<>()[\]\\.,;:\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),de=e=>e.every(ie),se=e=>{let t=X("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);let o=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);return t.select(),document.execCommand("copy"),document.body.removeChild(t),!!o&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(o),!0)};(e=>{window&&"undefined"!=typeof window&&((()=>{let e=X("style");e.id="mailgo-style",e.type="text/css",e.appendChild(Y('.m-modal{position:fixed;top:0;right:0;bottom:0;left:0;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal a,.m-modal p,.m-modal span,.m-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";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.m-modal .m-modal-content{position:relative;z-index:10002;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;-webkit-box-shadow:0 3px 20px rgba(32,35,42,.5);-moz-box-shadow:0 3px 20px rgba(32,35,42,.5);box-shadow:0 3px 20px rgba(32,35,42,.5);color:#4a4a4a;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:auto;padding:20px;-webkit-transition:.5s -webkit-box-shadow;transition:.5s -webkit-box-shadow;-o-transition:.5s box-shadow;-moz-transition:.5s box-shadow,.5s -moz-box-shadow;transition:.5s box-shadow;transition:.5s box-shadow,.5s -webkit-box-shadow,.5s -moz-box-shadow}.m-modal .m-modal-content:hover{opacity:1;-webkit-box-shadow:0 7px 20px rgba(32,35,42,.85);-moz-box-shadow:0 7px 20px rgba(32,35,42,.85);box-shadow:0 7px 20px rgba(32,35,42,.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;-o-text-overflow:ellipsis;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-copy:hover,.m-modal .m-modal-content a.m-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:.8rem;padding:5px;color:#4a4a4a;opacity:.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}')),document.head.appendChild(e)})(),(null==e?void 0:e.initEvent)?document.addEventListener(e.initEvent,_):_(),document.addEventListener("click",$))})({initEvent:"DOMContentLoaded"})}])})); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.mailgo=t():e.mailgo=t()}(window,(function(){return function(e){var t={};function o(a){if(t[a])return t[a].exports;var n=t[a]={i:a,l:!1,exports:{}};return e[a].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,a){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(o.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(a,n,function(t){return e[t]}.bind(null,n));return a},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=1)}([function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a,n,i,d,l,r,c,s,m,p,u,b,f,h,g,x,v,w,y,C="mailto:",k="tel:",L="callto:",z="javascript:void(0);",j="span",A="",E="",N="",S="",R="",_="",M="",U="",I="",T=function(){var e=Y();e.style.display="none",e.id="mailgo",e.classList.add("m-modal");var t=Y();t.className="m-modal-back",e.appendChild(t);var o=Y();o.className="m-modal-content",e.appendChild(o),(a=Y("strong")).id="m-title",a.className="m-title",o.appendChild(a);var C=Y();C.id="m-details",C.className="m-details",(i=Y("p")).id="m-cc";var k=Y(j);k.className="w-500",k.appendChild(ee("cc ")),(c=Y(j)).id="m-cc-value",i.appendChild(k),i.appendChild(c),C.appendChild(i),(d=Y("p")).id="m-bcc";var L=Y(j);L.className="w-500",L.appendChild(ee("bcc ")),(s=Y(j)).id="m-bcc-value",d.appendChild(L),d.appendChild(s),C.appendChild(d),(l=Y("p")).id="m-subject";var A=Y(j);A.className="w-500",A.appendChild(ee("subject ")),(m=Y(j)).id="m-subject-value",l.appendChild(A),l.appendChild(m),C.appendChild(l),(r=Y("p")).id="m-body";var E=Y(j);E.className="w-500",E.appendChild(ee("body ")),(p=Y(j)).id="m-body-value",r.appendChild(E),r.appendChild(p),C.appendChild(r),o.appendChild(C),(u=Y("a")).id="m-gmail",u.href=z,u.classList.add("m-open"),u.classList.add("m-gmail"),u.appendChild(ee("open in "));var N=Y(j);N.className="w-500",N.appendChild(ee("Gmail")),u.appendChild(N),o.appendChild(u),(b=Y("a")).id="m-outlook",b.href=z,b.classList.add("m-open"),b.classList.add("m-outlook"),b.appendChild(ee("open in "));var S=Y(j);S.className="w-500",S.appendChild(ee("Outlook")),b.appendChild(S),o.appendChild(b),(f=Y("a")).id="m-open",f.href=z,f.classList.add("m-open"),f.classList.add("m-default");var R=Y(j);R.className="w-500",R.appendChild(ee("open")),f.appendChild(R),f.appendChild(ee(" default")),o.appendChild(f),(w=Y("a")).id="m-copy",w.href=z,w.classList.add("m-copy"),w.classList.add("w-500"),w.appendChild(ee("copy")),o.appendChild(w),o.appendChild(X()),document.body.appendChild(e),t.addEventListener("click",Q);var _=Y();_.style.display="none",_.id="mailgo-tel",_.classList.add("m-modal");var M=Y();M.className="m-modal-back",_.appendChild(M);var U=Y();U.className="m-modal-content",_.appendChild(U),(n=Y("strong")).id="m-tel-title",n.className="m-title",U.appendChild(n),(h=Y("a")).id="m-tg",h.href=z,h.classList.add("m-open"),h.classList.add("m-tg"),h.style.display="none",h.appendChild(ee("open in "));var I=Y(j);I.className="w-500",I.appendChild(ee("Telegram")),h.appendChild(I),U.appendChild(h),(g=Y("a")).id="m-wa",g.href=z,g.classList.add("m-open"),g.classList.add("m-wa"),g.appendChild(ee("open in "));var T=Y(j);T.className="w-500",T.appendChild(ee("WhatsApp")),g.appendChild(T),U.appendChild(g),(x=Y("a")).id="m-skype",x.href=z,x.classList.add("m-open"),x.classList.add("m-skype"),x.appendChild(ee("open in "));var O=Y(j);O.className="w-500",O.appendChild(ee("Skype")),x.appendChild(O),U.appendChild(x),(v=Y("a")).id="m-call",v.href=z,v.classList.add("m-open"),v.classList.add("m-default");var P=Y(j);P.className="w-500",P.appendChild(ee("call")),v.appendChild(P),v.appendChild(ee(" as default")),U.appendChild(v),(y=Y("a")).id="m-tel-copy",y.href=z,y.classList.add("m-copy"),y.classList.add("w-500"),y.appendChild(ee("copy")),U.appendChild(y),U.appendChild(X()),document.body.appendChild(_),M.addEventListener("click",Q)},O=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"mail",t=arguments.length>1?arguments[1]:void 0;if("mail"===e){if(t.href&&t.href.toLowerCase().startsWith(C)){A=decodeURIComponent(t.href.split("?")[0].split(C)[1].trim());var o=new URL(t.href).searchParams;N=o.get("cc"),S=o.get("bcc"),R=o.get("subject"),_=o.get("body")}else A=t.getAttribute("data-address")+"@"+t.getAttribute("data-domain"),new URL(C+encodeURIComponent(A)),N=t.getAttribute("data-cc-address")+"@"+t.getAttribute("data-cc-domain"),S=t.getAttribute("data-bcc-address")+"@"+t.getAttribute("data-bcc-domain"),R=t.getAttribute("data-subject"),_=t.getAttribute("data-body");if(!re(A.split(",")))return;N&&!re(N.split(","))&&(N=""),S&&!re(S.split(","))&&(S=""),a.innerHTML=A.split(",").join("
"),N?(i.style.display="block",c.innerHTML=N.split(",").join("
")):i.style.display="none",S?(d.style.display="block",s.innerHTML=S.split(",").join("
")):d.style.display="none",R?(l.style.display="block",m.textContent=R):l.style.display="none",_?(r.style.display="block",p.textContent=_):r.style.display="none",u.addEventListener("click",P),b.addEventListener("click",W),E=oe(A),f.addEventListener("click",H),w.addEventListener("click",(function(){return G(A)}))}"tel"===e&&(t.href&&t.href.toLowerCase().startsWith(k)?M=decodeURIComponent(t.href.split("?")[0].split(k)[1].trim()):t.href&&t.href.toLowerCase().startsWith(L)?M=decodeURIComponent(t.href.split("?")[0].split(L)[1].trim()):t.hasAttribute("data-tel")&&(M=t.getAttribute("data-tel"),t.getAttribute("data-msg")),t.hasAttribute("data-telegram")&&(U=t.getAttribute("data-telegram")),t.hasAttribute("data-skype")&&(I=t.getAttribute("data-skype")),n.innerHTML=M,g.addEventListener("click",Z),U&&(ie("m-tg","block"),h.addEventListener("click",D)),x.addEventListener("click",B),v.addEventListener("click",F),y.addEventListener("click",(function(){return G(M)}))),K(e),document.addEventListener("keydown",J)},P=function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(A);N&&(e=e.concat("&cc="+encodeURIComponent(N))),S&&(e=e.concat("&bcc="+encodeURIComponent(S))),R&&(e=e.concat("&subject="+R)),_&&(e=e.concat("&body="+_)),window.open(e,"_blank"),Q()},W=function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(A);R&&(e=e.concat("&subject="+R)),_&&(e=e.concat("&body="+_)),window.open(e,"_blank"),Q()},H=function(){te(E),Q()},D=function(){var e="https://t.me/"+U;window.open(e,"_blank"),Q()},B=function(){var e="skype:"+(""!==I?I:M);window.open(e,"_blank"),Q()},Z=function(){var e="https://wa.me/"+M;window.open(e,"_blank"),Q()},F=function(){var e="tel:"+M;window.open(e),Q()},G=function(e){var t;ce(e),(t=V("mail")?w:y).textContent="copied",setTimeout((function(){t.textContent="copy",Q()}),999)},$=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"mail",o=e.href;return"mail"===t?o&&o.toLowerCase().startsWith(C)&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(o&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")):"tel"===t&&(o&&(o.toLowerCase().startsWith(k)||o.toLowerCase().startsWith(L))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&o&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))},q=function(e){if(document.contains(ae("mailgo"))&&document.contains(ae("mailgo-tel"))){if(V("mail")||V("tel"))return!1;var t=e.composedPath&&e.composedPath()||de(e.target);return t&&t.forEach((function(t){return!(t instanceof HTMLDocument||t instanceof Window)&&($(t,"mail")?(e.preventDefault(),O("mail",t),!0):$(t,"tel")?(e.preventDefault(),O("tel",t),!0):void 0)})),!1}},J=function(e){if(V("mail"))switch(e.keyCode){case 27:Q();break;case 71:P();break;case 79:W();break;case 32:case 13:H();break;case 67:G(A);break;default:return}else if(V("tel"))switch(e.keyCode){case 27:Q();break;case 84:D();break;case 87:Z();break;case 32:case 13:F();break;case 67:G(M);break;default:return}},K=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"mail";return"mail"===e?(ie("mailgo","flex"),!0):"tel"===e&&(ie("mailgo-tel","flex"),!0)},Q=function(){ie("mailgo","none"),ie("mailgo-tel","none"),document.removeEventListener("keydown",J)},V=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"mail";return"mail"===e?"flex"===ne("mailgo"):"tel"===e&&"flex"===ne("mailgo-tel")},X=function(){var e=Y("a");return e.href="https://mailgo.js.org?ref=mailgo-modal",e.className="m-by",e.target="_blank",e.rel="noopener noreferrer",e.appendChild(ee("mailgo.js.org")),e},Y=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"div";return document.createElement(e)},ee=function(e){return document.createTextNode(e)},te=function(e){return window.location.href=C+atob(e)},oe=function(e){return btoa(e)},ae=function(e){return document.getElementById(e)},ne=function(e){return ae(e).style.display},ie=function(e,t){return ae(e).style.display=t},de=function(e){for(var t=[];e;){if(t.push(e),"HTML"===e.tagName)return t.push(document),t.push(window),t;e=e.parentElement}},le=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)},re=function(e){return e.every(le)},ce=function(e){var t=Y("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);var o=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);return t.select(),document.execCommand("copy"),document.body.removeChild(t),!!o&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(o),!0)},se=function(e){var t;window&&"undefined"!=typeof window&&((t=Y("style")).id="mailgo-style",t.type="text/css",t.appendChild(ee('.m-modal{position:fixed;top:0;right:0;bottom:0;left:0;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal a,.m-modal p,.m-modal span,.m-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";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.m-modal .m-modal-content{position:relative;z-index:10002;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;-webkit-box-shadow:0 3px 20px rgba(32,35,42,.5);-moz-box-shadow:0 3px 20px rgba(32,35,42,.5);box-shadow:0 3px 20px rgba(32,35,42,.5);color:#4a4a4a;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:auto;padding:20px;-webkit-transition:.5s -webkit-box-shadow;transition:.5s -webkit-box-shadow;-o-transition:.5s box-shadow;-moz-transition:.5s box-shadow,.5s -moz-box-shadow;transition:.5s box-shadow;transition:.5s box-shadow,.5s -webkit-box-shadow,.5s -moz-box-shadow}.m-modal .m-modal-content:hover{opacity:1;-webkit-box-shadow:0 7px 20px rgba(32,35,42,.85);-moz-box-shadow:0 7px 20px rgba(32,35,42,.85);box-shadow:0 7px 20px rgba(32,35,42,.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;-o-text-overflow:ellipsis;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-copy:hover,.m-modal .m-modal-content a.m-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:.8rem;padding:5px;color:#4a4a4a;opacity:.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}')),document.head.appendChild(t),(null==e?void 0:e.initEvent)?document.addEventListener(e.initEvent,T):T(),document.addEventListener("click",q))};t.default=se},function(e,t,o){"use strict";o.r(t);var a=o(0);o.n(a)()({initEvent:"DOMContentLoaded"})}])})); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 6dd58e0..354170d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,6 +11,9 @@ const autoprefixer = require("gulp-autoprefixer"); const sass = require("gulp-sass"); sass.compiler = require("node-sass"); +const uglify = require("gulp-uglify"); +const babel = require("gulp-babel"); + const fs = require("fs"); function style() { @@ -31,21 +34,22 @@ function js() { return src("src/*.ts") .pipe(replace("MAILGO_STYLE", cssMinContent)) .pipe(tsProject()) + .pipe(babel()) .pipe(dest("./")); } +/* function ts() { let cssMinContent = fs.readFileSync("dist/mailgo.min.css", "utf8"); - return ( - src("src/*.ts") - .pipe(replace("MAILGO_STYLE", cssMinContent)) - // .pipe(tsProject()) - .pipe(dest("./")) - ); + return src("src/*.ts") + .pipe(replace("MAILGO_STYLE", cssMinContent)) + .pipe(babel()) + .pipe(dest("./")); } +*/ exports.js = js; -exports.ts = ts; +// exports.ts = ts; exports.style = style; -exports.default = series(style, ts, js); +exports.default = series(style, js); diff --git a/mailgo.js b/mailgo.js index d3ca55f..456dccf 100644 --- a/mailgo.js +++ b/mailgo.js @@ -1,455 +1,474 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; // links -const MAILTO = "mailto:"; -const TEL = "tel:"; -const CALLTO = "callto:"; -// mailgo types -const MAIL_TYPE = "mail"; -const TEL_TYPE = "tel"; -// default href for links -const DEFAULT_BTN_HREF = "javascript:void(0);"; -// html tags -const span = "span"; -// mailgo variables -let url, mail = "", encEmail = "", cc = "", bcc = "", subject = "", bodyMail = ""; -// mailgo tel variables -let tel = "", msg = "", telegramUsername = "", skypeUsername = ""; -// the DOM elements -let title, titleTel, detailCc, detailBcc, detailSubject, detailBody, ccValue, bccValue, subjectValue, bodyValue; -// mailgo buttons (actions) -let gmail, outlook, open, telegram, wa, skype, call, copyMail, copyTel; +var MAILTO = "mailto:"; +var TEL = "tel:"; +var CALLTO = "callto:"; // mailgo types + +var MAIL_TYPE = "mail"; +var TEL_TYPE = "tel"; // default href for links + +var DEFAULT_BTN_HREF = "javascript:void(0);"; // html tags + +var span = "span"; // mailgo variables + +var url, + mail = "", + encEmail = "", + cc = "", + bcc = "", + subject = "", + bodyMail = ""; // mailgo tel variables + +var tel = "", + msg = "", + telegramUsername = "", + skypeUsername = ""; // the DOM elements + +var title, titleTel, detailCc, detailBcc, detailSubject, detailBody, ccValue, bccValue, subjectValue, bodyValue; // mailgo buttons (actions) + +var gmail, outlook, open, telegram, wa, skype, call, copyMail, copyTel; /** * mailgoInit * the function that creates the mailgo elements in DOM */ -const mailgoInit = () => { - // mailgo mail - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo"; - modal.classList.add("m-modal"); - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - // title (email address) - title = createElement("strong"); - title.id = "m-title"; - title.className = "m-title"; - modalContent.appendChild(title); - // details - let details = createElement(); - details.id = "m-details"; - details.className = "m-details"; - detailCc = createElement("p"); - detailCc.id = "m-cc"; - let ccSpan = createElement(span); - ccSpan.className = "w-500"; - ccSpan.appendChild(createTextNode("cc ")); - ccValue = createElement(span); - ccValue.id = "m-cc-value"; - detailCc.appendChild(ccSpan); - detailCc.appendChild(ccValue); - details.appendChild(detailCc); - detailBcc = createElement("p"); - detailBcc.id = "m-bcc"; - let bccSpan = createElement(span); - bccSpan.className = "w-500"; - bccSpan.appendChild(createTextNode("bcc ")); - bccValue = createElement(span); - bccValue.id = "m-bcc-value"; - detailBcc.appendChild(bccSpan); - detailBcc.appendChild(bccValue); - details.appendChild(detailBcc); - detailSubject = createElement("p"); - detailSubject.id = "m-subject"; - let subjectSpan = createElement(span); - subjectSpan.className = "w-500"; - subjectSpan.appendChild(createTextNode("subject ")); - subjectValue = createElement(span); - subjectValue.id = "m-subject-value"; - detailSubject.appendChild(subjectSpan); - detailSubject.appendChild(subjectValue); - details.appendChild(detailSubject); - detailBody = createElement("p"); - detailBody.id = "m-body"; - let bodySpan = createElement(span); - bodySpan.className = "w-500"; - bodySpan.appendChild(createTextNode("body ")); - bodyValue = createElement(span); - bodyValue.id = "m-body-value"; - detailBody.appendChild(bodySpan); - detailBody.appendChild(bodyValue); - details.appendChild(detailBody); - modalContent.appendChild(details); - // Gmail - gmail = createElement("a"); - gmail.id = "m-gmail"; - gmail.href = DEFAULT_BTN_HREF; - gmail.classList.add("m-open"); - gmail.classList.add("m-gmail"); - gmail.appendChild(createTextNode("open in ")); - let gmailSpan = createElement(span); - gmailSpan.className = "w-500"; - gmailSpan.appendChild(createTextNode("Gmail")); - gmail.appendChild(gmailSpan); - modalContent.appendChild(gmail); - // Outlook - outlook = createElement("a"); - outlook.id = "m-outlook"; - outlook.href = DEFAULT_BTN_HREF; - outlook.classList.add("m-open"); - outlook.classList.add("m-outlook"); - outlook.appendChild(createTextNode("open in ")); - let outlookSpan = createElement(span); - outlookSpan.className = "w-500"; - outlookSpan.appendChild(createTextNode("Outlook")); - outlook.appendChild(outlookSpan); - modalContent.appendChild(outlook); - // open default - open = createElement("a"); - open.id = "m-open"; - open.href = DEFAULT_BTN_HREF; - open.classList.add("m-open"); - open.classList.add("m-default"); - let openSpan = createElement(span); - openSpan.className = "w-500"; - openSpan.appendChild(createTextNode("open")); - open.appendChild(openSpan); - open.appendChild(createTextNode(" default")); - modalContent.appendChild(open); - // copy - copyMail = createElement("a"); - copyMail.id = "m-copy"; - copyMail.href = DEFAULT_BTN_HREF; - copyMail.classList.add("m-copy"); - copyMail.classList.add("w-500"); - copyMail.appendChild(createTextNode("copy")); - modalContent.appendChild(copyMail); - modalContent.appendChild(byElement()); - // add the modal at the end of the body - document.body.appendChild(modal); - // every click outside the modal will hide the modal - modalBackground.addEventListener("click", hideMailgo); - } - // mailgo tel - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo-tel"; - modal.classList.add("m-modal"); - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - // title (telephone number) - titleTel = createElement("strong"); - titleTel.id = "m-tel-title"; - titleTel.className = "m-title"; - modalContent.appendChild(titleTel); - // Telegram - telegram = createElement("a"); - telegram.id = "m-tg"; - telegram.href = DEFAULT_BTN_HREF; - telegram.classList.add("m-open"); - telegram.classList.add("m-tg"); - // by default not display - telegram.style.display = "none"; - telegram.appendChild(createTextNode("open in ")); - let telegramSpan = createElement(span); - telegramSpan.className = "w-500"; - telegramSpan.appendChild(createTextNode("Telegram")); - telegram.appendChild(telegramSpan); - modalContent.appendChild(telegram); - // WhatsApp - wa = createElement("a"); - wa.id = "m-wa"; - wa.href = DEFAULT_BTN_HREF; - wa.classList.add("m-open"); - wa.classList.add("m-wa"); - wa.appendChild(createTextNode("open in ")); - let waSpan = createElement(span); - waSpan.className = "w-500"; - waSpan.appendChild(createTextNode("WhatsApp")); - wa.appendChild(waSpan); - modalContent.appendChild(wa); - // Skype - skype = createElement("a"); - skype.id = "m-skype"; - skype.href = DEFAULT_BTN_HREF; - skype.classList.add("m-open"); - skype.classList.add("m-skype"); - skype.appendChild(createTextNode("open in ")); - let skypeSpan = createElement(span); - skypeSpan.className = "w-500"; - skypeSpan.appendChild(createTextNode("Skype")); - skype.appendChild(skypeSpan); - modalContent.appendChild(skype); - // call default - call = createElement("a"); - call.id = "m-call"; - call.href = DEFAULT_BTN_HREF; - call.classList.add("m-open"); - call.classList.add("m-default"); - let callSpan = createElement(span); - callSpan.className = "w-500"; - callSpan.appendChild(createTextNode("call")); - call.appendChild(callSpan); - call.appendChild(createTextNode(" as default")); - modalContent.appendChild(call); - // copy - copyTel = createElement("a"); - copyTel.id = "m-tel-copy"; - copyTel.href = DEFAULT_BTN_HREF; - copyTel.classList.add("m-copy"); - copyTel.classList.add("w-500"); - copyTel.appendChild(createTextNode("copy")); - modalContent.appendChild(copyTel); - modalContent.appendChild(byElement()); - // add the modal at the end of the body - document.body.appendChild(modal); - // every click outside the modal will hide the modal - modalBackground.addEventListener("click", hideMailgo); - } + +var mailgoInit = function mailgoInit() { + // mailgo mail + { + // modal + var modal = createElement(); + modal.style.display = "none"; + modal.id = "mailgo"; + modal.classList.add("m-modal"); // background + + var modalBackground = createElement(); + modalBackground.className = "m-modal-back"; + modal.appendChild(modalBackground); // modal content + + var modalContent = createElement(); + modalContent.className = "m-modal-content"; + modal.appendChild(modalContent); // title (email address) + + title = createElement("strong"); + title.id = "m-title"; + title.className = "m-title"; + modalContent.appendChild(title); // details + + var details = createElement(); + details.id = "m-details"; + details.className = "m-details"; + detailCc = createElement("p"); + detailCc.id = "m-cc"; + var ccSpan = createElement(span); + ccSpan.className = "w-500"; + ccSpan.appendChild(createTextNode("cc ")); + ccValue = createElement(span); + ccValue.id = "m-cc-value"; + detailCc.appendChild(ccSpan); + detailCc.appendChild(ccValue); + details.appendChild(detailCc); + detailBcc = createElement("p"); + detailBcc.id = "m-bcc"; + var bccSpan = createElement(span); + bccSpan.className = "w-500"; + bccSpan.appendChild(createTextNode("bcc ")); + bccValue = createElement(span); + bccValue.id = "m-bcc-value"; + detailBcc.appendChild(bccSpan); + detailBcc.appendChild(bccValue); + details.appendChild(detailBcc); + detailSubject = createElement("p"); + detailSubject.id = "m-subject"; + var subjectSpan = createElement(span); + subjectSpan.className = "w-500"; + subjectSpan.appendChild(createTextNode("subject ")); + subjectValue = createElement(span); + subjectValue.id = "m-subject-value"; + detailSubject.appendChild(subjectSpan); + detailSubject.appendChild(subjectValue); + details.appendChild(detailSubject); + detailBody = createElement("p"); + detailBody.id = "m-body"; + var bodySpan = createElement(span); + bodySpan.className = "w-500"; + bodySpan.appendChild(createTextNode("body ")); + bodyValue = createElement(span); + bodyValue.id = "m-body-value"; + detailBody.appendChild(bodySpan); + detailBody.appendChild(bodyValue); + details.appendChild(detailBody); + modalContent.appendChild(details); // Gmail + + gmail = createElement("a"); + gmail.id = "m-gmail"; + gmail.href = DEFAULT_BTN_HREF; + gmail.classList.add("m-open"); + gmail.classList.add("m-gmail"); + gmail.appendChild(createTextNode("open in ")); + var gmailSpan = createElement(span); + gmailSpan.className = "w-500"; + gmailSpan.appendChild(createTextNode("Gmail")); + gmail.appendChild(gmailSpan); + modalContent.appendChild(gmail); // Outlook + + outlook = createElement("a"); + outlook.id = "m-outlook"; + outlook.href = DEFAULT_BTN_HREF; + outlook.classList.add("m-open"); + outlook.classList.add("m-outlook"); + outlook.appendChild(createTextNode("open in ")); + var outlookSpan = createElement(span); + outlookSpan.className = "w-500"; + outlookSpan.appendChild(createTextNode("Outlook")); + outlook.appendChild(outlookSpan); + modalContent.appendChild(outlook); // open default + + open = createElement("a"); + open.id = "m-open"; + open.href = DEFAULT_BTN_HREF; + open.classList.add("m-open"); + open.classList.add("m-default"); + var openSpan = createElement(span); + openSpan.className = "w-500"; + openSpan.appendChild(createTextNode("open")); + open.appendChild(openSpan); + open.appendChild(createTextNode(" default")); + modalContent.appendChild(open); // copy + + copyMail = createElement("a"); + copyMail.id = "m-copy"; + copyMail.href = DEFAULT_BTN_HREF; + copyMail.classList.add("m-copy"); + copyMail.classList.add("w-500"); + copyMail.appendChild(createTextNode("copy")); + modalContent.appendChild(copyMail); + modalContent.appendChild(byElement()); // add the modal at the end of the body + + document.body.appendChild(modal); // every click outside the modal will hide the modal + + modalBackground.addEventListener("click", hideMailgo); + } // mailgo tel + + { + // modal + var _modal = createElement(); + + _modal.style.display = "none"; + _modal.id = "mailgo-tel"; + + _modal.classList.add("m-modal"); // background + + + var _modalBackground = createElement(); + + _modalBackground.className = "m-modal-back"; + + _modal.appendChild(_modalBackground); // modal content + + + var _modalContent = createElement(); + + _modalContent.className = "m-modal-content"; + + _modal.appendChild(_modalContent); // title (telephone number) + + + titleTel = createElement("strong"); + titleTel.id = "m-tel-title"; + titleTel.className = "m-title"; + + _modalContent.appendChild(titleTel); // Telegram + + + telegram = createElement("a"); + telegram.id = "m-tg"; + telegram.href = DEFAULT_BTN_HREF; + telegram.classList.add("m-open"); + telegram.classList.add("m-tg"); // by default not display + + telegram.style.display = "none"; + telegram.appendChild(createTextNode("open in ")); + var telegramSpan = createElement(span); + telegramSpan.className = "w-500"; + telegramSpan.appendChild(createTextNode("Telegram")); + telegram.appendChild(telegramSpan); + + _modalContent.appendChild(telegram); // WhatsApp + + + wa = createElement("a"); + wa.id = "m-wa"; + wa.href = DEFAULT_BTN_HREF; + wa.classList.add("m-open"); + wa.classList.add("m-wa"); + wa.appendChild(createTextNode("open in ")); + var waSpan = createElement(span); + waSpan.className = "w-500"; + waSpan.appendChild(createTextNode("WhatsApp")); + wa.appendChild(waSpan); + + _modalContent.appendChild(wa); // Skype + + + skype = createElement("a"); + skype.id = "m-skype"; + skype.href = DEFAULT_BTN_HREF; + skype.classList.add("m-open"); + skype.classList.add("m-skype"); + skype.appendChild(createTextNode("open in ")); + var skypeSpan = createElement(span); + skypeSpan.className = "w-500"; + skypeSpan.appendChild(createTextNode("Skype")); + skype.appendChild(skypeSpan); + + _modalContent.appendChild(skype); // call default + + + call = createElement("a"); + call.id = "m-call"; + call.href = DEFAULT_BTN_HREF; + call.classList.add("m-open"); + call.classList.add("m-default"); + var callSpan = createElement(span); + callSpan.className = "w-500"; + callSpan.appendChild(createTextNode("call")); + call.appendChild(callSpan); + call.appendChild(createTextNode(" as default")); + + _modalContent.appendChild(call); // copy + + + copyTel = createElement("a"); + copyTel.id = "m-tel-copy"; + copyTel.href = DEFAULT_BTN_HREF; + copyTel.classList.add("m-copy"); + copyTel.classList.add("w-500"); + copyTel.appendChild(createTextNode("copy")); + + _modalContent.appendChild(copyTel); + + _modalContent.appendChild(byElement()); // add the modal at the end of the body + + + document.body.appendChild(_modal); // every click outside the modal will hide the modal + + _modalBackground.addEventListener("click", hideMailgo); + } }; /** * mailgoRender * function to render a mailgo (mail or tel) */ -const mailgoRender = (type = MAIL_TYPE, mailgo) => { - // mailgo mail - if (type === MAIL_TYPE) { - // if the element href=^"mailto:" - if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { - mail = decodeURIComponent(mailgo.href.split("?")[0].split(MAILTO)[1].trim()); - url = new URL(mailgo.href); - let urlParams = url.searchParams; - // optional parameters for the email - cc = urlParams.get("cc"); - bcc = urlParams.get("bcc"); - subject = urlParams.get("subject"); - bodyMail = urlParams.get("body"); - } - else { - // if the element href="#mailgo" or class="mailgo" - // mail = data-address + @ + data-domain - mail = - mailgo.getAttribute("data-address") + - "@" + - mailgo.getAttribute("data-domain"); - url = new URL(MAILTO + encodeURIComponent(mail)); - // cc = data-cc-address + @ + data-cc-domain - cc = - mailgo.getAttribute("data-cc-address") + - "@" + - mailgo.getAttribute("data-cc-domain"); - // bcc = data-bcc-address + @ + data-bcc-domain - bcc = - mailgo.getAttribute("data-bcc-address") + - "@" + - mailgo.getAttribute("data-bcc-domain"); - // subject = data-subject - subject = mailgo.getAttribute("data-subject"); - // body = data-body - bodyMail = mailgo.getAttribute("data-body"); - } - // validate the email address - if (!validateEmails(mail.split(","))) - return; - // if cc, bcc is not valid cc, bcc = "" - if (cc && !validateEmails(cc.split(","))) - cc = ""; - if (bcc && !validateEmails(bcc.split(","))) - bcc = ""; - // the title of the modal (email address) - title.innerHTML = mail.split(",").join("
"); - // add the details if provided - cc - ? ((detailCc.style.display = "block"), - (ccValue.innerHTML = cc.split(",").join("
"))) - : (detailCc.style.display = "none"); - bcc - ? ((detailBcc.style.display = "block"), - (bccValue.innerHTML = bcc.split(",").join("
"))) - : (detailBcc.style.display = "none"); - subject - ? ((detailSubject.style.display = "block"), - (subjectValue.textContent = subject)) - : (detailSubject.style.display = "none"); - bodyMail - ? ((detailBody.style.display = "block"), - (bodyValue.textContent = bodyMail)) - : (detailBody.style.display = "none"); - // add the actions - gmail.addEventListener("click", openGmail); - outlook.addEventListener("click", openOutlook); - encEmail = encodeEmail(mail); - open.addEventListener("click", openDefault); - copyMail.addEventListener("click", () => copy(mail)); + + +var mailgoRender = function mailgoRender() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + var mailgo = arguments.length > 1 ? arguments[1] : undefined; + + // mailgo mail + if (type === MAIL_TYPE) { + // if the element href=^"mailto:" + if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { + mail = decodeURIComponent(mailgo.href.split("?")[0].split(MAILTO)[1].trim()); + url = new URL(mailgo.href); + var urlParams = url.searchParams; // optional parameters for the email + + cc = urlParams.get("cc"); + bcc = urlParams.get("bcc"); + subject = urlParams.get("subject"); + bodyMail = urlParams.get("body"); + } else { + // if the element href="#mailgo" or class="mailgo" + // mail = data-address + @ + data-domain + mail = mailgo.getAttribute("data-address") + "@" + mailgo.getAttribute("data-domain"); + url = new URL(MAILTO + encodeURIComponent(mail)); // cc = data-cc-address + @ + data-cc-domain + + cc = mailgo.getAttribute("data-cc-address") + "@" + mailgo.getAttribute("data-cc-domain"); // bcc = data-bcc-address + @ + data-bcc-domain + + bcc = mailgo.getAttribute("data-bcc-address") + "@" + mailgo.getAttribute("data-bcc-domain"); // subject = data-subject + + subject = mailgo.getAttribute("data-subject"); // body = data-body + + bodyMail = mailgo.getAttribute("data-body"); + } // validate the email address + + + if (!validateEmails(mail.split(","))) return; // if cc, bcc is not valid cc, bcc = "" + + if (cc && !validateEmails(cc.split(","))) cc = ""; + if (bcc && !validateEmails(bcc.split(","))) bcc = ""; // the title of the modal (email address) + + title.innerHTML = mail.split(",").join("
"); // add the details if provided + + cc ? (detailCc.style.display = "block", ccValue.innerHTML = cc.split(",").join("
")) : detailCc.style.display = "none"; + bcc ? (detailBcc.style.display = "block", bccValue.innerHTML = bcc.split(",").join("
")) : detailBcc.style.display = "none"; + subject ? (detailSubject.style.display = "block", subjectValue.textContent = subject) : detailSubject.style.display = "none"; + bodyMail ? (detailBody.style.display = "block", bodyValue.textContent = bodyMail) : detailBody.style.display = "none"; // add the actions + + gmail.addEventListener("click", openGmail); + outlook.addEventListener("click", openOutlook); + encEmail = encodeEmail(mail); + open.addEventListener("click", openDefault); + copyMail.addEventListener("click", function () { + return copy(mail); + }); + } // mailgo tel + + + if (type === TEL_TYPE) { + if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { + tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); + } else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { + tel = decodeURIComponent(mailgo.href.split("?")[0].split(CALLTO)[1].trim()); + } else if (mailgo.hasAttribute("data-tel")) { + tel = mailgo.getAttribute("data-tel"); + msg = mailgo.getAttribute("data-msg"); + } // information + // let titleEl = getE("m-tel-title"); + // Telegram username + + + if (mailgo.hasAttribute("data-telegram")) { + telegramUsername = mailgo.getAttribute("data-telegram"); + } // Telegram username + + + if (mailgo.hasAttribute("data-skype")) { + skypeUsername = mailgo.getAttribute("data-skype"); + } // the title of the modal (tel) + + + titleTel.innerHTML = tel; // add the actions to buttons + + wa.addEventListener("click", openWhatsApp); + + if (telegramUsername) { + setDisplay("m-tg", "block"); + telegram.addEventListener("click", openTelegram); } - // mailgo tel - if (type === TEL_TYPE) { - if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); - } - else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(CALLTO)[1].trim()); - } - else if (mailgo.hasAttribute("data-tel")) { - tel = mailgo.getAttribute("data-tel"); - msg = mailgo.getAttribute("data-msg"); - } - // information - // let titleEl = getE("m-tel-title"); - // Telegram username - if (mailgo.hasAttribute("data-telegram")) { - telegramUsername = mailgo.getAttribute("data-telegram"); - } - // Telegram username - if (mailgo.hasAttribute("data-skype")) { - skypeUsername = mailgo.getAttribute("data-skype"); - } - // the title of the modal (tel) - titleTel.innerHTML = tel; - // add the actions to buttons - wa.addEventListener("click", openWhatsApp); - if (telegramUsername) { - setDisplay("m-tg", "block"); - telegram.addEventListener("click", openTelegram); - } - skype.addEventListener("click", openSkype); - call.addEventListener("click", callDefault); - copyTel.addEventListener("click", () => copy(tel)); - } - // show the mailgo - showMailgo(type); - // add listener keyDown - document.addEventListener("keydown", mailgoKeydown); + + skype.addEventListener("click", openSkype); + call.addEventListener("click", callDefault); + copyTel.addEventListener("click", function () { + return copy(tel); + }); + } // show the mailgo + + + showMailgo(type); // add listener keyDown + + document.addEventListener("keydown", mailgoKeydown); +}; // actions + + +var openGmail = function openGmail() { + // Gmail url + var gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + encodeURIComponent(mail); // the details if provided + + if (cc) gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); + if (bcc) gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); + if (subject) gmailUrl = gmailUrl.concat("&subject=" + subject); + if (bodyMail) gmailUrl = gmailUrl.concat("&body=" + bodyMail); // open the link + + window.open(gmailUrl, "_blank"); // hide the modal + + hideMailgo(); }; -// actions -const openGmail = () => { - // Gmail url - let gmailUrl = "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + - encodeURIComponent(mail); - // the details if provided - if (cc) - gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); - if (bcc) - gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); - if (subject) - gmailUrl = gmailUrl.concat("&subject=" + subject); - if (bodyMail) - gmailUrl = gmailUrl.concat("&body=" + bodyMail); - // open the link - window.open(gmailUrl, "_blank"); - // hide the modal + +var openOutlook = function openOutlook() { + // Outlook url + var outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + encodeURIComponent(mail); // the details if provided + + if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject); + if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail); // open the link + + window.open(outlookUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openDefault = function openDefault() { + mailToEncoded(encEmail); + hideMailgo(); +}; + +var openTelegram = function openTelegram() { + // Telegram url + var tgUrl = "https://t.me/" + telegramUsername; // open the url + + window.open(tgUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openSkype = function openSkype() { + var skype = skypeUsername !== "" ? skypeUsername : tel; // Telegram url + + var skypeUrl = "skype:" + skype; // open the url + + window.open(skypeUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var openWhatsApp = function openWhatsApp() { + // WhatsApp url + var waUrl = "https://wa.me/" + tel; // the details if provided + + if (msg) waUrl + "?text=" + msg; // open the url + + window.open(waUrl, "_blank"); // hide the modal + + hideMailgo(); +}; + +var callDefault = function callDefault() { + var callUrl = "tel:" + tel; + window.open(callUrl); + hideMailgo(); +}; + +var copy = function copy(content) { + copyToClipboard(content); + var activeCopy; // the correct copyButton (mail or tel) + + mailgoIsShowing(MAIL_TYPE) ? activeCopy = copyMail : activeCopy = copyTel; + activeCopy.textContent = "copied"; + setTimeout(function () { + activeCopy.textContent = "copy"; // hide after the timeout + hideMailgo(); -}; -const openOutlook = () => { - // Outlook url - let outlookUrl = "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + - encodeURIComponent(mail); - // the details if provided - if (subject) - outlookUrl = outlookUrl.concat("&subject=" + subject); - if (bodyMail) - outlookUrl = outlookUrl.concat("&body=" + bodyMail); - // open the link - window.open(outlookUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openDefault = () => { - mailToEncoded(encEmail); - hideMailgo(); -}; -const openTelegram = () => { - // Telegram url - let tgUrl = "https://t.me/" + telegramUsername; - // open the url - window.open(tgUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openSkype = () => { - let skype = skypeUsername !== "" ? skypeUsername : tel; - // Telegram url - let skypeUrl = "skype:" + skype; - // open the url - window.open(skypeUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const openWhatsApp = () => { - // WhatsApp url - let waUrl = "https://wa.me/" + tel; - // the details if provided - if (msg) - waUrl + "?text=" + msg; - // open the url - window.open(waUrl, "_blank"); - // hide the modal - hideMailgo(); -}; -const callDefault = () => { - let callUrl = "tel:" + tel; - window.open(callUrl); - hideMailgo(); -}; -const copy = (content) => { - copyToClipboard(content); - let activeCopy; - // the correct copyButton (mail or tel) - mailgoIsShowing(MAIL_TYPE) ? (activeCopy = copyMail) : (activeCopy = copyTel); - activeCopy.textContent = "copied"; - setTimeout(() => { - activeCopy.textContent = "copy"; - // hide after the timeout - hideMailgo(); - }, 999); -}; -// function that returns if an element is a mailgo -const isMailgo = (element, type = MAIL_TYPE) => { - let href = element.href; - // mailgo type mail - if (type === MAIL_TYPE) { - return ( - // first case: it is an element with "mailto:..." in href and no no-mailgo in classList - (href && - href.toLowerCase().startsWith(MAILTO) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-address") && - // second case: the href=#mailgo - ((href && element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo"))))); - } - // mailgo type tel - if (type === TEL_TYPE) { - return ( - // first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList - (href && - (href.toLowerCase().startsWith(TEL) || - href.toLowerCase().startsWith(CALLTO)) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-tel") && - // second case: the href=#mailgo - href && - element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo"))); - } - return false; + }, 999); +}; // function that returns if an element is a mailgo + + +var isMailgo = function isMailgo(element) { + var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : MAIL_TYPE; + var href = element.href; // mailgo type mail + + if (type === MAIL_TYPE) { + return (// first case: it is an element with "mailto:..." in href and no no-mailgo in classList + href && href.toLowerCase().startsWith(MAILTO) && !element.classList.contains("no-mailgo") || element.hasAttribute("data-address") && ( // second case: the href=#mailgo + href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo + element.classList && element.classList.contains("mailgo")) + ); + } // mailgo type tel + + + if (type === TEL_TYPE) { + return (// first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList + href && (href.toLowerCase().startsWith(TEL) || href.toLowerCase().startsWith(CALLTO)) && !element.classList.contains("no-mailgo") || element.hasAttribute("data-tel") && // second case: the href=#mailgo + href && element.getAttribute("href").toLowerCase() === "#mailgo" || // third case: the classList contains mailgo + element.classList && element.classList.contains("mailgo") + ); + } + + return false; }; /** * mailgoCheckRender @@ -467,216 +486,270 @@ const isMailgo = (element, type = MAIL_TYPE) => { * 'a[href^="callto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo' * ); */ -const mailgoCheckRender = (event) => { - // check if the id=mailgo exists in the body - if (!document.contains(getE("mailgo")) || - !document.contains(getE("mailgo-tel"))) - return; - // if a mailgo is already showing do nothing - if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) - return false; - // the path of the event - let path = (event.composedPath && event.composedPath()) || - composedPath(event.target); - if (path) { - path.forEach((element) => { - if (element instanceof HTMLDocument || element instanceof Window) - return false; - // go in the event.path to find if the user has clicked on a mailgo element - if (isMailgo(element, MAIL_TYPE)) { - // stop the normal execution of the element click - event.preventDefault(); - // render mailgo - mailgoRender(MAIL_TYPE, element); - return true; - } - if (isMailgo(element, TEL_TYPE)) { - // stop the normal execution of the element click - event.preventDefault(); - // render mailgo - mailgoRender(TEL_TYPE, element); - return true; - } - }); - } - return false; + + +var mailgoCheckRender = function mailgoCheckRender(event) { + // check if the id=mailgo exists in the body + if (!document.contains(getE("mailgo")) || !document.contains(getE("mailgo-tel"))) return; // if a mailgo is already showing do nothing + + if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) return false; // the path of the event + + var path = event.composedPath && event.composedPath() || composedPath(event.target); + + if (path) { + path.forEach(function (element) { + if (element instanceof HTMLDocument || element instanceof Window) return false; // go in the event.path to find if the user has clicked on a mailgo element + + if (isMailgo(element, MAIL_TYPE)) { + // stop the normal execution of the element click + event.preventDefault(); // render mailgo + + mailgoRender(MAIL_TYPE, element); + return true; + } + + if (isMailgo(element, TEL_TYPE)) { + // stop the normal execution of the element click + event.preventDefault(); // render mailgo + + mailgoRender(TEL_TYPE, element); + return true; + } + }); + } + + return false; }; /** * mailgoKeydown * function to manage the keydown event when the modal is showing */ -const mailgoKeydown = (event) => { - // if mailgo is showing - if (mailgoIsShowing(MAIL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 71: - // g -> open GMail - openGmail(); - break; - case 79: - // o -> open Outlook - openOutlook(); - break; - case 32: - case 13: - // spacebar or enter -> open default - openDefault(); - break; - case 67: - // c -> copy - copy(mail); - break; - default: - return; - } + + +var mailgoKeydown = function mailgoKeydown(event) { + // if mailgo is showing + if (mailgoIsShowing(MAIL_TYPE)) { + switch (event.keyCode) { + case 27: + // Escape + hideMailgo(); + break; + + case 71: + // g -> open GMail + openGmail(); + break; + + case 79: + // o -> open Outlook + openOutlook(); + break; + + case 32: + case 13: + // spacebar or enter -> open default + openDefault(); + break; + + case 67: + // c -> copy + copy(mail); + break; + + default: + return; } - else if (mailgoIsShowing(TEL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 84: - // t -> open Telegram - openTelegram(); - break; - case 87: - // w -> open WhatsApp - openWhatsApp(); - break; - case 32: - case 13: - // spacebar or enter -> call default - callDefault(); - break; - case 67: - // c -> copy - copy(tel); - break; - default: - return; - } + } else if (mailgoIsShowing(TEL_TYPE)) { + switch (event.keyCode) { + case 27: + // Escape + hideMailgo(); + break; + + case 84: + // t -> open Telegram + openTelegram(); + break; + + case 87: + // w -> open WhatsApp + openWhatsApp(); + break; + + case 32: + case 13: + // spacebar or enter -> call default + callDefault(); + break; + + case 67: + // c -> copy + copy(tel); + break; + + default: + return; } - return; + } + + return; +}; // show the modal + + +var showMailgo = function showMailgo() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + + // show mailgo type mail + if (type === MAIL_TYPE) { + setDisplay("mailgo", "flex"); + return true; + } // show mailgo type tel + + + if (type === TEL_TYPE) { + setDisplay("mailgo-tel", "flex"); + return true; + } + + return false; +}; // hide the modal + + +var hideMailgo = function hideMailgo() { + setDisplay("mailgo", "none"); + setDisplay("mailgo-tel", "none"); // remove listener keyDown + + document.removeEventListener("keydown", mailgoKeydown); +}; // is the mailgo modal hidden? + + +var mailgoIsShowing = function mailgoIsShowing() { + var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE; + return type === MAIL_TYPE ? getDisplay("mailgo") === "flex" : type === TEL_TYPE ? getDisplay("mailgo-tel") === "flex" : false; }; -// show the modal -const showMailgo = (type = MAIL_TYPE) => { - // show mailgo type mail - if (type === MAIL_TYPE) { - setDisplay("mailgo", "flex"); - return true; + +var byElement = function byElement() { + // by + var by = createElement("a"); + by.href = "https://mailgo.js.org?ref=mailgo-modal"; + by.className = "m-by"; + by.target = "_blank"; + by.rel = "noopener noreferrer"; + by.appendChild(createTextNode("mailgo.js.org")); + return by; +}; // create element + + +var createElement = function createElement() { + var element = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "div"; + return document.createElement(element); +}; // create text node + + +var createTextNode = function createTextNode(element) { + return document.createTextNode(element); +}; // decrypt email + + +var mailToEncoded = function mailToEncoded(encoded) { + return window.location.href = MAILTO + atob(encoded); +}; // encode email + + +var encodeEmail = function encodeEmail(email) { + return btoa(email); +}; // getE shorthand + + +var getE = function getE(id) { + return document.getElementById(id); +}; // get display value + + +var getDisplay = function getDisplay(id) { + return getE(id).style.display; +}; // get display value + + +var setDisplay = function setDisplay(id, value) { + return getE(id).style.display = value; +}; // custom composedPath if path or event.composedPath() are not defined + + +var composedPath = function composedPath(el) { + var path = []; + + while (el) { + path.push(el); + + if (el.tagName === "HTML") { + path.push(document); + path.push(window); + return path; } - // show mailgo type tel - if (type === TEL_TYPE) { - setDisplay("mailgo-tel", "flex"); - return true; - } - return false; + + el = el.parentElement; + } +}; // validate a single email with regex + + +var validateEmail = function validateEmail(email) { + 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(email); +}; // validate an array of emails + + +var validateEmails = function validateEmails(arr) { + return arr.every(validateEmail); +}; // copy of a string + + +var copyToClipboard = function copyToClipboard(str) { + var el = createElement("textarea"); + el.value = str; + el.setAttribute("readonly", ""); + el.style.position = "absolute"; + el.style.left = "-9999px"; + document.body.appendChild(el); + var selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; + el.select(); + document.execCommand("copy"); + document.body.removeChild(el); + + if (selected) { + document.getSelection().removeAllRanges(); + document.getSelection().addRange(selected); + return true; + } + + return false; }; -// hide the modal -const hideMailgo = () => { - setDisplay("mailgo", "none"); - setDisplay("mailgo-tel", "none"); - // remove listener keyDown - document.removeEventListener("keydown", mailgoKeydown); + +var mailgoStyle = function mailgoStyle() { + // mailgo style + var mailgoCSS = createElement("style"); + mailgoCSS.id = "mailgo-style"; + mailgoCSS.type = "text/css"; + mailgoCSS.appendChild(createTextNode(".m-modal{position:fixed;top:0;right:0;bottom:0;left:0;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal a,.m-modal p,.m-modal span,.m-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\";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.m-modal .m-modal-content{position:relative;z-index:10002;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;-webkit-box-shadow:0 3px 20px rgba(32,35,42,.5);-moz-box-shadow:0 3px 20px rgba(32,35,42,.5);box-shadow:0 3px 20px rgba(32,35,42,.5);color:#4a4a4a;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:auto;padding:20px;-webkit-transition:.5s -webkit-box-shadow;transition:.5s -webkit-box-shadow;-o-transition:.5s box-shadow;-moz-transition:.5s box-shadow,.5s -moz-box-shadow;transition:.5s box-shadow;transition:.5s box-shadow,.5s -webkit-box-shadow,.5s -moz-box-shadow}.m-modal .m-modal-content:hover{opacity:1;-webkit-box-shadow:0 7px 20px rgba(32,35,42,.85);-moz-box-shadow:0 7px 20px rgba(32,35,42,.85);box-shadow:0 7px 20px rgba(32,35,42,.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;-o-text-overflow:ellipsis;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-copy:hover,.m-modal .m-modal-content a.m-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:.8rem;padding:5px;color:#4a4a4a;opacity:.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}")); + document.head.appendChild(mailgoCSS); +}; // mailgo + + +var mailgo = function mailgo(mailgoConfig) { + // if the window is defined... + if (window && typeof window !== "undefined") { + // add the style for mailgo + mailgoStyle(); // if is set an initEvent add the listener + + if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) { + document.addEventListener(mailgoConfig.initEvent, mailgoInit); + } else { + mailgoInit(); + } // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered + + + document.addEventListener("click", mailgoCheckRender); + } }; -// is the mailgo modal hidden? -const mailgoIsShowing = (type = MAIL_TYPE) => { - return type === MAIL_TYPE - ? getDisplay("mailgo") === "flex" - : type === TEL_TYPE - ? getDisplay("mailgo-tel") === "flex" - : false; -}; -const byElement = () => { - // by - let by = createElement("a"); - by.href = "https://mailgo.js.org?ref=mailgo-modal"; - by.className = "m-by"; - by.target = "_blank"; - by.rel = "noopener noreferrer"; - by.appendChild(createTextNode("mailgo.js.org")); - return by; -}; -// create element -const createElement = (element = "div") => document.createElement(element); -// create text node -const createTextNode = (element) => document.createTextNode(element); -// decrypt email -const mailToEncoded = (encoded) => (window.location.href = MAILTO + atob(encoded)); -// encode email -const encodeEmail = (email) => btoa(email); -// getE shorthand -const getE = (id) => document.getElementById(id); -// get display value -const getDisplay = (id) => getE(id).style.display; -// get display value -const setDisplay = (id, value) => (getE(id).style.display = value); -// custom composedPath if path or event.composedPath() are not defined -const composedPath = (el) => { - let path = []; - while (el) { - path.push(el); - if (el.tagName === "HTML") { - path.push(document); - path.push(window); - return path; - } - el = el.parentElement; - } -}; -// validate a single email with regex -const validateEmail = (email) => /^(([^<>()[\]\\.,;:\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(email); -// validate an array of emails -const validateEmails = (arr) => arr.every(validateEmail); -// copy of a string -const copyToClipboard = (str) => { - let el = createElement("textarea"); - el.value = str; - el.setAttribute("readonly", ""); - el.style.position = "absolute"; - el.style.left = "-9999px"; - document.body.appendChild(el); - let selected = document.getSelection().rangeCount > 0 - ? document.getSelection().getRangeAt(0) - : false; - el.select(); - document.execCommand("copy"); - document.body.removeChild(el); - if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); - return true; - } - return false; -}; -const mailgoStyle = () => { - // mailgo style - let mailgoCSS = createElement("style"); - mailgoCSS.id = "mailgo-style"; - mailgoCSS.type = "text/css"; - mailgoCSS.appendChild(createTextNode(`.m-modal{position:fixed;top:0;right:0;bottom:0;left:0;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal a,.m-modal p,.m-modal span,.m-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";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.m-modal .m-modal-content{position:relative;z-index:10002;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;-webkit-box-shadow:0 3px 20px rgba(32,35,42,.5);-moz-box-shadow:0 3px 20px rgba(32,35,42,.5);box-shadow:0 3px 20px rgba(32,35,42,.5);color:#4a4a4a;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:auto;padding:20px;-webkit-transition:.5s -webkit-box-shadow;transition:.5s -webkit-box-shadow;-o-transition:.5s box-shadow;-moz-transition:.5s box-shadow,.5s -moz-box-shadow;transition:.5s box-shadow;transition:.5s box-shadow,.5s -webkit-box-shadow,.5s -moz-box-shadow}.m-modal .m-modal-content:hover{opacity:1;-webkit-box-shadow:0 7px 20px rgba(32,35,42,.85);-moz-box-shadow:0 7px 20px rgba(32,35,42,.85);box-shadow:0 7px 20px rgba(32,35,42,.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;-o-text-overflow:ellipsis;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-copy:hover,.m-modal .m-modal-content a.m-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:.8rem;padding:5px;color:#4a4a4a;opacity:.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}`)); - document.head.appendChild(mailgoCSS); -}; -// mailgo -const mailgo = (mailgoConfig) => { - // if the window is defined... - if (window && typeof window !== "undefined") { - // add the style for mailgo - mailgoStyle(); - // if is set an initEvent add the listener - if (mailgoConfig === null || mailgoConfig === void 0 ? void 0 : mailgoConfig.initEvent) { - document.addEventListener(mailgoConfig.initEvent, mailgoInit); - } - else { - mailgoInit(); - } - // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered - document.addEventListener("click", mailgoCheckRender); - } -}; -export default mailgo; + +var _default = mailgo; +exports["default"] = _default; \ No newline at end of file diff --git a/mailgo.ts b/mailgo.ts deleted file mode 100644 index 0593cd0..0000000 --- a/mailgo.ts +++ /dev/null @@ -1,851 +0,0 @@ -// links -const MAILTO: string = "mailto:"; -const TEL: string = "tel:"; -const CALLTO: string = "callto:"; - -// mailgo types -const MAIL_TYPE: string = "mail"; -const TEL_TYPE: string = "tel"; - -// default href for links -const DEFAULT_BTN_HREF: string = "javascript:void(0);"; - -// html tags -const span: string = "span"; - -// mailgo variables -let url: URL, - mail: string = "", - encEmail: string = "", - cc: string = "", - bcc: string = "", - subject: string = "", - bodyMail: string = ""; - -// mailgo tel variables -let tel: string = "", - msg: string = "", - telegramUsername: string = "", - skypeUsername: string = ""; - -// the DOM elements -let title: HTMLElement, - titleTel: HTMLElement, - detailCc: HTMLElement, - detailBcc: HTMLElement, - detailSubject: HTMLElement, - detailBody: HTMLElement, - ccValue: HTMLElement, - bccValue: HTMLElement, - subjectValue: HTMLElement, - bodyValue: HTMLElement; - -// mailgo buttons (actions) -let gmail: HTMLLinkElement, - outlook: HTMLLinkElement, - open: HTMLLinkElement, - telegram: HTMLLinkElement, - wa: HTMLLinkElement, - skype: HTMLLinkElement, - call: HTMLLinkElement, - copyMail: HTMLLinkElement, - copyTel: HTMLLinkElement; - -/** - * mailgoInit - * the function that creates the mailgo elements in DOM - */ -const mailgoInit = (): void => { - // mailgo mail - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo"; - modal.classList.add("m-modal"); - - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - - // title (email address) - title = createElement("strong"); - title.id = "m-title"; - title.className = "m-title"; - modalContent.appendChild(title); - - // details - let details = createElement(); - details.id = "m-details"; - details.className = "m-details"; - - detailCc = createElement("p"); - detailCc.id = "m-cc"; - let ccSpan = createElement(span); - ccSpan.className = "w-500"; - ccSpan.appendChild(createTextNode("cc ")); - ccValue = createElement(span); - ccValue.id = "m-cc-value"; - detailCc.appendChild(ccSpan); - detailCc.appendChild(ccValue); - details.appendChild(detailCc); - - detailBcc = createElement("p"); - detailBcc.id = "m-bcc"; - let bccSpan = createElement(span); - bccSpan.className = "w-500"; - bccSpan.appendChild(createTextNode("bcc ")); - bccValue = createElement(span); - bccValue.id = "m-bcc-value"; - detailBcc.appendChild(bccSpan); - detailBcc.appendChild(bccValue); - details.appendChild(detailBcc); - - detailSubject = createElement("p"); - detailSubject.id = "m-subject"; - let subjectSpan = createElement(span); - subjectSpan.className = "w-500"; - subjectSpan.appendChild(createTextNode("subject ")); - subjectValue = createElement(span); - subjectValue.id = "m-subject-value"; - detailSubject.appendChild(subjectSpan); - detailSubject.appendChild(subjectValue); - details.appendChild(detailSubject); - - detailBody = createElement("p"); - detailBody.id = "m-body"; - let bodySpan = createElement(span); - bodySpan.className = "w-500"; - bodySpan.appendChild(createTextNode("body ")); - bodyValue = createElement(span); - bodyValue.id = "m-body-value"; - detailBody.appendChild(bodySpan); - detailBody.appendChild(bodyValue); - details.appendChild(detailBody); - - modalContent.appendChild(details); - - // Gmail - gmail = createElement("a"); - gmail.id = "m-gmail"; - gmail.href = DEFAULT_BTN_HREF; - gmail.classList.add("m-open"); - gmail.classList.add("m-gmail"); - gmail.appendChild(createTextNode("open in ")); - let gmailSpan = createElement(span); - gmailSpan.className = "w-500"; - gmailSpan.appendChild(createTextNode("Gmail")); - gmail.appendChild(gmailSpan); - - modalContent.appendChild(gmail); - - // Outlook - outlook = createElement("a"); - outlook.id = "m-outlook"; - outlook.href = DEFAULT_BTN_HREF; - outlook.classList.add("m-open"); - outlook.classList.add("m-outlook"); - outlook.appendChild(createTextNode("open in ")); - let outlookSpan = createElement(span); - outlookSpan.className = "w-500"; - outlookSpan.appendChild(createTextNode("Outlook")); - outlook.appendChild(outlookSpan); - - modalContent.appendChild(outlook); - - // open default - open = createElement("a"); - open.id = "m-open"; - open.href = DEFAULT_BTN_HREF; - open.classList.add("m-open"); - open.classList.add("m-default"); - let openSpan = createElement(span); - openSpan.className = "w-500"; - openSpan.appendChild(createTextNode("open")); - open.appendChild(openSpan); - open.appendChild(createTextNode(" default")); - - modalContent.appendChild(open); - - // copy - copyMail = createElement("a"); - copyMail.id = "m-copy"; - copyMail.href = DEFAULT_BTN_HREF; - copyMail.classList.add("m-copy"); - copyMail.classList.add("w-500"); - copyMail.appendChild(createTextNode("copy")); - - modalContent.appendChild(copyMail); - - modalContent.appendChild(byElement()); - - // add the modal at the end of the body - document.body.appendChild(modal); - - // every click outside the modal will hide the modal - modalBackground.addEventListener("click", hideMailgo); - } - // mailgo tel - { - // modal - let modal = createElement(); - modal.style.display = "none"; - modal.id = "mailgo-tel"; - modal.classList.add("m-modal"); - - // background - let modalBackground = createElement(); - modalBackground.className = "m-modal-back"; - modal.appendChild(modalBackground); - - // modal content - let modalContent = createElement(); - modalContent.className = "m-modal-content"; - modal.appendChild(modalContent); - - // title (telephone number) - titleTel = createElement("strong"); - titleTel.id = "m-tel-title"; - titleTel.className = "m-title"; - modalContent.appendChild(titleTel); - - // Telegram - telegram = createElement("a"); - telegram.id = "m-tg"; - telegram.href = DEFAULT_BTN_HREF; - telegram.classList.add("m-open"); - telegram.classList.add("m-tg"); - - // by default not display - telegram.style.display = "none"; - - telegram.appendChild(createTextNode("open in ")); - let telegramSpan = createElement(span); - telegramSpan.className = "w-500"; - telegramSpan.appendChild(createTextNode("Telegram")); - telegram.appendChild(telegramSpan); - - modalContent.appendChild(telegram); - - // WhatsApp - wa = createElement("a"); - wa.id = "m-wa"; - wa.href = DEFAULT_BTN_HREF; - wa.classList.add("m-open"); - wa.classList.add("m-wa"); - wa.appendChild(createTextNode("open in ")); - let waSpan = createElement(span); - waSpan.className = "w-500"; - waSpan.appendChild(createTextNode("WhatsApp")); - wa.appendChild(waSpan); - - modalContent.appendChild(wa); - - // Skype - skype = createElement("a"); - skype.id = "m-skype"; - skype.href = DEFAULT_BTN_HREF; - skype.classList.add("m-open"); - skype.classList.add("m-skype"); - skype.appendChild(createTextNode("open in ")); - let skypeSpan = createElement(span); - skypeSpan.className = "w-500"; - skypeSpan.appendChild(createTextNode("Skype")); - skype.appendChild(skypeSpan); - - modalContent.appendChild(skype); - - // call default - call = createElement("a"); - call.id = "m-call"; - call.href = DEFAULT_BTN_HREF; - call.classList.add("m-open"); - call.classList.add("m-default"); - let callSpan = createElement(span); - callSpan.className = "w-500"; - callSpan.appendChild(createTextNode("call")); - call.appendChild(callSpan); - call.appendChild(createTextNode(" as default")); - - modalContent.appendChild(call); - - // copy - copyTel = createElement("a"); - copyTel.id = "m-tel-copy"; - copyTel.href = DEFAULT_BTN_HREF; - copyTel.classList.add("m-copy"); - copyTel.classList.add("w-500"); - copyTel.appendChild(createTextNode("copy")); - - modalContent.appendChild(copyTel); - - modalContent.appendChild(byElement()); - - // add the modal at the end of the body - document.body.appendChild(modal); - - // every click outside the modal will hide the modal - modalBackground.addEventListener("click", hideMailgo); - } -}; - -/** - * mailgoRender - * function to render a mailgo (mail or tel) - */ -const mailgoRender = (type = MAIL_TYPE, mailgo: any): void => { - // mailgo mail - if (type === MAIL_TYPE) { - // if the element href=^"mailto:" - if (mailgo.href && mailgo.href.toLowerCase().startsWith(MAILTO)) { - mail = decodeURIComponent( - mailgo.href.split("?")[0].split(MAILTO)[1].trim() - ); - - url = new URL(mailgo.href); - let urlParams: URLSearchParams = url.searchParams; - - // optional parameters for the email - cc = urlParams.get("cc"); - bcc = urlParams.get("bcc"); - subject = urlParams.get("subject"); - bodyMail = urlParams.get("body"); - } else { - // if the element href="#mailgo" or class="mailgo" - // mail = data-address + @ + data-domain - mail = - mailgo.getAttribute("data-address") + - "@" + - mailgo.getAttribute("data-domain"); - - url = new URL(MAILTO + encodeURIComponent(mail)); - - // cc = data-cc-address + @ + data-cc-domain - cc = - mailgo.getAttribute("data-cc-address") + - "@" + - mailgo.getAttribute("data-cc-domain"); - - // bcc = data-bcc-address + @ + data-bcc-domain - bcc = - mailgo.getAttribute("data-bcc-address") + - "@" + - mailgo.getAttribute("data-bcc-domain"); - - // subject = data-subject - subject = mailgo.getAttribute("data-subject"); - - // body = data-body - bodyMail = mailgo.getAttribute("data-body"); - } - - // validate the email address - if (!validateEmails(mail.split(","))) return; - - // if cc, bcc is not valid cc, bcc = "" - if (cc && !validateEmails(cc.split(","))) cc = ""; - if (bcc && !validateEmails(bcc.split(","))) bcc = ""; - - // the title of the modal (email address) - title.innerHTML = mail.split(",").join("
"); - - // add the details if provided - cc - ? ((detailCc.style.display = "block"), - (ccValue.innerHTML = cc.split(",").join("
"))) - : (detailCc.style.display = "none"); - - bcc - ? ((detailBcc.style.display = "block"), - (bccValue.innerHTML = bcc.split(",").join("
"))) - : (detailBcc.style.display = "none"); - - subject - ? ((detailSubject.style.display = "block"), - (subjectValue.textContent = subject)) - : (detailSubject.style.display = "none"); - - bodyMail - ? ((detailBody.style.display = "block"), - (bodyValue.textContent = bodyMail)) - : (detailBody.style.display = "none"); - - // add the actions - gmail.addEventListener("click", openGmail); - - outlook.addEventListener("click", openOutlook); - - encEmail = encodeEmail(mail); - open.addEventListener("click", openDefault); - - copyMail.addEventListener("click", () => copy(mail)); - } - // mailgo tel - if (type === TEL_TYPE) { - if (mailgo.href && mailgo.href.toLowerCase().startsWith(TEL)) { - tel = decodeURIComponent(mailgo.href.split("?")[0].split(TEL)[1].trim()); - } else if (mailgo.href && mailgo.href.toLowerCase().startsWith(CALLTO)) { - tel = decodeURIComponent( - mailgo.href.split("?")[0].split(CALLTO)[1].trim() - ); - } else if (mailgo.hasAttribute("data-tel")) { - tel = mailgo.getAttribute("data-tel"); - msg = mailgo.getAttribute("data-msg"); - } - - // information - // let titleEl = getE("m-tel-title"); - - // Telegram username - if (mailgo.hasAttribute("data-telegram")) { - telegramUsername = mailgo.getAttribute("data-telegram"); - } - - // Telegram username - if (mailgo.hasAttribute("data-skype")) { - skypeUsername = mailgo.getAttribute("data-skype"); - } - - // the title of the modal (tel) - titleTel.innerHTML = tel; - - // add the actions to buttons - wa.addEventListener("click", openWhatsApp); - - if (telegramUsername) { - setDisplay("m-tg", "block"); - telegram.addEventListener("click", openTelegram); - } - - skype.addEventListener("click", openSkype); - - call.addEventListener("click", callDefault); - - copyTel.addEventListener("click", () => copy(tel)); - } - - // show the mailgo - showMailgo(type); - - // add listener keyDown - document.addEventListener("keydown", mailgoKeydown); -}; - -// actions -const openGmail = (): void => { - // Gmail url - let gmailUrl = - "https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" + - encodeURIComponent(mail); - - // the details if provided - if (cc) gmailUrl = gmailUrl.concat("&cc=" + encodeURIComponent(cc)); - if (bcc) gmailUrl = gmailUrl.concat("&bcc=" + encodeURIComponent(bcc)); - if (subject) gmailUrl = gmailUrl.concat("&subject=" + subject); - if (bodyMail) gmailUrl = gmailUrl.concat("&body=" + bodyMail); - - // open the link - window.open(gmailUrl, "_blank"); - - // hide the modal - hideMailgo(); -}; - -const openOutlook = (): void => { - // Outlook url - let outlookUrl = - "https://outlook.live.com/owa/?path=/mail/action/compose&to=" + - encodeURIComponent(mail); - - // the details if provided - if (subject) outlookUrl = outlookUrl.concat("&subject=" + subject); - if (bodyMail) outlookUrl = outlookUrl.concat("&body=" + bodyMail); - - // open the link - window.open(outlookUrl, "_blank"); - - // hide the modal - hideMailgo(); -}; - -const openDefault = (): void => { - mailToEncoded(encEmail); - hideMailgo(); -}; - -const openTelegram = (): void => { - // Telegram url - let tgUrl = "https://t.me/" + telegramUsername; - - // open the url - window.open(tgUrl, "_blank"); - - // hide the modal - hideMailgo(); -}; - -const openSkype = (): void => { - let skype = skypeUsername !== "" ? skypeUsername : tel; - - // Telegram url - let skypeUrl = "skype:" + skype; - - // open the url - window.open(skypeUrl, "_blank"); - - // hide the modal - hideMailgo(); -}; - -const openWhatsApp = (): void => { - // WhatsApp url - let waUrl = "https://wa.me/" + tel; - - // the details if provided - if (msg) waUrl + "?text=" + msg; - - // open the url - window.open(waUrl, "_blank"); - - // hide the modal - hideMailgo(); -}; - -const callDefault = (): void => { - let callUrl = "tel:" + tel; - window.open(callUrl); - hideMailgo(); -}; - -const copy = (content: string): void => { - copyToClipboard(content); - let activeCopy: HTMLElement; - // the correct copyButton (mail or tel) - mailgoIsShowing(MAIL_TYPE) ? (activeCopy = copyMail) : (activeCopy = copyTel); - activeCopy.textContent = "copied"; - setTimeout(() => { - activeCopy.textContent = "copy"; - // hide after the timeout - hideMailgo(); - }, 999); -}; - -// function that returns if an element is a mailgo -const isMailgo = (element: HTMLElement, type: string = MAIL_TYPE): boolean => { - let href: string = (element as HTMLLinkElement).href; - - // mailgo type mail - if (type === MAIL_TYPE) { - return ( - // first case: it is an
element with "mailto:..." in href and no no-mailgo in classList - (href && - href.toLowerCase().startsWith(MAILTO) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-address") && - // second case: the href=#mailgo - ((href && element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo")))) - ); - } - - // mailgo type tel - if (type === TEL_TYPE) { - return ( - // first case: it is an element with "tel:..." or "callto:..." in href and no no-mailgo in classList - (href && - (href.toLowerCase().startsWith(TEL) || - href.toLowerCase().startsWith(CALLTO)) && - !element.classList.contains("no-mailgo")) || - (element.hasAttribute("data-tel") && - // second case: the href=#mailgo - href && - element.getAttribute("href").toLowerCase() === "#mailgo") || - // third case: the classList contains mailgo - (element.classList && element.classList.contains("mailgo")) - ); - } - - return false; -}; - -/** - * mailgoCheckRender - * function to check if an element is mailgo-enabled or not referencing to - * mail: - * document.querySelectorAll( - * 'a[href^="mailto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo' - * ); - * tel: - * document.querySelectorAll( - * 'a[href^="tel:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo' - * ); - * or - * document.querySelectorAll( - * 'a[href^="callto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo' - * ); - */ -const mailgoCheckRender = (event: Event): boolean => { - // check if the id=mailgo exists in the body - if ( - !document.contains(getE("mailgo")) || - !document.contains(getE("mailgo-tel")) - ) - return; - - // if a mailgo is already showing do nothing - if (mailgoIsShowing(MAIL_TYPE) || mailgoIsShowing(TEL_TYPE)) return false; - - // the path of the event - let path = - (event.composedPath && event.composedPath()) || - composedPath(event.target as HTMLElement); - - if (path) { - path.forEach((element: HTMLElement) => { - if (element instanceof HTMLDocument || element instanceof Window) - return false; - - // go in the event.path to find if the user has clicked on a mailgo element - if (isMailgo(element, MAIL_TYPE)) { - // stop the normal execution of the element click - event.preventDefault(); - - // render mailgo - mailgoRender(MAIL_TYPE, element); - - return true; - } - if (isMailgo(element, TEL_TYPE)) { - // stop the normal execution of the element click - event.preventDefault(); - - // render mailgo - mailgoRender(TEL_TYPE, element); - - return true; - } - }); - } - - return false; -}; - -/** - * mailgoKeydown - * function to manage the keydown event when the modal is showing - */ -const mailgoKeydown = (event: KeyboardEvent): void => { - // if mailgo is showing - if (mailgoIsShowing(MAIL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 71: - // g -> open GMail - openGmail(); - break; - case 79: - // o -> open Outlook - openOutlook(); - break; - case 32: - case 13: - // spacebar or enter -> open default - openDefault(); - break; - case 67: - // c -> copy - copy(mail); - break; - default: - return; - } - } else if (mailgoIsShowing(TEL_TYPE)) { - switch (event.keyCode) { - case 27: - // Escape - hideMailgo(); - break; - case 84: - // t -> open Telegram - openTelegram(); - break; - case 87: - // w -> open WhatsApp - openWhatsApp(); - break; - case 32: - case 13: - // spacebar or enter -> call default - callDefault(); - break; - case 67: - // c -> copy - copy(tel); - break; - default: - return; - } - } - return; -}; - -// show the modal -const showMailgo = (type = MAIL_TYPE): boolean => { - // show mailgo type mail - if (type === MAIL_TYPE) { - setDisplay("mailgo", "flex"); - return true; - } - // show mailgo type tel - if (type === TEL_TYPE) { - setDisplay("mailgo-tel", "flex"); - return true; - } - return false; -}; - -// hide the modal -const hideMailgo = (): void => { - setDisplay("mailgo", "none"); - setDisplay("mailgo-tel", "none"); - - // remove listener keyDown - document.removeEventListener("keydown", mailgoKeydown); -}; - -// is the mailgo modal hidden? -const mailgoIsShowing = (type = MAIL_TYPE): boolean => { - return type === MAIL_TYPE - ? getDisplay("mailgo") === "flex" - : type === TEL_TYPE - ? getDisplay("mailgo-tel") === "flex" - : false; -}; - -const byElement = (): HTMLLinkElement => { - // by - let by: HTMLLinkElement = createElement("a"); - by.href = "https://mailgo.js.org?ref=mailgo-modal"; - by.className = "m-by"; - by.target = "_blank"; - by.rel = "noopener noreferrer"; - by.appendChild(createTextNode("mailgo.js.org")); - - return by; -}; - -// create element -const createElement = (element: string = "div"): HTMLElement => - document.createElement(element); - -// create text node -const createTextNode = (element: string): Text => - document.createTextNode(element); - -// decrypt email -const mailToEncoded = (encoded: string): string => - (window.location.href = MAILTO + atob(encoded)); - -// encode email -const encodeEmail = (email: string): string => btoa(email); - -// getE shorthand -const getE = (id: string): HTMLElement => document.getElementById(id); - -// get display value -const getDisplay = (id: string): string => getE(id).style.display; - -// get display value -const setDisplay = (id: string, value: string): string => - (getE(id).style.display = value); - -// custom composedPath if path or event.composedPath() are not defined -const composedPath = ( - el: HTMLElement -): (HTMLElement | Document | (Window & typeof globalThis))[] => { - let path = []; - - while (el) { - path.push(el); - - if (el.tagName === "HTML") { - path.push(document); - path.push(window); - return path; - } - - el = el.parentElement; - } -}; - -// validate a single email with regex -const validateEmail = (email: string): boolean => - /^(([^<>()[\]\\.,;:\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( - email - ); - -// validate an array of emails -const validateEmails = (arr: string[]): boolean => arr.every(validateEmail); - -// copy of a string -const copyToClipboard = (str: string): boolean => { - let el: HTMLInputElement = createElement("textarea"); - el.value = str; - el.setAttribute("readonly", ""); - el.style.position = "absolute"; - el.style.left = "-9999px"; - document.body.appendChild(el); - let selected = - document.getSelection().rangeCount > 0 - ? document.getSelection().getRangeAt(0) - : false; - el.select(); - document.execCommand("copy"); - document.body.removeChild(el); - if (selected) { - document.getSelection().removeAllRanges(); - document.getSelection().addRange(selected); - return true; - } - return false; -}; - -const mailgoStyle = (): void => { - // mailgo style - let mailgoCSS: HTMLStyleElement = createElement("style"); - mailgoCSS.id = "mailgo-style"; - mailgoCSS.type = "text/css"; - mailgoCSS.appendChild(createTextNode(`.m-modal{position:fixed;top:0;right:0;bottom:0;left:0;-webkit-box-pack:center;-webkit-justify-content:center;-moz-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;-moz-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.m-modal a,.m-modal p,.m-modal span,.m-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";text-rendering:optimizeLegibility}.m-modal strong{font-weight:700}.m-modal .m-modal-back{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.m-modal .m-modal-content{position:relative;z-index:10002;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;-webkit-box-shadow:0 3px 20px rgba(32,35,42,.5);-moz-box-shadow:0 3px 20px rgba(32,35,42,.5);box-shadow:0 3px 20px rgba(32,35,42,.5);color:#4a4a4a;display:-webkit-box;display:-webkit-flex;display:-moz-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-direction:column;-moz-box-orient:vertical;-moz-box-direction:normal;-ms-flex-direction:column;flex-direction:column;overflow:auto;padding:20px;-webkit-transition:.5s -webkit-box-shadow;transition:.5s -webkit-box-shadow;-o-transition:.5s box-shadow;-moz-transition:.5s box-shadow,.5s -moz-box-shadow;transition:.5s box-shadow;transition:.5s box-shadow,.5s -webkit-box-shadow,.5s -moz-box-shadow}.m-modal .m-modal-content:hover{opacity:1;-webkit-box-shadow:0 7px 20px rgba(32,35,42,.85);-moz-box-shadow:0 7px 20px rgba(32,35,42,.85);box-shadow:0 7px 20px rgba(32,35,42,.85)}.m-modal .m-modal-content .m-title{margin-bottom:8px;overflow:hidden;white-space:nowrap;-o-text-overflow:ellipsis;text-overflow:ellipsis}.m-modal .m-modal-content .m-details{margin-bottom:10px}.m-modal .m-modal-content .m-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.m-modal .m-modal-content a{padding:10px;color:#4a4a4a;-webkit-border-radius:8px;-moz-border-radius:8px;border-radius:8px;text-decoration:none}.m-modal .m-modal-content a.m-gmail{color:#d44638}.m-modal .m-modal-content a.m-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.m-modal .m-modal-content a.m-outlook{color:#0072c6}.m-modal .m-modal-content a.m-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.m-modal .m-modal-content a.m-tg{color:#08c}.m-modal .m-modal-content a.m-tg:hover{background-color:rgba(0,114,198,.08);color:#08c}.m-modal .m-modal-content a.m-wa{color:#00bfa5}.m-modal .m-modal-content a.m-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.m-modal .m-modal-content a.m-skype{color:#00aff0}.m-modal .m-modal-content a.m-skype:hover{background-color:rgba(0,175,240,.08);color:#00aff0}.m-modal .m-modal-content a.m-copy{padding:16px 10px;font-size:16px}.m-modal .m-modal-content a.m-copy:hover,.m-modal .m-modal-content a.m-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.m-modal .m-modal-content a.m-by{font-size:8px;margin-top:.8rem;padding:5px;color:#4a4a4a;opacity:.5}.m-modal .m-modal-content a.m-by:hover{opacity:1}.m-modal .m-modal-content .w-500{font-weight:500}`)); - document.head.appendChild(mailgoCSS); -}; - -// mailgo -const mailgo = (mailgoConfig?: any): void => { - // if the window is defined... - if (window && typeof window !== "undefined") { - // add the style for mailgo - mailgoStyle(); - - // if is set an initEvent add the listener - if (mailgoConfig?.initEvent) { - document.addEventListener(mailgoConfig.initEvent, mailgoInit); - } else { - mailgoInit(); - } - - // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered - document.addEventListener("click", mailgoCheckRender); - } -}; - -export default mailgo; diff --git a/package.json b/package.json index e1e3881..d032e4e 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@babel/parser": "^7.9.4", "@babel/preset-env": "^7.9.5", "@babel/preset-flow": "^7.9.0", + "@babel/preset-typescript": "^7.9.0", "@babel/types": "^7.9.5", "flow-bin": "^0.123.0", "gulp": "^4.0.2", diff --git a/tsconfig.json b/tsconfig.json index b4b6f0d..eb647e2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,5 +7,6 @@ "jsx": "react", "allowJs": true, "moduleResolution": "node" - } + }, + "include": ["src"] } diff --git a/yarn.lock b/yarn.lock index 8c99013..5cc098e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -92,6 +92,18 @@ levenary "^1.1.1" semver "^5.5.0" +"@babel/helper-create-class-features-plugin@^7.8.3": + version "7.9.5" + resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.9.5.tgz#79753d44017806b481017f24b02fd4113c7106ea" + integrity sha512-IipaxGaQmW4TfWoXdqjY0TzoXQ1HRS0kPpEgvjosb3u7Uedcq297xFqDQiCcQtRRwzIMif+N1MLVI8C5a4/PAA== + dependencies: + "@babel/helper-function-name" "^7.9.5" + "@babel/helper-member-expression-to-functions" "^7.8.3" + "@babel/helper-optimise-call-expression" "^7.8.3" + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/helper-replace-supers" "^7.8.6" + "@babel/helper-split-export-declaration" "^7.8.3" + "@babel/helper-create-regexp-features-plugin@^7.8.3", "@babel/helper-create-regexp-features-plugin@^7.8.8": version "7.8.8" resolved "https://registry.yarnpkg.com/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.8.8.tgz#5d84180b588f560b7864efaeea89243e58312087" @@ -426,6 +438,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" +"@babel/plugin-syntax-typescript@^7.8.3": + version "7.8.3" + resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.8.3.tgz#c1f659dda97711a569cef75275f7e15dcaa6cabc" + integrity sha512-GO1MQ/SGGGoiEXY0e0bSpHimJvxqB7lktLLIq2pv8xG7WZ8IMEle74jIe1FhprHBWjwjZtXHkycDLZXIWM5Wfg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/plugin-transform-arrow-functions@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.8.3.tgz#82776c2ed0cd9e1a49956daeb896024c9473b8b6" @@ -670,6 +689,15 @@ dependencies: "@babel/helper-plugin-utils" "^7.8.3" +"@babel/plugin-transform-typescript@^7.9.0": + version "7.9.4" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.9.4.tgz#4bb4dde4f10bbf2d787fce9707fb09b483e33359" + integrity sha512-yeWeUkKx2auDbSxRe8MusAG+n4m9BFY/v+lPjmQDgOFX5qnySkUY5oXzkp6FwPdsYqnKay6lorXYdC0n3bZO7w== + dependencies: + "@babel/helper-create-class-features-plugin" "^7.8.3" + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/plugin-syntax-typescript" "^7.8.3" + "@babel/plugin-transform-unicode-regex@^7.8.3": version "7.8.3" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.8.3.tgz#0cef36e3ba73e5c57273effb182f46b91a1ecaad" @@ -763,6 +791,14 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" +"@babel/preset-typescript@^7.9.0": + version "7.9.0" + resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.9.0.tgz#87705a72b1f0d59df21c179f7c3d2ef4b16ce192" + integrity sha512-S4cueFnGrIbvYJgwsVFKdvOmpiL0XGw9MFW9D0vgRys5g36PBhZRL8NX8Gr2akz8XRtzq6HuDXPD/1nniagNUg== + dependencies: + "@babel/helper-plugin-utils" "^7.8.3" + "@babel/plugin-transform-typescript" "^7.9.0" + "@babel/runtime@^7.8.4": version "7.9.2" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.9.2.tgz#d90df0583a3a252f09aaa619665367bae518db06" @@ -2408,13 +2444,6 @@ debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" -debug@^3.2.6: - version "3.2.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== - dependencies: - ms "^2.1.1" - debug@^4.1.0, debug@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" @@ -2432,11 +2461,6 @@ decode-uri-component@^0.2.0: resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= -deep-extend@^0.6.0: - version "0.6.0" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" - integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== - deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -2511,11 +2535,6 @@ detect-file@^1.0.0: resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= -detect-libc@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" - integrity sha1-+hN8S9aY7fVc1c0CrFWfkaTEups= - detect-newline@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" @@ -3061,13 +3080,6 @@ from2@^2.1.0: inherits "^2.0.1" readable-stream "^2.0.0" -fs-minipass@^1.2.5: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== - dependencies: - minipass "^2.6.0" - fs-mkdirp-stream@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs-mkdirp-stream/-/fs-mkdirp-stream-1.0.0.tgz#0b7815fc3201c6a69e14db98ce098c16935259eb" @@ -3591,7 +3603,7 @@ human-signals@^1.1.1: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== -iconv-lite@0.4.24, iconv-lite@^0.4.4: +iconv-lite@0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== @@ -3608,13 +3620,6 @@ iferr@^0.1.5: resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501" integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE= -ignore-walk@^3.0.1: - version "3.0.3" - resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.3.tgz#017e2447184bfeade7c238e4aefdd1e8f95b1e37" - integrity sha512-m7o6xuOaT1aqheYHKf8W6J5pYH85ZI9w077erOzLje3JsB1gkafkAhHHY19dqjulgIZHFm32Cp5uNZgcQqdJKw== - dependencies: - minimatch "^3.0.4" - import-local@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" @@ -3676,7 +3681,7 @@ inherits@2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -ini@^1.3.4, ini@^1.3.5, ini@~1.3.0: +ini@^1.3.4, ini@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== @@ -4892,21 +4897,6 @@ minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== -minipass@^2.6.0, minipass@^2.8.6, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== - dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" - -minizlib@^1.2.1: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== - dependencies: - minipass "^2.9.0" - mississippi@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" @@ -4992,15 +4982,6 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= -needle@^2.2.1: - version "2.4.1" - resolved "https://registry.yarnpkg.com/needle/-/needle-2.4.1.tgz#14af48732463d7475696f937626b1b993247a56a" - integrity sha512-x/gi6ijr4B7fwl6WYL9FwlCvRQKGlUNvnceho8wxkwXqN8jvVmmmATTmZPRRG7b/yC1eode26C2HO9jl78Du9g== - dependencies: - debug "^3.2.6" - iconv-lite "^0.4.4" - sax "^1.2.4" - neo-async@^2.5.0, neo-async@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" @@ -5084,22 +5065,6 @@ node-notifier@^6.0.0: shellwords "^0.1.1" which "^1.3.1" -node-pre-gyp@*: - version "0.14.0" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.14.0.tgz#9a0596533b877289bcad4e143982ca3d904ddc83" - integrity sha512-+CvDC7ZttU/sSt9rFjix/P05iS43qHCOOGzcr3Ry99bXG7VX953+vFyEuph/tfqoYu8dttBkE86JSKBO2OzcxA== - dependencies: - detect-libc "^1.0.2" - mkdirp "^0.5.1" - needle "^2.2.1" - nopt "^4.0.1" - npm-packlist "^1.1.6" - npmlog "^4.0.2" - rc "^1.2.7" - rimraf "^2.6.1" - semver "^5.3.0" - tar "^4.4.2" - node-releases@^1.1.53: version "1.1.53" resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.53.tgz#2d821bfa499ed7c5dffc5e2f28c88e78a08ee3f4" @@ -5135,14 +5100,6 @@ node-sass@^4.14.0, node-sass@^4.8.3: dependencies: abbrev "1" -nopt@^4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" - integrity sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg== - dependencies: - abbrev "1" - osenv "^0.1.4" - normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" @@ -5177,27 +5134,6 @@ now-and-later@^2.0.0: dependencies: once "^1.3.2" -npm-bundled@^1.0.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.1.1.tgz#1edd570865a94cdb1bc8220775e29466c9fb234b" - integrity sha512-gqkfgGePhTpAEgUsGEgcq1rqPXA+tv/aVBlgEzfXwA1yiUJF7xtEt3CtVwOjNYQOVknDk0F20w58Fnm3EtG0fA== - dependencies: - npm-normalize-package-bin "^1.0.1" - -npm-normalize-package-bin@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-1.0.1.tgz#6e79a41f23fd235c0623218228da7d9c23b8f6e2" - integrity sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA== - -npm-packlist@^1.1.6: - version "1.4.8" - resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.4.8.tgz#56ee6cc135b9f98ad3d51c1c95da22bbb9b2ef3e" - integrity sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A== - dependencies: - ignore-walk "^3.0.1" - npm-bundled "^1.0.1" - npm-normalize-package-bin "^1.0.1" - npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -5212,7 +5148,7 @@ npm-run-path@^4.0.0: dependencies: path-key "^3.0.0" -"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.0, npmlog@^4.0.2: +"npmlog@0 || 1 || 2 || 3 || 4", npmlog@^4.0.0: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -5375,7 +5311,7 @@ os-tmpdir@^1.0.0: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -osenv@0, osenv@^0.1.4: +osenv@0: version "0.1.5" resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" integrity sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g== @@ -5843,16 +5779,6 @@ randomfill@^1.0.3: randombytes "^2.0.5" safe-buffer "^5.1.0" -rc@^1.2.7: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - react-is@^16.12.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" @@ -6182,7 +6108,7 @@ ret@~0.1.10: resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== -rimraf@2, rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.3: +rimraf@2, rimraf@^2.5.4, rimraf@^2.6.3: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== @@ -6263,11 +6189,6 @@ sass-graph@^2.2.4: scss-tokenizer "^0.2.3" yargs "^7.0.0" -sax@^1.2.4: - version "1.2.4" - resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" - integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw== - saxes@^3.1.9: version "3.1.11" resolved "https://registry.yarnpkg.com/saxes/-/saxes-3.1.11.tgz#d59d1fd332ec92ad98a2e0b2ee644702384b1c5b" @@ -6299,7 +6220,7 @@ semver-greatest-satisfied-range@^1.1.0: dependencies: sver-compat "^1.5.0" -"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: +"semver@2 || 3 || 4 || 5", semver@^5.4.1, semver@^5.5.0, semver@^5.6.0: version "5.7.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== @@ -6728,11 +6649,6 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= - supports-color@6.1.0, supports-color@^6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" @@ -6794,19 +6710,6 @@ tar@^2.0.0: fstream "^1.0.12" inherits "2" -tar@^4.4.2: - version "4.4.13" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.13.tgz#43b364bc52888d555298637b10d60790254ab525" - integrity sha512-w2VwSrBoHa5BsSyH+KxEqeQBAllHhccyMFVHtGtdMpF4W7IRWfZjFiQceJPChOeTsSDVUpER2T8FA93pr0L+QA== - dependencies: - chownr "^1.1.1" - fs-minipass "^1.2.5" - minipass "^2.8.6" - minizlib "^1.2.1" - mkdirp "^0.5.0" - safe-buffer "^5.1.2" - yallist "^3.0.3" - terminal-link@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994" @@ -7561,7 +7464,7 @@ yallist@^2.1.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= -yallist@^3.0.0, yallist@^3.0.2, yallist@^3.0.3: +yallist@^3.0.2: version "3.1.1" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==