mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +01:00
LSformElement::password: Improve UX with confirmInput and confirmChange features enabled
This commit is contained in:
parent
7ed325bac7
commit
e58999bbaf
1 changed files with 17 additions and 24 deletions
|
@ -88,20 +88,15 @@ var LSformElement_password_field = new Class({
|
|||
}
|
||||
|
||||
this.initialize_input();
|
||||
if (this.params.confirmInput) {
|
||||
this.input_confirm = this.input.getNext('div.LSformElement_password_confirm').getElement('input');
|
||||
varLSform.addEvent(
|
||||
'submit',
|
||||
this.onLSformSubmit_confirmInput.bind(this),
|
||||
'LSformElement_password('+this.name+') :: confirmInput'
|
||||
);
|
||||
}
|
||||
|
||||
if (this.params.confirmChange) {
|
||||
if (this.params.confirmInput || this.params.confirmChange) {
|
||||
if (this.params.confirmInput) {
|
||||
this.input_confirm = this.input.getNext('div.LSformElement_password_confirm').getElement('input');
|
||||
}
|
||||
varLSform.addEvent(
|
||||
'submit',
|
||||
this.onLSformSubmit_confirmChange.bind(this),
|
||||
'LSformElement_password('+this.name+') :: confirmChange'
|
||||
this.onLSformSubmit.bind(this),
|
||||
'LSformElement_password('+this.name+') :: onLSformSubmit'
|
||||
);
|
||||
}
|
||||
},
|
||||
|
@ -269,14 +264,21 @@ var LSformElement_password_field = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
onLSformSubmit_confirmChange: function(form, on_confirm, on_cancel) {
|
||||
// If no new password set, just confirm
|
||||
if (!this.input.value) {
|
||||
onLSformSubmit: function(form, on_confirm, on_cancel) {
|
||||
// Handle confirmInput feature
|
||||
if (this.params.confirmInput && this.input.value != this.input_confirm.value) {
|
||||
varLSform.addError(this.params.confirmInputError, this.name);
|
||||
on_cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// If confirmChange feature not enabled or no new password set, just confirm
|
||||
if (!this.params.confirmChange || !this.input.value) {
|
||||
on_confirm();
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, ask user confirmation
|
||||
// Otherwise, ask user confirmation for password change
|
||||
this.confirmBox = new LSconfirmBox({
|
||||
text: this.params.confirmChangeQuestion,
|
||||
startElement: this.input,
|
||||
|
@ -288,13 +290,4 @@ var LSformElement_password_field = new Class({
|
|||
});
|
||||
},
|
||||
|
||||
onLSformSubmit_confirmInput: function(form, on_confirm, on_cancel) {
|
||||
if (this.input.value == this.input_confirm.value) {
|
||||
on_confirm();
|
||||
}
|
||||
else {
|
||||
varLSform.addError(this.params.confirmInputError, this.name);
|
||||
on_cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue