Anton Shestakov <av6@dwimlabs.net>, Tue, 22 Mar 2016 15:05:34 +0800
rivets: more idiomatic first-letter formatter
coffee/register.coffee
Permissions: -rw-r--r--
window.X = new Tram.XMPPInterface() $('[data-step="registration"]').removeClass('uk-hidden') $('[data-step="registration"]').addClass('uk-hidden') $('[data-msg="registration-closed"]').removeClass('uk-hidden') Tram.validation.setError($('#username'), 'A user with this username already exists.') $('[data-msg="registration-failed"]').removeClass('uk-hidden') $('#nickname').val($('#username').val()) $('[data-step="vcard"]').removeClass('uk-hidden') $('[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', -> fullname: $('#fullname').val() nickname: $('#nickname').val() console.debug('vcard is set!', arguments) $('[data-step="vcard"]').addClass('uk-hidden') console.warn('vcard is NOT set!', arguments) $('[data-msg="save-failed"]').removeClass('uk-hidden') file = $('#avatar').get(0).files[0] reader = new FileReader() _(data).extend(avatar: reader.result) X.savevCard(data, okcb, failcb) reader.readAsDataURL(file) X.savevCard(data, okcb, failcb)