gallery.accords-library.com/client/js/views/registration_view.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
const config = require('../config.js');
2016-04-07 17:03:49 +00:00
const events = require('../events.js');
const BaseView = require('./base_view.js');
class RegistrationView extends BaseView {
constructor() {
super();
this.template = this.getTemplate('user-registration-template');
}
2016-04-08 08:35:38 +00:00
render(ctx) {
const target = this.contentHolder;
const source = this.template();
2016-04-08 08:35:38 +00:00
const form = source.querySelector('form');
const userNameField = source.querySelector('#user-name');
const passwordField = source.querySelector('#user-password');
const emailField = source.querySelector('#user-email');
2016-04-07 17:03:49 +00:00
this.decorateValidator(form);
2016-04-06 18:38:45 +00:00
userNameField.setAttribute('pattern', config.userNameRegex);
passwordField.setAttribute('pattern', config.passwordRegex);
form.addEventListener('submit', e => {
e.preventDefault();
2016-03-31 20:33:49 +00:00
this.clearMessages();
2016-04-06 13:11:20 +00:00
this.disableForm(form);
2016-04-08 08:35:38 +00:00
ctx.register(
userNameField.value,
passwordField.value,
emailField.value)
.always(() => { this.enableForm(form); });
});
2016-04-08 08:35:38 +00:00
this.showView(target, source);
}
}
module.exports = RegistrationView;