- Patch #788166 by TR: password_confirm() element breaks if there is more than 1 on a page.

merge-requests/26/head
Dries Buytaert 2010-07-20 10:17:59 +00:00
parent 18516bd971
commit 7c2bcffab1
3 changed files with 15 additions and 12 deletions

View File

@ -204,7 +204,7 @@ dl.multiselect .form-item {
/** /**
* Password strength indicator * Password strength indicator
*/ */
#password-strength { .password-strength {
width: 17em; width: 17em;
float: right; /* LTR */ float: right; /* LTR */
margin-top: 1.4em; margin-top: 1.4em;
@ -212,16 +212,16 @@ dl.multiselect .form-item {
.password-strength-title { .password-strength-title {
display: inline; display: inline;
} }
#password-strength-text { .password-strength-text {
float: right; /* LTR */ float: right; /* LTR */
font-weight: bold; font-weight: bold;
} }
#password-indicator { .password-indicator {
background-color: #C4C4C4; background-color: #C4C4C4;
height: 0.3em; height: 0.3em;
width: 100%; width: 100%;
} }
#password-indicator div { .password-indicator div {
height: 100%; height: 100%;
width: 0%; width: 0%;
background-color: #47C965; background-color: #47C965;

View File

@ -13,9 +13,7 @@ Drupal.behaviors.password = {
var innerWrapper = $(this).parent(); var innerWrapper = $(this).parent();
var outerWrapper = $(this).parent().parent(); var outerWrapper = $(this).parent().parent();
// Add the password strength layers. // Add identifying class to password element parent.
var passwordStrength = $('span.password-strength', innerWrapper);
var passwordResult = $('span.password-result', passwordStrength);
innerWrapper.addClass('password-parent'); innerWrapper.addClass('password-parent');
// Add the password confirmation layer. // Add the password confirmation layer.
@ -25,10 +23,10 @@ Drupal.behaviors.password = {
var confirmChild = $('span', confirmResult); var confirmChild = $('span', confirmResult);
// Add the description box. // Add the description box.
var passwordMeter = '<div id="password-strength"><div id="password-strength-text" aria-live="assertive"></div><div class="password-strength-title">' + translate.strengthTitle + '</div><div id="password-indicator"><div id="indicator"></div></div></div>'; var passwordMeter = '<div class="password-strength"><div class="password-strength-text" aria-live="assertive"></div><div class="password-strength-title">' + translate['strengthTitle'] + '</div><div class="password-indicator"><div class="indicator"></div></div></div>';
$(confirmInput).parent().after('<div class="password-suggestions description"></div>'); $(confirmInput).parent().after('<div class="password-suggestions description"></div>');
$(innerWrapper).prepend(passwordMeter); $(innerWrapper).prepend(passwordMeter);
var passwordDescription = $("div.password-suggestions", outerWrapper).hide(); var passwordDescription = $('div.password-suggestions', outerWrapper).hide();
// Check the password strength. // Check the password strength.
var passwordCheck = function () { var passwordCheck = function () {
@ -50,10 +48,10 @@ Drupal.behaviors.password = {
} }
// Adjust the length of the strength indicator. // Adjust the length of the strength indicator.
$('#indicator').css('width', result.strength + '%'); $(innerWrapper).find('.indicator').css('width', result.strength + '%');
// Update the strength indication text. // Update the strength indication text.
$("#password-strength-text").html(result.indicatorText); $(innerWrapper).find('.password-strength-text').html(result.indicatorText);
passwordCheckMatch(); passwordCheckMatch();
}; };

View File

@ -3361,7 +3361,12 @@ function user_form_process_password_confirm($element) {
); );
$element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js'; $element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
// Ensure settings are only added once per page.
static $already_added = FALSE;
if (!$already_added) {
$already_added = TRUE;
$element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting'); $element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
}
return $element; return $element;
} }