Mike,
Nice! FYI: http://encyte
media.com/event-selectors/ takes a similar
approach; using the behaviour idea but capitalizing on
prototype to
make it shorter/faster/better. Event selectors also add an
event
assignment syntax into the css itself (like div:click or
div:hover).
I thought you might like to take a look at it.
Anyway, good job.
Ben West (not Nolan)
On 9/13/06, Mike Crute <mcrute gmail.com> wrote:
>
> After staring long and hard at the Behaviour code I
decided I loved the
> concept and hated the implementation. Here is an
alternative
> implementation.
>
> var Behaviour = Class.create();
> Behaviour.prototype = {
> initialize: function(s) { this.sheet = s; },
> apply: function(){
> for (sel in this.sheet){
> var els = $$(sel);
> for (var i=0; i<els.length;
i++)
>
this.sheet[sel].call(this,els[i]);
> }
> }
> };
>
> And for implementation, you pass the same hashmap you
would have passed
> to the old function and then do something like this:
>
> var actions = new Behavior(myrules);
>
Event.observe(window,'load',function(){actions.apply();},f
alse);
>
> Note that I removed the ability to add multiple sheets,
instead opting
> to create a new instance of the class for each sheet
that I wish to
> apply.
>
> Let me know what you think.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Behaviour Javascript Library"
group.
To post to this group, send email to behaviour googlegroups.com
To unsubscribe from this group, send email to
behaviour-unsubscribe googlegroups.com
For more options, visit this group at http://group
s.google.com/group/behaviour
-~----------~----~----~----~------~----~------~--~---
|