ZZEE DHTML Menu Help Contents

1. Introduction

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 1. Introduction

ZZEE DHTML Menu is a library with both Javascript and PHP interfaces that allows to create dynamic drop down menus similar to those that clients use in their desktop programs. The library is aimed at developers who need to quickly create familiar menus for their web and HTML applications. For legal information see file "license.txt".

2. Benefits

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 2. Benefits

3. Features

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 3. Features

4. Comparison between Javascript and HTML versions

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 4. Comparison between Javascript and HTML versions

Note, this section applies only if you do your menus in PHP. In this case you can select either Javascript or HTML output code.

Javascript output from PHP inteface has exactly the same capabilities as Javascript library interface, while HTML output is search engine friendly. You need to choose which features suit you the most.

HTML code Javascipt code
Menus defined via Pure HTML code (UL & LI tags) Javascript code
Search engine friendly Yes No
Will the menu be available with Javascript turned off In CSS-compatible browsers (such as FF, IE7 or Opera9) submenus will still expand and collapse (but not so gracefully as if Javascript is enabled). In other browsers (including search engines crawlers) the menu will be rendered as nested lists. No
"onclick" property available No Yes (but Opera 9)
Can you add and delete items and submenus on the fly No Yes
Can you check and uncheck items and radio items No Yes
Can you enable and disable items and submenus No Yes
Can specify different icon onmouseover No Yes
Javascript libraries download size about 13Kb about 19Kb

All other features for these interfaces are the same.

5. Difference between Free and Full versions

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 5. Difference between Free and Full versions

The Free Version doesn't have the PHP interface, it adds a new menu item "ZZEE DHTML Menu" to menus, and it comes only with one style "Vista". Note, you may not alter any of the files of the Software.

6. Using Javascript interface

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 6. Using Javascript interface

For a detailed example see the test.html file that comes along with the library.

6.1. Include needed .js files

In the HEAD section of your HTML file, include links to a CSS file and Javascript files:
<link rel="stylesheet" href="zzmenu/vista.css" />
<!--[if lt IE 6]>
<style type="text/css">ul.zzmenuNS li.v, ul.zzmenuNS li.sv { margin-left: -20px; }</style>
<![endif]-->
<!--[if IE]>
<style type="text/css">ul.zzmenuNS span.h { float: left; }</style>
<![endif]-->
<script src="zzmenu/zzmenujs.js" type="text/javascript"></script>
<!--[if lt IE 7]>
<script src="zzmenu/zzmenuiehack.js" type="text/javascript"></script>
<![endif]-->

Note the paths depend on where you put the library code. You can replace the CSS file by another one.

6.2. Create a library object

ZZEEMenus class is a class that defines a menu library. Create it with the new keyword. You need to create it only once per HTML page.

var menus = new ZZEEMenus();

6.3. Create a menu

newMenu method of ZZEEMenus class creates a new menu. Call this function as many times as many different menus you need on a page. Returns a new menu object.

var menu1 = menus.newMenu();

6.4. Add items and define properties of the menu

Once you have created a menu via newMenu function you need to add its items. You add items via methods like add, addItems, insert, etc.

menu1.addItems([
    {caption: "&First", subitems: [
        {caption: "&ZZEE website",  url: "http://www.zzee.com/"},
        {caption: "&Javascript Alert Test", url: "javascript:alert('Hiya!');"},
        // Here we create a separator. Set the caption to "-" and you have a separator:
        {caption: "-"},
        // Another submenu, you can have unlimited nested submenus
        {caption: "Submenu", subitems: [
            // Third level menu items:
            {caption: "SubSubItem 1"},
            {caption: "SubSubItem 2"}
            ]}
        ]},
    {caption: "&Shortcuts", subitems: [
        {caption: "&Yahoo",     shortcut: "Ctrl+Y", url: "http://www.yahoo.com",
            target: "_self"},
        {caption: "&Google",    shortcut: "Ctrl+G", url: "http://www.google.com"},
        {caption: "&Microsoft in new window", shortcut: "Ctrl+M", url: "http://www.microsoft.com",
            target: "_blank"}
        ]}
    ]);

Note, for checkbox items you need to initialize their checked or unchecked state in advance using the setChecked method.

Note, for Opera 9, do not set the onclick property, instead set the url property to "javascript:" like in the item "Javascript Alert Test" in the example above.

6.5. Initialize the menu

The last step is to initialize the menu, passing its HTML container.

