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;
|
||||
},
|
||||
|
||||
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'),
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,8 @@ const
|
|||
screenName = defaultScreenName;
|
||||
}
|
||||
|
||||
if (fireEvent('sm-show-screen', screenName, 1)) {
|
||||
|
||||
// Close all popups
|
||||
for (let vm of visiblePopups) {
|
||||
false === vm.onClose() || vm.close();
|
||||
|
|
@ -228,6 +230,7 @@ const
|
|||
}, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ export class AdminLoginView extends AbstractViewLogin {
|
|||
submitCommand(self, event) {
|
||||
let form = event.target.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.passwordError(!this.password());
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ export class LoginUserView extends AbstractViewLogin {
|
|||
submitCommand(self, event) {
|
||||
let form = event.target.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.passwordError(!this.password());
|
||||
|
|
|
|||
|
|
@ -383,9 +383,15 @@ $Plugin->addHook('hook.name', 'functionName');
|
|||
|
||||
### sm-admin-login
|
||||
event.detail = FormData
|
||||
cancelable using preventDefault()
|
||||
### sm-admin-login-response
|
||||
event.detail = { error: int, data: {JSON response} }
|
||||
### sm-user-login
|
||||
event.detail = FormData
|
||||
cancelable using preventDefault()
|
||||
### sm-user-login-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