Refactored dropin script event handlers

no-issue
This commit is contained in:
Fabien O'Carroll 2019-04-17 11:24:49 +02:00
parent 547b27aa68
commit 3c3cbabacf

View File

@ -59,8 +59,7 @@ function setupMembersListeners() {
removeCookie();
});
function signout(event) {
event.preventDefault();
function signout() {
members.signout()
.then(() => {
return removeCookie();
@ -68,8 +67,7 @@ function setupMembersListeners() {
.then(reload);
}
function signin(event) {
event.preventDefault();
function signin() {
members.signin()
.then(() => {
return members.getSSRToken({
@ -81,8 +79,7 @@ function setupMembersListeners() {
.then(reload);
}
function upgrade(event) {
event.preventDefault();
function upgrade() {
members.upgrade()
.then(() => {
return members.getSSRToken({
@ -95,14 +92,23 @@ function setupMembersListeners() {
}
for (let el of signinEls) {
el.addEventListener('click', signin);
el.addEventListener('click', (event) => {
event.preventDefault();
signin();
});
}
for (let el of upgradeEls) {
el.addEventListener('click', upgrade);
el.addEventListener('click', (event) => {
event.preventDefault();
upgrade();
});
}
for (let el of signoutEls) {
el.addEventListener('click', signout);
el.addEventListener('click', (event) => {
event.preventDefault();
signout();
});
}
}