79 lines
1.7 KiB
JavaScript
79 lines
1.7 KiB
JavaScript
|
|
Hedera.Conf = new Class
|
|
({
|
|
Extends: Hedera.Form
|
|
|
|
,activate: function ()
|
|
{
|
|
this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
|
|
this.$('addresses').setInfo ('a', 'address_view', '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'});
|
|
}
|
|
});
|
|
|