menuLibrary.initMenu(menu1, document.getElementById('menuDiv'));

Now the menu will be displayed and active. You can also check / uncheck menu items, assign / check / uncheck radio items, enable or disable items, add or insert new items or delete existing ones.

7. Using PHP interface

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 7. Using PHP interface

With PHP library you can generate code for both HTML menu code and Javascript code. You can find more about the difference between them here.

For a detailed example see the test.php file that comes along with the library.

7.1. Include library file

require_once $PATH_TO_YOUR_WEBDOCROOT . '/zzmenu/zzmenu.php';

7.2. Create a menu library object and set its properties

$menuLibrary = new ZZEEMenus();
$menuLibrary->setInterface('html');
$menuLibrary->cssFile = 'vista.css';

7.3. Create a menu

$m1 = $menuLibrary->newMenu();

7.4. Set properties of the menu and add its items

$m1->horizontal = true;
$m1->items = array(
    array('caption' => "Link to &Yahoo", 'url' => 'http://www.yahoo.com/'),
    array('caption' => "&Submenu", 'subitems' => array(
        array('caption' => "Subitem 1", 'url' => "javascript:alert(this.caption);"),
        array('caption' => "-"),  // separator
        array('caption' => "Subitem 2")
        )),
    array('caption' => "&Last one")
    );

7.5. In the <HEAD> section of your HTML output, call headCode function

<?php echo $menuLibrary->headCode(); ?>

7.6. For each of your menus, inside their HTML containers, put the HTML code for the menu with menuCode function

<?php echo $menuLibrary->menuCode($m1); ?>

7.7. Finally call bodyCode function to finish

<?php echo $menuLibrary->bodyCode(); ?>

Do this is as the last thing after menuCode function is called for all of your menus on the page.

8. Customization

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization

8.1. Style

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization > 8.1. Style

You can use any of the CSS files supplied to define a style of your menu, and besides you have more possibilities with Javascript interface. The following CSS stylesheets ship with the library:

Vista Vista Black XP XP Grey
vista menu vista black menu xp menu xp grey menu

8.1.1. Javascript interface

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization > 8.1. Style > 8.1.1. Javascript interface

You can assign individual style for any of the items in the menu.

8.2. Icons for menu items

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization > 8.2. Icons for menu items

You can assign 16x16 pixels icons to menu items with the following exceptions:

8.3. Javascript functions for menu items

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization > 8.3. Javascript functions for menu items
There are two ways to assign a javascript function to an item. First is to make its URL to be something like:
javascript:myFunction(myParam);
Second is assign an onclick event for a menu item (this can be used when you build the menu with Javascript interface):
item.onclick = myFunc;
The syntax in the latter case shall be the same as you use when you assign events to any HTML objects with Javascript. Note, use the first method with "javascript:" URLs, if you want your menu to work in Opera.

9. Deployment

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 9. Deployment

"zzmenu" subdirectory of the ZZEE DHTML Menu zip file contains the files that you need to put to your webserver. Create "zzmenu" folder in your website root directory. Put there all files, including CSS, javascript and images from the "zzmenu" subdirectory of ZZEE DHTML Menu.

Now you can add menus to your website HTML files and scripts.

10. Javascript interface reference

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 10. Javascript interface reference

10.1. ZZEEMenus

ZZEEMenus class is a class that defines a menu library. Create it with the new keyword. You need to create it only once per HTML file.

10.1.1. ZZEEMenus Constructor

ZZEEMenus()
Creates a new menu library. You need to create it only once per HTML file.

10.1.2. Summary of ZZEEMenus Properties

int capPad
Padding in pixels for a menu item.
BOOL doFocus
If to expand submenus on focus.
BOOL dontUseAltUp
Prohibits handling of a single ALT keypress.
string expandText
Text that pops up on mouseover when automatic top submenus expansion is not allowed.
string libPath
Webserver path where deployment files are stored.
int minSubWidth
Minimum width in pixels of a submenu.
int overlayX
Distance in pixels between a submenu and its parent.
int overlayY
Distance in pixels between a submenu and its parent.
int rArrOffset
Offset in pixels between the right edge of a caption and the right arrow (for submenus).
int scOffset
Offset in pixels between the right edge of a caption and the left edge of a shortcut text.
string version

10.1.3. Summary of ZZEEMenus Methods

void initMenu(<Object> menu, <Object> htmlContainer)
Initializes the menu, so it will become visible and working.
Object newMenu()
Create a new menu.

