0
1
Fork 0
hedera-web-mindshore/forms/account/conf/conf.js

78 lines
1.6 KiB
JavaScript

Hedera.Conf = new Class
({
Extends: Hedera.Form
,activate: function ()
{
this.$('user-model').setInfo ('c', 'myClient', 'hedera');
}
,onPassChangeClick: function ()
{
this.$('old-password').value = '';
this.$('new-password').value = '';
this.$('repeat-password').value = '';
var recoverPass = this.$('user-form').get ('recoverPass');
this.$('old-password').style.display = recoverPass ? 'none' : 'block';
this.$('change-password').show ();
if (recoverPass)
this.$('new-password').focus ();
else
this.$('old-password').focus ();
}
,onPassModifyClick: function ()
{
try {
var oldPassword = this.$('old-password').value;
var newPassword = this.$('new-password').value;
var repeatedPassword = this.$('repeat-password').value;
if (newPassword == '' && repeatedPassword == '')
throw new Error (_('Passwords empty'));
if (newPassword !== repeatedPassword)
throw new Error (_('Passwords doesn\'t match'));
var params = {
oldPassword: oldPassword,
newPassword: newPassword
};
this.conn.send ('core/change-password', params,
this._onPassChange.bind (this));
}
catch (e)
{
Htk.Toast.showError (e.message);
}
}
,_onPassChange: function (json, error)
{
if (json)
{
this.$('change-password').hide ();
Htk.Toast.showMessage (_('Password changed!'));
this.$('user-form').refresh ();
}
else
{
Htk.Toast.showError (error.message);
this.$('old-password').select ();
}
}
,onPassInfoClick: function ()
{
this.$('password-info').show ();
}
,onAddressesClick: function ()
{
this.hash.set ({form: 'account/address-list'});
}
});