Skip to content

Instantly share code, notes, and snippets.

@dotnetCarpenter
Forked from jed/LICENSE.txt
Created January 20, 2013 20:38
Show Gist options
  • Save dotnetCarpenter/4581556 to your computer and use it in GitHub Desktop.
Save dotnetCarpenter/4581556 to your computer and use it in GitHub Desktop.
function(
a, // A DOM element
b, // an event name such as "click"
c, // a handler function
d // (placeholder)
){
a = a || document; // use the document by default
d = a[ // save the current onevent handler
b = "on" + b // prepend the event name with "on"
];
b = a[b] = // cache and replace the current handler
function(e) { // with a function that
d = d && d( // executes/caches the previous handler
e = e || a.event // with a cross-browser object,
);
return (c = c && b(e)) // and executes/caches the passed function,
? b // returning the current handler if it rebinds
: d // and the previous handler otherwise.
};
a = this // cache the window to fetch IE events
}
function(a,b,c,d){a=a||document;d=a[b="on"+b];b=a[b]=function(e){d=d&&d(e=e||a.event);return(c=c&&b(e))?b:d};a=this}
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Jed Schmidt <http://jed.is>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
{
"name": "on",
"keywords": ["bind", "events", "event", "DOM"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment