removed obj actions

This commit is contained in:
Matteo Manzinello 2019-10-28 08:36:59 +01:00
parent 08ce4c434b
commit 09e57d1730
3 changed files with 113 additions and 115 deletions

2
dist/mailgo.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -392,7 +392,7 @@
let bodyEl = getE("mailgo-body");
let bodyValueEl = getE("mailgo-body-value");
// actions
// action buttons
gmailButton = getE("mailgo-gmail");
outlookButton = getE("mailgo-outlook");
openButton = getE("mailgo-open");
@ -423,14 +423,14 @@
: (bodyEl.style.display = "none");
// add the actions
gmailButton.addEventListener("click", () => actions.openGmail());
gmailButton.addEventListener("click", () => openGmail());
outlookButton.addEventListener("click", () => actions.openOutlook());
outlookButton.addEventListener("click", () => openOutlook());
encEmail = encodeEmail(mail);
openButton.addEventListener("click", () => actions.openDefault());
openButton.addEventListener("click", () => openDefault());
copyButton.addEventListener("click", () => actions.copy(mail || tel));
copyButton.addEventListener("click", () => copy(mail || tel));
}
// mailgo tel
if (type === TEL_TYPE) {
@ -477,18 +477,18 @@
titleEl.innerHTML = tel;
// add the actions to buttons
waButton.addEventListener("click", () => actions.openWhatsApp());
waButton.addEventListener("click", () => openWhatsApp());
if (telegramUsername) {
setDisplay("mailgo-telegram", "block");
telegramButton.addEventListener("click", () => actions.openTelegram());
telegramButton.addEventListener("click", () => openTelegram());
}
skypeButton.addEventListener("click", () => actions.openSkype());
skypeButton.addEventListener("click", () => openSkype());
callButton.addEventListener("click", () => actions.callDefault());
callButton.addEventListener("click", () => callDefault());
copyButton.addEventListener("click", () => actions.copy(tel));
copyButton.addEventListener("click", () => copy(tel));
}
// show the mailgo
@ -499,8 +499,7 @@
};
// actions
const actions = {
openGmail: () => {
openGmail = () => {
// Gmail url
let gmailUrl =
"https://mail.google.com/mail/u/0/?view=cm&source=mailto&to=" +
@ -517,9 +516,9 @@
// hide the modal
hideMailgo();
},
};
openOutlook: () => {
openOutlook = () => {
// Outlook url
let outlookUrl =
"https://outlook.live.com/owa/?path=/mail/action/compose&to=" +
@ -534,14 +533,14 @@
// hide the modal
hideMailgo();
},
};
openDefault: () => {
openDefault = () => {
mailToEncoded(encEmail);
hideMailgo();
},
};
openTelegram: () => {
openTelegram = () => {
// Telegram url
let tgUrl = "https://t.me/" + telegramUsername;
@ -550,9 +549,9 @@
// hide the modal
hideMailgo();
},
};
openSkype: () => {
openSkype = () => {
let skype = skypeUsername !== "" ? skypeUsername : tel;
// Telegram url
@ -563,9 +562,9 @@
// hide the modal
hideMailgo();
},
};
openWhatsApp: () => {
openWhatsApp = () => {
// WhatsApp url
let waUrl = "https://wa.me/" + tel;
@ -577,15 +576,15 @@
// hide the modal
hideMailgo();
},
};
callDefault: () => {
callDefault = () => {
let callUrl = "tel:" + tel;
window.open(callUrl);
hideMailgo();
},
};
copy: content => {
copy = content => {
copyToClipboard(content);
// the correct copyButton (mail or tel)
mailgoIsShowing(MAIL_TYPE)
@ -597,7 +596,6 @@
// hide after the timeout
hideMailgo();
}, 999);
}
};
// function that returns if an element is a mailgo
@ -715,20 +713,20 @@
break;
case 71:
// g -> open GMail
actions.openGmail();
openGmail();
break;
case 79:
// o -> open Outlook
actions.openOutlook();
openOutlook();
break;
case 32:
case 13:
// spacebar or enter -> open default
actions.openDefault();
openDefault();
break;
case 67:
// c -> copy
actions.copy(mail);
copy(mail);
break;
default:
return;
@ -741,20 +739,20 @@
break;
case 84:
// t -> open Telegram
actions.openTelegram();
openTelegram();
break;
case 87:
// w -> open WhatsApp
actions.openWhatsApp();
openWhatsApp();
break;
case 32:
case 13:
// spacebar or enter -> call default
actions.callDefault();
callDefault();
break;
case 67:
// c -> copy
actions.copy(tel);
copy(tel);
break;
default:
return;