Admin: Don't use the `keyup` event in addition to the `input` event.

The `keyup` event was used to provide support for IE8, where which doesn't support the `input` event. As we dropped IE8 support some time ago, this was simply adding unnecessary complexity and double-event triggers.

Props dlh, afercia.
Fixes #32882.



git-svn-id: https://develop.svn.wordpress.org/trunk@44539 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2019-01-10 02:56:24 +00:00
parent 1f13137463
commit fa886b237f
4 changed files with 7 additions and 33 deletions

View File

@ -17,19 +17,7 @@
$toggleButton,
$submitButtons,
$submitButton,
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';
}
currentPass;
function generatePassword() {
if ( typeof zxcvbn !== 'function' ) {
@ -71,7 +59,7 @@
.addClass( $pass1[0].className )
.data( 'pw', $pass1.data( 'pw' ) )
.val( $pass1.val() )
.on( inputEvent, function () {
.on( 'input', function () {
if ( $pass1Text.val() === currentPass ) {
return;
}
@ -86,7 +74,7 @@
generatePassword();
}
$pass1.on( inputEvent + ' pwupdate', function () {
$pass1.on( 'input' + ' pwupdate', function () {
if ( $pass1.val() === currentPass ) {
return;
}
@ -188,7 +176,7 @@
* This fixes the issue by copying any changes from the hidden
* pass2 field to the pass1 field, then running check_pass_strength.
*/
$pass2 = $('#pass2').on( inputEvent, function () {
$pass2 = $( '#pass2' ).on( 'input', function () {
if ( $pass2.val().length > 0 ) {
$pass1.val( $pass2.val() );
$pass2.val('');
@ -336,7 +324,7 @@
current_name = select.val(),
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
$('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
$( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength );
$('#pass-strength-result').show();
$('.color-palette').click( function() {
$(this).siblings('input[name="admin_color"]').prop('checked', true);

View File

@ -873,26 +873,14 @@
},
attachQuickSearchListeners : function() {
var searchTimer,
inputEvent;
var searchTimer;
// Prevent form submission.
$( '#nav-menu-meta' ).on( 'submit', function( event ) {
event.preventDefault();
});
/*
* Use feature detection to determine whether inputs should use
* the `keyup` or `input` event. Input is preferred but lacks support
* in legacy browsers. See changeset 34078, see also ticket #26600#comment:59
*/
if ( 'oninput' in document.createElement( 'input' ) ) {
inputEvent = 'input';
} else {
inputEvent = 'keyup';
}
$( '#nav-menu-meta' ).on( inputEvent, '.quick-search', function() {
$( '#nav-menu-meta' ).on( 'input', '.quick-search', function() {
var $this = $( this );
$this.attr( 'autocomplete', 'off' );

View File

@ -156,7 +156,6 @@
events: {
'input #menu-items-search': 'debounceSearch',
'keyup #menu-items-search': 'debounceSearch',
'focus .menu-item-tpl': 'focus',
'click .menu-item-tpl': '_submit',
'click #custom-menu-item-submit': '_submitLink',

View File

@ -144,7 +144,6 @@
events: {
'input #widgets-search': 'search',
'keyup #widgets-search': 'search',
'focus .widget-tpl' : 'focus',
'click .widget-tpl' : '_submit',
'keypress .widget-tpl' : '_submit',