NlsMenu Pro
addobject.com
References
NlsMenu Professional - Advanced Javascript Drop Down Menu Control
   
  1. NlsMenuManager
  2. NlsMenu
  3. XML Functions
  4. NlsMenubar
  5. NlsMenuItem
  6. Public Functions

1. NlsMenuManager

Below are all public properties and function available in menu manager. Properties in menu manager applied to all menus created by the menu manager.

NameTypeDescription
timeout Property Menu timeout, times in millisecond the submenu remains visible when mouse moves out from the menu.
flowOverFormElement Property
  • If the value is true, the menu will flow over form's element (<select>) and ActiveX object.
  • If false, the form's element will be hidden. This property will be ignored in IE 5.0 and the form's element will be hidden.
defaultEffect Property Default effect applies to all menus managed by the menu manager. Refer to NlsMenu Effect for more information about configuring menu effect.
memorizeSel Property True to enable selection path.
icPath Property Icon path. Is specified, the menu script will search for the menu item icon and submenu pointer icon in the specified path.
menuDelay Property Specify menu delay time in millisecond. When specified, menu will displayed after the amount of times ellapsed.
createMenu(mId) Function

Create a menu (submenu).

Arguments:
  • mId is the menu id, cannot contains underscore ("_") character and space.
Returns: NlsMenu object
createMenubar(mbarId) Function Create a menubar.

Arguments:
  • mbarId is the menubar id, cannot contains underscore ("_") character and space.
Returns: NlsMenubar object
renderMenus(elmId) Function Render all menus created by the menu manager. If elmId is specified, the menus will be rendered in the specified element.

Note that since version 3.0, renderMenubar() automatically renders submenus and therefore, there is no need to explicitly call renderMenus() to render submenus as in previous version. The renderMenus() function is used on special menu only such as context or popup menu which doesn't have menubar.
renderMenubar(elmId, incSub) Function

Render menubar created by the menu manager.

Arguments:
  • elmId, If elmId is specified, menu will be rendered in the specified element.
  • incSub, If omitted or true, submenus will be rendered. If false, submenus will not be rendered and "render on demand" is activated if there is not explicit call to renderMenus();
hideMenus() Function Hide all menus created by the menu manager.
addAssocMenuMgr(frm, mgrId) Function Add associate menu manager in cross frame menu.
Arguments:
  • frm is the associate frame object.
  • mgrId is the associate menu manager in the associate frame.
getMenu(mId) Function

Get a menu by menu id.

Arguments:
  • mId is the menu id, cannot contains underscore ("_") character and space.
Returns: NlsMenu object
selectPath(mId, itemId) Function

Highlight path to the specified menu item.

Arguments:
  • mId is the menu id.
  • itemId is the menu item id.
unselectPath(mId, itemId) Function Unselect the path.
loadMenuFromHTML(elmId, incMbar, renderMenu, opts) Function

Creates menu structure from HTML (UL/LI).

Arguments:
  • elmId, this is an id of element in which the menu structure is defined. This element can be DIV or SPAN
  • incMbar, if true, the first UL element will be the menubar. If this parameter is false, the menu doesn't have menubar for example when you creating context menu/popup menu
  • renderMenu, if true, menu will be generated and rendered in the element which the id specified in first parameter.
  • opts, menu and item property in JSON text. This argument is optional.


2. NlsMenu

Below are all public properties and function available in menu object.

NameTypeDescription
mId Property Menu Id, cannot contains underscore ("_") character and space.
absWidth Property Absolute width of the menu
orient Property Menu orientation, "V" for vertical and "H" for horizontal.
subMenuIc Property Array of submenu pointer icon, format: ['normal icon', 'mouseover icon'].
target Property Target window when a menu item is clicked, if not specify, the target is current window.
stlprf Property Style prefix. If this value is specified, style rules with the prefix in stylesheet will be applied to the menu.
showIcon Property true to show menu item icon.
showSubIcon Property true to show submenu pointer icon.
icPath Property Icon path. Is specified, the menu script will search for the menu item icon and submenu pointer icon in the specified path. This property override the icPath in menu manager.
itemSpc Property Specifies space between menu item for example menu.itemSpc="2px";
selection Property If true, the selected item in the menu will be highlighted.
defItmEff Property Item effect (IE only). Menu item effect when mouse move over a menu item.
maxHeight Property Specify submenu maximum height. If the height is exceeded, vertical scrollbar will be displayed.
scrollType Property Specify vertical scroll type, 1 is default system scrollbar, 2 for custom scroll.
dropShadow(pos, offset) function

