Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 15:47:51 +0800
index: wire up login form
js/register.js
Permissions: -rw-r--r--
// Generated by CoffeeScript 1.10.0 window.X = new Tram.XMPPInterface(); X.on('register', function() { return $('[data-step="registration"]').removeClass('uk-hidden'); X.on('registered', function() { return $('[data-step="registration"]').addClass('uk-hidden'); X.on('regifail', function() { return $('[data-msg="registration-closed"]').removeClass('uk-hidden'); X.on('conflict', function() { return Tram.validation.setError($('#username'), 'A user with this username already exists.'); X.on('notacceptable', function() { return $('[data-msg="registration-failed"]').removeClass('uk-hidden'); X.on('connected', function() { $('#nickname').val($('#username').val()); $('[data-step="vcard"]').removeClass('uk-hidden'); return $('#fullname').focus(); $('[data-form="registration"], [data-form="vcard"]').each(function() { return $form.find('input').on('keydown', function(e) { if ((!this.required || this.value !== '') && e.keyCode === 13) { index = $form.find('input').index(this); $next = $form.find('input').eq(index + 1); if ($next.length !== 0) { return $form.find('button').trigger('click'); $('[data-form="registration"] button').on('click', function() { Tram.validation.unsetError($('#username, #password1, #password2')); ok &= Tram.validation.validateRequired($('#username'), true); ok &= Tram.validation.validatePasswords($('#password1'), $('#password2')); ok &= Tram.validation.validateRequired($('#password1')); ok &= Tram.validation.validateRequired($('#password2')); return X.register($('#username').val().trim(), $('#password1').val()); $('[data-form="vcard"] button').on('click', function() { var data, failcb, file, okcb, reader; fullname: $('#fullname').val(), nickname: $('#nickname').val() console.debug('vcard is set!', arguments); $('[data-step="vcard"]').addClass('uk-hidden'); return location.href = '/'; console.warn('vcard is NOT set!', arguments); return $('[data-msg="save-failed"]').removeClass('uk-hidden'); file = $('#avatar').get(0).files[0]; reader = new FileReader(); reader.onloadend = function() { return X.savevCard(data, okcb, failcb); return reader.readAsDataURL(file); return X.savevCard(data, okcb, failcb); //# sourceMappingURL=register.js.map