szurubooru/client/js/views/password_reset_view.js

33 lines
871 B
JavaScript
Raw Normal View History

'use strict';
const views = require('../util/views.js');
class PasswordResetView {
constructor() {
this._template = views.getTemplate('password-reset');
}
2016-04-08 10:35:38 +02:00
render(ctx) {
const target = document.getElementById('content-holder');
const source = this._template();
2016-04-08 10:35:38 +02:00
const form = source.querySelector('form');
const userNameOrEmailField = source.querySelector('#user-name');
views.decorateValidator(form);
form.addEventListener('submit', e => {
e.preventDefault();
views.clearMessages(target);
views.disableForm(form);
2016-04-08 10:35:38 +02:00
ctx.proceed(userNameOrEmailField.value)
.catch(() => { views.enableForm(form); });
});
2016-04-08 10:35:38 +02:00
views.listenToMessages(source);
views.showView(target, source);
}
}
module.exports = PasswordResetView;