mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
search: don't let scrollbar hijack input event of search term#210
This commit is contained in:
parent
5f76f6ce27
commit
6ad4f1c4fd
1 changed files with 6 additions and 3 deletions
|
@ -5,6 +5,8 @@ if( !isIE ){
|
||||||
}
|
}
|
||||||
var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
|
var touchsupport = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
|
||||||
|
|
||||||
|
var formelements = 'button, datalist, fieldset, input, label, legend, meter, optgroup, option, output, progress, select, textarea';
|
||||||
|
|
||||||
function switchTab(tabGroup, tabId) {
|
function switchTab(tabGroup, tabId) {
|
||||||
allTabItems = jQuery("[data-tab-group='"+tabGroup+"']");
|
allTabItems = jQuery("[data-tab-group='"+tabGroup+"']");
|
||||||
targetTabItems = jQuery("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
|
targetTabItems = jQuery("[data-tab-group='"+tabGroup+"'][data-tab-item='"+tabId+"']");
|
||||||
|
@ -178,7 +180,7 @@ function initArrowNav(){
|
||||||
});
|
});
|
||||||
|
|
||||||
// avoid keyboard navigation for input fields
|
// avoid keyboard navigation for input fields
|
||||||
jQuery('input, textarea').keydown(function (e) {
|
jQuery(formelements).keydown(function (e) {
|
||||||
if (e.which == '37' || e.which == '39') {
|
if (e.which == '37' || e.which == '39') {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}
|
}
|
||||||
|
@ -193,7 +195,7 @@ function initMenuScrollbar(){
|
||||||
content = '#body';
|
content = '#body';
|
||||||
}
|
}
|
||||||
var autofocus = false;
|
var autofocus = false;
|
||||||
document.addEventListener('keydown', function(){
|
document.addEventListener('keydown', function(event){
|
||||||
// for initial keyboard scrolling support, no element
|
// for initial keyboard scrolling support, no element
|
||||||
// may be hovered, but we still want to react on
|
// may be hovered, but we still want to react on
|
||||||
// cursor/page up/down. because we can't hack
|
// cursor/page up/down. because we can't hack
|
||||||
|
@ -203,7 +205,8 @@ function initMenuScrollbar(){
|
||||||
// happend
|
// happend
|
||||||
var p = document.querySelector(content).matches(':hover');
|
var p = document.querySelector(content).matches(':hover');
|
||||||
var m = document.querySelector('#content-wrapper').matches(':hover');
|
var m = document.querySelector('#content-wrapper').matches(':hover');
|
||||||
if( !p && !m ){
|
var f = event.target.matches( formelements );
|
||||||
|
if( !p && !m && !f ){
|
||||||
// only do this hack if none of our scrollbars
|
// only do this hack if none of our scrollbars
|
||||||
// is hovered
|
// is hovered
|
||||||
autofocus = true;
|
autofocus = true;
|
||||||
|
|
Loading…
Reference in a new issue