blob: 48034ddf6e04fbc8d2e9286cf491e6e341cd092e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
'use strict';
const events = require('../events.js');
const api = require('../api.js');
const views = require('../util/views.js');
const template = views.getTemplate('user-registration');
class RegistrationView extends events.EventTarget {
constructor() {
super();
this._hostNode = document.getElementById('content-holder');
views.replaceContent(this._hostNode, template({
userNamePattern: api.getUserNameRegex(),
passwordPattern: api.getPasswordRegex(),
}));
views.syncScrollPosition();
views.decorateValidator(this._formNode);
this._formNode.addEventListener('submit', e => this._evtSubmit(e));
}
clearMessages() {
views.clearMessages(this._hostNode);
}
showError(message) {
views.showError(this._hostNode, message);
}
enableForm() {
views.enableForm(this._formNode);
}
disableForm() {
views.disableForm(this._formNode);
}
_evtSubmit(e) {
e.preventDefault();
this.dispatchEvent(new CustomEvent('submit', {
detail: {
name: this._userNameFieldNode.value,
password: this._passwordFieldNode.value,
email: this._emailFieldNode.value,
},
}));
}
get _formNode() {
return this._hostNode.querySelector('form');
}
get _userNameFieldNode() {
return this._formNode.querySelector('[name=name]');
}
get _passwordFieldNode() {
return this._formNode.querySelector('[name=password]');
}
get _emailFieldNode() {
return this._formNode.querySelector('[name=email]');
}
}
module.exports = RegistrationView;
|
© 2015 - 2026 Jakob L. Kreuze