Class: DropMenuItem
- 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.0, 2002-10-28, $Id: DropMenuItem.php,v 1.4 2007/10/06 00:06:30 lux Exp $
- Access: public
DropMenuItem provides individual menu item facilities to the
DropMenu class, which generates HTML and JavaScript for DHTML drop menus.
New in 1.0:
- Fixed some outdated javascript mouse tracking function references.
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 to use to generate the menu item.
$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 drop menu this item is a part of. Used for
inheriting to a child menu.
$ypos
The y position of the drop menu this item is a part of. Used for
inheriting to a child menu.
$menuWidth
The width of the drop menu this item is a part of. Used for
inheriting to a child menu.
$lineHeight
The height of this item and each item in its parent drop menu.
Used for inheriting to a child menu.
$itemTemplate
The template used to draw each drop menu item.
$direction = 'right'
The direction of the drop menu this item is a part of. Used for
inheriting to a child menu.
$items = array ()
An array of DropMenuItem objects
$extraMouseOver = ''
Optional extra JavaScript to call when the item is in focus.
$extraMouseOut = ''
Optional extra JavaScript to call when the item loses focus.
$text
The text of the menu item.
$link
The URL to link this item to.
$menu_tpl
The menu template to use to generate child drop menus.
$child
The child DropMenu object of this item.
$mouseover
The private mouseover data detailing this item's behaviour.
Return to Top
Methods
DropMenuItem ($text, $link, $xpos = 0, $ypos = 0, $menuWidth = 150, $lineHeight = 18, $menu_tpl = '', $link_tpl = '')
Constructor method.
write ($show = '')
- Access: public
- Return: string
Writes the drop menu item, as well as any child menus, 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 child's menu if it has
any child menus.
&addChild ($name)
- Access: public
- Return: object
Creates a new DropMenu class, passing on what info is required,
and adding it to the child property. Note: an item may have only one
child menu.
Return to Top