I was asked to rig DHTML menu so that any open menu items would close when another menu item was opened, so that only one menu item can be open at a time. From what I have read, this is an option in the 6.x version, and I thought I would post my code here in case anyone wanted this facility in 5.x
I added the following to dhtml_menu.js, line 53, in the switchMenu function:
var siblings = $(parent).parent().find('li.expanded');
$(siblings).find('div.sub-expanded').animate({height: 'hide', opacity: 'hide'}, '500');
$(siblings).find('div.sub-expanded').removeClass('sub-expanded').addClass('sub-collapsed');
$(siblings).removeClass('expanded').addClass('collapsed');
I haven't done extensive testing, but it seems to work fine, so far.
Comments
Comment #1
fpedraza commentedThat's exactly what I was trying to do. Wonderful.
Thank you!
It works perfectly for me with drupal 5.14.
Comment #2
davedg629 commentedCan you show exactly where you put this code? That would help a lot because I put it in on line 53 and it didn't have any effect. I'm sure if I knew anything about javascript I could figure it out, but I don't.
Comment #3
fpedraza commentedThis works only if you have effects ON.
Comment #4
goldThis behavior is exactly what I've been looking for for a while now. L0rne, your JS skills are superior to mine. :) I'd pretty much given up on trying to get this to work.
I really need this functionality added to the module. The deployment environment we use uses subversion and we can only checkin modules from contrib.
To this end I've created a new JS file with this code included (attached) and added a checkbox to the Admin DHTML Menu form that allows the user to select it. The patch file will add this.
If people could review this it would be appreciated.
Comment #5
cburschkaPlease make this feature upward compatible with D6 by using the same system variable and/or providing an upgrade path that copies the variable over. People who upgrade their site from D5 to D6 will expect the option to remain enabled. :)
Also: All changes (including the ones to JS) must be provided in patch form. One patch file is preferable (use
cvs diff -upto generate a patch from your local version against the CVS branch), but if you can't use CVS you can also diff each file separately.Comment #6
vuilI close the issue as Closed (outdated).