POPUP/POPDOWN

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

POPUP/POPDOWN

Post by dhaack »

Have two minor problems

1) Cannot get overflow="scroll" working with popup or displayMenu
Works fine with showmenu

2) If I have a large submenu that uses popup, then when mouseover closes properly. But actually justs hides, and does not reset mouse control under popup. (Example href link under popup cannot access until reset by going to main menu)

Again if called from showmenu, mouseover close resets mouse control properly

Any suggestions would be helpful

Thanks Dave
User avatar
Ruth
 Team
 Team
Posts: 8763
Joined: Thu May 15, 2003 5:02 am
Location: Yucaipa, CA
Contact:

Post by Ruth »

A url would be the most helpful thing in order to see what's going on. I just put a long long submenu into a pop menu and set it to overflow="scroll" it seemed to work OK. So, browser where the problem occurs, OS and a test page would be the most helpful so we can see what's happening. I'm not sure I understand what you're saying is going wrong.

Ruth
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

URL

Post by dhaack »

Cannot give out url, system in an accounting database system.

Key is pop menu is a submenu without left/top set, but location based on parent. System uses allBuildMenu and spos to set the pos of menu on return to set location.

System automatically opens submenu on load.

Here is function that gets pos from cookie, sets spos and calls popup

Thanks Dave

function getcookiemenu(mainmenu) {
var cookie = getcookie(mainmenu);
c1 = cookie.indexOf(",",0);
c2 = cookie.indexOf(",",c1+1);
c3 = cookie.indexOf(",",c2+1);
c4 = cookie.indexOf(",",c3+1);
menuinfo = cookie.substr(0,c1);
toppos = cookie.substr(c1+1,c2-c1-1);
leftpos = cookie.substr(c2+1,c3-c2-1);
heightpos = cookie.substr(c3+1,c4-c3-1);
widthpos = cookie.substr(c4+1,cookie.length);
if (toppos != "")
{
menuNumber = getMenuByName(menuinfo);
spos(gmobj("menu" + menuNumber),toppos,leftpos,null,null);
popup(menuinfo);
}
return
}
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Have you tried the popi(itemnumber) function.

The only parameter you need for this is the item number for the parent item.

This will only work though if you have a main menu.

-- Andy
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

popi problem

Post by dhaack »

I do always have main menu displayed.

I can get itemnumber by using following function; but try to call popi(item#) and get errmsg saying object expected.

Do alert and do get an item number after calling following function

function mm_getItemByName(itemName)
{
for (i=0; i<_mi.length; i++) if (_mi[1].indexOf(itemName) != -1) return i;
return -1;
}

are you sure it is popi()? Maybe different spelling. am I missing something? Is popi function something I have to load

Thanks for the help

Dave
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

sorry the format is _popi(Int);

All menu items are numbered 0 to whatever - There are techniques that you can use to get the appropriate item number but let me know if it works for you first using hard coded values.

If it does, we can address the issue of returning the correct item number.

-- Andy
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

_popi

Post by dhaack »

no error message this time; but no submenus poping up.

Calling routine onload. Tried 0,1,2,5 for values.

Do I need to set the spos? keepalive? etc; I assumed system would figure out from parent.

Dave
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

test with popi

Post by dhaack »

I did some testing, and _popi does work if call after page is loaded; but when try to run calling onload does not.

Seems that even though onload is called, the routine wants to load before the main menu.

Any way to get routine to run after main menus are opened

Thanks for help Dave
User avatar
Andy
Milonic
Milonic
Posts: 3308
Joined: Sun May 19, 2002 8:23 pm
Location: Menu Developer
Contact:

Post by Andy »

Is this any help?

http://milonic.com/openmenusbyurl.js

it opens the menus based on the current url.

-- Andy
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

openmenusbyurl.js

Post by dhaack »

Tried, but no luck. No menus display except main menu.

I called routine after drawmenus() call; even tried before just in case. I assume problem is same as my problem. You are calling popi routine and it is being run before menus are drawn.

I put an alert 1st line in _ocURL() function to see if called after draw menus;

ocURL() is called 5 times; and 3-4 are called before main menu displays

Hope this helps you isolate problem

I assume we are close; mine is working well except for the scroll and url items after closed

Is there anyway to test that main menus are drawn before calling our routines?

Thanks for all your support; I am getting good responses from my clients

Dave
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Re: openmenusbyurl.js

Post by kevin3442 »

Hi Dave,
dhaack wrote:...Is there anyway to test that main menus are drawn before calling our routines?...
I have some functions that may help. You could put the following code at the top of you your menu_data.js file:

Code: Select all

var runWhenOpenedTimer = 0;

function mm_isOpen(menuName)
{
  menuObj = gmobj("menu" + getMenuByName(menuName));
  if (ns4) {
    return (menuObj.visibility == "show");
  }
  else {
    return (menuObj.style.visibility != "hidden");
  }
}

function mm_runWhenOpened(menuName, functionToRun)
{
  var checkInterval = 100;  //msec
  var funcStr = "mm_runWhenOpened("" + menuName + "", " + """ + functionToRun + "")";

  if (! mm_isOpen(menuName)) {
    runWhenOpenedTimer = setTimeout(funcStr, checkInterval);
  }
  else {
    clearTimeout(runWhenOpenedTimer);
    runWhenOpenedTimer = setTimeout(functionToRun, 0);
  }
}

function testFunction(menuName)
{
  alert("I'm now doing whatever with the menu named: " + menuName);
}
mm_isOpen(menuName) is a function that checks to see if a menu is open. It takes one parameter, menuName, which is the name of the menu to check. e.g., mm_isOpen("Main Menu") will return true if the menu named "Main Menu" is open, false if not.

mm_runWhenOpened(menuName, functionToRun) is a recursive function that will check to see if a named menu is open, and after the named menu is open will run a specified function. The mm_runWhenOpened() takes two parameters. menuName is the name of the menu to wait for (wait until it's opened) and functionToRun is the function that you want to run once the named menu is open. funcitonToRun must be a string expression, with any passed parameters specified literally. If you want to include variable in the parameters to pass, then build functionToRun as a separate string before passing it to mm_runWhenOpened().

In the above code, there's an example function called testFunction() that you would replace with your own function (i.e., whatever you want to run after the main menu appears).

So, suppose my main menu is named "Main Menu". Once "Main Menu" is open, I want to run testFunction() and pass it the name of a sub menu called "Products Submenu". At the bottom of my menu_data.js, after the call to drawMenus(), I would put:

Code: Select all

// first derive the name of the sub menu however you need to
var subMenuName = "Products Submenu";

// now build the function string to pass
var functionString = "testFunction('" + subMenuName + "')";

// start the waiting...
mm_runWhenOpened("Main Menu", functionString);
With my testFunction(), after the main menu appears, an alert pops up with the text, "I'm now doing whatever with the menu named: Products Submenu". You would, of course, substitute your own function (get cookies, pop a menu, etc.).

Hope that helps,

Kevin
dhaack
Advanced
Advanced
Posts: 15
Joined: Thu Aug 05, 2004 8:01 am
Location: Chicago, US

run function on open routines

Post by dhaack »

Works perfectly; now I can use popi which handles scroll and href under menus properly.

Thanks for all your help

Dave
Post Reply