2016-04-06 17:56:34 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
const events = require('../events.js');
|
2016-04-09 18:54:23 +02:00
|
|
|
const views = require('../util/views.js');
|
2016-04-06 17:56:34 +02:00
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
const template = views.getTemplate('password-reset');
|
|
|
|
|
|
|
|
class PasswordResetView extends events.EventTarget {
|
2016-04-06 17:56:34 +02:00
|
|
|
constructor() {
|
2016-06-14 10:31:48 +02:00
|
|
|
super();
|
|
|
|
this._hostNode = document.getElementById('content-holder');
|
|
|
|
|
|
|
|
views.replaceContent(this._hostNode, template());
|
2016-07-13 17:18:28 +02:00
|
|
|
views.syncScrollPosition();
|
2016-06-14 10:31:48 +02:00
|
|
|
|
2016-07-13 17:18:28 +02:00
|
|
|
views.decorateValidator(this._formNode);
|
2016-08-14 16:57:46 +02:00
|
|
|
this._formNode.addEventListener('submit', e => {
|
2016-06-14 10:31:48 +02:00
|
|
|
e.preventDefault();
|
|
|
|
this.dispatchEvent(new CustomEvent('submit', {
|
|
|
|
detail: {
|
|
|
|
userNameOrEmail: this._userNameOrEmailFieldNode.value,
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
});
|
2016-04-06 17:56:34 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
showSuccess(message) {
|
|
|
|
views.showSuccess(this._hostNode, message);
|
|
|
|
}
|
2016-04-08 10:35:38 +02:00
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
showError(message) {
|
|
|
|
views.showError(this._hostNode, message);
|
|
|
|
}
|
2016-04-06 17:56:34 +02:00
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
clearMessages() {
|
|
|
|
views.clearMessages(this._hostNode);
|
|
|
|
}
|
2016-04-06 17:56:34 +02:00
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
enableForm() {
|
|
|
|
views.enableForm(this._formNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
disableForm() {
|
|
|
|
views.disableForm(this._formNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
get _formNode() {
|
|
|
|
return this._hostNode.querySelector('form');
|
|
|
|
}
|
2016-04-08 10:35:38 +02:00
|
|
|
|
2016-06-14 10:31:48 +02:00
|
|
|
get _userNameOrEmailFieldNode() {
|
2016-08-05 20:09:11 +02:00
|
|
|
return this._formNode.querySelector('[name=user-name]');
|
2016-04-06 17:56:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = PasswordResetView;
|