QEvent??- a powerful tiny extensible standalone event library for elements and objects
?? -QEvent 为个元素及对象提供一个强大的可扩展的事件库
????* lightweight footprint
????* no namespace pollution – everything is wrapped in obj.$QEvent
????* normalizes the DOM event model
????* prevents repeated registration of same type and listener
????* ‘this’ in listeners references to object or element itself
????* fixes window ‘beforeunload’ issue (doesn’t work in Opera)
????* fixes window ‘unload’ (must be removed by itself)
????* fixes focus and blur events
????* DOM events are more extendable: event keys, event objects ( event.myCustomFn() ), custom events
????* firing events works for elements
????* toggled and flashed events (removed after first fire)
????* tested on (IE6-7, Firefox2/3, Safari, Opera, Chrome)
These custom events are included, view source to see how to create them.
????* mouseenter, mouseleave
????* beforeunload – doesnt work in Opera
????* clickout – also example to see how to attach custom DOM event
Why another library?
Good question. Several reasons.
????* Occasionally, I need a lightweight library that will work with other frameworks. Frameworks such as jQuery which don’t extend the native prototype and therefor have no compatibility issues are not modular enough to meet my needs.
????* No event implementation is perfect. So I took my own approach to the issue and created my dream package.
????* This implementation could serve as a model for others.
License: MIT-style license. Copyright: Copyright (c) 2008 Daniel Steigerwald, email@example.com
????* Some ideas and snippets have been taken from Mootools (see source for details).
????* There is also one potential leak for IE. If load event is not fired, also unload will not be fired too. This may be fixed in the future.