From 70662fee621b1d7fc69182f67a4d1be49199e8a5 Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Fri, 10 May 2019 16:27:28 +0200 Subject: [PATCH] release v0.2.8 --- README.md | 6 +++--- dist/mailgo.js | 15 +++++++++------ dist/mailgo.min.js | 2 +- package.json | 2 +- src/mailgo.js | 13 ++++++++----- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 68ab29a..df07147 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ mailgo will substitute all the `mailto:` links with the **mailgo modal** -[![mailgo.min.js size](https://img.shields.io/github/size/manzinello/mailgo/dist/mailgo.min.js.svg?label=mailgo.min.js&style=flat-square)](https://unpkg.com/mailgo@0.2.7/dist/mailgo.min.js) +[![mailgo.min.js size](https://img.shields.io/github/size/manzinello/mailgo/dist/mailgo.min.js.svg?label=mailgo.min.js&style=flat-square)](https://unpkg.com/mailgo@0.2.8/dist/mailgo.min.js) mailgo modal @@ -20,7 +20,7 @@ add at the end of the `` ``` ... - + ``` @@ -29,7 +29,7 @@ you can also import mailgo in `` using `defer` ``` ... - + ``` diff --git a/dist/mailgo.js b/dist/mailgo.js index 5ac687b..a11aed9 100644 --- a/dist/mailgo.js +++ b/dist/mailgo.js @@ -1,4 +1,4 @@ -const VERSION = "0.2.7"; +const VERSION = "0.2.8"; const MAILTO = "mailto:"; mailgoInit = () => { @@ -29,7 +29,8 @@ mailgoInit = () => { mailgo.href .split("?")[0] .split(MAILTO)[1] - .trim()); + .trim() + ); mailtoHref = mailgo.href; url = new URL(mailtoHref); @@ -132,8 +133,9 @@ mailgoInit = () => { // Gmail let gmail = document.createElement("a"); - gmail.href = "https://mail.google.com/mail?extsrc=mailto&url=" - + encodeURIComponent(mailtoHref); + gmail.href = + "https://mail.google.com/mail?extsrc=mailto&url=" + + encodeURIComponent(mailtoHref); gmail.classList.add("mailgo-open"); gmail.classList.add("gmail"); let gmailContent = document.createTextNode("open in "); @@ -149,8 +151,9 @@ mailgoInit = () => { // Outlook let outlook = document.createElement("a"); outlook.href = - "https://outlook.office.com/owa/?rru=compose&to=" - + encodeURIComponent(mail) + url.search.replace(/^[$]/, '&'); + "https://outlook.office.com/owa/?rru=compose&to=" + + encodeURIComponent(mail) + + url.search.replace(/^[$]/, "&"); outlook.classList.add("mailgo-open"); outlook.classList.add("outlook"); let outlookContent = document.createTextNode("open in "); diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index d05a63b..82b1796 100644 --- a/dist/mailgo.min.js +++ b/dist/mailgo.min.js @@ -1 +1 @@ -const VERSION="0.2.6",MAILTO="mailto:";mailgoInit=(()=>{const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href="https://unpkg.com/mailgo@0.2.6/dist/mailgo.min.css",document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo').forEach((e,t)=>{let a="",d="",l="",n="",o="",c="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){a=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),d=e.href,url=new URL(d);let t=new URLSearchParams(url.search);l=t.get("cc"),n=t.get("bcc"),o=t.get("subject"),c=t.get("body")}else a=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),d=MAILTO+encodeURIComponent(a),url=new URL(d);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",l&&""!=l){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let d=document.createTextNode(": "+l);e.appendChild(t),e.appendChild(d),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 d=document.createTextNode(": "+n);e.appendChild(t),e.appendChild(d),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 d=document.createTextNode(": "+o);e.appendChild(t),e.appendChild(d),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 d=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(d),u.appendChild(e)}p.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+encodeURIComponent(d),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="+encodeURIComponent(a)+url.search.replace(/^[$]/,"&"),N.classList.add("mailgo-open"),N.classList.add("outlook");let x=document.createTextNode("open in ");N.appendChild(x);let L=document.createElement("span");L.className="mailgo-weight-500";let T=document.createTextNode("Outlook");L.appendChild(T),N.appendChild(L),p.appendChild(N);let f=document.createElement("a");f.href="#mailgo-open";let b=encodeEmail(a);f.addEventListener("click",()=>{mailToEncoded(b)},!1),f.classList.add("mailgo-open"),f.classList.add("mailgo-weight-500");let v=document.createTextNode("open");f.appendChild(v),p.appendChild(f);let y=document.createElement("a");y.href="#mailgo-copy",y.classList.add("mailgo-copy"),y.classList.add("mailgo-weight-500");let w=document.createTextNode("copy");y.appendChild(w),y.addEventListener("click",e=>{copyToClipboard(a),y.textContent="copied",setTimeout(()=>{y.textContent="copy"},999)},!1),p.appendChild(y);let A=document.createElement("a");A.href="https://mailgo.js.org",A.className="mailgo-by",A.target="_blank";let I=document.createTextNode("mailgo.js.org");A.appendChild(I),p.appendChild(A),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))}),mailToEncoded=(e=>window.location.href=MAILTO+atob(e)),encodeEmail=(e=>btoa(e)); +const VERSION="0.2.8",MAILTO="mailto:";mailgoInit=(()=>{const e=document.createElement("link");e.rel="stylesheet",e.type="text/css",e.href="https://unpkg.com/mailgo@0.2.8/dist/mailgo.min.css",document.head.appendChild(e),document.querySelectorAll('a[href^="mailto:" i]:not(.no-mailgo), a[href="#mailgo"], a.mailgo').forEach((e,t)=>{let a="",d="",l="",n="",o="",c="";if(e.href&&e.href.toLowerCase().startsWith(MAILTO)){a=decodeURIComponent(e.href.split("?")[0].split(MAILTO)[1].trim()),d=e.href,url=new URL(d);let t=new URLSearchParams(url.search);l=t.get("cc"),n=t.get("bcc"),o=t.get("subject"),c=t.get("body")}else a=e.getAttribute("data-address")+"@"+e.getAttribute("data-domain"),d=MAILTO+encodeURIComponent(a),url=new URL(d);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",l&&""!=l){let e=document.createElement("p"),t=document.createElement("span");t.className="mailgo-weight-500";let a=document.createTextNode("cc");t.appendChild(a);let d=document.createTextNode(": "+l);e.appendChild(t),e.appendChild(d),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 d=document.createTextNode(": "+n);e.appendChild(t),e.appendChild(d),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 d=document.createTextNode(": "+o);e.appendChild(t),e.appendChild(d),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 d=document.createTextNode(": "+c);e.appendChild(t),e.appendChild(d),u.appendChild(e)}p.appendChild(u);let h=document.createElement("a");h.href="https://mail.google.com/mail?extsrc=mailto&url="+encodeURIComponent(d),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="+encodeURIComponent(a)+url.search.replace(/^[$]/,"&"),N.classList.add("mailgo-open"),N.classList.add("outlook");let x=document.createTextNode("open in ");N.appendChild(x);let L=document.createElement("span");L.className="mailgo-weight-500";let T=document.createTextNode("Outlook");L.appendChild(T),N.appendChild(L),p.appendChild(N);let f=document.createElement("a");f.href="#mailgo-open";let b=encodeEmail(a);f.addEventListener("click",()=>{mailToEncoded(b)},!1),f.classList.add("mailgo-open"),f.classList.add("mailgo-weight-500");let v=document.createTextNode("open");f.appendChild(v),p.appendChild(f);let y=document.createElement("a");y.href="#mailgo-copy",y.classList.add("mailgo-copy"),y.classList.add("mailgo-weight-500");let w=document.createTextNode("copy");y.appendChild(w),y.addEventListener("click",e=>{copyToClipboard(a),y.textContent="copied",setTimeout(()=>{y.textContent="copy"},999)},!1),p.appendChild(y);let A=document.createElement("a");A.href="https://mailgo.js.org",A.className="mailgo-by",A.target="_blank";let I=document.createTextNode("mailgo.js.org");A.appendChild(I),p.appendChild(A),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))}),mailToEncoded=(e=>window.location.href=MAILTO+atob(e)),encodeEmail=(e=>btoa(e)); \ No newline at end of file diff --git a/package.json b/package.json index 9df49d4..ea88df2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mailgo", - "version": "0.2.7", + "version": "0.2.8", "description": "a different mailto", "scripts": { "build": "gulp" diff --git a/src/mailgo.js b/src/mailgo.js index da8a20d..4922893 100644 --- a/src/mailgo.js +++ b/src/mailgo.js @@ -29,7 +29,8 @@ mailgoInit = () => { mailgo.href .split("?")[0] .split(MAILTO)[1] - .trim()); + .trim() + ); mailtoHref = mailgo.href; url = new URL(mailtoHref); @@ -132,8 +133,9 @@ mailgoInit = () => { // Gmail let gmail = document.createElement("a"); - gmail.href = "https://mail.google.com/mail?extsrc=mailto&url=" - + encodeURIComponent(mailtoHref); + gmail.href = + "https://mail.google.com/mail?extsrc=mailto&url=" + + encodeURIComponent(mailtoHref); gmail.classList.add("mailgo-open"); gmail.classList.add("gmail"); let gmailContent = document.createTextNode("open in "); @@ -149,8 +151,9 @@ mailgoInit = () => { // Outlook let outlook = document.createElement("a"); outlook.href = - "https://outlook.office.com/owa/?rru=compose&to=" - + encodeURIComponent(mail) + url.search.replace(/^[$]/, '&'); + "https://outlook.office.com/owa/?rru=compose&to=" + + encodeURIComponent(mail) + + url.search.replace(/^[$]/, "&"); outlook.classList.add("mailgo-open"); outlook.classList.add("outlook"); let outlookContent = document.createTextNode("open in ");