Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 15:47:51 +0800
index: wire up login form
coffee/index.coffee
Permissions: -rw-r--r--
window.X = new Tram.XMPPInterface() $('[data-msg^="a/"]').addClass('uk-hidden') $('[data-msg="a/fail"]').removeClass('uk-hidden') $('[data-step="login"]').removeClass('uk-hidden') X.on 'connected attached', -> $('[data-step="login"]').addClass('uk-hidden') $form = $('[data-form="connect"]') $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') $form.find('button').on 'click', (e) -> Tram.validation.unsetError($('#username, #password')) ok &= Tram.validation.validateRequired($('#username'), true) ok &= Tram.validation.validateRequired($('#password')) X.connect($('#username').val().trim(), $('#password').val())