introducing mailgoConfig in window
This commit is contained in:
1 parent
a7c0f7e48c
commit
cbec242435
12 files changed
+122
-31
No files matched your search
+28
-18
@@ -290,7 +290,8 @@ var gmail, outlook, mailgo_open, telegram, wa, skype, call, copyMail, copyTel;
|
||||
var mailgoInit = function mailgoInit() {
|
||||
var _config, _config2;
|
||||
|
||||
// translations
|
||||
console.log(config); // translations
|
||||
|
||||
var _ref = i18n,
|
||||
translations = _ref.translations; // if a default language is defined use it
|
||||
|
||||
@@ -313,7 +314,7 @@ var mailgoInit = function mailgoInit() {
|
||||
var strings = translations[lang]; // mailgo mail
|
||||
|
||||
{
|
||||
var _config3;
|
||||
var _config3, _config4, _config5;
|
||||
|
||||
// modal
|
||||
modalMailto = createElement();
|
||||
@@ -431,8 +432,12 @@ var mailgoInit = function mailgoInit() {
|
||||
copyMail.classList.add("m-copy");
|
||||
copyMail.classList.add("w-500");
|
||||
copyMail.appendChild(createTextNode(strings.copy || defaultStrings.copy));
|
||||
modalContent.appendChild(copyMail);
|
||||
modalContent.appendChild(byElement()); // add the modal at the end of the body
|
||||
modalContent.appendChild(copyMail); // show mailgo.dev in footer only if showFooter == true
|
||||
|
||||
if (typeof ((_config4 = config) === null || _config4 === void 0 ? void 0 : _config4.showFooter) === "undefined" || ((_config5 = config) === null || _config5 === void 0 ? void 0 : _config5.showFooter) === false) {
|
||||
modalContent.appendChild(byElement());
|
||||
} // add the modal at the end of the body
|
||||
|
||||
|
||||
document.body.appendChild(modalMailto); // every click outside the modal will hide the modal
|
||||
|
||||
@@ -440,7 +445,7 @@ var mailgoInit = function mailgoInit() {
|
||||
} // mailgo tel
|
||||
|
||||
{
|
||||
var _config4;
|
||||
var _config6, _config7, _config8;
|
||||
|
||||
// modal
|
||||
modalTel = createElement();
|
||||
@@ -451,7 +456,7 @@ var mailgoInit = function mailgoInit() {
|
||||
modalTel.setAttribute("tabindex", "-1");
|
||||
modalTel.setAttribute("aria-labelledby", "m-tel-title"); // if dark is in config
|
||||
|
||||
if ((_config4 = config) === null || _config4 === void 0 ? void 0 : _config4.dark) {
|
||||
if ((_config6 = config) === null || _config6 === void 0 ? void 0 : _config6.dark) {
|
||||
enableDarkMode(TEL_TYPE);
|
||||
} else {
|
||||
disableDarkMode(TEL_TYPE);
|
||||
@@ -540,9 +545,12 @@ var mailgoInit = function mailgoInit() {
|
||||
copyTel.classList.add("w-500");
|
||||
copyTel.appendChild(createTextNode(strings.copy || defaultStrings.copy));
|
||||
|
||||
_modalContent.appendChild(copyTel);
|
||||
_modalContent.appendChild(copyTel); // show mailgo.dev in footer only if showFooter == true
|
||||
|
||||
_modalContent.appendChild(byElement()); // add the modal at the end of the body
|
||||
|
||||
if (typeof ((_config7 = config) === null || _config7 === void 0 ? void 0 : _config7.showFooter) === "undefined" || ((_config8 = config) === null || _config8 === void 0 ? void 0 : _config8.showFooter) === false) {
|
||||
_modalContent.appendChild(byElement());
|
||||
} // add the modal at the end of the body
|
||||
|
||||
|
||||
document.body.appendChild(modalTel); // every click outside the modal will hide the modal
|
||||
@@ -559,14 +567,14 @@ var mailgoInit = function mailgoInit() {
|
||||
|
||||
|
||||
function mailgoRender() {
|
||||
var _config7;
|
||||
var _config11;
|
||||
|
||||
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MAIL_TYPE;
|
||||
var mailgoElement = arguments.length > 1 ? arguments[1] : undefined;
|
||||
|
||||
// mailgo mail
|
||||
if (type === MAIL_TYPE) {
|
||||
var _config5, _config6;
|
||||
var _config9, _config10;
|
||||
|
||||
// if the element href=^"mailto:"
|
||||
if (mailgoElement.href && mailgoElement.href.toLowerCase().startsWith(MAILTO)) {
|
||||
@@ -593,7 +601,7 @@ function mailgoRender() {
|
||||
bodyMail = mailgoElement.getAttribute("data-body");
|
||||
}
|
||||
|
||||
if (typeof ((_config5 = config) === null || _config5 === void 0 ? void 0 : _config5.validateEmail) === "undefined" || ((_config6 = config) === null || _config6 === void 0 ? void 0 : _config6.validateEmail) === true) {
|
||||
if (typeof ((_config9 = config) === null || _config9 === void 0 ? void 0 : _config9.validateEmail) === "undefined" || ((_config10 = config) === null || _config10 === void 0 ? void 0 : _config10.validateEmail) === true) {
|
||||
// validate the email address
|
||||
if (!validateEmails(mail.split(","))) return; // if cc, bcc are not valid cc, bcc = ""
|
||||
|
||||
@@ -661,7 +669,7 @@ function mailgoRender() {
|
||||
} // if config.dark is set to true then all the modals will be in dark mode
|
||||
|
||||
|
||||
if (!((_config7 = config) === null || _config7 === void 0 ? void 0 : _config7.dark)) {
|
||||
if (!((_config11 = config) === null || _config11 === void 0 ? void 0 : _config11.dark)) {
|
||||
// if the element contains dark as class enable dark mode
|
||||
if (mailgoElement.classList.contains("dark")) {
|
||||
enableDarkMode(type);
|
||||
@@ -1092,19 +1100,21 @@ var mailgoStyle = function mailgoStyle() {
|
||||
|
||||
|
||||
function mailgo(mailgoConfig) {
|
||||
// set the global config
|
||||
config = mailgoConfig; // if the window is defined...
|
||||
var _ref2;
|
||||
|
||||
// set the global config if passed as parameter or keep it from window
|
||||
config = mailgoConfig || ((_ref2 = window) === null || _ref2 === void 0 ? void 0 : _ref2.mailgoConfig); // if the window is defined...
|
||||
|
||||
if (window && typeof window !== "undefined") {
|
||||
var _config8;
|
||||
var _config12;
|
||||
|
||||
// add the style for mailgo
|
||||
mailgoStyle(); // if is set an initEvent add the listener
|
||||
|
||||
if ((_config8 = config) === null || _config8 === void 0 ? void 0 : _config8.initEvent) {
|
||||
var _config9;
|
||||
if ((_config12 = config) === null || _config12 === void 0 ? void 0 : _config12.initEvent) {
|
||||
var _config13;
|
||||
|
||||
if ((_config9 = config) === null || _config9 === void 0 ? void 0 : _config9.listenerOptions) {
|
||||
if ((_config13 = config) === null || _config13 === void 0 ? void 0 : _config13.listenerOptions) {
|
||||
// listener options specified
|
||||
document.addEventListener(config.initEvent, function () {
|
||||
mailgoInit();
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"sources":["webpack://mailgo/webpack/universalModuleDefinition","webpack://mailgo/webpack/bootstrap","webpack://mailgo/../src/mailgo.scss?16f9","webpack://mailgo/../src/mailgo.scss","webpack://mailgo/../node_modules/css-loader/dist/runtime/api.js","webpack://mailgo/../src/mailgo.ts","webpack://mailgo/./mailgo.lib.ts"],"names":["i18n","require","mailgoCSS","toString","DEFAULT_LANG","MAILTO","TEL","CALLTO","outlookDeepLink","MAIL_TYPE","TEL_TYPE","DEFAULT_BTN_HREF","spanHTMLTag","aHTMLTag","pHTMLTag","config","lang","modalMailto","modalTel","url","mail","encEmail","cc","bcc","subject","bodyMail","tel","msg","telegramUsername","skypeUsername","title","titleTel","detailCc","detailBcc","detailSubject","detailBody","ccValue","bccValue","subjectValue","bodyValue","activatedLink","gmail","outlook","open","telegram","wa","skype","call","copyMail","copyTel","mailgoInit","translations","languages","includes","forceLang","htmlLang","document","documentElement","defaultStrings","strings","createElement","style","display","id","classList","add","setAttribute","dark","enableDarkMode","disableDarkMode","modalBackground","className","appendChild","modalContent","details","ccSpan","createTextNode","cc_","bccSpan","bcc_","subjectSpan","subject_","bodySpan","body_","href","open_in_","gmailSpan","outlookSpan","openSpan","_default","copy","byElement","body","addEventListener","hideMailgo","telegramSpan","waSpan","whatsapp","skypeSpan","callSpan","_as_default","mailgoCheckRender","mailgoRender","type","mailgoElement","toLowerCase","startsWith","decodeURIComponent","split","trim","URL","urlParams","searchParams","get","getAttribute","encodeURIComponent","validateEmail","validateEmails","innerHTML","join","textContent","openGmail","openOutlook","encodeEmail","openDefault","hasAttribute","validateTel","openWhatsApp","getElementById","openTelegram","openSkype","callDefault","contains","showMailgo","mailgoKeydown","gmailUrl","concat","window","outlookUrl","mailToEncoded","tgUrl","skypeUrl","waUrl","callUrl","content","copyToClipboard","activeCopy","mailgoIsShowing","setTimeout","isMailgo","element","event","path","composedPath","target","forEach","HTMLDocument","Window","preventDefault","keyboardEvent","keyCode","setModalDisplay","removeEventListener","getModalDisplay","by","rel","encoded","location","atob","email","btoa","getModalHTMLElement","ref","value","modal","activeElement","focus","setFocusLoop","querySelector","leaveLastLink","leaveFirstLink","e","code","shiftKey","closest","remove","el","push","tagName","parentElement","test","arr","every","str","position","left","selected","getSelection","rangeCount","getRangeAt","select","execCommand","removeChild","removeAllRanges","addRange","mailgoStyle","mailgoCSSElement","head","mailgo","mailgoConfig","initEvent","listenerOptions"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;ACjFA,qBAAqB,mBAAO,CAAC,CAA0G;;AAEvI;AACA;AACA,SAAS;AACT;AACA;;;;;;;ACPA;AACA,kCAAkC,mBAAO,CAAC,CAAgD;AAC1F;AACA;AACA,8BAA8B,QAAS,YAAY,eAAe,MAAM,QAAQ,SAAS,OAAO,uBAAuB,mBAAmB,sBAAsB,gBAAgB,iBAAiB,cAAc,oDAAoD,SAAS,UAAU,eAAe,cAAc,yJAAyJ,kCAAkC,gBAAgB,gBAAgB,uBAAuB,kBAAkB,cAAc,MAAM,QAAQ,SAAS,OAAO,yBAAyB,YAAY,0BAA0B,kBAAkB,cAAc,uBAAuB,kBAAkB,gBAAgB,gBAAgB,sBAAsB,aAAa,mBAAmB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oB,4CAA4C,mDAAmD,4BAA4B,oBAAoB,6BAA6B,qBAAqB,oBAAoB,kCAAkC,8CAA8C,mBAAmB,OAAO,kBAAkB,2BAA2B,yBAAyB,4BAA4B,gCAAgC,2BAA2B,OAAO,oBAAoB,4BAA4B,WAAW,0BAA0B,0BAA0B,6BAA6B,SAAS,OAAO,WAAW,wBAAwB,sBAAsB,8BAA8B,8CAA8C,8BAA8B,qBAAqB,8BALine truncated
|
||||
{"version":3,"sources":["webpack://mailgo/webpack/universalModuleDefinition","webpack://mailgo/webpack/bootstrap","webpack://mailgo/../src/mailgo.scss?16f9","webpack://mailgo/../src/mailgo.scss","webpack://mailgo/../node_modules/css-loader/dist/runtime/api.js","webpack://mailgo/../src/mailgo.ts","webpack://mailgo/./mailgo.lib.ts"],"names":["i18n","require","mailgoCSS","toString","DEFAULT_LANG","MAILTO","TEL","CALLTO","outlookDeepLink","MAIL_TYPE","TEL_TYPE","DEFAULT_BTN_HREF","spanHTMLTag","aHTMLTag","pHTMLTag","config","lang","modalMailto","modalTel","url","mail","encEmail","cc","bcc","subject","bodyMail","tel","msg","telegramUsername","skypeUsername","title","titleTel","detailCc","detailBcc","detailSubject","detailBody","ccValue","bccValue","subjectValue","bodyValue","activatedLink","gmail","outlook","open","telegram","wa","skype","call","copyMail","copyTel","mailgoInit","console","log","translations","languages","includes","forceLang","htmlLang","document","documentElement","defaultStrings","strings","createElement","style","display","id","classList","add","setAttribute","dark","enableDarkMode","disableDarkMode","modalBackground","className","appendChild","modalContent","details","ccSpan","createTextNode","cc_","bccSpan","bcc_","subjectSpan","subject_","bodySpan","body_","href","open_in_","gmailSpan","outlookSpan","openSpan","_default","copy","showFooter","byElement","body","addEventListener","hideMailgo","telegramSpan","waSpan","whatsapp","skypeSpan","callSpan","_as_default","mailgoCheckRender","mailgoRender","type","mailgoElement","toLowerCase","startsWith","decodeURIComponent","split","trim","URL","urlParams","searchParams","get","getAttribute","encodeURIComponent","validateEmail","validateEmails","innerHTML","join","textContent","openGmail","openOutlook","encodeEmail","openDefault","hasAttribute","validateTel","openWhatsApp","getElementById","openTelegram","openSkype","callDefault","contains","showMailgo","mailgoKeydown","gmailUrl","concat","window","outlookUrl","mailToEncoded","tgUrl","skypeUrl","waUrl","callUrl","content","copyToClipboard","activeCopy","mailgoIsShowing","setTimeout","isMailgo","element","event","path","composedPath","target","forEach","HTMLDocument","Window","preventDefault","keyboardEvent","keyCode","setModalDisplay","removeEventListener","getModalDisplay","by","rel","encoded","location","atob","email","btoa","getModalHTMLElement","ref","value","modal","activeElement","focus","setFocusLoop","querySelector","leaveLastLink","leaveFirstLink","e","code","shiftKey","closest","remove","el","push","tagName","parentElement","test","arr","every","str","position","left","selected","getSelection","rangeCount","getRangeAt","select","execCommand","removeChild","removeAllRanges","addRange","mailgoStyle","mailgoCSSElement","head","mailgo","mailgoConfig","initEvent","listenerOptions"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,yCAAyC,iCAAiC;QAC1E,gHAAgH,mBAAmB,EAAE;QACrI;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;;QAGA;QACA;;;;;;;;;;;;;;ACjFA,qBAAqB,mBAAO,CAAC,CAA0G;;AAEvI;AACA;AACA,SAAS;AACT;AACA;;;;;;;ACPA;AACA,kCA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