Please Note:
HierMenus is protected by copyright laws. Use of the HierMenus code requires a paid licensing agreement.
Click Here to Register

Site Navigation
Bulletins
About
Documentation
FAQ
Samples
Known Issues
Technology Jobs

internet.commerce

Partner With Us














          
internet.com

IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

 
HierMenusCentral Enhance the Functionality of Your Web Site with DHTML HierMenus.
    

home / bulletins / 11

When TLC Isn't Enough

D.M Ragle, December 11, 2003

[The function described in this article was originally designed as an add on tool for HierMenus version 5. A version of the function is automatically included (and therefore immediately available) in the HierMenus version 6 HM_Loader.js file. The version supplied in the version 6 loader file is used in the same manner as the version described here. Note that in the version 6 codeset the function is called HM_f_GetMenuDimension. -Ed.]

A little used but powerful feature of HierMenus arrays allows for the X/Y coordinates of any top level menu (i.e,. the Top Left Corner of the menu) to be specified as JavaScript expressions. These expressions are then dynamically evaluated by HM each time the menu is displayed. Using your own custom function defitions, you can place top level menus on your Web page based on some other element of the page, such as dynamically created objects generated via your own JavaScript code. This "coordinates-as-expressions" functionality was originally introduced with the release of HierMenus 4.0; and later enhanced (in 4.0.10) to recognize the current mouse position in the expressions via the mouse_x_position and mouse_y_position keywords.

A common question asked by HM implementors is how to position the menus based not on the TLC of the menu, but instead based on one of the other coordinates. For example, in designs that pop up menus from the lower portion of the screen, the bottom left corner might be more appropriate. And for designs that pop up menus from the right edge of the screen (common in pages where right-to-left directionality is employed, see Bulletin 9 for more HM-specific information), top right corner positioning is called for. Though HM does not directly support such positioning schemes, using the coordinates-as-expressions feature described above in combination with a small amount of custom code that we will provide in this article will allow you to provide coordinates relative to the menu corner most appropriate for your specific design.

Which Corner is Which?

As mentioned above, top level menus in HierMenus can be positioned using either integers or JavaScript expressions that return integers representing the top left corner of the menu (each coordinate can be retrieved via a separate function). For permanently displayed menus, such coordinates are a required element of your menu configurations. For pop up menus they are optional, as all top-level pop up menus assume the current location of the mouse for the position of the top left corner of the menu. Since the current mouse position can also be referenced within JavaScript expressions (as of HM 4.0.10), this means that the following two menu configurations will behave identically:

HM_Array1 = [
[120,      // menu width
,          // left_position
],         // top_position
["Experts","/experts/",1,0,0],
["Contents","/index2.html",1,0,0]
]

HM_Array2 = [
[120,                 // menu width
"mouse_x_position",   // left_position
"mouse_y_position"],  // top_position
["Experts","/experts/",1,0,0],
["Contents","/index2.html",1,0,0]
]

While HierMenus recognizes only TLC based menu positioning, you can use custom JavaScript expressions to make those top left coordinates relative to other information on the page. Simple geometry dictates that, in order to position menus based on a different corner of the menu, we require only the width and/or height of the menu itself. Our JavaScript expressions can then place the TLC of a top level menu relative to those computed coordinates. Or, in other words:

Box Geometry, adding height or width to TLC gives coordinates of other box corners

This is all basic stuff, and most folks who ask the coordinate positioning question stated above already understand this. What they lack, however, is the code they could use in their own JavaScript expressions to determine the width and/or height of a menu. That's the main topic on the next page.

current pageTo Page 2
[next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

Created: 3/25/2004
Updated: 3/25/2004
URL: http://www.hiermenuscentral.com/bulletins/11/