24:04329aa80b7a
Anton Shestakov <av6@dwimlabs.net>, Mon, 21 Mar 2016 19:57:24 +0800
messages: new ui element and related things

next change 25:bab5df239765
previous change 23:98a9a4b85104

js/index.js

Permissions: -rw-r--r--

Other formats: Feeds:
// Generated by CoffeeScript 1.10.0
(function() {
var $form;
window.X = new Tram.XMPPInterface();
X.on('connecting', function() {
return $('[data-msg^="a/"]').addClass('uk-hidden');
});
X.on('authfail', function() {
return $('[data-msg="a/fail"]').removeClass('uk-hidden');
});
X.on('disconnected', function() {
$('[data-step="login"]').removeClass('uk-hidden');
return $('[data-step="main"]').addClass('uk-hidden');
});
X.on('connected attached', function() {
$('[data-step="login"]').addClass('uk-hidden');
return $('[data-step="main"]').removeClass('uk-hidden');
});
$('button[data-disconnect]').on('click', function() {
return X.disconnect('Logged out');
});
$form = $('[data-form="connect"]');
$form.find('input').on('keydown', function(e) {
var $next, index;
if ((!this.required || this.value !== '') && e.keyCode === 13) {
e.preventDefault();
index = $form.find('input').index(this);
$next = $form.find('input').eq(index + 1);
if ($next.length !== 0) {
return $next.focus();
} else {
return $form.find('button').trigger('click');
}
}
});
$form.find('button').on('click', function(e) {
var ok;
e.preventDefault();
ok = true;
Tram.validation.unsetError($('#username, #password'));
ok &= Tram.validation.validateRequired($('#username'), true);
ok &= Tram.validation.validateRequired($('#password'));
if (ok) {
return X.connect($('#username').val().trim(), $('#password').val());
}
});
}).call(this);
//# sourceMappingURL=index.js.map