3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 Ext.lib.Event = function() {
16 var loadComplete = false,
34 SCROLLLEFT = 'scrollLeft',
35 SCROLLTOP = 'scrollTop',
37 MOUSEOVER = 'mouseover',
38 MOUSEOUT = 'mouseout',
42 if (win.addEventListener) {
43 ret = function(el, eventName, fn, capture) {
44 if (eventName == 'mouseenter') {
45 fn = fn.createInterceptor(checkRelatedTarget);
46 el.addEventListener(MOUSEOVER, fn, (capture));
47 } else if (eventName == 'mouseleave') {
48 fn = fn.createInterceptor(checkRelatedTarget);
49 el.addEventListener(MOUSEOUT, fn, (capture));
51 el.addEventListener(eventName, fn, (capture));
55 } else if (win.attachEvent) {
56 ret = function(el, eventName, fn, capture) {
57 el.attachEvent("on" + eventName, fn);
66 doRemove = function(){
68 if (win.removeEventListener) {
69 ret = function (el, eventName, fn, capture) {
70 if (eventName == 'mouseenter') {
71 eventName = MOUSEOVER;
72 } else if (eventName == 'mouseleave') {
75 el.removeEventListener(eventName, fn, (capture));
77 } else if (win.detachEvent) {
78 ret = function (el, eventName, fn) {
79 el.detachEvent("on" + eventName, fn);
87 function checkRelatedTarget(e) {
88 return !elContains(e.currentTarget, pub.getRelatedTarget(e));
91 function elContains(parent, child) {
92 if(parent && parent.firstChild){
94 if(child === parent) {
97 child = child.parentNode;
98 if(child && (child.nodeType != 1)) {
107 function _tryPreloadAttach() {
110 element, i, v, override,
111 tryAgain = !loadComplete || (retryCount > 0);
116 for(i = 0; i < onAvailStack.length; ++i){
118 if(v && (element = doc.getElementById(v.id))){
119 if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
120 override = v.override;
121 element = override ? (override === true ? v.obj : override) : element;
122 v.fn.call(element, v.obj);
123 onAvailStack.remove(v);
131 retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
136 clearInterval(_interval);
139 ret = !(locked = false);
145 function startInterval() {
147 var callback = function() {
150 _interval = setInterval(callback, POLL_INTERVAL);
155 function getScroll() {
156 var dd = doc.documentElement,
158 if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
159 return [dd[SCROLLLEFT], dd[SCROLLTOP]];
161 return [db[SCROLLLEFT], db[SCROLLTOP]];
168 function getPageCoord (ev, xy) {
169 ev = ev.browserEvent || ev;
170 var coord = ev['page' + xy];
171 if (!coord && coord !== 0) {
172 coord = ev['client' + xy] || 0;
175 coord += getScroll()[xy == "X" ? 0 : 1];
184 onAvailable : function(p_id, p_fn, p_obj, p_override) {
189 override: p_override,
190 checkReady: false });
192 retryCount = POLL_RETRYS;
196 // This function should ALWAYS be called from Ext.EventManager
197 addListener: function(el, eventName, fn) {
200 if (eventName == UNLOAD) {
201 if (unloadListeners[el.id] === undefined) {
202 unloadListeners[el.id] = [];
204 unloadListeners[el.id].push([eventName, fn]);
207 return doAdd(el, eventName, fn, false);
212 // This function should ALWAYS be called from Ext.EventManager
213 removeListener: function(el, eventName, fn) {
217 if(eventName == UNLOAD){
218 if((lis = unloadListeners[el.id]) !== undefined){
219 for(i = 0, len = lis.length; i < len; i++){
220 if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
221 unloadListeners[el.id].splice(i, 1);
227 doRemove(el, eventName, fn, false);
231 getTarget : function(ev) {
232 ev = ev.browserEvent || ev;
233 return this.resolveTextNode(ev.target || ev.srcElement);
236 resolveTextNode : Ext.isGecko ? function(node){
240 // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
241 var s = HTMLElement.prototype.toString.call(node);
242 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
245 return node.nodeType == 3 ? node.parentNode : node;
247 return node && node.nodeType == 3 ? node.parentNode : node;
250 getRelatedTarget : function(ev) {
251 ev = ev.browserEvent || ev;
252 return this.resolveTextNode(ev.relatedTarget ||
253 (ev.type == MOUSEOUT ? ev.toElement :
254 ev.type == MOUSEOVER ? ev.fromElement : null));
257 getPageX : function(ev) {
258 return getPageCoord(ev, "X");
261 getPageY : function(ev) {
262 return getPageCoord(ev, "Y");
266 getXY : function(ev) {
267 return [this.getPageX(ev), this.getPageY(ev)];
270 stopEvent : function(ev) {
271 this.stopPropagation(ev);
272 this.preventDefault(ev);
275 stopPropagation : function(ev) {
276 ev = ev.browserEvent || ev;
277 if (ev.stopPropagation) {
278 ev.stopPropagation();
280 ev.cancelBubble = true;
284 preventDefault : function(ev) {
285 ev = ev.browserEvent || ev;
286 if (ev.preventDefault) {
289 ev.returnValue = false;
293 getEvent : function(e) {
296 var c = this.getEvent.caller;
299 if (e && Event == e.constructor) {
308 getCharCode : function(ev) {
309 ev = ev.browserEvent || ev;
310 return ev.charCode || ev.keyCode || 0;
313 //clearCache: function() {},
314 // deprecated, call from EventManager
315 getListeners : function(el, eventName) {
316 Ext.EventManager.getListeners(el, eventName);
319 // deprecated, call from EventManager
320 purgeElement : function(el, recurse, eventName) {
321 Ext.EventManager.purgeElement(el, recurse, eventName);
324 _load : function(e) {
326 var EU = Ext.lib.Event;
327 if (Ext.isIE && e !== true) {
328 // IE8 complains that _load is null or not an object
329 // so lets remove self via arguments.callee
330 doRemove(win, "load", arguments.callee);
334 _unload : function(e) {
335 var EU = Ext.lib.Event,
336 i, j, l, v, ul, id, len, index, scope;
339 for (id in unloadListeners) {
340 ul = unloadListeners[id];
341 for (i = 0, len = ul.length; i < len; i++) {
345 scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win;
346 v[FN].call(scope, EU.getEvent(e), v[OBJ]);
352 Ext.EventManager._unload();
354 doRemove(win, UNLOAD, EU._unload);
359 pub.on = pub.addListener;
360 pub.un = pub.removeListener;
361 if (doc && doc.body) {
364 doAdd(win, "load", pub._load);
366 doAdd(win, UNLOAD, pub._unload);