Enable menu shadow

Arguments:
  • pos, shadow position. Possible value:
    • none, no shadow
    • bottomright (default), display shadow at bottom right.
    • bottomleft, display shadow at bottom left.
    • topleft, display shadow at top left.
    • topright, display shadow at top right.
  • offset, shadow distance for example "5px".
applyBorder(bTop, bBottom, bLeft, bRight) function

Enable advanced menu borders.

Arguments:
  • bTop, true to enable top border
  • bBottom, true to enable bottom border
  • bLeft, true to enable left border
  • bRight, true to enable right border
addItem(key, capt, url, ico, enb, xtra, subId, title) Function

Add menu item to the menu.

Arguments:
  • key, menu item id, cannot contains underscore ("_") character and space.
  • capt, menu item caption/text
  • url, url/address when the menu is clicked
  • ico, array array menu item icon, ["normal icon", "on over icon", "disabled icon"]
  • enb, menu item state, true for enable, false for disable.
  • xtra, Extra property, no used by menu, provided for custom. You can store menu item data in this property as object or string or other type
  • subId, submenu id, the submenu will be displayed when mouse over this item.
  • title, tooltips displayed when mouse hover on menu item.
Returns: NlsMenuItem object.
addSubmenu(key, subId, crsFrame, subFrame, subPos, subPosAdj, subDir) Function

Add submenu to a menu item.

Arguments:
  • key, menu item id, cannot contains underscore ("_") character and space.
  • subId, submenu id, the submenu will be displayed when mouse move over this item.
  • crsFrame, true if the the submenu is in another frame
  • subFrame, specify the frame name where the submenu is created/rendered, if the submenu is located in the same frame as the menu item, set it to null. This property takes effect only if crsFrame=true.
  • subPos, submenu position. Array of submenu position, ["X position", "Y position"]. Use special value "REL" if you want the position of X or Y calculated based on menu item position.
    For example:
    -[5,5], display submenu at (x,y)=5,5.
    -["REL", 5] display menu at x calculated based on menu item position and y at 5.
    This property takes effect only if crsFrame=true
  • subPosAdj, submenu position adjustment, ["x adjustment", "y adjustment"]
  • subDir, submenu direction, possible value ["right", "down"], ["right", "up"], ["left", "down"], ["left", "up"]
addSeparator(separator) Function

Create menu item separator.

Arguments:
  • separator, Specify null for default separator, or custom NlsMenuSeparator object for custom separator.
addCustomMenu(custom) Function

Create custom menu.

Arguments:
  • custom, any html string.
setItemStyle(key, stlprf) Function

Set individual item style.

Arguments:
  • key, menu item id.
  • stlprf, style prefix.
setItemText(key, text) Function

Set menu item text/caption.

Arguments:
  • key, menu item id.
  • text, item text.
enableItem(key, b) Function Enable or disable menu item.
Arguments:
  • key, menu item id.
  • b, boolean value, true for enable, false for disable.
useEffect(effect) Function

Specify the menu effect.

Arguments:
  • effet, effect name.
renderMenu() Function Render the menu.
showMenu(x1, y1, x2, y2, mnOrient, subDir, subAdj) Function

Show submenu.

Arguments:
  • x1, X position of top left coordinate of menu item.
  • y1, Y position of top left coordinate of menu item.
  • x2, X position of bottom right coordinate of menu item.
  • y2, Y position of bottom right coordinate of menu item.
  • mnOrient, parent menu orientation.
  • subDir, submenu direction, possible value ["right", "down"], ["right", "up"], ["left", "down"], ["left", "up"].
  • subAdj, submenu position adjustment, ["x adjustment", "y adjustment"].
