> Event delegation is definitely one of the most important additions
> that we have in mind (along with element wrappers). We just need to
> deal with bugfixes before adding new features : )
Understood. I've been following all of the discussions here and on
related blogs. It sounds like there's a lot to do!
> Perhaps 1.6.1 is a good candidate for it (though such estimates are
> obviously not official by any means).
I would love to see this feature in 1.6.1. Do you know who is planning
to take on the development on this feature?
> Which addons were you using?
I've been reading a lot about Low Pro and others... I've been using my
own though, which I'm sure has about a billion holes in it. I'll paste
it at the end of this post.
Thanks for the response,
Dan
---
var CssEventObserver = {
/**
* State variable; ensures object isn't initialized more than once
*/
initialized: false,
/**
* Initializes object
*/
init: function() {
if (!this.initialized) {
this.initialized = true;
var body = $(document.body);
for (var e in this.handlers) {
body.observe(e,
this.__handleDomEvent.bind(this));
}
}
},
dispose: function() { /* TODO: removes bindings from INIT and
unregisters all handlers */ },
isRegistered: function(selector, eventName, handler) {
var queue = this.handlers[eventName];
if (queue) {
for (var i=0; i<queue.length; i++) {
if (queue[i][0] == selector && queue[i][1] ==
handler) {
return true;
}
}
}
return false;
},
/**
* Handlers which are acceptable for this situation; Many are not
present as they would
* create a performance nightmare.
*/
handlers: {
click: false, dblclick: false, mousedown: false, mouseup: false,
focus: false,
blur: false, change: false, keypress: false, keydown: false,
keyup:
false, resize: false
},
/**
* Registers an event handler for the given selector and event
*/
register: function(selector, eventName, handler) {
if (selector && eventName && handler &&
!this.isRegistered(selector,
eventName, handler)) {
if (!this.handlers[eventName]) {
this.handlers[eventName] = [];
}
this.handlers[eventName].push([selector, handler]);
}
},
unregister: function(selector, eventName, handler) {
if (selector && eventName && handler &&
this.isRegistered(selector,
eventName, handler)) {
for (var i=0; i<this.handlers[eventName].length; i++) {
if (this.handlers[eventName][i][0] == selector
&&
this.handlers[eventName][i][1] == handler) {
this.handlers[eventName].splice(i,1);
}
}
if (this.handlers[eventName].length == 0) {
this.handlers[eventName] = false;
}
}
},
__handleDomEvent: function(e) {
if (this.handlers[e.type]) {
for (var i=0; i<this.handlers[e.type].length; i++) {
var selector = this.handlers[e.type][i][0];
var element = e.element();
if (element.match(selector) ||
element.match(selector + " " +
element.nodeName + "#" + element.identify())) {
this.handlers[e.type][i][1](e);
}
}
}
}
}
Object.extend(Event, {
selector: function(selector, eventName, handler, cancel) {
if (cancel) {
CssEventObserver.unregister(selector, eventName,
handler);
return;
}
CssEventObserver.init();
CssEventObserver.register(selector, eventName, handler);
}
});
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---