10.1.4. Details of ZZEEMenus Properties

10.1.4.1. capPad

int capPad
Padding in pixels for a menu item. Default is 4.

10.1.4.2. doFocus

BOOL doFocus
If to expand submenus on focus. Set to false if you do a IE Webbrowser control based application with DOCHOSTUIFLAG_DIALOG flag enabled (i.e. when selection is prohibited). Default is true.

10.1.4.3. dontUseAltUp

BOOL dontUseAltUp
Prohibits handling of a single ALT keypress. Default is false (allow single ALT keypresses).

10.1.4.4. expandText

string expandText
Text that pops up on mouseover when automatic top submenus expansion is not allowed. Default is 'Click to expand'.

10.1.4.5. libPath

string libPath
Webserver path where deployment files are stored. This is the path to a directory which contains icons, javascript and CSS files. Default is '/zzmenu/'.

10.1.4.6. minSubWidth

int minSubWidth
Minimum width in pixels of a submenu. Default is 120.

10.1.4.7. overlayX

int overlayX
Distance in pixels between a submenu and its parent. Default is 2.

10.1.4.8. overlayY

int overlayY
Distance in pixels between a submenu and its parent. Default is 1.

10.1.4.9. rArrOffset

int rArrOffset
Offset in pixels between the right edge of a caption and the right arrow (for submenus). Default is 12.

10.1.4.10. scOffset

int scOffset
Offset in pixels between the right edge of a caption and the left edge of a shortcut text. Default is 16.

10.1.4.11. version

string version

10.1.5. Details of ZZEEMenus Methods

10.1.5.1. initMenu

void initMenu(<Object> menu, <Object> htmlContainer)
Initializes the menu, so it will become visible and working.
Parameters:
See:

10.1.5.2. newMenu

Object newMenu()
Create a new menu. Call this function as many times as many different menus you need on a page. After the menu is created and its items and properties are assigned, call the initMenu method.
Returns:
A new menu object
See:

10.2. Menu object

You need to create a menu only via newMenu method of ZZEEMenus object. Do not create it directly.

You can append submenus and items to the menu via addItems, add, insert and insertChild methods. Delete items via remove method. All these methods are inherited from the Menu Item object.

10.2.1. Summary of Menu Properties

BOOL allowSubmenuClick
Handles onclick event and url property of a submenu when user clicks it.
BOOL autoTopLevelExpansion
Allows top level submenus to expand automatically on mouseover.
BOOL closeOnmouseout
Closes expanded submenu when the cursor leaves it.

10.2.2. Summary of Menu Methods

void horizontal(<BOOL> h)
Defines if this menu will be horizontal or vertical.

10.2.3. Details of Menu Properties

10.2.3.1. allowSubmenuClick

BOOL allowSubmenuClick
Handles onclick event and url property of a submenu when user clicks it. Avoid setting true to this property. Default is false.

10.2.3.2. autoTopLevelExpansion

BOOL autoTopLevelExpansion
Allows top level submenus to expand automatically on mouseover. Default is true.

10.2.3.3. closeOnmouseout

BOOL closeOnmouseout
Closes expanded submenu when the cursor leaves it. Default is true.

10.2.4. Details of Menu Methods

10.2.4.1. horizontal

void horizontal(<BOOL> h)
Defines if this menu will be horizontal or vertical.
Parameters:

10.3. Menu Item object

This object defines both submenus and terminal menu items.

If you add items to a menu item it will become a submenu.

Do not create items directly, instead use methods addItems, add, insert and insertChild of both Menu object and submenus.

10.3.1. Summary of Menu Item Properties

string caption
Text for this menu item. Required.
string css
Additional style (besides that is defined in a CSS file) for the item.
string cssSubmenu
Additional style (besides that is defined in a CSS file) for the submenu of this item.
BOOL en
If the item is initially enabled. Optional.
string icon
Icon file name for this menu item. Optional.
string iconA
Icon file name that is shown when the cursor is over this menu item. Optional.
string iconD
Icon file name that is shown when this menu item is disabled. Optional.
Object onclick
Function that gets called when user clicks the menu item. Optional.
string shortcut
A string like "F1" or "Alt+Left Arrow" that defines the key combination that can be used to call this menu item. Optional.
array subitems
Array of objects which define the properties of the subitems of this menu item. Optional.
string target
A frame name like '_blank' that this menu item will lead to. Optional.
string url
URL that will load into the page when you click this menu item. Optional.

10.3.2. Summary of Menu Item Methods

