From bda52632a5aa033d44151c224a39236b223c6b0e Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Sun, 26 Apr 2009 19:18:46 +0000 Subject: #444402 by kkaefer and RobLoach: Enforce coding standards on all core JavaScript. --- modules/user/user.js | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'modules/user') diff --git a/modules/user/user.js b/modules/user/user.js index 66e74e890..10077434c 100644 --- a/modules/user/user.js +++ b/modules/user/user.js @@ -8,30 +8,30 @@ Drupal.behaviors.password = { attach: function(context, settings) { var translate = settings.password; - $("input.password-field:not(.password-processed)", context).each(function() { + $('input.password-field:not(.password-processed)', context).each(function() { var passwordInput = $(this).addClass('password-processed'); 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); - innerWrapper.addClass("password-parent"); + var passwordStrength = $('span.password-strength', innerWrapper); + var passwordResult = $('span.password-result', passwordStrength); + innerWrapper.addClass('password-parent'); // Add the description box at the end. var passwordMeter = '
' + translate.strengthTitle + '
'; - $("div.description", outerWrapper).prepend('
'); + $('div.description', outerWrapper).prepend('
'); $(innerWrapper).append(passwordMeter); - var passwordDescription = $("div.password-suggestions", outerWrapper).hide(); + var passwordDescription = $('div.password-suggestions', outerWrapper).hide(); // Add the password confirmation layer. - $("input.password-confirm", outerWrapper).after('
' + translate["confirmTitle"] + '
').parent().addClass("confirm-parent"); - var confirmInput = $("input.password-confirm", outerWrapper); - var confirmResult = $("div.password-confirm", outerWrapper); - var confirmChild = $("span", confirmResult); + $('input.password-confirm', outerWrapper).after('
' + translate['confirmTitle'] + '
').parent().addClass('confirm-parent'); + var confirmInput = $('input.password-confirm', outerWrapper); + var confirmResult = $('div.password-confirm', outerWrapper); + var confirmChild = $('span', confirmResult); // Check the password strength. - var passwordCheck = function () { + var passwordCheck = function() { // Evaluate the password strength. var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password); @@ -50,19 +50,19 @@ Drupal.behaviors.password = { } // Adjust the length of the strength indicator. - $("#indicator").css('width', result.strength + '%'); + $('#indicator').css('width', result.strength + '%'); passwordCheckMatch(); }; // Check that password and confirmation inputs match. - var passwordCheckMatch = function () { + var passwordCheckMatch = function() { if (confirmInput.val()) { var success = passwordInput.val() === confirmInput.val(); // Show the confirm result. - confirmResult.css({ visibility: "visible" }); + confirmResult.css({ visibility: 'visible' }); // Remove the previous styling if any exists. if (this.confirmClass) { @@ -70,12 +70,12 @@ Drupal.behaviors.password = { } // Fill in the success message and set the class accordingly. - var confirmClass = success ? "ok" : 'error'; - confirmChild.html(translate["confirm" + (success ? "Success" : "Failure")]).addClass(confirmClass); + var confirmClass = success ? 'ok' : 'error'; + confirmChild.html(translate['confirm' + (success ? 'Success' : 'Failure')]).addClass(confirmClass); this.confirmClass = confirmClass; } else { - confirmResult.css({ visibility: "hidden" }); + confirmResult.css({ visibility: 'hidden' }); } }; @@ -92,7 +92,7 @@ Drupal.behaviors.password = { * * Returns the estimated strength and the relevant output message. */ -Drupal.evaluatePasswordStrength = function (password, translate) { +Drupal.evaluatePasswordStrength = function(password, translate) { var weaknesses = 0, strength = 100, msg = []; var hasLowercase = password.match(/[a-z]+/); @@ -102,7 +102,7 @@ Drupal.evaluatePasswordStrength = function (password, translate) { // If there is a username edit box on the page, compare password to that, otherwise // use value from the database. - var usernameBox = $("input.username"); + var usernameBox = $('input.username'); var username = (usernameBox.length > 0) ? usernameBox.val() : translate.username; // Lose 10 points for every character less than 6. @@ -149,14 +149,14 @@ Drupal.evaluatePasswordStrength = function (password, translate) { } // Check if password is the same as the username. - if ((password !== '') && (password.toLowerCase() === username.toLowerCase())){ + if (password !== '' && password.toLowerCase() === username.toLowerCase()) { msg.push(translate.sameAsUsername); // Passwords the same as username are always very weak. strength = 5; } // Assemble the final message. - msg = translate.hasWeaknesses + ""; + msg = translate.hasWeaknesses + ''; return { strength: strength, message: msg }; }; @@ -167,7 +167,7 @@ Drupal.evaluatePasswordStrength = function (password, translate) { */ Drupal.behaviors.userSettings = { attach: function(context, settings) { - $('div.user-admin-picture-radios input[type=radio]:not(.userSettings-processed)', context).addClass('userSettings-processed').click(function () { + $('div.user-admin-picture-radios input[type=radio]:not(.userSettings-processed)', context).addClass('userSettings-processed').click(function() { $('div.user-admin-picture-settings', context)[['hide', 'show'][this.value]](); }); } -- cgit v1.2.3