szurubooru/client/js/views/password_reset_view.js

61 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
const config = require('../config.js');
const events = require('../events.js');
const views = require('../util/views.js');
const template = views.getTemplate('password-reset');
class PasswordResetView extends events.EventTarget {
constructor() {
super();
this._hostNode = document.getElementById('content-holder');
views.replaceContent(this._hostNode, template({
canSendMails: config.canSendMails,
contactEmail: config.contactEmail,
}));
2016-07-13 17:18:28 +02:00
views.syncScrollPosition();
2016-07-13 17:18:28 +02:00
views.decorateValidator(this._formNode);
this._formNode.addEventListener('submit', e => {
e.preventDefault();
this.dispatchEvent(new CustomEvent('submit', {
detail: {
userNameOrEmail: this._userNameOrEmailFieldNode.value,
},
}));
});
}
showSuccess(message) {
views.showSuccess(this._hostNode, message);
}
2016-04-08 10:35:38 +02:00
showError(message) {
views.showError(this._hostNode, message);
}
clearMessages() {
views.clearMessages(this._hostNode);
}
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
get _userNameOrEmailFieldNode() {
2016-08-05 20:09:11 +02:00
return this._formNode.querySelector('[name=user-name]');
}
}
module.exports = PasswordResetView;