showMenuAbs(x, y) Function Show submenu at x, y position
hideMenu() Function Hide the menu
hasSubmenu(key) Function

Check if the menu item has submenu.

Arguments:
  • key, menu item id.
Returns: true if the menu has submenu, otherwise false.
getItemById(key) Function

Get menu item by item id.

Arguments:
  • key, menu item id.
Returns: NlsMenuItem object.
setProperties(opts) Function

Set menu properties with JSON text.

Arguments:
  • opts, menu properties object.
    Format:
    
      {
        menuid_1: { property_1:value, property_2:value,..., property_n:value,
                    items:{
                    itemid_1:{itemproperty_1:value, itemproperty_2:value, ...},
                    itemid_2:{itemproperty_1:value, itemproperty_2:value, ...},
                    itemid_n:{itemproperty_1:value, itemproperty_2:value, ...},
                    }
        },
    
        menuid_2: {same as menuid_1
        },
    
        menuid_3: {same as menuid_1
        },
    
        menuid_n: {same as menuid_1
        }
    
      }
      
Returns: none object.
setItemProperties(itemId, opts) Function

Set menu item properties with JSON text.

Arguments:
  • itemId, Menu item id
  • opts, item properties object.
    Format:
        { itemproperties_1:value, itemproperties_2:value,... itemproperties_n:value }
      
menuOnClick(menuId, itemId) Event Fires when a menu item is clicked. The event handler will receive menuId and itemId of clicked menu item.
menuOnShow(menuId) Event Fires when a menu is about to be displayed. The event handler will receive menuId parameter.
menuOnHide(menuId) Event Fires when a menu is hidden. The event handler will receive menuId parameter.


NlsMenu Dynamic Functions

Dynamic functions are function available at runtime only. All this function are defined in nlsmenuext_dyn.js.

NameTypeDescription
reload() Function

Re-render the menu.

Arguments:
  • dontHide, boolean, if true, re-render the menu without hiding the menu, otherwise re-render after the menu is hidden. This option is useful when you need to re-render the menu while it is displayed.
setItemVisible(key, v) Function

Set visibility of an item.

Arguments:
  • key, menu item id.
  • v, false to hide the menu item.
addToggleItem(key, grp, capt, url, ico, enb, xtra, title) Function

Add toggle item.

Arguments:
  • key, menu item id, cannot contains underscore ("_") character and space.
  • grp, toggle item group. Specify null if the item is individual toggle item.
  • capt, menu item caption/text
  • url, url/address when the menu is clicked
  • ico, array array menu item icon, ["normal icon", "on over icon", "disabled icon"]
  • enb, menu item state, true for enable, false for disable.
  • xtra, Extra property, no used by menu, provided for custom. You can store menu item data in this property as object or string or other type
  • subId, submenu id, the submenu will be displayed when mouse over this item.
  • title, tooltips displayed when mouse hover on menu item.
deleteItem(key) Function

Delete the menu item.

Arguments:
  • key, menu item id.
setItemState(key, s) Function

Set menu item state (normal or selected). This function only works for toggle item

Arguments:
  • key, menu item id.
  • v, false to hide the menu item.


NlsMenu XML Functions

Function below are defined in nlsmenuext_xml.js. These functions are member of NlsMenu object.

NameTypeDescription
addAJAXSubmenu(key, subId, url, crsFrame, subFrame, subPos, subPosAdj, subDir) Function

Add load on demand submenu (AJAX submenu).

