Will Bueché

»

Blog

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.
http://www.elshaddai-edwards.com/2009/07/a-fix-to-phatfusions-image-menu-script/comment-page-1
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:

if(this.options.open){

with this:

if(this.options.open!=null){

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).

Replace:

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

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

}

})

}.bind(this));

With this:

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

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

}

}

} )

}.bind(this));

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