2009-05-24 19:39:56 -04:00
|
|
|
(function($){
|
|
|
|
|
|
|
|
function check_pass_strength() {
|
2010-03-31 04:45:51 -04:00
|
|
|
var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
|
2009-05-24 19:39:56 -04:00
|
|
|
|
|
|
|
$('#pass-strength-result').removeClass('short bad good strong');
|
2010-03-31 04:45:51 -04:00
|
|
|
if ( ! pass1 ) {
|
2009-05-24 19:39:56 -04:00
|
|
|
$('#pass-strength-result').html( pwsL10n.empty );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-31 04:45:51 -04:00
|
|
|
strength = passwordStrength(pass1, user, pass2);
|
2009-05-24 19:39:56 -04:00
|
|
|
|
|
|
|
switch ( strength ) {
|
|
|
|
case 2:
|
|
|
|
$('#pass-strength-result').addClass('bad').html( pwsL10n['bad'] );
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
$('#pass-strength-result').addClass('good').html( pwsL10n['good'] );
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
$('#pass-strength-result').addClass('strong').html( pwsL10n['strong'] );
|
|
|
|
break;
|
2010-03-31 04:45:51 -04:00
|
|
|
case 5:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
|
|
|
|
break;
|
2009-05-24 19:39:56 -04:00
|
|
|
default:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready( function() {
|
|
|
|
$('#pass1').val('').keyup( check_pass_strength );
|
2010-03-31 04:45:51 -04:00
|
|
|
$('#pass2').val('').keyup( check_pass_strength );
|
2010-09-25 06:58:01 -04:00
|
|
|
$('#pass-strength-result').show();
|
2009-05-24 19:39:56 -04:00
|
|
|
$('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
|
|
|
|
$('#nickname').blur(function(){
|
|
|
|
var str = $(this).val() || $('#user_login').val();
|
2010-03-01 17:34:43 -05:00
|
|
|
var select = $('#display_name');
|
|
|
|
var sel = select.children('option:selected').attr('id');
|
|
|
|
select.children('#display_nickname').remove();
|
|
|
|
if ( ! select.children('option[value=' + str + ']').length )
|
|
|
|
select.append('<option id="display_nickname" value="' + str + '">' + str + '</option>');
|
|
|
|
$('#'+sel).attr('selected', 'selected');
|
2009-05-24 19:39:56 -04:00
|
|
|
});
|
|
|
|
$('#first_name, #last_name').blur(function(){
|
2010-03-01 17:34:43 -05:00
|
|
|
var select = $('#display_name');
|
2009-05-24 19:39:56 -04:00
|
|
|
var first = $('#first_name').val(), last = $('#last_name').val();
|
2010-03-01 17:34:43 -05:00
|
|
|
var sel = select.children('option:selected').attr('id');
|
2009-05-24 19:39:56 -04:00
|
|
|
$('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
|
2010-03-01 17:34:43 -05:00
|
|
|
if ( first && ! select.children('option[value=' + first + ']').length )
|
|
|
|
select.append('<option id="display_firstname" value="' + first + '">' + first + '</option>');
|
|
|
|
if ( last && ! select.children('option[value=' + last + ']').length )
|
|
|
|
select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>');
|
2009-05-24 19:39:56 -04:00
|
|
|
if ( first && last ) {
|
2010-03-01 17:34:43 -05:00
|
|
|
if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
|
|
|
|
select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>');
|
|
|
|
if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
|
|
|
|
select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>');
|
2009-05-24 19:39:56 -04:00
|
|
|
}
|
2010-03-01 17:34:43 -05:00
|
|
|
$('#'+sel).attr('selected', 'selected');
|
2009-05-24 19:39:56 -04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|