dHTML Drop Down Menu Tutorial - Part 8
Showing the menus
The Code
There are actually two functions for showing the menus:
showMenu()
The "showMenu()" function displays menus below the label they are assigned to. Menus can be aligned flush with the left or right edge of the label, or centered.
function showMenu(m_No, eventObj) {
hideAllMenusTier(tier[m_No]-1);
var borderModSize = borderMod[m_No];
if (ns4) {
changeBGColour('menuLabel' + m_No, onColours[m_No]);
} else {
changeBGColour('labelCell' + m_No, onColours[m_No]);
changeClass('menuLink' + m_No, onClass[m_No]);
}
if (labelBulletName[m_No] != null){
changeImage('menuBullet' + m_No, labelBulletName[m_No] + '.onImage');
}
menuActive[m_No] = true;
if (menuType[m_No] != 'blank') {
if (ns4) labelObj = 'menuLabel'+m_No;
else labelObj = 'labelCell'+m_No;
x = getElementLeft(labelObj)-borderModSize;
y = getElementTop(labelObj) + getElementHeight(labelObj);
if (menus[m_No].align == 'center')
x = x + ((getElementWidth(labelObj)-getElementWidth('menu'+m_No))/2);
if (menus[m_No].align == 'right')
x = x + ((getElementWidth(labelObj)-
getElementWidth('menu'+m_No))) + (borderModSize*2);
moveXY('menu' + m_No, x, y);
if(changeObjectVisibility('menu' + m_No, 'visible'))
return true;
else
return false;
}
}
showMenuSide()
The "showMenuSide()" function displays menus flush with the top edge of their label. Menus can be displayed the left or right of the label.
function showMenuSide(m_No, eventObj, myTier) {
hideAllMenusTier(tier[m_No]-1);
var borderModSize = borderMod[m_No];
if (ns4) {
changeBGColour('menuLabel' + m_No, onColours[m_No]);
} else {
changeBGColour('labelCell' + m_No, onColours[m_No]);
changeClass('menuLink' + m_No, onClass[m_No]);
}
if (labelBulletName[m_No] != null)
changeImage('menuBullet' + m_No, labelBulletName[m_No] + '.onImage');
menuActive[m_No] = true;
if (menuType[m_No] != 'blank') {
if (ns4) {
labelObj = 'menuLabel'+m_No;
} else {
labelObj = 'labelCell'+m_No;
if (mac_ie) labelObj = 'labelRow'+m_No;
}
x = getElementLeft(labelObj);
y = getElementTop(labelObj) - borderModSize;
if (menus[m_No].align=='right')
x = x + getElementWidth(labelObj);
else
x = x - getElementWidth('menu'+m_No);
moveXY('menu' + m_No, x, y);
if(changeObjectVisibility('menu' + m_No, 'visible'))
return true;
else
return false;
}
}
|