File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 17
17
* CDDL HEADER END
18
18
*/
19
19
20
+ /* global textInputHasFocus */
21
+
20
22
/*
21
23
* Copyright (c) 2016, 2017 Oracle and/or its affiliates. All rights reserved.
22
24
*/
124
126
load : function ( $window ) {
125
127
var that = this
126
128
$ ( document ) . keypress ( function ( e ) {
129
+ if ( textInputHasFocus ( ) ) {
130
+ return true ;
131
+ }
127
132
var key = e . keyCode || e . which
128
133
switch ( key ) {
129
134
case 110 : // n
Original file line number Diff line number Diff line change 846
846
load : function ( $window ) {
847
847
var that = this ;
848
848
$ ( document ) . keypress ( function ( e ) {
849
+ if ( textInputHasFocus ( ) ) {
850
+ return true ;
851
+ }
849
852
var key = e . which ;
850
853
switch ( key ) {
851
854
case 49 : // 1
@@ -1953,13 +1956,14 @@ function isOnSearchPage() {
1953
1956
*/
1954
1957
function searchSubmit ( form ) {
1955
1958
var submitInitiator = '' ;
1956
- if ( document . activeElement && document . activeElement . nodeName === 'INPUT' ) {
1959
+ if ( textInputHasFocus ( ) ) {
1957
1960
submitInitiator = document . activeElement . getAttribute ( 'id' ) ;
1958
1961
}
1959
1962
if ( submitInitiator ) {
1960
1963
var input = document . createElement ( 'INPUT' ) ;
1961
1964
input . setAttribute ( 'name' , 'si' ) ;
1962
1965
input . value = submitInitiator ;
1966
+ input . type = 'hidden' ;
1963
1967
form . appendChild ( input ) ;
1964
1968
}
1965
1969
}
@@ -1980,3 +1984,12 @@ function restoreFocusAfterSearchSubmit() {
1980
1984
}
1981
1985
}
1982
1986
}
1987
+
1988
+ /**
1989
+ * @return {boolean } true if focus is on a input[type=text] element
1990
+ */
1991
+ function textInputHasFocus ( ) {
1992
+ return ! ! document . activeElement &&
1993
+ document . activeElement . nodeName === 'INPUT' &&
1994
+ document . activeElement . type === 'text' ;
1995
+ }
You can’t perform that action at this time.
0 commit comments