2009-05-25 01:39:56 +02:00
|
|
|
(function($){
|
|
|
|
|
|
|
|
function check_pass_strength() {
|
2010-03-31 10:45:51 +02:00
|
|
|
var pass1 = $('#pass1').val(), user = $('#user_login').val(), pass2 = $('#pass2').val(), strength;
|
2009-05-25 01:39:56 +02:00
|
|
|
|
|
|
|
$('#pass-strength-result').removeClass('short bad good strong');
|
2010-03-31 10:45:51 +02:00
|
|
|
if ( ! pass1 ) {
|
2009-05-25 01:39:56 +02:00
|
|
|
$('#pass-strength-result').html( pwsL10n.empty );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-31 10:45:51 +02:00
|
|
|
strength = passwordStrength(pass1, user, pass2);
|
2009-05-25 01:39:56 +02: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 10:45:51 +02:00
|
|
|
case 5:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['mismatch'] );
|
|
|
|
break;
|
2009-05-25 01:39:56 +02:00
|
|
|
default:
|
|
|
|
$('#pass-strength-result').addClass('short').html( pwsL10n['short'] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready( function() {
|
|
|
|
$('#pass1').val('').keyup( check_pass_strength );
|
2010-03-31 10:45:51 +02:00
|
|
|
$('#pass2').val('').keyup( check_pass_strength );
|
2010-09-25 12:58:01 +02:00
|
|
|
$('#pass-strength-result').show();
|
2009-05-25 01:39:56 +02: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 23:34:43 +01: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-25 01:39:56 +02:00
|
|
|
});
|
|
|
|
$('#first_name, #last_name').blur(function(){
|
2010-03-01 23:34:43 +01:00
|
|
|
var select = $('#display_name');
|
2009-05-25 01:39:56 +02:00
|
|
|
var first = $('#first_name').val(), last = $('#last_name').val();
|
2010-03-01 23:34:43 +01:00
|
|
|
var sel = select.children('option:selected').attr('id');
|
2009-05-25 01:39:56 +02:00
|
|
|
$('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
|
2010-03-01 23:34:43 +01: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-25 01:39:56 +02:00
|
|
|
if ( first && last ) {
|
2010-03-01 23:34:43 +01: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-25 01:39:56 +02:00
|
|
|
}
|
2010-03-01 23:34:43 +01:00
|
|
|
$('#'+sel).attr('selected', 'selected');
|
2009-05-25 01:39:56 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
})(jQuery);
|