Passwords: Refresh password fields when content is pasted into fields.
Use feature detection to determine whether password inputs should use the `keyup` or `input` event. Props peterwilsoncc, adamsilverstein. Fixes #33398. Built from https://develop.svn.wordpress.org/trunk@34060 git-svn-id: http://core.svn.wordpress.org/trunk@34028 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cd7c0f0b0d
commit
efcdeea2f1
|
@ -6,16 +6,25 @@
|
||||||
$pass1Wrap,
|
$pass1Wrap,
|
||||||
$pass1,
|
$pass1,
|
||||||
$pass1Text,
|
$pass1Text,
|
||||||
|
|
||||||
$pass2,
|
$pass2,
|
||||||
|
|
||||||
$weakRow,
|
$weakRow,
|
||||||
$weakCheckbox,
|
$weakCheckbox,
|
||||||
|
|
||||||
$toggleButton,
|
$toggleButton,
|
||||||
$submitButtons,
|
$submitButtons,
|
||||||
$submitButton,
|
$submitButton,
|
||||||
currentPass;
|
currentPass,
|
||||||
|
inputEvent;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use feature detection to determine whether password inputs should use
|
||||||
|
* the `keyup` or `input` event. Input is preferred but lacks support
|
||||||
|
* in legacy browsers.
|
||||||
|
*/
|
||||||
|
if ( 'oninput' in document.createElement( 'input' ) ) {
|
||||||
|
inputEvent = 'input';
|
||||||
|
} else {
|
||||||
|
inputEvent = 'keyup';
|
||||||
|
}
|
||||||
|
|
||||||
function generatePassword() {
|
function generatePassword() {
|
||||||
if ( typeof zxcvbn !== 'function' ) {
|
if ( typeof zxcvbn !== 'function' ) {
|
||||||
|
@ -47,7 +56,7 @@
|
||||||
.addClass( $pass1[0].className )
|
.addClass( $pass1[0].className )
|
||||||
.data( 'pw', $pass1.data( 'pw' ) )
|
.data( 'pw', $pass1.data( 'pw' ) )
|
||||||
.val( $pass1.val() )
|
.val( $pass1.val() )
|
||||||
.on( 'keyup', function () {
|
.on( inputEvent, function () {
|
||||||
if ( $pass1Text.val() === currentPass ) {
|
if ( $pass1Text.val() === currentPass ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +71,7 @@
|
||||||
generatePassword();
|
generatePassword();
|
||||||
}
|
}
|
||||||
|
|
||||||
$pass1.on( 'keyup pwupdate', function () {
|
$pass1.on( inputEvent + ' pwupdate', function () {
|
||||||
if ( $pass1.val() === currentPass ) {
|
if ( $pass1.val() === currentPass ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +174,7 @@
|
||||||
* This fixes the issue by copying any changes from the hidden
|
* This fixes the issue by copying any changes from the hidden
|
||||||
* pass2 field to the pass1 field, then running check_pass_strength.
|
* pass2 field to the pass1 field, then running check_pass_strength.
|
||||||
*/
|
*/
|
||||||
$pass2 = $('#pass2').on( 'keyup', function () {
|
$pass2 = $('#pass2').on( inputEvent, function () {
|
||||||
if ( $pass2.val().length > 0 ) {
|
if ( $pass2.val().length > 0 ) {
|
||||||
$pass1.val( $pass2.val() );
|
$pass1.val( $pass2.val() );
|
||||||
$pass2.val('');
|
$pass2.val('');
|
||||||
|
@ -250,7 +259,7 @@
|
||||||
var $colorpicker, $stylesheet, user_id, current_user_id,
|
var $colorpicker, $stylesheet, user_id, current_user_id,
|
||||||
select = $( '#display_name' );
|
select = $( '#display_name' );
|
||||||
|
|
||||||
$('#pass1').val('').on( 'keyup pwupdate', check_pass_strength );
|
$('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
|
||||||
$('#pass-strength-result').show();
|
$('#pass-strength-result').show();
|
||||||
$('.color-palette').click( function() {
|
$('.color-palette').click( function() {
|
||||||
$(this).siblings('input[name="admin_color"]').prop('checked', true);
|
$(this).siblings('input[name="admin_color"]').prop('checked', true);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34059';
|
$wp_version = '4.4-alpha-34060';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue