Commit aca54cc1 authored by Dries's avatar Dries

Patch #331893 by mgifford, nigel, Xano, Everett Zufelt | Cliff, Bojhan,...

Patch #331893 by mgifford, nigel, Xano, Everett Zufelt | Cliff, Bojhan, mcrittenden, webchick, Josh Waihi, alpritt, heather: improved the password checker.
parent d92389ae
......@@ -520,15 +520,22 @@ html.js .js-hide {
/*
** Password strength indicator
*/
#password-strength {
width: 17em;
float: right; /* LTR */
margin-top: 1.4em;
}
.password-strength-title {
float: left; /* LTR */
display: inline;
}
#password-strength-text {
float: right; /* LTR */
font-weight: bold;
}
#password-indicator {
border: 1px solid #B4B4B4;
float: right;
height: 0.9em;
margin: 0.3em 0.80em 0 0.3em;
width: 5em;
background-color: #C4C4C4;
height: 0.3em;
width: 100%;
}
#password-indicator div {
height: 100%;
......@@ -539,6 +546,10 @@ input.password-confirm, input.password-field {
width: 16em;
margin-bottom: 0.4em;
}
div.password-confirm {
display: inline;
padding-left: 1em;
}
div.password-suggestions {
padding: 0.2em 0.5em;
margin: 0.7em 0;
......@@ -550,8 +561,7 @@ div.password-suggestions ul {
}
.password-parent {
margin: 0;
float: left; /* LTR */
width: 17.3em;
width: 34.3em;
}
/*
......
......@@ -18,10 +18,11 @@ Drupal.behaviors.password = {
var passwordResult = $('span.password-result', passwordStrength);
innerWrapper.addClass('password-parent');
// Add the description box at the end.
var passwordMeter = '<div id="password-strength"><div class="password-strength-title">' + translate.strengthTitle + '</div><div id="password-indicator"><div id="indicator"></div></div></div>';
// Add the description box.
var passwordMeter = '<div id="password-strength"><div id="password-strength-text"></div><div class="password-strength-title">' + translate.strengthTitle + '</div><div id="password-indicator"><div id="indicator"></div></div></div>';
$('div.description', outerWrapper).prepend('<div class="password-suggestions"></div>');
$(innerWrapper).append(passwordMeter);
$(innerWrapper).prepend(passwordMeter);
var passwordDescription = $('div.password-suggestions', outerWrapper).hide();
// Add the password confirmation layer.
......@@ -52,6 +53,9 @@ Drupal.behaviors.password = {
// Adjust the length of the strength indicator.
$('#indicator').css('width', result.strength + '%');
// Update the strength indication text.
$("#password-strength-text").html(result.indicatorText);
passwordCheckMatch();
};
......@@ -155,9 +159,21 @@ Drupal.evaluatePasswordStrength = function (password, translate) {
strength = 5;
}
// Based on the strength, work out what text should be shown by the password strength meter.
if (strength < 60) {
indicatorText = translate.weak;
} else if (strength < 70) {
indicatorText = translate.fair;
} else if (strength < 80) {
indicatorText = translate.good;
} else if (strength < 100) {
indicatorText = translate.strong;
}
// Assemble the final message.
msg = translate.hasWeaknesses + '<ul><li>' + msg.join('</li><li>') + '</li></ul>';
return { strength: strength, message: msg };
return { strength: strength, message: msg, indicatorText: indicatorText }
};
/**
......
......@@ -2877,6 +2877,10 @@ function _user_password_dynamic_validation() {
'sameAsUsername' => t('Make it different from your username'),
'confirmSuccess' => t('yes'),
'confirmFailure' => t('no'),
'weak' => t('Weak'),
'fair' => t('Fair'),
'good' => t('Good'),
'strong' => t('Strong'),
'confirmTitle' => t('Passwords match:'),
'username' => (isset($user->name) ? $user->name : ''))),
'setting');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment