summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-07-20 10:17:59 +0000
committerDries Buytaert <dries@buytaert.net>2010-07-20 10:17:59 +0000
commit7c2bcffab133d360d99ed805474dac7076a3d550 (patch)
treef4b0212781dd60e0b750da20c22e407e15d08f4a
parent18516bd9713145dbfcf57dc801c211a9976b8768 (diff)
downloadbrdo-7c2bcffab133d360d99ed805474dac7076a3d550.tar.gz
brdo-7c2bcffab133d360d99ed805474dac7076a3d550.tar.bz2
- Patch #788166 by TR: password_confirm() element breaks if there is more than 1 on a page.
-rw-r--r--modules/system/system-behavior.css8
-rw-r--r--modules/user/user.js12
-rw-r--r--modules/user/user.module7
3 files changed, 15 insertions, 12 deletions
diff --git a/modules/system/system-behavior.css b/modules/system/system-behavior.css
index 9b72fea76..9dc63497d 100644
--- a/modules/system/system-behavior.css
+++ b/modules/system/system-behavior.css
@@ -204,7 +204,7 @@ dl.multiselect .form-item {
/**
* Password strength indicator
*/
-#password-strength {
+.password-strength {
width: 17em;
float: right; /* LTR */
margin-top: 1.4em;
@@ -212,16 +212,16 @@ dl.multiselect .form-item {
.password-strength-title {
display: inline;
}
-#password-strength-text {
+.password-strength-text {
float: right; /* LTR */
font-weight: bold;
}
-#password-indicator {
+.password-indicator {
background-color: #C4C4C4;
height: 0.3em;
width: 100%;
}
-#password-indicator div {
+.password-indicator div {
height: 100%;
width: 0%;
background-color: #47C965;
diff --git a/modules/user/user.js b/modules/user/user.js
index eab73495e..50bb84981 100644
--- a/modules/user/user.js
+++ b/modules/user/user.js
@@ -13,9 +13,7 @@ Drupal.behaviors.password = {
var innerWrapper = $(this).parent();
var outerWrapper = $(this).parent().parent();
- // Add the password strength layers.
- var passwordStrength = $('span.password-strength', innerWrapper);
- var passwordResult = $('span.password-result', passwordStrength);
+ // Add identifying class to password element parent.
innerWrapper.addClass('password-parent');
// Add the password confirmation layer.
@@ -25,10 +23,10 @@ Drupal.behaviors.password = {
var confirmChild = $('span', confirmResult);
// 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>');
$(innerWrapper).prepend(passwordMeter);
- var passwordDescription = $("div.password-suggestions", outerWrapper).hide();
+ var passwordDescription = $('div.password-suggestions', outerWrapper).hide();
// Check the password strength.
var passwordCheck = function () {
@@ -50,10 +48,10 @@ Drupal.behaviors.password = {
}
// Adjust the length of the strength indicator.
- $('#indicator').css('width', result.strength + '%');
+ $(innerWrapper).find('.indicator').css('width', result.strength + '%');
// Update the strength indication text.
- $("#password-strength-text").html(result.indicatorText);
+ $(innerWrapper).find('.password-strength-text').html(result.indicatorText);
passwordCheckMatch();
};
diff --git a/modules/user/user.module b/modules/user/user.module
index c07aa1461..3b3c6b2b4 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -3361,7 +3361,12 @@ function user_form_process_password_confirm($element) {
);
$element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
- $element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
+ // 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');
+ }
return $element;
}