Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2016-11-15 05:04:30

mikewren
Member
Registered: 2016-09-09
Posts: 13

Gallery Search Textbox Immediate Focus

When clicking on the search icon in the navigation menu bar, the search text box is shown as expected.  However, the search text box isn't in focus and isn't ready to accept text input - This is confusing for my users. While user testing, all of them first try typing a search term when presented with the text box, and those who weren't touch-typists, looked down and started typing, completing the word without realizing their text was getting lost.

It would be super helpful if the cursor is at the search text box is immediately ready to accept text input, without requiring the user the extra step of moving their mouse cursor to the search text box and clicking the mouse button.

Thanks!

Offline

#2 2016-11-15 05:28:58

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Gallery Search Textbox Immediate Focus

try placing this in a phplugins file and then use that phplugins file in the page template that controls the album template for your search page (under Advanced Customization):

/*Place focus on form input field
=========================================*/

function ttg_scripts ( $style, $path ) {
echo' 
<script>
window.onload = function() {
document.getElementById("q").focus();
}
</script>
 ';
} //END

Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#3 2016-11-15 20:58:16

jherman
Member
From: Kingsport, TN USA
Registered: 2012-12-09
Posts: 95
Website

Re: Gallery Search Textbox Immediate Focus

Works as advertised. I placed the above code in the user section of my phplugins.php file. Things have moved a bit since I last tried this, CE4.

There is a sample php file in .../backlight/custom/phplugins and it contains several sample functions all of which are inactive. I placed this function  at the end.  Location of the file is important for Backlight to be able to find it.

Then I renamed it to phplugins.php. This is important to prevent an inadvertent file overwrite with an update where Matt has traditionally updated only the phplugins-sample.php file.

I then went to my default page template and activated phplugins and selected my modified puplugins.php file.

I then made sure my browser reloaded the pages and now the focus is indeed in the text entry field.

I then tested in Chrome, IE, Edge  and FireFox - seems to work and no unusual behavior noted elsewhere in the site.

Jim.

Last edited by jherman (2016-11-15 21:25:01)


User with too little time but coding is therapeutic.

Offline

#4 2016-12-28 21:58:02

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Gallery Search Textbox Immediate Focus

Apparently the code above can throw a console error. See this for something better:
http://community.theturninggate.net/vie … 866#p43866


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

Board footer

Powered by FluxBB