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

96 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
Hedera.Conf = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Hedera.Form
,activate: function ()
{
2017-10-20 17:09:06 +00:00
this.$.userModel.setInfo ('c', 'customer_view', 'hedera');
2017-10-28 15:13:00 +00:00
if (this.hash.$.changePass)
this.onPassChangeClick ();
}
2017-11-02 09:45:04 +00:00
2017-10-28 15:13:00 +00:00
,onChangePassOpen: function ()
{
this.hash.assign ({changePass: true});
}
,onChangePassClose: function ()
{
this.hash.assign ({changePass: undefined});
}
2016-10-11 14:45:10 +00:00
,onPassChangeClick: function ()
{
2017-10-20 17:09:06 +00:00
this.$.oldPassword.value = '';
this.$.newPassword.value = '';
this.$.repeatPassword.value = '';
2017-10-20 17:09:06 +00:00
var recoverPass = this.$.user.get ('recoverPass');
this.$.oldPassword.style.display = recoverPass ? 'none' : 'block';
this.$.changePassword.show ();
2017-10-28 15:13:00 +00:00
var focusInput;
2016-10-11 14:45:10 +00:00
2016-10-14 10:58:35 +00:00
if (recoverPass)
2017-10-28 15:13:00 +00:00
focusInput = this.$.newPassword;
2016-10-14 10:58:35 +00:00
else
2017-10-28 15:13:00 +00:00
focusInput = this.$.oldPassword;
focusInput.focus ();
focusInput.select ();
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 {
2017-10-20 17:09:06 +00:00
var oldPassword = this.$.oldPassword.value;
var newPassword = this.$.newPassword.value;
var repeatedPassword = this.$.repeatPassword.value;
2016-10-11 14:45:10 +00:00
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 = {
2017-10-20 17:09:06 +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)
{
2016-10-11 14:45:10 +00:00
Htk.Toast.showError (e.message);
}
}
2016-10-27 11:22:04 +00:00
,_onPassChange: function (json, error)
{
2016-10-27 11:22:04 +00:00
if (json)
{
2017-10-20 17:09:06 +00:00
this.$.changePassword.hide ();
2016-10-11 14:45:10 +00:00
Htk.Toast.showMessage (_('Password changed!'));
2017-10-20 17:09:06 +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
{
2017-05-02 12:33:48 +00:00
Htk.Toast.showError (error.message);
2017-10-20 17:09:06 +00:00
this.$.oldPassword.select ();
2016-10-11 14:45:10 +00:00
}
2015-03-06 23:33:54 +00:00
}
2016-10-11 14:45:10 +00:00
,onPassInfoClick: function ()
2015-03-06 23:33:54 +00:00
{
2017-10-20 17:09:06 +00:00
this.$.passwordInfo.show ();
}
2015-07-23 15:58:48 +00:00
,onAddressesClick: function ()
{
2017-10-20 17:09:06 +00:00
this.hash.setAll ({form: 'account/address-list'});
}
});