On 2/10/06, Greg Militello <[EMAIL PROTECTED]> wrote: > You will notice former code had the hardcoded string 'highlightHover', but > the new code get the value of that class via the class options.
Yup. Looks good. An option that doesn't do anything doesn't sound like a very good option. :) > Check out the demo here: > http://thinkof.net/projects/js/highlight/highlight.html > I simply commented the old code so you guys can see it all inline; > http://thinkof.net/projects/js/highlight/javascript/highlight.js > > > What do you guys think? To much of a hack? Is there a better way? I think your indenting and some of your parenthesis' are weird. I really only looked at the event code because that seemed to be what you were stuck on, but a few observations: var mouseoverEventFunction = function(event) { if (!Element.hasClassName(el, this.options.hoverClass)) { Element.addClassName(el, this.options.hoverClass); } }.bind(this); Event.observe(el, 'mouseover', (mouseoverEventFunction)); You don't need to check if the Element hasClassName; the addClassName function does that internally. The same applies to the removeClassName function. You define a clickClass var that you never use: var clickClass = this.options.clickClass; There's an extra ; at the end of your clickEventFunction bind: }.bind(this);; Do you understand why el is available in your functions but that 'this' isn't any good unless you .bind(this)? The closures in JavaScript are one of the most difficult parts of the language to understand, but they're really powerful. Todd _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs