wpseek / wpseek-web

This repository is currently only used for issue tracking for wpseek.com
https://wpseek.com/
1 stars 0 forks source link

Autofocus search box #25

Closed kungtiger closed 9 years ago

kungtiger commented 9 years ago

First of all: Your API seach engine is great! I use it nearly daily. Just a small suggestion. Could you maybe autofocus the search box on page load? It's just a matter of adding autofocus="autofocus" to the seach box. Thanks!

oliverschloebe commented 9 years ago

Hi, I've had autofocus enabled in the beginning, but can't really remember why I dropped it later. I think the reason was that on tablets it would zoom in everytime the search box gets focussed on page load.

Will have a look at it later when I have my tablet at hands to check that.

kungtiger commented 9 years ago

Ah, I see. Since you are using jQuery, maybe add autofocus only for non-mobile. Something along the line:

jQuery(function(){
    var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
    if (!isMobile.test(navigator.userAgent)) {
        jQuery('#wpsearchterm').trigger('focus');
    }
});

Note: I have not tested the snippet.

oliverschloebe commented 9 years ago

Okay, autofocus is back in for all devices. No zooming, no keyboards popping up on tablets. All fine. :)

kungtiger commented 9 years ago

Does this include regular desktop screens? I didn't mentioned it before, but I'm using a regular old-school laptop and I've just checked wpseek and there is no autofocus.

oliverschloebe commented 9 years ago

Dangit. Forgot to wipe the server-side cache. Please try again. :)

kungtiger commented 9 years ago

Shezaam! Here we go! Thanks man, that makes life easier!