diff options
Diffstat (limited to 'modules/user/user.js')
-rw-r--r-- | modules/user/user.js | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/modules/user/user.js b/modules/user/user.js index d382375ab..52279db67 100644 --- a/modules/user/user.js +++ b/modules/user/user.js @@ -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 } + }; /** |