mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Allow cancelable on some custom javascript events.
This commit is contained in:
parent
9f2c06bcd3
commit
80eed213d9
5 changed files with 57 additions and 46 deletions
|
|
@ -27,7 +27,9 @@ export const
|
||||||
return el;
|
return el;
|
||||||
},
|
},
|
||||||
|
|
||||||
fireEvent = (name, detail) => dispatchEvent(new CustomEvent(name, {detail:detail})),
|
fireEvent = (name, detail, cancelable) => dispatchEvent(
|
||||||
|
new CustomEvent(name, {detail:detail, cancelable: !!cancelable})
|
||||||
|
),
|
||||||
|
|
||||||
formFieldFocused = () => doc.activeElement && doc.activeElement.matches('input,textarea'),
|
formFieldFocused = () => doc.activeElement && doc.activeElement.matches('input,textarea'),
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -173,6 +173,8 @@ const
|
||||||
screenName = defaultScreenName;
|
screenName = defaultScreenName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fireEvent('sm-show-screen', screenName, 1)) {
|
||||||
|
|
||||||
// Close all popups
|
// Close all popups
|
||||||
for (let vm of visiblePopups) {
|
for (let vm of visiblePopups) {
|
||||||
false === vm.onClose() || vm.close();
|
false === vm.onClose() || vm.close();
|
||||||
|
|
@ -228,6 +230,7 @@ const
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export class AdminLoginView extends AbstractViewLogin {
|
||||||
submitCommand(self, event) {
|
submitCommand(self, event) {
|
||||||
let form = event.target.form,
|
let form = event.target.form,
|
||||||
data = new FormData(form),
|
data = new FormData(form),
|
||||||
valid = form.reportValidity() && fireEvent('sm-admin-login', data);
|
valid = form.reportValidity() && fireEvent('sm-admin-login', data, 1);
|
||||||
|
|
||||||
this.loginError(!this.login());
|
this.loginError(!this.login());
|
||||||
this.passwordError(!this.password());
|
this.passwordError(!this.password());
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ export class LoginUserView extends AbstractViewLogin {
|
||||||
submitCommand(self, event) {
|
submitCommand(self, event) {
|
||||||
let form = event.target.form,
|
let form = event.target.form,
|
||||||
data = new FormData(form),
|
data = new FormData(form),
|
||||||
valid = form.reportValidity() && fireEvent('sm-user-login', data);
|
valid = form.reportValidity() && fireEvent('sm-user-login', data, 1);
|
||||||
|
|
||||||
this.emailError(!this.email());
|
this.emailError(!this.email());
|
||||||
this.passwordError(!this.password());
|
this.passwordError(!this.password());
|
||||||
|
|
|
||||||
|
|
@ -383,9 +383,15 @@ $Plugin->addHook('hook.name', 'functionName');
|
||||||
|
|
||||||
### sm-admin-login
|
### sm-admin-login
|
||||||
event.detail = FormData
|
event.detail = FormData
|
||||||
|
cancelable using preventDefault()
|
||||||
### sm-admin-login-response
|
### sm-admin-login-response
|
||||||
event.detail = { error: int, data: {JSON response} }
|
event.detail = { error: int, data: {JSON response} }
|
||||||
### sm-user-login
|
### sm-user-login
|
||||||
event.detail = FormData
|
event.detail = FormData
|
||||||
|
cancelable using preventDefault()
|
||||||
### sm-user-login-response
|
### sm-user-login-response
|
||||||
event.detail = { error: int, data: {JSON response} }
|
event.detail = { error: int, data: {JSON response} }
|
||||||
|
|
||||||
|
### sm-show-screen
|
||||||
|
event.detail = 'screenname'
|
||||||
|
cancelable using preventDefault()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue