Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 10:29:04 +0800
register: move onConnect to XMPPInterface
coffee/register.coffee
Permissions: -rw-r--r--
window.X = new Tram.XMPPInterface() $('[data-form="registration"], [data-form="vcard"]').each -> $form.find('input').on 'keydown', (e) -> if (not @required or @value isnt '') and e.keyCode is 13 index = $form.find('input').index(@) $next = $form.find('input').eq(index + 1) $form.find('button').trigger('click') $('[data-form="registration"] button').on 'click', -> 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')) X.register($('#username').val().trim(), $('#password1').val()) $('[data-form="vcard"] button').on 'click', -> file = $('#avatar').get(0).files[0] reader = new FileReader() fullname: $('#fullname').val() nickname: $('#nickname').val() reader.readAsDataURL(file) fullname: $('#fullname').val() nickname: $('#nickname').val() $('[data-step="registration"]').removeClass('uk-hidden') $('[data-step="registration"]').addClass('uk-hidden') $('[data-msg="r/closed"]').removeClass('uk-hidden') Tram.validation.setError($('#username'), 'A user with this username already exists.') $('[data-msg="r/failed"]').removeClass('uk-hidden') $('#nickname').val($('#username').val()) $('[data-step="vcard"]').removeClass('uk-hidden') $('[data-step="vcard"]').addClass('uk-hidden') $('[data-msg="v/failed"]').removeClass('uk-hidden')