EnhancedElement v0.1
I've written a simple class that allows me to enhance elements with additional class names, styles, events and/or attributes whenever JavaScript is enabled. This is being done through a hidden comment within the tag element that I want enhanced. This way I can use artificial HTML attributes when I want to and I can more clearly support screen readers and website crawlers in a suitable fashion since they will always ignore the hidden comments.
Here's a link to the script:
http://www.tobymiller.com/js/mootools-1.2-plus.js
I am currently executing it like this:
I have found this useful for doing things like adding class names to elements that you only want to be applied if JavaScript is enabled. Turning display of certain elements on/off based on JavaScript being enabled. I've also found numerous other ways to use this method of element enhancement to provide a very manageable way to have one codebase that houses a flat html experience, a javascript enhanced experience and a flash enhanced experience for any page. Plus this way I am getting the benefit of a standardized coding format for enhancing elements across multiple projects.
Any thoughts on how I might go about eliminating this looping step so that this enhancement is a native behavior of all elements? I cannot figure out a way to do this without touching the core and that's really just not an option. If you have any other comments have at it. =)
Here's a link to the script:
http://www.tobymiller.com/js/mootools-1.2-plus.js
I am currently executing it like this:
- window.addEvent('domready', function(){ $$('*').enhanceElement({}) });
I have found this useful for doing things like adding class names to elements that you only want to be applied if JavaScript is enabled. Turning display of certain elements on/off based on JavaScript being enabled. I've also found numerous other ways to use this method of element enhancement to provide a very manageable way to have one codebase that houses a flat html experience, a javascript enhanced experience and a flash enhanced experience for any page. Plus this way I am getting the benefit of a standardized coding format for enhancing elements across multiple projects.
Any thoughts on how I might go about eliminating this looping step so that this enhancement is a native behavior of all elements? I cannot figure out a way to do this without touching the core and that's really just not an option. If you have any other comments have at it. =)