1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
!function(e,a){"object"==typeof exports&&"object"==typeof module?module.exports=a():"function"==typeof define&&define.amd?define([],a):"object"==typeof exports?exports.mailgo=a():e.mailgo=a()}(window,(function(){return function(e){var a={};function t(o){if(a[o])return a[o].exports;var l=a[o]={i:o,l:!1,exports:{}};return e[o].call(l.exports,l,l.exports,t),l.l=!0,l.exports}return t.m=e,t.c=a,t.d=function(e,a,o){t.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,a){if(1&a&&(e=t(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var l in e)t.d(o,l,function(a){return e[a]}.bind(null,l));return o},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},t.p="",t(t.s=0)}([function(e,a,t){"use strict";var o=document.createElement("style");o.id="mailgo-style",o.type="text/css";var l=document.createTextNode('.mailgo-modal{position:fixed;top:0;right:0;bottom:0;left:0;justify-content:center;align-items:center;flex-direction:column;overflow:hidden;font-size:15px;z-index:10000}.mailgo-modal a,.mailgo-modal p,.mailgo-modal span,.mailgo-modal strong{margin:0;padding:0;font-size:100%;line-height:1;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"}.mailgo-modal strong{font-weight:700}.mailgo-modal .mailgo-modal-background{position:absolute;z-index:10001;top:0;right:0;bottom:0;left:0;background-color:rgba(32,35,42,.75);opacity:.8}.mailgo-modal .mailgo-modal-content{position:relative;z-index:10002;box-sizing:content-box;text-align:center;min-width:200px;max-width:240px;background-color:#fff;opacity:.97;border-radius:5px;box-shadow:0 3px 8px 0 rgba(32,35,42,.12);color:#4a4a4a;display:block;overflow:auto;padding:20px}.mailgo-modal .mailgo-modal-content:hover{opacity:1;box-shadow:0 18px 30px 0 rgba(32,35,42,.23)}.mailgo-modal .mailgo-modal-content .mailgo-title{display:block;margin-bottom:5px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.mailgo-modal .mailgo-modal-content .mailgo-details{margin-bottom:10px}.mailgo-modal .mailgo-modal-content .mailgo-details p{font-size:12px;margin-top:3px;margin-bottom:3px}.mailgo-modal .mailgo-modal-content a{display:block;padding:10px;color:#4a4a4a;border-radius:5px;text-decoration:none}.mailgo-modal .mailgo-modal-content a.mailgo-gmail{color:#d44638}.mailgo-modal .mailgo-modal-content a.mailgo-outlook{color:#0072c6}.mailgo-modal .mailgo-modal-content a.mailgo-wa{color:#00bfa5}.mailgo-modal .mailgo-modal-content a.mailgo-telegram{color:#08c}.mailgo-modal .mailgo-modal-content a.mailgo-copy{padding:16px 10px;font-size:16px}.mailgo-modal .mailgo-modal-content a.mailgo-copy:hover,.mailgo-modal .mailgo-modal-content a.mailgo-default:hover{background-color:rgba(0,0,0,.08);color:#4a4a4a}.mailgo-modal .mailgo-modal-content a.mailgo-gmail:hover{background-color:rgba(212,70,56,.08);color:#d44638}.mailgo-modal .mailgo-modal-content a.mailgo-outlook:hover{background-color:rgba(0,114,198,.08);color:#0072c6}.mailgo-modal .mailgo-modal-content a.mailgo-telegram:hover{background-color:rgba(0,114,198,.08);color:#08c}.mailgo-modal .mailgo-modal-content a.mailgo-wa:hover{background-color:rgba(0,191,165,.08);color:#00bfa5}.mailgo-modal .mailgo-modal-content a.mailgo-by{display:block;font-size:8px;margin-top:1rem;padding:0;color:#4a4a4a;opacity:.5}.mailgo-modal .mailgo-modal-content a.mailgo-by:hover{opacity:1}.mailgo-modal .mailgo-modal-content .mailgo-weight-500{font-weight:500}');o.appendChild(l),document.head.appendChild(o);var n,i,d,c,m,r,s,p="mailto:",g="tel:",u="callto:",h="",f="",v="",b="",y="",C="",x="",w="",k="",E=function(e,a){var t=0<arguments.length&&void 0!==e?e:"mail",o=1<arguments.length?a:void 0;if("mail"===t){if(o.href&&o.href.toLowerCase().startsWith(p)){f=decodeURIComponent(o.href.split("?")[0].split(p)[1].trim()),h=new URL(o.href);var l=new URLSearchParams(h.search);b=l.get("cc"),y=l.get("bcc"),C=l.get("subject"),x=l.get("body")}else f=o.getAttribute("data-address")+"@"+o.getAttribute("data-domain"),h=new URL(p+encodeURIComponent(f)),b=o.getAttribute("data-cc-address")+"@"+o.getAttribute("data-cc-domain"),y=o.getAttribute("data-bcc-address")+"@"+o.getAttribute("data-bcc-domain"),C=o.getAttribute("data-subject"),x=o.getAttribute("data-body");if(!W(f.split(",")))return;b&&!W(b.split(","))&&(b=""),y&&!W(y.split(","))&&(y="");var E=I("mailgo-title"),N=(I("mailgo-details"),I("mailgo-cc")),A=I("mailgo-cc-value"),R=I("mailgo-bcc"),S=I("mailgo-bcc-value"),M=I("mailgo-subject"),O=I("mailgo-subject-value"),_=I("mailgo-body"),z=I("mailgo-body-value");n=I("mailgo-gmail"),i=I("mailgo-outlook"),d=I("mailgo-open"),s=I("mailgo-copy"),E.innerHTML=f.split(",").join("<br/>"),b?(N.style.display="block",A.innerHTML=b.split(",").join("<br/>")):N.style.display="none",y?(R.style.display="block",S.innerHTML=y.split(",").join("<br/>")):R.style.display="none",C?(M.style.display="block",O.textContent=C):M.style.display="none",x?(_.style.display="block",z.textContent=x):_.style.display="none",n.addEventListener("click",(function(){return L.openGmail()})),i.addEventListener("click",(function(){return L.openOutlook()})),v=U(f),d.addEventListener("click",(function(){return L.openDefault()})),s.addEventListener("click",(function(){return L.copy()}))}if("tel"===t){o.href&&o.href.toLowerCase().startsWith(g)?w=decodeURIComponent(o.href.split("?")[0].split(g)[1].trim()):o.href&&o.href.toLowerCase().startsWith(u)?w=decodeURIComponent(o.href.split("?")[0].split(u)[1].trim()):o.hasAttribute("data-tel")&&(w=o.getAttribute("data-tel"),k=o.getAttribute("data-msg"));var D=I("mailgo-tel-title");c=I("mailgo-wa"),m=I("mailgo-telegram"),r=I("mailgo-call"),s=I("mailgo-tel-copy"),D.innerHTML=w,c.addEventListener("click",(function(){return L.openWhatsApp()})),m.addEventListener("click",(function(){return L.openTelegram()})),r.addEventListener("click",(function(){return L.callDefault()})),s.addEventListener("click",(function(){return L.copy(w)}))}j(t),document.addEventListener("keydown",T)},L={openGmail:function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(f);b&&(e=e.concat("&cc="+encodeURIComponent(b))),y&&(e=e.concat("&bcc="+encodeURIComponent(y))),C&&(e=e.concat("&subject="+C)),x&&(e=e.concat("&body="+x)),window.open(e,"_blank"),A()},openOutlook:function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(f);C&&(e=e.concat("&subject="+C)),x&&(e=e.concat("&body="+x)),window.open(e,"_blank"),A()},openDefault:function(){S(v),A()},openTelegram:function(){var e="tg://msg?text="+k+"&to="+w;window.open(e,"_blank"),A()},openWhatsApp:function(){var e="https://wa.me/"+w;window.open(e,"_blank"),A()},callDefault:function(){var e="tel:"+w;window.open(e),A()},copy:function(e){D(e),(s=R("mail")?I("mailgo-copy"):I("mailgo-tel-copy")).textContent="copied",setTimeout((function(){s.textContent="copy",A()}),999)}},N=function(e,a){var t=1<arguments.length&&void 0!==a?a:"mail";return"mail"===t?e.href&&e.href.toLowerCase().startsWith(p)&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-address")&&(e.href&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo")):"tel"===t&&(e.href&&(e.href.toLowerCase().startsWith(g)||e.href.toLowerCase().startsWith(u))&&!e.classList.contains("no-mailgo")||e.hasAttribute("data-tel")&&e.href&&"#mailgo"===e.getAttribute("href").toLowerCase()||e.classList&&e.classList.contains("mailgo"))},T=function(e){if(R("mail"))switch(e.keyCode){case 27:A();break;case 71:L.openGmail();break;case 79:L.openOutlook();break;case 32:case 13:L.openDefault();break;case 67:L.copy(f);break;default:return}else if(R("tel"))switch(e.keyCode){case 27:A();break;case 84:L.openTelegram();break;case 87:L.openWhatsApp();break;case 32:case 13:L.openDefault();break;case 67:L.copy(w);break;default:return}};document.addEventListener("DOMContentLoaded",(function(){var e=document.createElement("div");e.style.display="none",e.id="mailgo",e.classList.add("mailgo-modal");var a=document.createElement("div");a.className="mailgo-modal-background",e.appendChild(a);var t=document.createElement("div");t.className="mailgo-modal-content",e.appendChild(t);var o=document.createElement("strong");o.id="mailgo-title",o.className="mailgo-title",t.appendChild(o);var l=document.createElement("div");l.id="mailgo-details",l.className="mailgo-details";var n=document.createElement("p");n.id="mailgo-cc";var i=document.createElement("span");i.className="mailgo-weight-500";var d=document.createTextNode("cc ");i.appendChild(d);var c=document.createElement("span");c.id="mailgo-cc-value",n.appendChild(i),n.appendChild(c),l.appendChild(n);var m=document.createElement("p");m.id="mailgo-bcc";var r=document.createElement("span");r.className="mailgo-weight-500";var s=document.createTextNode("bcc ");r.appendChild(s);var p=document.createElement("span");p.id="mailgo-bcc-value",m.appendChild(r),m.appendChild(p),l.appendChild(m);var g=document.createElement("p");g.id="mailgo-subject";var u=document.createElement("span");u.className="mailgo-weight-500";var h=document.createTextNode("subject ");u.appendChild(h);var f=document.createElement("span");f.id="mailgo-subject-value",g.appendChild(u),g.appendChild(f),l.appendChild(g);var v=document.createElement("p");v.id="mailgo-body";var b=document.createElement("span");b.className="mailgo-weight-500";var y=document.createTextNode("body ");b.appendChild(y);var C=document.createElement("span");C.id="mailgo-body-value",v.appendChild(b),v.appendChild(C),l.appendChild(v),t.appendChild(l);var x=document.createElement("a");x.id="mailgo-gmail",x.href="#mailgo-gmail",x.classList.add("mailgo-open"),x.classList.add("mailgo-gmail");var w=document.createTextNode("open in ");x.appendChild(w);var k=document.createElement("span");k.className="mailgo-weight-500";var E=document.createTextNode("Gmail");k.appendChild(E),x.appendChild(k),t.appendChild(x);var L=document.createElement("a");L.id="mailgo-outlook",L.href="#mailgo-outlook",L.classList.add("mailgo-open"),L.classList.add("mailgo-outlook");var N=document.createTextNode("open in ");L.appendChild(N);var T=document.createElement("span");T.className="mailgo-weight-500";var j=document.createTextNode("Outlook");T.appendChild(j),L.appendChild(T),t.appendChild(L);var R=document.createElement("a");R.id="mailgo-open",R.href="#mailgo-open",R.classList.add("mailgo-open"),R.classList.add("mailgo-default");var S=document.createElement("span");S.className="mailgo-weight-500";var U=document.createTextNode("open");S.appendChild(U);var I=document.createTextNode(" default");R.appendChild(S),R.appendChild(I),t.appendChild(R);var M=document.createElement("a");M.id="mailgo-copy",M.href="#mailgo-copy",M.classList.add("mailgo-copy"),M.classList.add("mailgo-weight-500");var O=document.createTextNode("copy");M.appendChild(O),t.appendChild(M);var _=document.createElement("a");_.href="https://mailgo.js.org?ref=mailgo-modal",_.className="mailgo-by",_.target="_blank",_.rel="noopener noreferrer";var z=document.createTextNode("mailgo.js.org");_.appendChild(z),t.appendChild(_),document.body.appendChild(e),a.addEventListener("click",A);var W=document.createElement("div");W.style.display="none",W.id="mailgo-tel",W.classList.add("mailgo-modal");var D=document.createElement("div");D.className="mailgo-modal-background",W.appendChild(D);var P=document.createElement("div");P.className="mailgo-modal-content",W.appendChild(P);var H=document.createElement("strong");H.id="mailgo-tel-title",H.className="mailgo-title",P.appendChild(H);var G=document.createElement("a");G.id="mailgo-telegram",G.href="#mailgo-telegram",G.classList.add("mailgo-open"),G.classList.add("mailgo-telegram");var B=document.createTextNode("open in ");G.appendChild(B);var Z=document.createElement("span");Z.className="mailgo-weight-500";var F=document.createTextNode("Telegram");Z.appendChild(F),G.appendChild(Z),P.appendChild(G);var $=document.createElement("a");$.id="mailgo-wa",$.href="#mailgo-wa",$.classList.add("mailgo-open"),$.classList.add("mailgo-wa");var q=document.createTextNode("open in ");$.appendChild(q);var J=document.createElement("span");J.className="mailgo-weight-500";var K=document.createTextNode("WhatsApp");J.appendChild(K),$.appendChild(J),P.appendChild($);var Q=document.createElement("a");Q.id="mailgo-call",Q.href="#mailgo-call",Q.classList.add("mailgo-open"),Q.classList.add("mailgo-default");var V=document.createElement("span");V.className="mailgo-weight-500";var X=document.createTextNode("call");V.appendChild(X);var Y=document.createTextNode(" as default");Q.appendChild(V),Q.appendChild(Y),P.appendChild(Q);var ee=document.createElement("a");ee.id="mailgo-tel-copy",ee.href="#mailgo-copy",ee.classList.add("mailgo-copy"),ee.classList.add("mailgo-weight-500");var ae=document.createTextNode("copy");ee.appendChild(ae),P.appendChild(ee);var te=document.createElement("a");te.href="https://mailgo.js.org?ref=mailgo-modal",te.className="mailgo-by",te.target="_blank",te.rel="noopener noreferrer";var oe=document.createTextNode("mailgo.js.org");te.appendChild(oe),P.appendChild(te),document.body.appendChild(W),D.addEventListener("click",A)})),document.addEventListener("click",(function(e){if(document.contains(I("mailgo"))&&document.contains(I("mailgo-tel"))&&!R("mail")&&!R("tel")){var a=e.path||e.composedPath&&e.composedPath()||_(e.target);a&&a.forEach((function(a){if(!(a instanceof HTMLDocument||a instanceof Window))return N(a,"mail")?(e.preventDefault(),void E("mail",a)):N(a,"tel")?(e.preventDefault(),void E("tel",a)):void 0}))}}));var j=function(e){var a=0<arguments.length&&void 0!==e?e:"mail";"mail"!==a?"tel"!==a||O("mailgo-tel","flex"):O("mailgo","flex")},A=function(){O("mailgo","none"),O("mailgo-tel","none"),document.removeEventListener("keydown",T)},R=function(e){var a=0<arguments.length&&void 0!==e?e:"mail";return"mail"===a?"flex"===M("mailgo"):"tel"===a&&"flex"===M("mailgo-tel")},S=function(e){return window.location.href=p+atob(e)},U=function(e){return btoa(e)},I=function(e){return document.getElementById(e)},M=function(e){return I(e).style.display},O=function(e,a){return I(e).style.display=a},_=function(e){for(var a=[];e;){if(a.push(e),"HTML"===e.tagName)return a.push(document),a.push(window),a;e=e.parentElement}},z=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)},W=function(e){return e.every(z)},D=function(e){var a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a);var t=0<document.getSelection().rangeCount&&document.getSelection().getRangeAt(0);a.select(),document.execCommand("copy"),document.body.removeChild(a),t&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(t))}}])})); |