var LoginPage; var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; LoginPage = (function() { function LoginPage(session, startPage) { this.session = session; this.startPage = startPage; } LoginPage.prototype.start = function() { var id, jid, password, _ref; $('#error').hide(); _ref = (function() { var _i, _len, _ref, _results; _ref = ['#jid', '#password']; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { id = _ref[_i]; _results.push($(id).val().trim()); } return _results; })(), jid = _ref[0], password = _ref[1]; if (jid.length === 0 || password.length === 0 || jid.indexOf('@') === -1) { $('#error').show(); return; } return this.session.connect(jid, password, __bind(function(success) { if (!success) { this.session.disconnect(); $('#error').show(); $('#password').val('').focus(); return; } localStorage['jid'] = jid; $('#current-user-name').text(this.session.bareJid()); $('#current-user-avatar').attr('src', this.session.avatar(this.session.jid())); $('#current-user-avatar').attr('alt', this.session.bareJid()); return $('#container').fadeOut(200, __bind(function() { $('#navbar').show(); return window.location.hash = this.startPage; }, this)); }, this)); }; LoginPage.prototype.draw = function() { var jid; this.session.disconnect(); jid = localStorage['jid'] || ''; $('#navbar').hide(); $('body').attr('id', 'login-page'); $('#container').hide().empty(); $("
").appendTo('#container'); $('#container').fadeIn(1000); $('#login-form').submit(__bind(function() { this.start(); return false; }, this)); $('#jid').keydown(function() { return $('#error').fadeOut(); }); $('#password').keydown(function() { return $('#error').fadeOut(); }); return this.resize(); }; LoginPage.prototype.resize = function() { var form, sizer, win; win = $(window); form = $('#login-form'); sizer = function() { return form.css('top', win.height() / 2 - form.height() / 2); }; win.resize(sizer); return sizer(); }; return LoginPage; })();