Simplify key press event handlers
Remove eventSupported checks and just rely on jquery.keydown
This commit is contained in:
@@ -225,12 +225,7 @@
|
||||
} );
|
||||
|
||||
// Handle key press events on the menu
|
||||
this.$menu.on( 'keypress', $.proxy( this.keypress, this ) )
|
||||
.on( 'keyup', $.proxy( this.keyup, this ) );
|
||||
|
||||
if ( this.eventSupported( 'keydown' ) ) {
|
||||
this.$menu.on( 'keydown', $.proxy( this.keypress, this ) );
|
||||
}
|
||||
this.$menu.keydown( $.proxy( this.keypress, this ) );
|
||||
|
||||
languagesCount = Object.keys( this.options.languages ).length;
|
||||
lcd = this.$resultsView.lcd( {
|
||||
@@ -280,18 +275,6 @@
|
||||
this.hide();
|
||||
},
|
||||
|
||||
keyup: function ( e ) {
|
||||
if ( !this.shown ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( e.keyCode === 27 ) { // escape
|
||||
this.cancel();
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
},
|
||||
|
||||
keypress: function ( e ) {
|
||||
if ( !this.shown ) {
|
||||
return;
|
||||
@@ -312,17 +295,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
eventSupported: function ( eventName ) {
|
||||
var isSupported = eventName in this.$menu;
|
||||
|
||||
if ( !isSupported ) {
|
||||
this.$element.setAttribute( eventName, 'return;' );
|
||||
isSupported = typeof this.$element[ eventName ] === 'function';
|
||||
}
|
||||
|
||||
return isSupported;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the panel menu width parameter
|
||||
* @return {string}
|
||||
|
||||
Reference in New Issue
Block a user