Class: DropMenu
- Package: saf.GUI
- Author: John Luxford <lux@simian.ca>
- Copyright: Copyright (C) 2001-2003, Simian Systems Inc.
- License: http://www.sitellite.org/index/license Simian Open Software License
- Version: 1.2, 2003-04-15, $Id: DropMenu.php,v 1.4 2007/10/06 00:06:30 lux Exp $
- Access: public
DropMenu generates HTML and JavaScript for DHTML drop menus.
This class is accompanied by a JavaScript script which provides the
necessary JavaScript components to the drop menu system.
Also requires the DropMenuItem and Template classes.
New in 1.0:
- Fixed some outdated javascript mouse tracking function references.
New in 1.2:
- Updated the javascript function names and modified the generated templates
to use the new SimpleTemplate syntax.
Usage Example
<?php
$dropMenu = new DropMenu ('company', 10, 30);
// set a background colour change on each item
$dropMenu->extraMouseOver = 'sdmSetBgcolor (\'_td_{layerID}\', \'#CCCCCC\')';
$dropMenu->extraMouseOut = 'sdmSetBgcolor (\'_td_{layerID}\', \'#FFFFFF\');
$aboutItem =& $dropMenu->addItem ('About Us', '/index/about');
$aboutMenu =& $aboutItem->addChild ('about');
$aboutMenu->addItem ('Corporate Profile', '/index/corporate');
$aboutMenu->addItem ('History', '/index/history');
$invItem =& $aboutMenu->addItem ('Investor Relations', '/index/investors');
$invMenu =& $invItem->addChild ('inv');
$invMenu->addItem ('Annual Report', '/index/annual_report');
$aboutMenu->addItem ('Contact Us', '/index/contact');
// create the drop menu divs
echo $dropMenu->write ();
// next, we need the dropmenu.js file
echo '<script language="javascript1.2" src="/js/dropmenu.js"></script>';
// we also need a javascript list of menus called menuList
echo '<script language="javascript1.2"><!--' . "\n";
echo "sdmMenuList = new Array ('" . join ("', '", $dropMenu->getList ()) . "');\n";
echo '// --></script>';
// attach this drop menu to something visible on the page.
echo '<a href="/index/company" onmouseover="sdmShowAndHide(\'company\')">Company</a>';
?>
Return to Top
Properties
$template
The template used to draw the drop menu DIV.
$fill
The object or associative array to use to fill the template with upon
calling render().
$span
The span of this cell. Set to -1 and the cell will disappear. Use
$this->attrs['colspan'] or ['rowspan'] to set these properties in the
corresponding HTML <td> tag.
$attrs = array ()
Contains all HTML <td> properties for the current object.
$default
$default is an optional default value to place in cells whose
templates result in no output.
$type = 'db'
$collection
$limit
$fields
$total = 0
$list = false
$remember = array ()
$skipHeaders = array ()
$header = ''
$footer = ''
$editUrl = false
$addUrl = false
$deleteUrl = false
$error
$name
The name of the menu.
$xpos
The x position of the top-left corner of the menu.
$ypos
The y position of the top-left corner of the menu.
$menuWidth
The width of the menu.
$lineHeight = 19
The height of each item in the menu. Default is 19.
$itemTemplate
The template used to draw each drop menu item.
$direction = 'right'
The direction the menu should open to a new level. Defaults
to 'right'.
$items = array ()
An array of DropMenuItem objects
$extraMouseOver = ''
Optional extra JavaScript to call when each item is in focus.
$extraMouseOut = ''
Optional extra JavaScript to call in each item loses focus.
Return to Top
Methods
DropMenu ($name, $xpos = 0, $ypos = 0, $menuWidth = 150, $lineHeight = 18, $template = '', $direction = 'right')
Constructor method.
&addItem ($text, $link)
- Access: public
- Return: object
Creates a new DropMenuItem class, passing on what info is required,
and adding it to the items array.
write ($show = '')
- Access: public
- Return: string
Writes the drop menu div and returns it as a string. The 'show'
property is for internal use, as this method may be called again by one
of the items inside this menu if it has any child menus.
getList ()
- Access: public
- Return: array
Returns a list of menu names, including the current menu
and all its children.
Return to Top