|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
UnivMOMenu
Programmatically creates a set of visible mouse-over activated menus, consistent across many (all?) browsers. Not a pop-up menu.
Copyright (c) 2001 by Andrew J. Peterson (andy@ndpsoftware.com). All Rights Reserved. Permission granted to use only if you send me an email about it, and allow me to link to your site, if it is on the Internet.
This class features:
include('UnivMOMenu.php');
$mo_menu = new UnivMOMenu("momenu");
-- If you want, you can set any or all of the following...
$mo_menu->setListWidth(700);
$mo_menu->setListHeight(20);
$mo_menu->setPadding(5);
$mo_menu->setBorders(false);
$mo_menu->setFontSize("12px");
$mo_menu->setColors("631", "360", "fff");
$mo_menu->setListVertical( false, true );
$mo_menu->setHorizontalAlign("center");
$mo_menu->setVerticalAlign("top");
...
-- Add the actual menu items
$mo_menu->addMenuItem("Page 1", "page1.html");
$mo_menu->addMenuItem("Page 2", "http: $mo_menu->addMenuItem("Page 2", "http: ...
-- Somewhere in a style section (even linked) include:
<style>
<?php $mo_menu->displayStyles(); ?>
</style>
...
-- Finally, when you get to where you want the menu, output it...
print $mo_menu->display();
For debugging purposes, you can set the global variable $gUnivMOMenuForceTechnique
to either 0, 1, 2 or 3. These force the display method despite the browser type. You can see the
display method from the constants here, or by using the function getRenderingTechnique.
There is a live example at aida2.org.
There is a demo of some of the options aida2.org/univmomenu_egs.php.
This was inspired by the original code by Stefano SteO Arcidiacono - info@steo.it or http: He featured a nice layout with consistent borders, and the analysis of which technique to use (Layers, JS, CSS) for each browser. Andrew Peterson added the OO interface, cleaned, and parameterized it.
| Constructor Summary | |
UnivMOMenu(var $inName)
|
|
| Method Summary | |
void |
addMenuItem(var $title,
var $url,
var $target,
var $inCellColor)
Add a new item to the list. |
void |
addUnivMOMenuItem(var $inMenuListItem)
Add a new item to the list. |
int |
determineRenderingTechnique(var $inUseThisOne)
Calculates the preferred rendering technique for the list. |
string |
display()
Returns the HTML code that will draw/perform the list actions. |
void |
displayStyles()
Returns the style sheets necessary to implement the given list in the given browser. |
string |
getRenderingTechnique()
Returns the name of the current rendering technique. |
boolean |
isListVertical()
|
void |
setBorderColor(var $inBorderColor)
Set the color of the borders, if there are any. |
void |
setBorders(var $inWantBorders)
Set whether or not there are borders between items, or whether they blend into each other. |
void |
setColors(var $inCellColor,
var $inHiliteColor,
var $inTextColor)
Set colors of the items. |
void |
setFontFamily(var $inFontFamily)
Set the CSS-style font family. |
void |
setFontSize(var $inCSSFontSize)
Set the font size. |
void |
setHorizontalAlign(var $inAlign)
Set the CSS-style horizontal alignment for all text items. |
void |
setListEvenlySpaced(var $inIsEvenlySpaced)
Evenly spaced is an attribute that attempts to keep each item of the table the same size. |
void |
setListHeight(var $inHeight)
Set the preferred height of the list. |
void |
setListVertical(var $inIsVertical,
var $inIsEvenlySpaced)
Set the layout of the list. |
void |
setListWidth(var $inWidth)
Set the preferred width for the list. |
void |
setPadding(var $inCellPadding)
Set the amount of padding around each item; it's the same as cell padding in an HTML table. |
void |
setVerticalAlign(var $inAlign)
Set the CSS-style vertical alignment for all text items. |
| Constructor Detail |
public UnivMOMenu(var $inName)
string - name of this list. This is a "code-name" that will be used
to identify the list in various places. (Right now it is
only used in some places to identify the CSS.) By necessity,
this name should be simple and unique, using only characters
and numbers (if necessary). Please, no underlines (illegal in
CSS), or punctuation marks.| Method Detail |
public int determineRenderingTechnique(var $inUseThisOne)
$inUseThisOne - Default Value: TECHNIQUE_AUTOpublic string getRenderingTechnique()
public void setListWidth(var $inWidth)
$inWidth - Default Value: 0public void setListHeight(var $inHeight)
$inHeight - Default Value: 0public void setPadding(var $inCellPadding)
$inCellPadding - Default Value: 0public void setBorders(var $inWantBorders)
boolean - whether the items have a one-pixel border (or not)public void setBorderColor(var $inBorderColor)
string - the item's color when the user's mouse is over it (indicating that
a click will follow the link).
public void setColors(var $inCellColor,
var $inHiliteColor,
var $inTextColor)
string - background color of each itemstring - the item's color when the user's mouse is over it (indicating that
a click will follow the link).string - color of the text for the item. Must have significant contrast
with foreground AND background color to work well. NOTE:
There is no way to set the mouseover text color.public void setFontFamily(var $inFontFamily)
string - in CSS-complain style, eg "Verdana, Helvetica, sans-serif"public void setFontSize(var $inCSSFontSize)
string - CSS-complain font size, like "12pt", "10px" or "110%"int - HTML 3.2-style font size, from 1 to 7, or "+3". Will only be used
for browsers without CSS support.public void setVerticalAlign(var $inAlign)
string - CSS-complain vertical alignment. For example, "top", "middle", "text-top", "%"$inAlign - Default Value: "middle"public void setHorizontalAlign(var $inAlign)
string - CSS-complain horizontal alignment. One of "left", "right", "center" or "justify".$inAlign - Default Value: "left"
public void setListVertical(var $inIsVertical,
var $inIsEvenlySpaced)
boolean - if vertical layout is desiredboolean - if evenly-sized elements are desired. See setListEvenlySpaced$inIsEvenlySpaced - Default Value: falsepublic boolean isListVertical()
public void setListEvenlySpaced(var $inIsEvenlySpaced)
boolean - if evenly-sized elements are desired$inIsEvenlySpaced - Default Value: truepublic void displayStyles()
public void addMenuItem(var $title,
var $url,
var $target,
var $inCellColor)
string - Title to display in the cell.string - URL to link to when the user clicks. A missing URL implies
no hiliting when the item when it is moused over.string - Target window for the URL, default is "_self", per HTML.string - HTML color (name or 6-digit hex color). Note: There is
no way to control the hilite color or text color on an individual
basis so design accordingly. Default uses default background color.$url - Default Value: ""$target - Default Value: ""$inCellColor - Default Value: ""public void addUnivMOMenuItem(var $inMenuListItem)
UnivMOMenuItem. - Dynamically allocated by caller. This takes ownership of it.public string display()
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||