Safari Fix

David Findley <[email protected]> Tue, 15 Feb 2005 15:32:06 -0800 (PST)
Newsgroups gmane.comp.krysalis.metamorphosis.sandbox
Message-ID <[email protected]>
I just downloaded Krysalis 0.1 and it looks pretty
good, but it didn't work properly in Safari.  The
primary cause seems to be that offsetWidth and
offsetTop are 0 in the table rows used to draw the
menu (I don't know why, that's just what I found). 
Anyway, here's what I did to fix it, and still have it
work in IE on Windows, and FireFox on Mac and Windows:

In MenuItem.script, in function "function initItem(
buttonElement, submenuElement )", in the first "if
(submenmuElement)" block I changed the existing code
from this:

if (submenuElement)
{
	submenuElement.style.top = (topMargin(buttonElement))
+ "px";
	submenuElement.style.left =
(leftMargin(buttonElement) + buttonElement.offsetWidth
- 9) + "px";
	addClass( submenuElement, "menuDropDivVisible" );
	currentSubmenu = submenuElement;
}

to this:

if (submenuElement)
{
	// get top starting from _any_ TD inside the TR
(instead of the TR)
	submenuElement.style.top =
(topMargin(buttonElement.cells[0]) ) + "px";
	// compute "buttonElement.offsetWidth" (for TR) by
summing all TD offsetWidths
	var rowWidth = 0;
	for ( var i = 0; i < buttonElement.cells.length; ++i
) {
		rowWidth += buttonElement.cells[i].offsetWidth;
	}
	submenuElement.style.left =
(leftMargin(buttonElement) + rowWidth - 9) + "px";
	addClass( submenuElement, "menuDropDivVisible" );
	currentSubmenu = submenuElement;
}

My exact version of Safari is 1.2.4 (v125.12).

Thanks,
David Findley


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click