horizon/horizon/static/horizon/js/horizon.users.js
Eddie Ramirez ccdb7b4ffd Fix show/hide password when clicking password icon
This patch overrides a Bootstrap's default property that disables
mouse events on elements with .form-control-feedback class. The password
icon had pointer-events: none; affecting password reveal functionality
in login form and Identity->Users->Create User. It also modifies the default
cursor for the password icon with pointer.

This patch also fixes a bug where the Eye Icon is misaligned when passwords
don't match (See #1604196)

Change-Id: I052321a5cc9adc1a7ffdfce4da0b55c245481a2d
Closes-bug: #1593430
Closes-bug: #1604196
2016-07-19 00:04:25 +00:00

32 lines
934 B
JavaScript

horizon.user = {
init: function() {
$("#id_password").change(function () {
if ($("#id_confirm_password").val() !== "") {
horizon.user.check_passwords_match();
}
});
$("#id_confirm_password").change(function () {
horizon.user.check_passwords_match();
});
},
check_passwords_match: function() {
var row = $("input#id_confirm_password");
var error_id = "id_confirm_password_error";
var msg = "<span id='" + error_id + "' class='help-block'>" + gettext("Passwords do not match.") + "</span>";
var password = $("#id_password").val();
var confirm_password = $("#id_confirm_password").val();
if (password !== confirm_password && $("#" + error_id).length === 0) {
$(row).parent().addClass("has-error").append(msg);
} else if (password === confirm_password) {
$(row).parent().removeClass("has-error");
$("#" + error_id).remove();
}
}
};