-
-
Save dotnetCarpenter/4581556 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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