diff --git a/core/modules/user/user.js b/core/modules/user/user.js index 2ae0897..bd0177a 100644 --- a/core/modules/user/user.js +++ b/core/modules/user/user.js @@ -23,12 +23,15 @@ Drupal.behaviors.password = { var confirmResult = outerWrapper.find('div.password-confirm'); var confirmChild = confirmResult.find('span'); + // If password strength indicator enabled, add the description box. + if (typeof settings.password.strengthTitle != 'undefined') { // Add the description box. - var passwordMeter = '
' + translate.strengthTitle + '
'; - confirmInput.parent().after('
'); - innerWrapper.prepend(passwordMeter); - var passwordDescription = outerWrapper.find('div.password-suggestions').hide(); - + var passwordMeter = '
' + translate.strengthTitle + '
'; + confirmInput.parent().after('
'); + innerWrapper.prepend(passwordMeter); + var passwordDescription = outerWrapper.find('div.password-suggestions').hide(); + } + // Check that password and confirmation inputs match. var passwordCheckMatch = function () { @@ -55,31 +58,32 @@ Drupal.behaviors.password = { // Check the password strength. var passwordCheck = function () { + // Check if we are actually checking the password strength + if (typeof settings.password.strengthTitle != 'undefined') { + // Evaluate the password strength. + var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password); + + // Update the suggestions for how to improve the password. + if (passwordDescription.html() !== result.message) { + passwordDescription.html(result.message); + } - // Evaluate the password strength. - var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password); + // Only show the description box if there is a weakness in the password. + if (result.strength === 100) { + passwordDescription.hide(); + } + else { + passwordDescription.show(); + } - // Update the suggestions for how to improve the password. - if (passwordDescription.html() !== result.message) { - passwordDescription.html(result.message); - } + // Adjust the length of the strength indicator. + innerWrapper.find('.indicator') + .css('width', result.strength + '%') + .css('background-color', result.indicatorColor); - // Only show the description box if there is a weakness in the password. - if (result.strength === 100) { - passwordDescription.hide(); + // Update the strength indication text. + innerWrapper.find('.password-strength-text').html(result.indicatorText); } - else { - passwordDescription.show(); - } - - // Adjust the length of the strength indicator. - innerWrapper.find('.indicator') - .css('width', result.strength + '%') - .css('background-color', result.indicatorColor); - - // Update the strength indication text. - innerWrapper.find('.password-strength-text').html(result.indicatorText); - passwordCheckMatch(); };