forked from verdnatura/hedera-web
80 lines
1.3 KiB
JavaScript
Executable File
80 lines
1.3 KiB
JavaScript
Executable File
|
|
Vn.includeCss ('js/hedera/login.css');
|
|
Vn.resource ('js/hedera/login.xml');
|
|
Vn.define (function () {
|
|
|
|
Vn.Login = new Class
|
|
({
|
|
Extends: Htk.Widget
|
|
|
|
,initialize: function (props)
|
|
{
|
|
this.parent (props);
|
|
this.builderInit ('js/hedera/login.xml');
|
|
|
|
var self = this;
|
|
this.$('form').onsubmit = function ()
|
|
{
|
|
self.onSubmit ();
|
|
return false;
|
|
};
|
|
}
|
|
|
|
,show: function ()
|
|
{
|
|
document.body.appendChild (this.node);
|
|
|
|
if (Vn.Cookie.check ('vn_user'))
|
|
this.$('user').value = Vn.Cookie.get ('vn_user');
|
|
|
|
this.focusUserInput ();
|
|
}
|
|
|
|
,hide: function ()
|
|
{
|
|
Vn.Node.remove (this.node);
|
|
}
|
|
|
|
,focusUserInput: function ()
|
|
{
|
|
var userEntry = this.$('user');
|
|
userEntry.focus ();
|
|
userEntry.select ();
|
|
}
|
|
|
|
,disableInputs: function (disabled)
|
|
{
|
|
this.$('user').disabled = disabled;
|
|
this.$('pass').disabled = disabled;
|
|
this.$('submit').disabled = disabled;
|
|
}
|
|
|
|
,onSubmit: function ()
|
|
{
|
|
this.disableInputs (true);
|
|
this.conn.open (
|
|
this.$('user').value,
|
|
this.$('pass').value,
|
|
this.$('remember').value,
|
|
this.onConnOpen.bind (this)
|
|
);
|
|
}
|
|
|
|
,onConnOpen: function (conn, success)
|
|
{
|
|
this.$('pass').value = '';
|
|
|
|
if (!success)
|
|
{
|
|
Htk.Toast.showError (_('InvalidLogin'));
|
|
}
|
|
else
|
|
this.signalEmit ('login');
|
|
|
|
this.disableInputs (false);
|
|
this.focusUserInput ();
|
|
}
|
|
});
|
|
|
|
});
|