On Thu, Jun 15, 2006 at 02:26:37PM -0600, Gregory Hill wrote:
# This is obviously rough draft and not thoroughly tested, but it seems to
# work. If you'd like, give it a try (load it after you load
# prototype.js):
#
#
# Function.prototype.bindAsEventListener = function(object) {
# var __method = this;
# return function(event) {
# return __method.call(object, new SuperEvent(event || window.event));
# }
# }
#
# var SuperEvent = Class.create();
# Object.extend(SuperEvent.prototype, {
# initialize: function (event) {
# for (attr in event) {
# this[attr] = event[attr];
# }
# this.target = Event.element(event);
# this.srcElement = Event.element(event);
# this.which = event.which || event.button;
# this.button = event.button || event.which;
# this.pageX = Event.pointerX(event);
# this.pageY = Event.pointerY(event);
# this.clientX = this.pageX - (document.documentElement.scrollLeft
# || document.body.scrollLeft);
# this.clientY = this.pageY - (document.documentElement.scrollTop
# || document.body.scrollTop);
# this.preventDefault = Event.stop.bind(Event, event);
# this.stopPropagation = Event.stop.bind(Event, event);
# }
# } );
#
# There are probably more things that would need to be addressed; I just
# based this off of what functionality was in prototype 'cause I believe
# most of the remaining attributes/functions work cross-browser already
# (and should be inherited in the for attr in event loop).
#
# This is obviously less efficient since it gathers data for every bound
# event, despite whether you use it or not. But, it will let you call
# IE-specific event functions in Firefox, so long as you still bound the
# events using the bindAsEventListener function.
Seems to work great! Can I use that code in my project? My eventual
hope is to release the project under the GPLv2.
Thanks!
-Sam
_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs