Skip to content

Instantly share code, notes, and snippets.

@caridy
Created June 22, 2010 16:48
Show Gist options
  • Save caridy/448735 to your computer and use it in GitHub Desktop.
Save caridy/448735 to your computer and use it in GitHub Desktop.
YUI_config = {
// standard YUI_config configuration
combine: true,
filter: 'min',
// event binder configuration starts here
eventbinder: {
// set of options that should be preserved for every event (all optional)
ev: {
ctrlKey: 0,
altKey: 0,
shiftKey: 0,
metaKey: 0,
keyCode: 0,
charCode: 0,
screenX: 0,
screenY: 0,
clientX: 0,
clientY: 0,
button: 0,
relatedTarget: 0
},
// listener callback function
fn: function(e) {
var o = YUI_config.eventbinder,
filter = /yui3-event-binder/, i,
t = (e.target ? e.target: e.srcElement),
p = {
target: t,
type: e.type
},
container = t;
// look for an element with the class yui3-event-binder
while (container && !filter.test(container.className)) {
container = container.parentNode;
}
if (container) {
t.className += ' yui3-waiting';
// back up the event properties to simulate the event later on
for (i in (o.ev || {})) {
if (o.ev.hasOwnProperty(i)) {
p[i] = e[i];
}
}
(o.q = o.q || []).push(p);
// prevent the default browser action for this event
if (e.preventDefault) {
e.preventDefault();
}
return (e.returnValue = false);
}
},
add: function(type) {
var d = document;
if (d.addEventListener) {
d.addEventListener(type, this.fn, false);
}
else {
d.attachEvent('on' + type, this.fn);
}
return this;
}
}
};
// add events to the monitoring process
YUI_config.eventbinder.add('click');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment