2015-01-23 13:09:30 +00:00
|
|
|
|
2016-09-26 09:28:47 +00:00
|
|
|
Hedera.Conf = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-09-26 09:28:47 +00:00
|
|
|
Extends: Hedera.Form
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
,activate: function ()
|
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
this.$('user-model').setInfo ('c', 'customer_view', 'hedera');
|
|
|
|
this.$('addresses').setInfo ('a', 'address_view', 'hedera');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2016-10-11 14:45:10 +00:00
|
|
|
|
|
|
|
,onPassChangeClick: function ()
|
|
|
|
{
|
|
|
|
this.$('old-password').value = '';
|
|
|
|
this.$('new-password').value = '';
|
|
|
|
this.$('repeat-password').value = '';
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2016-12-23 08:57:49 +00:00
|
|
|
var recoverPass = this.$('user').get ('recoverPass');
|
2016-10-14 10:58:35 +00:00
|
|
|
this.$('old-password').style.display = recoverPass ? 'none' : 'block';
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('change-password').show ();
|
|
|
|
|
2016-10-14 10:58:35 +00:00
|
|
|
if (recoverPass)
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('new-password').focus ();
|
2016-10-14 10:58:35 +00:00
|
|
|
else
|
|
|
|
this.$('old-password').focus ();
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onPassModifyClick: function ()
|
2015-03-06 23:33:54 +00:00
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
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'));
|
|
|
|
|
2016-10-27 11:22:04 +00:00
|
|
|
var params = {
|
2016-10-14 10:58:35 +00:00
|
|
|
'oldPassword': oldPassword,
|
|
|
|
'newPassword': newPassword
|
2016-10-27 11:22:04 +00:00
|
|
|
};
|
|
|
|
this.conn.send ('core/change-password', params,
|
|
|
|
this._onPassChange.bind (this));
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
|
|
|
catch (e)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
Htk.Toast.showError (e.message);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-27 11:22:04 +00:00
|
|
|
,_onPassChange: function (json, error)
|
2015-01-23 13:09:30 +00:00
|
|
|
{
|
2016-10-27 11:22:04 +00:00
|
|
|
if (json)
|
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('change-password').hide ();
|
|
|
|
Htk.Toast.showMessage (_('Password changed!'));
|
2016-12-23 08:57:49 +00:00
|
|
|
this.$('user').refresh ();
|
2016-10-11 14:45:10 +00:00
|
|
|
}
|
2016-10-27 11:22:04 +00:00
|
|
|
else
|
2016-10-11 14:45:10 +00:00
|
|
|
{
|
|
|
|
Htk.Toast.showError (_('Password doesn\'t meet the requirements'));
|
|
|
|
this.$('old-password').select ();
|
|
|
|
}
|
2015-03-06 23:33:54 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
2016-10-11 14:45:10 +00:00
|
|
|
,onPassInfoClick: function ()
|
2015-03-06 23:33:54 +00:00
|
|
|
{
|
2016-10-11 14:45:10 +00:00
|
|
|
this.$('password-info').show ();
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
|
2015-07-23 15:58:48 +00:00
|
|
|
,onAddressesClick: function ()
|
2015-03-27 19:10:49 +00:00
|
|
|
{
|
2015-07-23 15:58:48 +00:00
|
|
|
this.hash.set ({'form': 'account/address-list'});
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
});
|
|
|
|
|