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".
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 2. Benefits |
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 3. Features |
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.
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.
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.
<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.
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();
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();
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.
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.
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.
require_once $PATH_TO_YOUR_WEBDOCROOT . '/zzmenu/zzmenu.php';
$menuLibrary = new ZZEEMenus(); $menuLibrary->setInterface('html'); $menuLibrary->cssFile = 'vista.css';
$m1 = $menuLibrary->newMenu();
$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") );
<?php echo $menuLibrary->headCode(); ?>
<?php echo $menuLibrary->menuCode($m1); ?>
<?php echo $menuLibrary->bodyCode(); ?>
Do this is as the last thing after menuCode function is called for all of your menus on the page.
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization |
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 |
---|---|---|---|
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.
subitem.cssSM = "background-color: green, width: 300px";If you want one of the items to differ from the others, you can pass additional CSS to this specific item:
item.css = "font-weight: bold";
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:
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 8. Customization > 8.3. Javascript functions for menu items |
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.
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.
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 10. Javascript interface reference |
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.
ZZEEMenus()
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
|
void |
initMenu(<Object> menu, <Object> htmlContainer)
Initializes the menu, so it will become visible and working. |
Object |
newMenu()
Create a new menu. |
int capPad
BOOL doFocus
BOOL dontUseAltUp
string expandText
string libPath
int minSubWidth
int overlayX
int overlayY
int rArrOffset
int scOffset
string version
void initMenu(<Object> menu, <Object> htmlContainer)
menu
- A menu object. htmlContainer
- An HTML object that will hold the menu being initialized Object newMenu()
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.
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. |
void |
horizontal(<BOOL> h)
Defines if this menu will be horizontal or vertical. |
BOOL allowSubmenuClick
BOOL autoTopLevelExpansion
BOOL closeOnmouseout
void horizontal(<BOOL> h)
h
- Pass true to make this menu horizontal or false to make it vertical. 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.
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. |
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 |
string caption
string css
string cssSubmenu
BOOL en
string icon
string iconA
string iconD
Object onclick
string shortcut
array subitems
string target
string url
Object add(<Object> obj)
obj
- Contains the needed features of the menu item to be added void addItems(<array> arr)
arr
- an array of objects, that will define menu items properties void disable()
void enable()
BOOL getChecked()
BOOL getEnabled()
Object getItem(<array> arr)
arr
- An array consisting of indexes that defines the path from the needed node to the one which address we need to get. Object insert(<Object> beforeItem, <Object> obj)
beforeItem
- Before which menu item we need to insert this one, it must be a valid menu item obj
- An object to contain needed properties for a new item Object insertChild(<Object> obj)
obj
- An object to contain needed properties for a new item void remove(<Object> mItem)
mItem
- A menu item object to be removed. This object can be obtained via methods that return a menu item object like add, insert or getItem. void setChecked(<BOOL> b)
b
- Either check or uncheck the item void setRadio(<int> iRadioGroup)
iRadioGroup
- The integer ID of the radio group void update()
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 11. PHP interface reference |
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. |
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. |
string $cssFile = 'xp8.css'
It must be one of the existing CSS files.
BOOL $ieSelectHack = 1
This is needed if your page can contain <SELECT> tags and it can rendered by IE.
array $jsProps =array()
For the list of properties of the menu library, see Javascript documentation.
string $libPath = ''
Must end in slash '/'. You can leave it blank.
string bodyCode()
This function needs to be called the last, and its output should be placed before the closing BODY tag.
string getInterface()
string headCode()
This is the first function you need to call after you are done with the settings for the library.
string menuCode(Object $menu)
Output of this function should be placed inside an HTML container for the menu. The function shall be called once for each menu.
ZZEEMenu newMenu()
boolean setInterface(string $ifc)
HTML output is compatible with search engines, while Javascript code has more capabilities.
Do not create menus directly, instead use newMenu() method of ZZEEMenus.
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. |
bool $horizontal = false
array $items =array()
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.
array $jsProps =array()
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.
ZZEE DHTML Menu Help | www.zzee.com | You are here: Contents > 12. Known issues |