- This topic has 46 replies, 3 voices, and was last updated 4 years, 3 months ago by
Tom.
-
AuthorPosts
-
March 4, 2019 at 11:44 am #828711
David
StaffCustomer SupportWhere did you add the jQuery? I just tried that script in the Dev tools and it works. Let me know
March 4, 2019 at 11:47 am #828717Neil
I added a code snippet to put it in the header of every page. Where should I add it?
add_action( 'wp_head', function () { ?> <script> jQuery('.custom-search-item').on('click', function(e) { jQuery(this).toggleClass("close-search"); jQuery('#dgwt_wcas_ajax_search-2').toggleClass("visible"); e.preventDefault(); }); </script> <?php } );
I’ve checked the page source and it is in there.
March 4, 2019 at 11:52 am #828718David
StaffCustomer SupportPlace in the WP_Foot, as the elements need to have loaded before the script is run.
March 4, 2019 at 12:04 pm #828733Neil
Right, that’s got the cross appearing now but nothing happens with regards to the search box. Re-reading your earlier reply, I need to do something with the visible class on the search box. I’m not sure how to do that, sorry.
March 4, 2019 at 12:16 pm #828738Neil
I’m in a little over my head here :/
Trying to add this functionality to the mobile header and can’t find anything on how to do that.
March 4, 2019 at 1:18 pm #828779David
StaffCustomer SupportOK, so replace all the CSS with this, and make sure the jQuery is in the WP_foot…..
.custom-search-item a:before { content: "\f002"; font-family: GeneratePress; width: 1.28571429em; text-align: center; display: inline-block; margin-left: 10px; } .custom-search-item.close-search a:before { content: "\f00d"; } @media (min-width: 769px) { .custom-search-item { display: none; } } @media (max-width: 768px) { .inside-header .header-widget { display: flex; align-items: center; flex-direction: row-reverse; } .site-header { display: block !important; opacity: 1; padding: 0; z-index: 100; } .site-header .site-logo { display: none; } .inside-header .header-widget { display: flex; align-items: center; } .site-header .inside-header { padding: 0; } .site-header .site-logo { display: none; } .site-header .header-widget { position: absolute; bottom: -100px; left: 50%; transform: translateX(-50%); } #dgwt_wcas_ajax_search-2:not(.visible) { display: none; } }
March 4, 2019 at 1:46 pm #828793Neil
I’m learning lots of new CSS here π
Not quite working though, jquery doesn’t seem to do anything anymore. Also there are some strange things going on with the alignment.
To clarify, I’m putting the jquery in the wp_footer, is that right?
March 4, 2019 at 1:56 pm #828797David
StaffCustomer SupportThats good π
Forgot to add some z-index to the Site Header to move it in front of the navigation
Also noticed i had doubled up on some CSS above, so i have edited and compacted the CSS above.March 4, 2019 at 2:05 pm #828805Neil
Nearly there. This is great, thank-you but just a couple of issues remaining.
We’ve lost the search box when not on mobile.
There’s some funny alignment/ordering things going on when you reduce the screen size.
March 4, 2019 at 3:43 pm #828856David
StaffCustomer SupportI made a tweak on the code above so it appears on desktop. The issue on small screens is there is not enough room for it so it overlaps the cart icon…. so need to free up some room. Is the “Menu” label necessary on the mobile menu?
March 5, 2019 at 6:13 am #829359Neil
Hi David, thanks so much for your efforts on this. I’m having to spend the day on something else but hopefully will be back on this soon.
I’ve updated the code on the server so you can see what it looks like. The place I’m trying to get to is so that it mimics how the search function in GP works on mobile.
Here’s a screenshot of how it looks on one of my other projects.
You see how the search box fills the whole width of the screen and is shown above what is currently in the header.
March 5, 2019 at 6:31 am #829374David
StaffCustomer SupportTricky one. Does that Search Widget come with a shortcode? As it may be best we hook it into the header. Otherwise its gonna be impossible to size and fix its positioned for the sticky mobile header. Let me know.
March 5, 2019 at 6:35 am #829379Neil
Yep, it sure does –
[wcas-search-form]
I do have a child theme if it’s going to be easier to overwrite some of the base GP functionality rather than trying to achieve everything in CSS.
March 5, 2019 at 6:41 am #829384David
StaffCustomer Supportwish i had asked that earlier lol
SO if you can create a GP Hook Element:https://docs.generatepress.com/article/hooks-element-overview/
Add the short code in there. Select the
inside_mobile_header
hook. Check the Execute Shortcodes. And Set the display rules to the entire site….. it will look a complete mess but ill have a look when i get a minute.March 5, 2019 at 6:44 am #829386Neil
π
I’ll take a look a bit later on this evening. I’ve got something else I need to get finished first.
I will definitely owe you a coffee/beer after we get this sorted!
-
AuthorPosts
- You must be logged in to reply to this topic.