Arguments:
  • key, menu item id, cannot contains underscore ("_") character and space.
  • subId, submenu id, the submenu will be displayed when mouse move over this item.
  • url, url or xml file to load the submenu.
  • crsFrame, true if the the submenu is in another frame
  • subFrame, specify the frame name where the submenu is created/rendered, if the submenu is located in the same frame as the menu item, set it to null. This property takes effect only if crsFrame=true.
  • subPos, submenu position. Array of submenu position, ["X position", "Y position"]. Use special value "REL" if you want the position of X or Y calculated based on menu item position.
    For example:
    -[5,5], display submenu at (x,y)=5,5.
    -["REL", 5] display menu at x calculated based on menu item position and y at 5.
    This property takes effect only if crsFrame=true
  • subPosAdj, submenu position adjustment, ["x adjustment", "y adjustment"]
  • subDir, submenu direction, possible value ["right", "down"], ["right", "up"], ["left", "down"], ["left", "up"]
setSubmenuUrl(key, url) Function

Set the AJAX menu url. You can use standard addSubmenu() function to add submenu and then use this function to set the submenu url.

Arguments:
  • key, menu item id.
  • v, the url to load the submenu. It can be XML file name.


3. XML Functions

Functions below are defined in nlsmenuext_xml.js.

NameTypeDescription
NlsMenuUtil.createFromXML(xmlDoc) Property

Create menu from xml document object.

Arguments:
  • xml, the xml document object.
Returns: NlsMenuManager object.
NlsMenuUtil.createFromXMLString(sXml) Function

Create menu from xml string.

Arguments:
  • sXml, the xml string.
Returns: NlsMenuManager object.
NlsMenuUtil.createFromXMLFile(fName) Function

Create menu from xml file. This function is only supported in IE and Firefox.

Arguments:
  • fName, the xml file name.
Returns: NlsMenuManager object.
NlsMenuUtil.loadFromXMLFile(fName, mCnt) Function

Loads (and render) menu from xml file.

Arguments:
  • fName, the xml file name.
  • mCnd, the id of html element where the menu bar will be rendered. See "Loading Menu from XML" for more detail.
Returns: nothing.


4. NlsMenubar

Menubar has all properties/functions of NlsMenu with some additional properties.

NameTypeDescription
dropOnClick Property true to activate drop down on click feature.
renderMenubar Function Render the menubar.


5. NlsMenuItem

Below are public properties/functions available in menu item:

NameTypeDescription
id Property Menu item id, cannot contains underscore ("_") character and space.
capt Property Menu item caption/text.
url Property URL or link address.
target Property Target window when menu clicked.
ico Property Array of menu item's icons, format: ["normal icon", "mouse over icon", "disabled icon"].
enable Property true indicates the menu item is enabled, false for disabled.
xtra Property Extra placeholder for custom data.
subMenuId Property Submenu id.
crsFrame Property true if the submenu is located in another frame.
subFrame Property The frame object where the submenu is located. If the value is null, the sub menu is in the same frame as menu item.
subPos Property Array of submenu position, format: ["X position", "Y position"]. Use special value "REL" if you want the position of X or Y calculated based on menu item position.
For example:
-[5,5], display submenu at (x,y)=5,5.
-["REL", 5] display menu at x calculated based on menu item position and y at 5.
This property is available only if crsFrame=true.
subPosAdj Property Submenu position adjustment, format: ["x adjustment", "y adjustment"].
subDir Property Submenu direction, possible values are ["right", "down"], ["right", "up"], ["left", "down"], ["left", "up"]


6. Public Functions

Below are public properties/functions available:

NameTypeDescription
nls_showMenu(mId, oIt, orient, subDir, subPosAdj) Function

Use this function when you want to show menu relative to a html element. This function is used when you create your own custom menubar. See HTML Menubar example for implementation.

Arguments:
  • mId, Menu Id
  • oIt, Reference to the custom element
  • orient, Reference element oriantation, the value is either "H" or "V"
  • subDir, Submenu direction, possible value ["right", "down"], ["right", "up"], ["left", "down"], ["left", "up"]
  • subPosAdj, Submenu position adjustment, ["x adjustment", "y adjustment"]
nls_hideMenu() Function

Use this function when you want to hide menu. This function is used when you create your own custom menubar. See HTML Menubar example for implementation.

Arguments:
  • mId, menu Id