mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-18 08:19:05 +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();
|
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(
|
varLSform.addEvent(
|
||||||
'submit',
|
'submit',
|
||||||
this.onLSformSubmit_confirmChange.bind(this),
|
this.onLSformSubmit.bind(this),
|
||||||
'LSformElement_password('+this.name+') :: confirmChange'
|
'LSformElement_password('+this.name+') :: onLSformSubmit'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -269,14 +264,21 @@ var LSformElement_password_field = new Class({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onLSformSubmit_confirmChange: function(form, on_confirm, on_cancel) {
|
onLSformSubmit: function(form, on_confirm, on_cancel) {
|
||||||
// If no new password set, just confirm
|
// Handle confirmInput feature
|
||||||
if (!this.input.value) {
|
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();
|
on_confirm();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, ask user confirmation
|
// Otherwise, ask user confirmation for password change
|
||||||
this.confirmBox = new LSconfirmBox({
|
this.confirmBox = new LSconfirmBox({
|
||||||
text: this.params.confirmChangeQuestion,
|
text: this.params.confirmChangeQuestion,
|
||||||
startElement: this.input,
|
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