Created
February 7, 2011 19:38
-
-
Save rixth/815030 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
// Cache element clicks | |
(function () { | |
var eventTypes = ['click'], | |
eventStack = [], | |
handler = function(event) { | |
document.getElementById('debug').innerHTML += "Caching event\n"; | |
eventStack.push(event); | |
}; | |
eventTypes.forEach(function (eventType) { | |
document.body.addEventListener(eventType, handler, true); | |
}); | |
window.addEventListener('DOMContentLoaded', function() { | |
eventTypes.forEach(function (eventType) { | |
document.body.removeEventListener(eventType, handler, true); | |
}); | |
eventStack.forEach(function (event) { | |
console.log('Firing', event); | |
event.target.dispatchEvent(event); | |
}); | |
}, false); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment