Fixed search on mobile/tablet devices
Fixed a research (second search query) not working on mobile & tablet devices. Also, ensured a blank search gives alert.
This commit is contained in:
parent
4a8ad937bc
commit
4413387b38
1 changed files with 13 additions and 2 deletions
|
|
@ -694,10 +694,21 @@ if(searchbox_wrapper.length !== 0){
|
||||||
/*
|
/*
|
||||||
Textarea shortcuts
|
Textarea shortcuts
|
||||||
*/
|
*/
|
||||||
|
// Auto submit on enter for touch devices
|
||||||
|
const isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
||||||
|
if(isTouchDevice) {
|
||||||
|
document.addEventListener("change", function(key){
|
||||||
|
if(searchbox.value !== ""){
|
||||||
|
submit(form);
|
||||||
|
} else {
|
||||||
|
alert("Please fill out the search query.");
|
||||||
|
searchbox.focus();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
document.addEventListener("keydown", function(key){
|
document.addEventListener("keydown", function(key){
|
||||||
|
|
||||||
switch(key.keyCode){
|
switch(key.keyCode){
|
||||||
|
|
||||||
case 191:
|
case 191:
|
||||||
// 191 = /
|
// 191 = /
|
||||||
if(document.activeElement.tagName == "INPUT"){
|
if(document.activeElement.tagName == "INPUT"){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue