V5 Hiding/Showing Menues Manually

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
gporterfield
Advanced
Advanced
Posts: 15
Joined: Thu Jun 12, 2003 1:58 pm
Contact:

V5 Hiding/Showing Menues Manually

Post by gporterfield »

The following code for version 3 was posted elsewhere in this forum (#7095).

Code: Select all

function mm_showMenu(menuName) // + , alwaysVis) 
{ 
  var menuNum = getMenuByName(menuName); 
  if (arguments.length > 1) { 
    var menuArr = eval("menu" + menuNum); 
    menuArr[7] = arguments[1]; 
  } 
  SDiv("menu" + menuNum, 1); 
}


Will this also work for version 5? Or is there a different way to do this in version 5? I am primarily interested in being able to turn on/off the "alwaysvisible" attribute when showing (popup?) or hiding (popdn?) a sub-menu in a fixed location.

TIA,
George
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Nothing has been found yet. But its something I would like to put together, much like Kevin did. If someone beats me to it, more power to them. But I am gonna play around with it in the mean time.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi All,

My this seems to have been a busy forum of late! Looks like I've been missing a lot of fun. Haven't had much time these days for menu tinkering. I probably shouldn't admit it, but I'm still using v3 and am just now getting the chance to really play with v5 ( :oops: don't scold me John!). I've just been reading the latest posts to try to learn more about actually using v5... IMHO this forum is still the best learning resource, with so many people helping out, especially guys like John and Dave (thanks guys).

Anyway, I came across this thread and figured that, since v5 still has essentially the same built-in gmobj() and getMenuByName() functions that I co-opted for doing stuff like this in v3, a similar solution might present itself for v5. So I figured this might be a good place to get my v5 "tinkering" feet wet. (I hope you don't mind me jumping in Dave). v5 no longer has an SDiv() function, so the approach is a little different, but only a little, from the v3 function earlier in this thread. Fortunately, the menu object styles in v5 seem to be a lot more accessible (at least to me). Anyway, it's late and I'm rambling... so here it is:

Code: Select all

function mm5_setMenuVisibility(menuName, visState)
{
  menuObj = gmobj("menu" + getMenuByName(menuName));
  if(ns4) {
    menuObj.visibility = visState ? "show" : "hide";
  }
  else {
    menuObj.style.visibility = visState ? "visible" : "hidden";
  }
}
mm5_setMenuVisibility() takes two parameters: menuName is the name of the menu you want to hide or show, passed as a string. visState specifies the state of the menu style's visibility attribute: pass a 1 to show the menu or a 0 to hide it (true or false, respectively, will also work if you prefer). So, to hide a menu named "mainmenu", you'd call:

Code: Select all

mm5_setMenuVisibility('mainmenu', 0)
To show it again, you'd call:

Code: Select all

mm5_setMenuVisibility('mainmenu', 1)
George... I did a quicky test and it worked in IE6, NS7, and Opera 6.05 in Windows. The conditional should, in theory, allow it to work in NS4, but it'd be wise to test first, if you care about NS4, because I didn't (and I don't!).

Hope that helps. Cheers all. Hope to be back soon.

Kevin
gporterfield
Advanced
Advanced
Posts: 15
Joined: Thu Jun 12, 2003 1:58 pm
Contact:

Manually Hiding/Showing in V5

Post by gporterfield »

Kevin:

Have not had a chance to test your suggestion in NS4 yet, but will do so tonight. However, what I REALLY need is to be able to control the ALWAYSVISIBLE attribute through my code. I am trying to keep these menus from disappearing after an item is clicked.

George
gporterfield
Advanced
Advanced
Posts: 15
Joined: Thu Jun 12, 2003 1:58 pm
Contact:

NS4 Test

Post by gporterfield »

Quick test results from NS4 look good. Will check in more detail later.

George
Post Reply