Created
September 15, 2012 22:51
-
-
Save walterdavis/3730215 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//gather all the tooltips into an array and hide them | |
var tips = $$('.tooltip').invoke('hide'); | |
//gather all the triggers into another array, and loop over them | |
var triggers = $$('.trigger').each(function(elm, idx){ | |
//link each tip to its trigger, using its position in the source order as the key | |
elm.tip = tips[idx]; | |
//watch each trigger for a mouseover | |
elm.observe('mouseenter', function(evt){ | |
//remove the "hover" style from all triggers | |
triggers.invoke('removeClassName','hover'); | |
//add it to this one that you're hovering over | |
this.addClassName('hover'); | |
//hide all the tips | |
tips.invoke('hide'); | |
//show the one related to this trigger | |
this.tip.show(); | |
//now do the same thing in reverse for a mouseout | |
}).observe('mouseleave', function(evt){ | |
//hide all the tips | |
tips.invoke('hide'); | |
//remove the hover style from this one | |
this.removeClassName('hover'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment