Event is the standard dom-events wrapper in RightJS. It provides a cross-browser interface to deal with common dom-events related operations, plus it has several w3c style properties
include, find, offset, position, preventDefault, stop, stopPropagation
Event.include(Object methods[, boolean dont_rewrite])
Registers additional methods for the DOM events.
Event.include({
myMethod: function() {....}
});
$('my_element').onClick(function(event) {
event.myMethod()
});
find(String css_rule) -> Element
This method finds the first matching element between the element that triggered the event and the one where the event listener was attached.
/*
<div id="first">
<div id="second">
<div id="third"></div>
</div>
</div>
*/
$('first').onClick(function(event) {
event.find('div#second');
});
$('third').fire('click');
offset() -> {
x: NNN, y: NNN}
Returns the current cursor position relatively to the target element (useful for handling relatively positioned elements within the target element)
$(
'element').onMousemove(function(event) {
$('relative-element').moveTo(event.offset());
});
position() -> {
x: NNN, y: NNN}
Returns the current event position.
$(
'element').onMouseover(function(event) {
$('nice-looking-title').show().moveTo(event.position());
});