Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › 'Compact Mode' Question: Hiding Primary Navigation?
- This topic has 5 replies, 2 voices, and was last updated 5 years, 8 months ago by
Ernest Marcinko.
-
AuthorPosts
-
September 11, 2020 at 6:19 pm #29320
DanHostettler45
ParticipantHey Ernest & team,
As mentioned in the pre-sale question, I love the plugin! I purchased now the Pro version in order to use the “slide-function” in the compact mode.
I implemented the search function into my child theme template, all works great, styling too. No bugs.I do have 2 questions though (CSS, functionality). Please see the full details in the attached PDF.
Thank you!
Best from Prague,
DanSeptember 14, 2020 at 12:34 pm #29338Ernest Marcinko
KeymasterHi,
Thank you for your kind words!
1. The plugin changes the asp-compact attribute on the search from “closed” to “open”. So you can detect if the main container is open with this custom CSS:
.asp_m[asp-compact=open] { /* styles here */ }Although I’m afraid you cannot use this to change parent element styles, as currently as far as I know CSS implementation does not have a parent or custom node selector. I think the only possible solution here is use javascript, to perhaps detect a “click” event on the magnifier icon, and then check on the “asp-compact” value after a timeout, and then set the desired element to invisible.
2. This requires some custom javascript coding, starting off with something like this may help:
jQuery(function($){ $('.proclose').on('mouseup', function(e){ var $e = jQuery(this).closest('.asp_w'); ASP.instances[$e.data('id') + '_' + $e.data('instance')].closeCompact(); }); });September 14, 2020 at 1:04 pm #29340DanHostettler45
ParticipantThanks for the follow-up, Ernesto!
Meanwhile, I have found a (less elegant) JS solution to hide/bring back the primary menu. As you mentioned, no pure CSS solution possible.
For now, my code looks as follows:jQuery(document).ready(function() { $('.promagnifier').on('click', function(){ $('#et-menu').toggle(); }); });To make the UX flow work, I had to disable “Close on document click”, which means the user has to click on the Search icon again to go back to the original state. Yet…
To make this UX logical, the Search SVG should change to an ‘X’ (or similar) once the state changes. For that, I am still looking for a “swap icon” JS within that same div (.innericon). Any idea for a how-to tackle that the last step, swapping the icon?
Thank you!
September 14, 2020 at 4:05 pm #29355Ernest Marcinko
KeymasterWell, that is bit more difficult, but I would probably use the same event as you used for the menu toggle. Probably inject an element next to the magnifier icon, and style it via custom CSS. Then hide the element on the clicks:
jQuery(document).ready(function($) { var open = false; $('.promagnifier').on('click', function(){ $('#et-menu').toggle(); open = !open; $icon = $(this).closest('.asp_w').find('.my-custom-icon'); if ( $icon.length == 0 ) { $(this).after('<div class="my-custom-icon item-hidden"></div>'); } if ( open ) { $(this).closest('.asp_w').find('.promagnifier').addClass('item-hidden'); $icon.removeClass('item-hidden'); } else { $(this).closest('.asp_w').find('.promagnifier').removeClass('item-hidden'); $icon.addClass('item-hidden'); } }); });September 15, 2020 at 7:09 pm #29379DanHostettler45
ParticipantThanks for your efforts & finished snippet, Ernest.
I got hiding & swap work. All good now. Great! Thanks for bearing with me 🙂We can consider this ticket as closed.
Best,
DanSeptember 16, 2020 at 8:38 am #29386Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- The topic ‘'Compact Mode' Question: Hiding Primary Navigation?’ is closed to new replies.