YUILight - Spotlight Your Page Elements With YUI
YUILight is a customisable YUI Script that will highlight an element on your page simply by applying a class of 'yuilight' to that element. When that element is clicked and focused on, everything else on the page will be covered by a mask and that single element will stand out from the rest.
It is a very simple script to implement only requiring two javascript files and no CSS! The options for customising the script can be found at the top of the javascript file (which is fully commented for you). At the moment you can change the generic background colour (when no background colour has been specified for the element). This option is so that your element doesn't disappear with the text.
You can also configure the opacity of the mask element and the animation speed that it shows and hides. I will be adding more customisable fields later on but if you have any requests please feel free to leave them in the comments section at the bottom of this post.
<script type="text/javascript" src="yui/utilities.js"></script> <script type="text/javascript" src="yui/yuilight.js"></script>
I've prepared a little example page here which will guide you through the various options in a little more detail. Comments welcome below and please enjoy the script!
Article Info
- Posted By: Alex Hall
- On: 26th Mar 2010 @ 13:38:46
- Comments: 2
- Rating: 5 / 5
- Hits: 1142
- Listed In: tutorials, tools, javascript, css
- Short URL: http://bit.ly/akVFYf

Author: Luke Smith
#1 | 07th Apr 10 @ 18:37
Nice work, Alex! The point you note about the mouseover of an element that has child nodes is because the mouseover event fires for the child elements then bubbles up to the element that has the subscriber that triggers the light behavior. You can avoid this by using the mouseenter event or confirming in the subscriber that YAHOO.util.Event.getTarget(e) === theNodeThatShouldTrigger;
You should make this into a YUI 3 Gallery module!
reply
Author: Alex Hall
#2 | 20th Apr 10 @ 11:21
Hi Luke,
Thanks for the comments, and for the fix. I'll get that implemented right away!
I've been playing around with YUI3 quite a bit recently so I'll look at doing that. There's some very amazing stuff in the YUI 3 Gallery modules!
reply