webui-aria2/js/libs/dojo/_base/event.js.uncompressed.js
2012-05-01 19:52:07 +08:00

53 lines
1.4 KiB
JavaScript

//>>built
define("dojo/_base/event", ["./kernel", "../on", "../has", "../dom-geometry"], function(dojo, on, has, dom){
// module:
// dojo/_base/event
// summary:
// This module defines dojo DOM event API.
if(on._fixEvent){
var fixEvent = on._fixEvent;
on._fixEvent = function(evt, se){
// add some additional normalization for back-compat, this isn't in on.js because it is somewhat more expensive
evt = fixEvent(evt, se);
if(evt){
dom.normalizeEvent(evt);
}
return evt;
};
}
dojo.fixEvent = function(/*Event*/ evt, /*DOMNode*/ sender){
// summary:
// normalizes properties on the event object including event
// bubbling methods, keystroke normalization, and x/y positions
// evt: Event
// native event object
// sender: DOMNode
// node to treat as "currentTarget"
if(on._fixEvent){
return on._fixEvent(evt, sender);
}
return evt; // Event
};
dojo.stopEvent = function(/*Event*/ evt){
// summary:
// prevents propagation and clobbers the default action of the
// passed event
// evt: Event
// The event object. If omitted, window.event is used on IE.
if(has("dom-addeventlistener") || (evt && evt.preventDefault)){
evt.preventDefault();
evt.stopPropagation();
}else{
evt = evt || window.event;
evt.cancelBubble = true;
on._preventDefault.call(evt);
}
};
return {
fix: dojo.fixEvent,
stop: dojo.stopEvent
};
});