diff --git a/dist/mailgo.css b/dist/mailgo.css index cdc8310..3155e6f 100644 --- a/dist/mailgo.css +++ b/dist/mailgo.css @@ -2,14 +2,17 @@ display: block; margin-bottom: 5px; } + .mailgo-details { margin-bottom: 10px; } + .mailgo-details p { font-size: 12px; margin-top: 3px; margin-bottom: 3px; } + .mailgo-modal-background { position: absolute; top: 0; @@ -19,6 +22,7 @@ background-color: rgba(10, 10, 10, 0.86); opacity: 0.8; } + .mailgo-modal { position: fixed; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, @@ -34,9 +38,11 @@ overflow: hidden; z-index: 100000; } + .mailgo-modal.is-active { display: flex; } + .mailgo-modal-content { z-index: 1000; text-align: center; @@ -49,34 +55,43 @@ overflow: auto; padding: 1.25rem; } + .mailgo-modal-content a { display: block; color: #4a4a4a; border-radius: 4px; text-decoration: none; } + .mailgo-modal-content a { padding: 10px; } + .mailgo-modal-content a.mailgo-open:hover, .mailgo-modal-content a.mailgo-copy:hover { background-color: rgba(0, 0, 0, 0.08); } + .mailgo-modal-content a.outlook { color: #0072c6; } + .mailgo-modal-content a.gmail { color: #d44638; } + .mailgo-modal-content a.outlook:hover { background-color: rgba(0, 114, 198, 0.08); } + .mailgo-modal-content a.gmail:hover { background-color: rgba(212, 70, 56, 0.08); } + .mailgo-modal-content a.mailgo-copy { padding: 16px 10px; } + .mailgo-modal-content a.mailgo-by { display: block; font-size: 8px; @@ -84,6 +99,7 @@ padding: 0px; font-style: italic; } + .mailgo-weight-500 { font-weight: 500; } diff --git a/dist/mailgo.js b/dist/mailgo.js index 52413e0..1c5295f 100644 --- a/dist/mailgo.js +++ b/dist/mailgo.js @@ -1,7 +1,7 @@ mailgoInit = () => { const styleSheet = document.createElement("style"); styleSheet.type = "text/css"; - styleSheet.innerText = styles; + styleSheet.src = "https://unpkg.com/mailgo@latest/dist/mailgo.min.css"; document.head.appendChild(styleSheet); // ottengo tutti i mailto contenuti nella pagina diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index 7f7cfb3..a83c79a 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -mailgoInit=(()=>{const e=document.createElement("style");e.type="text/css",e.innerText=styles,document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo), a[href="#mailgo"], a.mailgo').forEach((e,t)=>{let a="",l="",d="",n="",o="",c="";if(e.href&&e.href.includes("mailto:")){a=e.href.split("?")[0].split("mailto:")[1].trim(),l=e.href,url=new URL(l);let t=new URLSearchParams(url.search);d=t.get("cc"),n=t.get("bcc"),o=t.get("subject"),c=t.get("body")}else l="mailto:"+(a=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain")),url=new URL(l);if(!validateEmail(a))return;let i=document.createElement("div");i.classList.add("mailgo-modal"),i.setAttribute("data-index",t);let m=document.createElement("div");m.className="mailgo-modal-background",i.appendChild(m);let p=document.createElement("div");p.className="mailgo-modal-content",i.appendChild(p);let s=document.createElement("strong");s.className="mailgo-title";let r=document.createTextNode(a);s.appendChild(r),p.appendChild(s);let u=document.createElement("div");if(u.className="mailgo-details",d&&""!=d){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+d);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(n&&""!=n){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("bcc");t.appendChild(a);let l=document.createTextNode(": "+n);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(o&&""!=o){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+o);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(c&&""!=c){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(l),u.appendChild(e)}p.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+l,h.classList.add("mailgo-open"),h.classList.add("gmail");let g=document.createTextNode("open in ");h.appendChild(g);let C=document.createElement("span");C.className="mailgo-weight-500";let E=document.createTextNode("Gmail");C.appendChild(E),h.appendChild(C),p.appendChild(h);let N=document.createElement("a");N.href="https://outlook.office.com/owa/?rru=compose&to="+a+url.search,N.classList.add("mailgo-open"),N.classList.add("outlook");let x=document.createTextNode("open in ");N.appendChild(x);let f=document.createElement("span");f.className="mailgo-weight-500";let T=document.createTextNode("Outlook");f.appendChild(T),N.appendChild(f),p.appendChild(N);let L=document.createElement("a");L.href=l,L.classList.add("mailgo-open"),L.classList.add("mailgo-weight-500");let b=document.createTextNode("open");L.appendChild(b),p.appendChild(L);let y=document.createElement("a");y.href="#mailgo-copy",y.classList.add("mailgo-copy"),y.classList.add("mailgo-weight-500");let v=document.createTextNode("copy");y.appendChild(v),y.addEventListener("click",e=>{copyToClipboard(a),y.innerHTML="copied";setTimeout(()=>{y.innerHTML="copy"},999)},!1),p.appendChild(y);let w=document.createElement("a");w.href="https://mailgo.js.org",w.className="mailgo-by",w.target="_blank";let A=document.createTextNode("mailgo.js.org");w.appendChild(A),p.appendChild(w),e.parentNode.insertBefore(i,e.nextSibling),e.addEventListener("click",t=>{t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),m.addEventListener("click",t=>{e.nextElementSibling.classList.remove("is-active")},!1)})}),document.addEventListener("DOMContentLoaded",mailgoInit,!1),validateEmail=(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)}),copyToClipboard=(e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const a=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),a&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(a))}); \ No newline at end of file +mailgoInit=(()=>{const e=document.createElement("style");e.type="text/css",e.src="https://unpkg.com/mailgo@latest/dist/mailgo.min.css",document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo), a[href="#mailgo"], a.mailgo').forEach((e,t)=>{let a="",l="",d="",n="",o="",c="";if(e.href&&e.href.includes("mailto:")){a=e.href.split("?")[0].split("mailto:")[1].trim(),l=e.href,url=new URL(l);let t=new URLSearchParams(url.search);d=t.get("cc"),n=t.get("bcc"),o=t.get("subject"),c=t.get("body")}else l="mailto:"+(a=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain")),url=new URL(l);if(!validateEmail(a))return;let i=document.createElement("div");i.classList.add("mailgo-modal"),i.setAttribute("data-index",t);let m=document.createElement("div");m.className="mailgo-modal-background",i.appendChild(m);let p=document.createElement("div");p.className="mailgo-modal-content",i.appendChild(p);let s=document.createElement("strong");s.className="mailgo-title";let r=document.createTextNode(a);s.appendChild(r),p.appendChild(s);let u=document.createElement("div");if(u.className="mailgo-details",d&&""!=d){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+d);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(n&&""!=n){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("bcc");t.appendChild(a);let l=document.createTextNode(": "+n);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(o&&""!=o){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+o);e.appendChild(t),e.appendChild(l),u.appendChild(e)}if(c&&""!=c){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let l=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(l),u.appendChild(e)}p.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+l,h.classList.add("mailgo-open"),h.classList.add("gmail");let g=document.createTextNode("open in ");h.appendChild(g);let C=document.createElement("span");C.className="mailgo-weight-500";let E=document.createTextNode("Gmail");C.appendChild(E),h.appendChild(C),p.appendChild(h);let N=document.createElement("a");N.href="https://outlook.office.com/owa/?rru=compose&to="+a+url.search,N.classList.add("mailgo-open"),N.classList.add("outlook");let x=document.createTextNode("open in ");N.appendChild(x);let f=document.createElement("span");f.className="mailgo-weight-500";let L=document.createTextNode("Outlook");f.appendChild(L),N.appendChild(f),p.appendChild(N);let T=document.createElement("a");T.href=l,T.classList.add("mailgo-open"),T.classList.add("mailgo-weight-500");let b=document.createTextNode("open");T.appendChild(b),p.appendChild(T);let v=document.createElement("a");v.href="#mailgo-copy",v.classList.add("mailgo-copy"),v.classList.add("mailgo-weight-500");let y=document.createTextNode("copy");v.appendChild(y),v.addEventListener("click",e=>{copyToClipboard(a),v.innerHTML="copied";setTimeout(()=>{v.innerHTML="copy"},999)},!1),p.appendChild(v);let w=document.createElement("a");w.href="https://mailgo.js.org",w.className="mailgo-by",w.target="_blank";let k=document.createTextNode("mailgo.js.org");w.appendChild(k),p.appendChild(w),e.parentNode.insertBefore(i,e.nextSibling),e.addEventListener("click",t=>{t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),m.addEventListener("click",t=>{e.nextElementSibling.classList.remove("is-active")},!1)})}),document.addEventListener("DOMContentLoaded",mailgoInit,!1),validateEmail=(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)}),copyToClipboard=(e=>{const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="absolute",t.style.left="-9999px",document.body.appendChild(t);const a=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),a&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(a))}); \ No newline at end of file