Object add(<Object> obj)
This function adds an item to a menu or submenu, a new item is appended to the end of menu items.
void addItems(<array> arr)
This function adds multiple (recursive) items to a menu or submenu, they are appended to the end of menu items
void disable()
Disables an item after the menu has been initialized with initMenu()
void enable()
Enables an item after the menu has been initialized with initMenu()
BOOL getChecked()
If the item is checked.
BOOL getEnabled()
If an item is enabled
Object getItem(<array> arr)
Returns a menu item object, given a path from the root.
Object insert(<Object> beforeItem, <Object> obj)
This function inserts a new item to a menu or submenu
Object insertChild(<Object> obj)
Inserts a new item to a menu or submenu as the first child
void remove(<Object> mItem)
Removes a menu item from the submenu
void setChecked(<BOOL> b)
Checks or unchecks a menu item.
void setRadio(<int> iRadioGroup)
Makes an item to belong to a radio group and makes it a radio item.
void update()
Updates an item and all of its subitems (if any) recursively

10.3.3. Details of Menu Item Properties

10.3.3.1. caption

string caption
Text for this menu item. Required. If the caption is "-", then this menu item becomes a separator. If the caption contains the "&" symbol, the next symbol after it will be an underscored hot key. If you want to have the literal "&" in the caption, then double it like "&&".

10.3.3.2. css

string css
Additional style (besides that is defined in a CSS file) for the item.

10.3.3.3. cssSubmenu

string cssSubmenu
Additional style (besides that is defined in a CSS file) for the submenu of this item.

10.3.3.4. en

BOOL en
If the item is initially enabled. Once the menu holding the item is initialized with initMenu(), then you need to use enable() and disable() methods to enable or disable the item.

10.3.3.5. icon

string icon
Icon file name for this menu item. Optional.

10.3.3.6. iconA

string iconA
Icon file name that is shown when the cursor is over this menu item. Optional.

10.3.3.7. iconD

string iconD
Icon file name that is shown when this menu item is disabled. Optional.

10.3.3.8. onclick

Object onclick
Function that gets called when user clicks the menu item. Optional. It takes priority over url property.

10.3.3.9. shortcut

string shortcut
A string like "F1" or "Alt+Left Arrow" that defines the key combination that can be used to call this menu item. Optional. If you assign a shortcut, the library will handle everything for you. Supported keys are Bksp, Esc, PgUp, PdDown, End, Home, Left Arrow, Up Arrow, Down Arrow, Ins, Del and F1 through F12. Supported additional keys are Alt, Ctrl and Shift.

10.3.3.10. subitems

array subitems
Array of objects which define the properties of the subitems of this menu item. Optional. The subitems may have their own subitems as well.

10.3.3.11. target

string target
A frame name like '_blank' that this menu item will lead to. Optional. Valid only if the url property is set.

10.3.3.12. url

string url
URL that will load into the page when you click this menu item. Optional. You can leave it blank or set to "#" if you want to handle the onclick event. If onclick property is set, then it takes prioriry over the url property.

10.3.4. Details of Menu Item Methods

10.3.4.1. add

Object add(<Object> obj)
This function adds an item to a menu or submenu, a new item is appended to the end of menu items.
Parameters:
Returns:
A new menu item object created
See:

10.3.4.2. addItems

void addItems(<array> arr)
This function adds multiple (recursive) items to a menu or submenu, they are appended to the end of menu items
Parameters:
See:

10.3.4.3. disable

void disable()
Disables an item after the menu has been initialized with initMenu()
See:

10.3.4.4. enable

void enable()
Enables an item after the menu has been initialized with initMenu()
See:

10.3.4.5. getChecked

BOOL getChecked()
If the item is checked.
See:

10.3.4.6. getEnabled

BOOL getEnabled()
If an item is enabled
See:

10.3.4.7. getItem

Object getItem(<array> arr)
Returns a menu item object, given a path from the root.
Parameters:
Returns:
A menu item or false on failure
See:

10.3.4.8. insert

Object insert(<Object> beforeItem, <Object> obj)
This function inserts a new item to a menu or submenu
Parameters:
Returns:
A new menu item object created
See:

10.3.4.9. insertChild

Object insertChild(<Object> obj)
Inserts a new item to a menu or submenu as the first child
Parameters:
Returns:
A new menu item object created
See:

10.3.4.10. remove

void remove(<Object> mItem)
Removes a menu item from the submenu
Parameters:
See:

