Will Bueché



I don't blog much 

PhatFusion Image Menu: Fix for the "2-clicks needed on pre-expanded items" problem

Posted in Personal by Will on Sunday, December 6th, 2009 ~ 7pm

OMG! I’ve impressed myself. I don’t even know how to speak java, but I managed to fix a longstanding problem with the popular PhatFusion Image Menu, in which if one’s web page is written to set one of the menu items to be open (expanded) on start, that open (expanded) item must be clicked *twice* in order for the window.location=(e) to send the user to the desired url. Whereas all the other items correctly send a user to a desired url with a single click, as would be expected.

After moderation un-hides my posts, the solution will be visible here, which may provide more context.
But in the meantime, here is the fix, summarized to its key points:

Solution to the “two clicks needed on pre-expanded item” problem!

First, implement ElShaddai Edwards’ change in imageMenu.js:

Replace this:


with this:


Next (again according to ElShaddai Edwards’ discovery), implement in your web page html the statement “open:0″ in the following line, where it did not exist before:

var myMenu = new ImageMenu($$(‘#imageMenu a’),{openWidth:500,
open:0, border:0,onOpen:function(e,i){window.location=(e);}});

(Of course your own choice may be 0, or 1 or 2 etc. Whichever menu item you wish to be open from the very start.) (And make sure that “window.location=” has replaced the demo’s “alert”, too. I highlighted that, above, as well.)

The above gets you as far as enabling the pre-expansion of one of the menu items.

But that’s where it was discovered that the preexpanded item had to be clicked twice for it to respond. To overcome this bug, to make it clickable with a single click, implement my fix below (in imageMenu.js).


el.addEvent(‘click’, function(e){

new Event(e).stop();
if(obj.options.open == i){
obj.options.open = null;
obj.options.onClose(this.href, i);
obj.options.open = i;
obj.options.onOpen(this.href, i);




With this:

el.addEvent(‘click’, function(e) {

new Event(e).stop();
obj.options.onOpen(this.href, i);



} )


This is tested on Firefox and IE on a Windows PC. So far I haven’t been able to test it on a Mac’s Firefox, nor on a Mac’s Safari. I really hope it works there too.

If it does, I will have achieved the impossible of having rewritten a bit of javascript without knowing how to speak javascript. And that makes me mighty! Mighty lucky. Or mighty clever. But mighty something, for sure!

I deserve a mm’Inara moment!

Inara composite image by Chung Designs
Inara composite image by Chung Designs

Leave a Reply