From 1606a2b30ad627565452b1a3bf96161a02cca52b Mon Sep 17 00:00:00 2001 From: Matteo Manzinello Date: Fri, 24 Apr 2020 15:57:07 +0200 Subject: [PATCH] working on typescript and ssr problems... --- dist/mailgo.min.js | 2 +- mailgo.js | 2 +- src/mailgo.ts | 27 ++++++++++++++++----------- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/dist/mailgo.min.js b/dist/mailgo.min.js index 04dd36d..0601d19 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";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=function(){function e(e,t){var o=0"),_?(i.style.display="block",c.innerHTML=_.split(",").join("
")):i.style.display="none",M?(d.style.display="block",s.innerHTML=M.split(",").join("
")):d.style.display="none",U?(l.style.display="block",m.textContent=U):l.style.display="none",I?(r.style.display="block",p.textContent=I):r.style.display="none",u.addEventListener("click",W),b.addEventListener("click",H),R=te(S),f.addEventListener("click",D),w.addEventListener("click",(function(){return $(S)}))}o===A&&(C.href&&C.href.toLowerCase().startsWith(L)?T=decodeURIComponent(C.href.split("?")[0].split(L)[1].trim()):C.href&&C.href.toLowerCase().startsWith(z)?T=decodeURIComponent(C.href.split("?")[0].split(z)[1].trim()):C.hasAttribute("data-tel")&&(T=C.getAttribute("data-tel"),C.getAttribute("data-msg")),C.hasAttribute("data-telegram")&&(O=C.getAttribute("data-telegram")),C.hasAttribute("data-skype")&&(P=C.getAttribute("data-skype")),n.innerHTML=T,g.addEventListener("click",F),O&&(ne("m-tg","block"),h.addEventListener("click",B)),x.addEventListener("click",Z),v.addEventListener("click",G),y.addEventListener("click",(function(){return $(T)}))),J(o),document.addEventListener("keydown",q)}function t(e,t){var o=1()[\]\\.,;:\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)}var a,n,i,d,l,r,c,s,m,p,u,b,f,h,g,x,v,w,y,C,k="mailto:",L="tel:",z="callto:",j="mail",A="tel",E="javascript:void(0);",N="span",S="",R="",_="",M="",U="",I="",T="",O="",P="",W=function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(S);_&&(e=e.concat("&cc="+encodeURIComponent(_))),M&&(e=e.concat("&bcc="+encodeURIComponent(M))),U&&(e=e.concat("&subject="+U)),I&&(e=e.concat("&body="+I)),window.open(e,"_blank"),K()},H=function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(S);U&&(e=e.concat("&subject="+U)),I&&(e=e.concat("&body="+I)),window.open(e,"_blank"),K()},D=function(){ee(R),K()},B=function(){var e="https://t.me/"+O;window.open(e,"_blank"),K()},Z=function(){var e="skype:"+(""!==P?P:T);window.open(e,"_blank"),K()},F=function(){var e="https://wa.me/"+T;window.open(e,"_blank"),K()},G=function(){var e="tel:"+T;window.open(e),K()},$=function(e){var t;le(e),(t=Q(j)?w:y).textContent="copied",setTimeout((function(){t.textContent="copy",K()}),999)},q=function(e){if(Q(j))switch(e.keyCode){case 27:K();break;case 71:W();break;case 79:H();break;case 32:case 13:D();break;case 67:$(S);break;default:return}else if(Q(A))switch(e.keyCode){case 27:K();break;case 84:B();break;case 87:F();break;case 32:case 13:G();break;case 67:$(T);break;default:return}},J=function(e){var t=0"),M?(l.style.display="block",m.innerHTML=M.split(",").join("
")):l.style.display="none",U?(r.style.display="block",p.innerHTML=U.split(",").join("
")):r.style.display="none",I?(c.style.display="block",u.textContent=I):c.style.display="none",T?(s.style.display="block",b.textContent=T):s.style.display="none",f.addEventListener("click",H),h.addEventListener("click",D),_=oe(R),g.addEventListener("click",B),C.addEventListener("click",(function(){return q(R)}))}o===E&&(a.href&&a.href.toLowerCase().startsWith(z)?O=decodeURIComponent(a.href.split("?")[0].split(z)[1].trim()):a.href&&a.href.toLowerCase().startsWith(j)?O=decodeURIComponent(a.href.split("?")[0].split(j)[1].trim()):a.hasAttribute("data-tel")&&(O=a.getAttribute("data-tel"),a.getAttribute("data-msg")),a.hasAttribute("data-telegram")&&(P=a.getAttribute("data-telegram")),a.hasAttribute("data-skype")&&(W=a.getAttribute("data-skype")),d.innerHTML=O,v.addEventListener("click",G),P&&(ie("m-tg","block"),x.addEventListener("click",Z)),w.addEventListener("click",F),y.addEventListener("click",$),k.addEventListener("click",(function(){return q(O)}))),K(o),document.addEventListener("keydown",J)}function o(e,t){var o=1()[\]\\.,;:\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)}var i,d,l,r,c,s,m,p,u,b,f,h,g,x,v,w,y,C,k,L="mailto:",z="tel:",j="callto:",A="mail",E="tel",N="javascript:void(0);",S="span",R="",_="",M="",U="",I="",T="",O="",P="",W="",H=function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(R);M&&(e=e.concat("&cc="+encodeURIComponent(M))),U&&(e=e.concat("&bcc="+encodeURIComponent(U))),I&&(e=e.concat("&subject="+I)),T&&(e=e.concat("&body="+T)),window.open(e,"_blank"),Q()},D=function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(R);I&&(e=e.concat("&subject="+I)),T&&(e=e.concat("&body="+T)),window.open(e,"_blank"),Q()},B=function(){te(_),Q()},Z=function(){var e="https://t.me/"+P;window.open(e,"_blank"),Q()},F=function(){var e="skype:"+(""!==W?W:O);window.open(e,"_blank"),Q()},G=function(){var e="https://wa.me/"+O;window.open(e,"_blank"),Q()},$=function(){var e="tel:"+O;window.open(e),Q()},q=function(e){var t;re(e),(t=V(A)?C:k).textContent="copied",setTimeout((function(){t.textContent="copy",Q()}),999)},J=function(e){if(V(A))switch(e.keyCode){case 27:Q();break;case 71:H();break;case 79:D();break;case 32:case 13:B();break;case 67:q(R);break;default:return}else if(V(E))switch(e.keyCode){case 27:Q();break;case 84:Z();break;case 87:G();break;case 32:case 13:$();break;case 67:q(O);break;default:return}},K=function(e){var t=0"),_?(i.style.display="block",c.innerHTML=_.split(",").join("
")):i.style.display="none",M?(d.style.display="block",s.innerHTML=M.split(",").join("
")):d.style.display="none",U?(l.style.display="block",m.textContent=U):l.style.display="none",I?(r.style.display="block",p.textContent=I):r.style.display="none",u.addEventListener("click",W),b.addEventListener("click",H),R=te(S),f.addEventListener("click",D),w.addEventListener("click",(function(){return $(S)}))}o===A&&(C.href&&C.href.toLowerCase().startsWith(L)?T=decodeURIComponent(C.href.split("?")[0].split(L)[1].trim()):C.href&&C.href.toLowerCase().startsWith(z)?T=decodeURIComponent(C.href.split("?")[0].split(z)[1].trim()):C.hasAttribute("data-tel")&&(T=C.getAttribute("data-tel"),C.getAttribute("data-msg")),C.hasAttribute("data-telegram")&&(O=C.getAttribute("data-telegram")),C.hasAttribute("data-skype")&&(P=C.getAttribute("data-skype")),n.innerHTML=T,g.addEventListener("click",F),O&&(ne("m-tg","block"),h.addEventListener("click",B)),x.addEventListener("click",Z),v.addEventListener("click",G),y.addEventListener("click",(function(){return $(T)}))),J(o),document.addEventListener("keydown",q)}function t(e,t){var o=1()[\]\\.,;:\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)}var a,n,i,d,l,r,c,s,m,p,u,b,f,h,g,x,v,w,y,C,k="mailto:",L="tel:",z="callto:",j="mail",A="tel",E="javascript:void(0);",N="span",S="",R="",_="",M="",U="",I="",T="",O="",P="",W=function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(S);_&&(e=e.concat("&cc="+encodeURIComponent(_))),M&&(e=e.concat("&bcc="+encodeURIComponent(M))),U&&(e=e.concat("&subject="+U)),I&&(e=e.concat("&body="+I)),window.open(e,"_blank"),K()},H=function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(S);U&&(e=e.concat("&subject="+U)),I&&(e=e.concat("&body="+I)),window.open(e,"_blank"),K()},D=function(){ee(R),K()},B=function(){var e="https://t.me/"+O;window.open(e,"_blank"),K()},Z=function(){var e="skype:"+(""!==P?P:T);window.open(e,"_blank"),K()},F=function(){var e="https://wa.me/"+T;window.open(e,"_blank"),K()},G=function(){var e="tel:"+T;window.open(e),K()},$=function(e){var t;le(e),(t=Q(j)?w:y).textContent="copied",setTimeout((function(){t.textContent="copy",K()}),999)},q=function(e){if(Q(j))switch(e.keyCode){case 27:K();break;case 71:W();break;case 79:H();break;case 32:case 13:D();break;case 67:$(S);break;default:return}else if(Q(A))switch(e.keyCode){case 27:K();break;case 84:B();break;case 87:F();break;case 32:case 13:G();break;case 67:$(T);break;default:return}},J=function(e){var t=0"),M?(l.style.display="block",m.innerHTML=M.split(",").join("
")):l.style.display="none",U?(r.style.display="block",p.innerHTML=U.split(",").join("
")):r.style.display="none",I?(c.style.display="block",u.textContent=I):c.style.display="none",T?(s.style.display="block",b.textContent=T):s.style.display="none",f.addEventListener("click",H),h.addEventListener("click",D),_=oe(R),g.addEventListener("click",B),C.addEventListener("click",(function(){return q(R)}))}o===E&&(a.href&&a.href.toLowerCase().startsWith(z)?O=decodeURIComponent(a.href.split("?")[0].split(z)[1].trim()):a.href&&a.href.toLowerCase().startsWith(j)?O=decodeURIComponent(a.href.split("?")[0].split(j)[1].trim()):a.hasAttribute("data-tel")&&(O=a.getAttribute("data-tel"),a.getAttribute("data-msg")),a.hasAttribute("data-telegram")&&(P=a.getAttribute("data-telegram")),a.hasAttribute("data-skype")&&(W=a.getAttribute("data-skype")),d.innerHTML=O,v.addEventListener("click",G),P&&(ie("m-tg","block"),x.addEventListener("click",Z)),w.addEventListener("click",F),y.addEventListener("click",$),k.addEventListener("click",(function(){return q(O)}))),K(o),document.addEventListener("keydown",J)}function o(e,t){var o=1()[\]\\.,;:\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)}var i,d,l,r,c,s,m,p,u,b,f,h,g,x,v,w,y,C,k,L="mailto:",z="tel:",j="callto:",A="mail",E="tel",N="javascript:void(0);",S="span",R="",_="",M="",U="",I="",T="",O="",P="",W="",H=function(){var e="https://mail.google.com/mail/u/0/?view=cm&source=mailto&to="+encodeURIComponent(R);M&&(e=e.concat("&cc="+encodeURIComponent(M))),U&&(e=e.concat("&bcc="+encodeURIComponent(U))),I&&(e=e.concat("&subject="+I)),T&&(e=e.concat("&body="+T)),window.open(e,"_blank"),Q()},D=function(){var e="https://outlook.live.com/owa/?path=/mail/action/compose&to="+encodeURIComponent(R);I&&(e=e.concat("&subject="+I)),T&&(e=e.concat("&body="+T)),window.open(e,"_blank"),Q()},B=function(){te(_),Q()},Z=function(){var e="https://t.me/"+P;window.open(e,"_blank"),Q()},F=function(){var e="skype:"+(""!==W?W:O);window.open(e,"_blank"),Q()},G=function(){var e="https://wa.me/"+O;window.open(e,"_blank"),Q()},$=function(){var e="tel:"+O;window.open(e),Q()},q=function(e){var t;re(e),(t=V(A)?C:k).textContent="copied",setTimeout((function(){t.textContent="copy",Q()}),999)},J=function(e){if(V(A))switch(e.keyCode){case 27:Q();break;case 71:H();break;case 79:D();break;case 32:case 13:B();break;case 67:q(R);break;default:return}else if(V(E))switch(e.keyCode){case 27:Q();break;case 84:Z();break;case 87:G();break;case 32:case 13:$();break;case 67:q(O);break;default:return}},K=function(e){var t=0 { // start mailgo (() => { - // if the window object exists... - // mailgo style (gulp) - let mailgoCSS: HTMLStyleElement = createElement("style"); - mailgoCSS.id = "mailgo-style"; - mailgoCSS.type = "text/css"; - mailgoCSS.appendChild(createTextNode(`MAILGO_STYLE`)); - document.head.appendChild(mailgoCSS); + // if the window is defined... + if (window && typeof window !== "undefined") { + // if the window object exists... + // mailgo style (gulp) + let mailgoCSS: HTMLStyleElement = ( + createElement("style") + ); + mailgoCSS.id = "mailgo-style"; + mailgoCSS.type = "text/css"; + mailgoCSS.appendChild(createTextNode(`MAILGO_STYLE`)); + document.head.appendChild(mailgoCSS); - // DOMContentLoaded -> mailgoInit (creates the modals) - document.addEventListener("DOMContentLoaded", mailgoInit); + // DOMContentLoaded -> mailgoInit (creates the modals) + document.addEventListener("DOMContentLoaded", mailgoInit); - // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered - document.addEventListener("click", mailgoCheckRender); + // event listener on body, if the element is mailgo-compatible the mailgo modal will be rendered + document.addEventListener("click", mailgoCheckRender); + } })(); };