Closed (outdated)
Project:
Nice Menus
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
5 Apr 2009 at 07:11 UTC
Updated:
2 May 2024 at 08:06 UTC
Jump to comment: Most recent
Comments
Comment #1
mariusooms commentedThis is what I'm adding currently in my own js file and it seems to work, but I wonder if there is a better way and if this should be by default for horizontal children? Also my javascripting is very noobiesh, so I'm positive this code could probably be rewritten to two lines :)
Comment #2
jenpasch commentedDid you add the above .js to the nice_menus.js? Would you mind explaining what you did? This indeed seems like a very useful feature for the downdown/horizontal menu style.
many thanks!
jen
Comment #3
mariusooms commentedHi Jen,
Though not perfect it works for me somewhat. I have a theme javascript file with all my jquery functions. E.g. you can just create a global.js file in your theme folder and add it through your info file:
scripts[] = global.js
This loads the javascript file in your header.
As far as the code goes, this is my current code:
I'm terrible at explaining this behavior. This article, http://www.learningjquery.com/2007/03/accordion-madness , should help you understand the basic jquery to show and hide behavior of menus.
As I said, it is not perfect, but it kinda works. Sometime the mouseevent is not binded properly when hovering in and out multiple times within the 800ms period.
I hope this vagly helps,
Marius
Comment #4
jenpasch commentedThanks ever so much. Did you get the "active-trail" class through "Menu Trails" or hacking nice menus?
Comment #5
mariusooms commentedIt is part of the suckerfish code which is included in the 6.x-2.x-dev branch.
Comment #6
add1sun commentedFor this to get into NM we need an actual patch that can be applied to the nice_menus.js file.
Comment #7
aubjr_drupal commentedI used the code above in comment #3 in a site I built with Nice Menus and a secondary horizontal menu and for the most part it worked great. However, I came across a small bug. The secondary menu was not restored if I moused out of the ul.nice-menu (the primary menu in this case) from the li.active-trail element. The secondary menu, which is set to visibility:visible and display: block when you mouse over li.active-trail (as it should be), disappeared upon mouseout/mouseleave.
The visibility and display CSS value attached to $active appears to toggled back to hidden/none in suckerfish.js (in the Nice Menus module's js directory), line 104-105.
I don't have a solution yet, but I'm looking for one. I can set the delay higher than 600 and hope that the scripts fire in the order that allows it to reappear right after it's hidden by suckerfish.js, but it's not ideal.
Comment #8
Jonasvh commentedJust do it with CSS
You must only override the elemen.style.
See example of my css
#block-nice-menus-1 .active-trail ul {
display: block !important;
visibility: visible !important;
}
Comment #9
leozzz commentedi found a simply solution.
jQuery('ul.nice-menu li.active-trail').unbind();
add it to nice_menu.js
just unbind the active-trail, then the hover/mouseleave bugs will not happen again
final:
jQuery(document).ready(function() {
// Set active-trail visible on page load
// This only sets the secondary list of the active trail to visible
jQuery('ul.nice-menu li.active-trail ul').show();
jQuery('ul.nice-menu li.active-trail ul').css('visibility', 'visible');
// Bind the menu to mouseleave to set active-trail visible when done navigating
// Suckerfish will hide all secondary lists for you when hovering the main menu
// So we want to repeat the initial behavior when done navigating
jQuery('ul.nice-menu li.active-trail').unbind('mouseout');
jQuery('ul.nice-menu').bind("mouseleave", function(){
var jQueryactive = jQuery('ul.nice-menu li.active-trail ul');
// Set the timer to the value specified in the admin settings
// This prevents overlap of the secondary menu items
// The trick to make it work is that we set the active trail to visible inside the function
jQueryactive.animate({ opacity: 1.0 }, 10, function() {
jQuery('ul.nice-menu li.active-trail ul').css('visibility', 'visible');
jQuery('ul.nice-menu li.active-trail ul').show();
});
});
});
Comment #10
johnnydarkko commentedI implemented #9, but I was having an issue with the drop-down menu text overlapping because the active-trail menu would animate immediately animate back if the mouse ever leaves the ul. I used the trick from http://stackoverflow.com/questions/1273566/how-do-i-check-if-the-mouse-i... to add a delay. Hope this helps!
Comment #11
astonvictor commentedI'm closing it because the issue was created a long time ago without any further steps.
if you still need it then raise a new one.
thanks