...

View Full Version : Removing toggle property of search box



dsrussell
11-15-2010, 07:59 PM
Hello,

I'm a complete noobie to JavaScript so my apologies in advance if I'm asking something totally stupid.

I'm trying to get a website up and running using WordPress. A particular plug-in for WP makes the site I'm building mobile-phone etc friendly - and I have a question regarding some JS that is part of the plug-in.

Before people think badly of me, the licensing terms of the plug-in allow users to modify the code, but the suppliers will not respond for requests for help in doing so. I'm therefore having to see whether I can figure out how to do this myself.

If I've understood correctly, the extract of code below will show/hide a search box when the user clicks on the search button on the menu page. However, I would like the search box to always be visible when the user visits the menu page (but not on any other pages).

With the extract provided, could anybody tell me please, how to change the code to keep the search box permanently visible? :confused:

With many thanks in advance
Darren

PS I've only selected what I think are the important lines of code - hope I've included enough ....


var touchJS = jQuery.noConflict();

/* Toggling the search bar from within the menu */
touchJS( 'a#tab-search' ).unbind( 'click' ).click( function() {

touchJS( '#search-bar' ).toggleClass( 'show-search' );
touchJS( this ).toggleClass( 'search-toggle-open' );

if ( touchJS( '#search-bar' ).hasClass( 'show-search' ) ) {
touchJS( 'input#search-input' ).focus();
} else{
touchJS( 'input#search-input' ).blur();
}
return false;
});

Old Pedant
11-15-2010, 08:32 PM
Well, we have to *guess* what the meaning of some of that is, but I would certainly guess that the culprit are these lines:


touchJS( '#search-bar' ).toggleClass( 'show-search' );
touchJS( this ).toggleClass( 'search-toggle-open' );

Seems to clealy be saying it is toggling the class of the objects. So try commenting out those lines and see if the toggle effect doesn't go away.

dsrussell
11-15-2010, 10:04 PM
Many thanks, OP!

I really appreciate your suggestion - which I tried, but I'm afraid it didn't work. All it did was to disable the button, so that when you click on it, the search bar stays hidden.

Being new to JS, I didn't know whether it was "standard" code that would therefore be quite easy to change.

I'll do so more investigating to see if there's anything else that might need changing.

Thank you, however, for your help
Darren



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum