From 9b03dde1ba6cea579579fcf72b56aaa4ff341c7e Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Mon, 6 May 2019 14:55:27 +0200 Subject: [PATCH] gulp --- dist/mailgo.js | 14 +++++++------- dist/mailgo.min.js | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dist/mailgo.js b/dist/mailgo.js index f09f69c..376f384 100644 --- a/dist/mailgo.js +++ b/dist/mailgo.js @@ -1,8 +1,5 @@ function mailgoInit() { - // ottengo tutti i mailto contenuti nella pagina - let mailgos = document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)'); - - let styles = ` + const styles = ` .mailgo { all: initial; * { @@ -93,12 +90,15 @@ function mailgoInit() { font-weight: 500; }`; - let styleSheet = document.createElement("style"); + const styleSheet = document.createElement("style"); styleSheet.type = "text/css"; styleSheet.innerText = styles; document.head.appendChild(styleSheet); - console.log("mailgo is WIP!"); + // ottengo tutti i mailto contenuti nella pagina + const mailgos = document.querySelectorAll( + 'a[href^="mailto:"]:not(.no-mailgo)' + ); // attivo mailgo su tutti gli elementi mailgos.forEach(function(mailgo, index) { @@ -288,7 +288,7 @@ function mailgoInit() { document.addEventListener("DOMContentLoaded", mailgoInit, false); function validateEmail(email) { - var re = /^(([^<>()[\]\\.,;:\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,}))$/; + let re = /^(([^<>()[\]\\.,;:\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,}))$/; return re.test(email); } diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index dd4ac04..47772ee 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -function mailgoInit(){let e=document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)'),t=document.createElement("style");t.type="text/css",t.innerText='\n .mailgo {\n all: initial;\n * {\n all: unset;\n }\n }\n .mailgo-title {\n display: block;\n margin-bottom: 5px;\n }\n .mailgo-details {\n font-size: 12px;\n margin-bottom: 10px;\n }\n .mailgo-details p {\n margin-top: 3px;\n margin-bottom: 3px;\n }\n .mailgo-modal-background {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(10,10,10,.86);\n opacity: 0.8;\n }\n .mailgo-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: none;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";\n }\n .mailgo-modal.is-active {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .mailgo-modal-content {\n z-index: 1000;\n text-align: center;\n width: 200px;\n background-color: #fff;\n border-radius: 6px;\n box-shadow: 0 2px 3px rgba(10,10,10,.1), 0 0 0 1px rgba(10,10,10,.1);\n color: #4a4a4a;\n display: block;\n padding: 1.25rem;\n }\n .mailgo-modal-content a {\n display: block;\n color: #4a4a4a;\n border-radius: 4px;\n text-decoration: none;\n }\n .mailgo-modal-content a {\n padding: 10px;\n }\n .mailgo-modal-content a.mailgo-open:hover, .mailgo-modal-content a.mailgo-copy:hover {\n background-color: rgba(0, 0, 0, 0.08);\n }\n .mailgo-modal-content a.outlook {\n color: #0072C6;\n }\n .mailgo-modal-content a.gmail {\n color: #D44638;\n }\n .mailgo-modal-content a.outlook:hover {\n background-color: rgba(0, 114, 198, 0.08);\n }\n .mailgo-modal-content a.gmail:hover {\n background-color: rgba(212, 70, 56, 0.08);\n }\n .mailgo-modal-content a.mailgo-copy {\n padding: 16px 10px;\n }\n .mailgo-modal-content a.mailgo-by {\n display: block;\n font-size: 8px;\n margin-top: 1rem;\n padding: 0px;\n font-style: italic;\n }\n .mailgo-weight-500 {\n font-weight: 500;\n }',document.head.appendChild(t),console.log("mailgo is WIP!"),e.forEach(function(e,t){let n=e.href.split("?")[0].split("mailto:")[1].trim(),a=new URL(e.href),o=new URLSearchParams(a.search),l=o.get("cc"),d=o.get("bcc"),i=o.get("subject"),c=o.get("body");if(!validateEmail(n))return;let m=document.createElement("div");m.classList.add("mailgo"),m.classList.add("mailgo-modal"),m.setAttribute("data-index",t);let p=document.createElement("div");p.className="mailgo-modal-background",m.appendChild(p);let r=document.createElement("div");r.className="mailgo-modal-content",m.appendChild(r);let s=document.createElement("strong");s.className="mailgo-title";let g=document.createTextNode(n);s.appendChild(g),r.appendChild(s);let u=document.createElement("div");if(u.className="mailgo-details",l&&""!=l){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("cc");t.appendChild(n);let a=document.createTextNode(": "+l);e.appendChild(t),e.appendChild(a),u.appendChild(e)}if(d&&""!=d){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("bcc");t.appendChild(n);let a=document.createTextNode(": "+d);e.appendChild(t),e.appendChild(a),u.appendChild(e)}if(i&&""!=i){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("cc");t.appendChild(n);let a=document.createTextNode(": "+i);e.appendChild(t),e.appendChild(a),u.appendChild(e)}if(c&&""!=c){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("cc");t.appendChild(n);let a=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(a),u.appendChild(e)}r.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+e.href,h.classList.add("mailgo-open"),h.classList.add("gmail");let x=document.createTextNode("open in ");h.appendChild(x);let b=document.createElement("span");b.className="mailgo-weight-500";let C=document.createTextNode("Gmail");b.appendChild(C),h.appendChild(b),r.appendChild(h);let f=document.createElement("a");f.href="https://outlook.office.com/owa/?rru=compose&to="+n+a.search,f.classList.add("mailgo-open"),f.classList.add("outlook");let E=document.createTextNode("open in ");f.appendChild(E);let y=document.createElement("span");y.className="mailgo-weight-500";let N=document.createTextNode("Outlook");y.appendChild(N),f.appendChild(y),r.appendChild(f);let v=document.createElement("a");v.href=e.href,v.classList.add("mailgo-open"),v.classList.add("mailgo-weight-500");let k=document.createTextNode("open");v.appendChild(k),r.appendChild(v);let L=document.createElement("a");L.href="#mailgo-copy",L.classList.add("mailgo-copy"),L.classList.add("mailgo-weight-500");let T=document.createTextNode("copy");L.appendChild(T),L.addEventListener("click",function(e){copyToClipboard(n),L.innerHTML="copied!"},!1),r.appendChild(L);let w=document.createElement("a");w.href="https://mailgo.js.org",w.className="mailgo-by",w.target="_blank";let S=document.createTextNode("mailgo.js.org");w.appendChild(S),r.appendChild(w),e.parentNode.insertBefore(m,e.nextSibling),e.addEventListener("click",function(t){t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),p.addEventListener("click",function(t){e.nextElementSibling.classList.remove("is-active")},!1)})}function 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)}function 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 n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),n&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n))}document.addEventListener("DOMContentLoaded",mailgoInit,!1); \ No newline at end of file +function mailgoInit(){const e=document.createElement("style");e.type="text/css",e.innerText='\n .mailgo {\n all: initial;\n * {\n all: unset;\n }\n }\n .mailgo-title {\n display: block;\n margin-bottom: 5px;\n }\n .mailgo-details {\n font-size: 12px;\n margin-bottom: 10px;\n }\n .mailgo-details p {\n margin-top: 3px;\n margin-bottom: 3px;\n }\n .mailgo-modal-background {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(10,10,10,.86);\n opacity: 0.8;\n }\n .mailgo-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n display: none;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";\n }\n .mailgo-modal.is-active {\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .mailgo-modal-content {\n z-index: 1000;\n text-align: center;\n width: 200px;\n background-color: #fff;\n border-radius: 6px;\n box-shadow: 0 2px 3px rgba(10,10,10,.1), 0 0 0 1px rgba(10,10,10,.1);\n color: #4a4a4a;\n display: block;\n padding: 1.25rem;\n }\n .mailgo-modal-content a {\n display: block;\n color: #4a4a4a;\n border-radius: 4px;\n text-decoration: none;\n }\n .mailgo-modal-content a {\n padding: 10px;\n }\n .mailgo-modal-content a.mailgo-open:hover, .mailgo-modal-content a.mailgo-copy:hover {\n background-color: rgba(0, 0, 0, 0.08);\n }\n .mailgo-modal-content a.outlook {\n color: #0072C6;\n }\n .mailgo-modal-content a.gmail {\n color: #D44638;\n }\n .mailgo-modal-content a.outlook:hover {\n background-color: rgba(0, 114, 198, 0.08);\n }\n .mailgo-modal-content a.gmail:hover {\n background-color: rgba(212, 70, 56, 0.08);\n }\n .mailgo-modal-content a.mailgo-copy {\n padding: 16px 10px;\n }\n .mailgo-modal-content a.mailgo-by {\n display: block;\n font-size: 8px;\n margin-top: 1rem;\n padding: 0px;\n font-style: italic;\n }\n .mailgo-weight-500 {\n font-weight: 500;\n }',document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:"]:not(.no-mailgo)').forEach(function(e,t){let n=e.href.split("?")[0].split("mailto:")[1].trim(),a=new URL(e.href),o=new URLSearchParams(a.search),l=o.get("cc"),d=o.get("bcc"),i=o.get("subject"),c=o.get("body");if(!validateEmail(n))return;let m=document.createElement("div");m.classList.add("mailgo"),m.classList.add("mailgo-modal"),m.setAttribute("data-index",t);let p=document.createElement("div");p.className="mailgo-modal-background",m.appendChild(p);let r=document.createElement("div");r.className="mailgo-modal-content",m.appendChild(r);let s=document.createElement("strong");s.className="mailgo-title";let g=document.createTextNode(n);s.appendChild(g),r.appendChild(s);let u=document.createElement("div");if(u.className="mailgo-details",l&&""!=l){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("cc");t.appendChild(n);let a=document.createTextNode(": "+l);e.appendChild(t),e.appendChild(a),u.appendChild(e)}if(d&&""!=d){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("bcc");t.appendChild(n);let a=document.createTextNode(": "+d);e.appendChild(t),e.appendChild(a),u.appendChild(e)}if(i&&""!=i){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("cc");t.appendChild(n);let a=document.createTextNode(": "+i);e.appendChild(t),e.appendChild(a),u.appendChild(e)}if(c&&""!=c){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let n=document.createTextNode("cc");t.appendChild(n);let a=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(a),u.appendChild(e)}r.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+e.href,h.classList.add("mailgo-open"),h.classList.add("gmail");let x=document.createTextNode("open in ");h.appendChild(x);let b=document.createElement("span");b.className="mailgo-weight-500";let C=document.createTextNode("Gmail");b.appendChild(C),h.appendChild(b),r.appendChild(h);let f=document.createElement("a");f.href="https://outlook.office.com/owa/?rru=compose&to="+n+a.search,f.classList.add("mailgo-open"),f.classList.add("outlook");let E=document.createTextNode("open in ");f.appendChild(E);let y=document.createElement("span");y.className="mailgo-weight-500";let N=document.createTextNode("Outlook");y.appendChild(N),f.appendChild(y),r.appendChild(f);let v=document.createElement("a");v.href=e.href,v.classList.add("mailgo-open"),v.classList.add("mailgo-weight-500");let k=document.createTextNode("open");v.appendChild(k),r.appendChild(v);let L=document.createElement("a");L.href="#mailgo-copy",L.classList.add("mailgo-copy"),L.classList.add("mailgo-weight-500");let T=document.createTextNode("copy");L.appendChild(T),L.addEventListener("click",function(e){copyToClipboard(n),L.innerHTML="copied!"},!1),r.appendChild(L);let w=document.createElement("a");w.href="https://mailgo.js.org",w.className="mailgo-by",w.target="_blank";let S=document.createTextNode("mailgo.js.org");w.appendChild(S),r.appendChild(w),e.parentNode.insertBefore(m,e.nextSibling),e.addEventListener("click",function(t){t.preventDefault(),e.nextElementSibling.classList.add("is-active")},!1),p.addEventListener("click",function(t){e.nextElementSibling.classList.remove("is-active")},!1)})}function 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)}function 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 n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);t.select(),document.execCommand("copy"),document.body.removeChild(t),n&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n))}document.addEventListener("DOMContentLoaded",mailgoInit,!1); \ No newline at end of file