10.3.4.11. setChecked

void setChecked(<BOOL> b)
Checks or unchecks a menu item. For radio items it will automatically uncheck the rest of the group.
Parameters:
See:

10.3.4.12. setRadio

void setRadio(<int> iRadioGroup)
Makes an item to belong to a radio group and makes it a radio item. Sets the onclick event as well, so the item will automatically get checked or unchecked on click. To find out which item of the group is checked, use getChecked method. To select an item in a group, use setChecked method.
Parameters:
See:

10.3.4.13. update

void update()
Updates an item and all of its subitems (if any) recursively
See:

11. PHP interface reference

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 11. PHP interface reference

11.1. Class ZZEEMenus


	
			

11.1.1. ZZEEMenus Variable Summary

string $cssFile
Which CSS file you want for your menu.
BOOL $ieSelectHack
If you need the Internet Explorer SELECT hack.
array $jsProps
Defines various Javascript properties for the menu library.
string $libPath
Where all library files for ZZEE menu are stored.

11.1.2. ZZEEMenus Method Summary

string bodyCode()
Outputs HTML code needed to initialize the menus.
string getInterface()
Which output this PHP API will generate: HTML or Javascript.
string headCode()
Will output HTML code to go to the HEAD section of the HTML page.
string menuCode(Object $menu)
Outputs HTML code needed for a particular menu.
ZZEEMenu newMenu()
Creates a new menu.
boolean setInterface(string $ifc)
Set either 'HTML' or 'Javascript' output for the code.

11.1.3. ZZEEMenus Variables

11.1.3.1. $cssFile

string $cssFile = 'xp8.css'
Which CSS file you want for your menu.

It must be one of the existing CSS files.


11.1.3.2. $ieSelectHack

BOOL $ieSelectHack = 1
If you need the Internet Explorer SELECT hack.

This is needed if your page can contain <SELECT> tags and it can rendered by IE.


11.1.3.3. $jsProps

array $jsProps =array()
Defines various Javascript properties for the menu library.

For the list of properties of the menu library, see Javascript documentation.

  1.  $menus->jsProps array('minSubWidth' => 150'expandText' => '');


11.1.3.4. $libPath

string $libPath = ''
Where all library files for ZZEE menu are stored.

Must end in slash '/'. You can leave it blank.


11.1.4. ZZEEMenus Methods

11.1.4.1. bodyCode

string bodyCode()
Outputs HTML code needed to initialize the menus.

This function needs to be called the last, and its output should be placed before the closing BODY tag.


11.1.4.2. getInterface

string getInterface()
Which output this PHP API will generate: HTML or Javascript.

11.1.4.3. headCode

string headCode()
Will output HTML code to go to the HEAD section of the HTML page.

This is the first function you need to call after you are done with the settings for the library.


11.1.4.4. menuCode

string menuCode(Object $menu)
Outputs HTML code needed for a particular menu.

Output of this function should be placed inside an HTML container for the menu. The function shall be called once for each menu.


11.1.4.5. newMenu

ZZEEMenu newMenu()
Creates a new menu.

11.1.4.6. setInterface

boolean setInterface(string $ifc)
Set either 'HTML' or 'Javascript' output for the code.

HTML output is compatible with search engines, while Javascript code has more capabilities.


11.2. Class ZZEEMenu

Do not create menus directly, instead use newMenu() method of ZZEEMenus.


	
			

11.2.1. ZZEEMenu Variable Summary

bool $horizontal
If the menu is horizontal
array $items
Menu items. This is the array of item descriptions.
array $jsProps
Defines various Javascript properties for the menu.

11.2.2. ZZEEMenu Variables

11.2.2.1. $horizontal

bool $horizontal = false
If the menu is horizontal

11.2.2.2. $items

array $items =array()
Menu items. This is the array of item descriptions.

Each item description is in turn an array (a hash) of menu item properties. If the item is submenu, its description can contain a 'subitems' property, which must be an array of arrays (just like this $items property). Thus you can define subitems recursively. See the list of properties for menu items in the documentation for Javascript interface.

  1.  $mymenu->items array('caption' => '&Home''url' => "http://www.example.com");
  2.  $mymenu->items array('caption' => 'Submenu''subitems' => array());


11.2.2.3. $jsProps

array $jsProps =array()
Defines various Javascript properties for the menu.

The only property you can't define here is whether the menu is horizontal. For the list of properties of the menu, see documentation for Javascript interface.


12. Known issues

ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 12. Known issues