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.0
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() {
111 tryAgain = !loadComplete || (retryCount > 0);
116 for (i = 0, len = onAvailStack.length; i < len; i++) {
118 if(v && (element = doc.getElementById(v.id))){
119 if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
120 element = v.override ? (v.override === true ? v.obj : v.override) : element;
121 v.fn.call(element, v.obj);
122 onAvailStack.remove(v);
129 retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
134 clearInterval(_interval);
138 ret = !(locked = false);
144 function startInterval() {
146 var callback = function() {
149 _interval = setInterval(callback, POLL_INTERVAL);
154 function getScroll() {
155 var dd = doc.documentElement,
157 if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
158 return [dd[SCROLLLEFT], dd[SCROLLTOP]];
160 return [db[SCROLLLEFT], db[SCROLLTOP]];
167 function getPageCoord (ev, xy) {
168 ev = ev.browserEvent || ev;
169 var coord = ev['page' + xy];
170 if (!coord && coord !== 0) {
171 coord = ev['client' + xy] || 0;
174 coord += getScroll()[xy == "X" ? 0 : 1];
183 onAvailable : function(p_id, p_fn, p_obj, p_override) {
188 override: p_override,
189 checkReady: false });
191 retryCount = POLL_RETRYS;
195 // This function should ALWAYS be called from Ext.EventManager
196 addListener: function(el, eventName, fn) {
199 if (eventName == UNLOAD) {
200 if (unloadListeners[el.id] === undefined) {
201 unloadListeners[el.id] = [];
203 unloadListeners[el.id].push([eventName, fn]);
206 return doAdd(el, eventName, fn, false);
211 // This function should ALWAYS be called from Ext.EventManager
212 removeListener: function(el, eventName, fn) {
216 if(eventName == UNLOAD){
217 if((lis = unloadListeners[el.id]) !== undefined){
218 for(i = 0, len = lis.length; i < len; i++){
219 if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
220 unloadListeners[el.id].splice(i, 1);
226 doRemove(el, eventName, fn, false);
230 getTarget : function(ev) {
231 ev = ev.browserEvent || ev;
232 return this.resolveTextNode(ev.target || ev.srcElement);
235 resolveTextNode : Ext.isGecko ? function(node){
239 // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
240 var s = HTMLElement.prototype.toString.call(node);
241 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
244 return node.nodeType == 3 ? node.parentNode : node;
246 return node && node.nodeType == 3 ? node.parentNode : node;
249 getRelatedTarget : function(ev) {
250 ev = ev.browserEvent || ev;
251 return this.resolveTextNode(ev.relatedTarget ||
252 (ev.type == MOUSEOUT ? ev.toElement :
253 ev.type == MOUSEOVER ? ev.fromElement : null));
256 getPageX : function(ev) {
257 return getPageCoord(ev, "X");
260 getPageY : function(ev) {
261 return getPageCoord(ev, "Y");
265 getXY : function(ev) {
266 return [this.getPageX(ev), this.getPageY(ev)];
269 stopEvent : function(ev) {
270 this.stopPropagation(ev);
271 this.preventDefault(ev);
274 stopPropagation : function(ev) {
275 ev = ev.browserEvent || ev;
276 if (ev.stopPropagation) {
277 ev.stopPropagation();
279 ev.cancelBubble = true;
283 preventDefault : function(ev) {
284 ev = ev.browserEvent || ev;
285 if (ev.preventDefault) {
288 ev.returnValue = false;
292 getEvent : function(e) {
295 var c = this.getEvent.caller;
298 if (e && Event == e.constructor) {
307 getCharCode : function(ev) {
308 ev = ev.browserEvent || ev;
309 return ev.charCode || ev.keyCode || 0;
312 //clearCache: function() {},
313 // deprecated, call from EventManager
314 getListeners : function(el, eventName) {
315 Ext.EventManager.getListeners(el, eventName);
318 // deprecated, call from EventManager
319 purgeElement : function(el, recurse, eventName) {
320 Ext.EventManager.purgeElement(el, recurse, eventName);
323 _load : function(e) {
325 var EU = Ext.lib.Event;
326 if (Ext.isIE && e !== true) {
327 // IE8 complains that _load is null or not an object
328 // so lets remove self via arguments.callee
329 doRemove(win, "load", arguments.callee);
333 _unload : function(e) {
334 var EU = Ext.lib.Event,
335 i, j, l, v, ul, id, len, index, scope;
338 for (id in unloadListeners) {
339 ul = unloadListeners[id];
340 for (i = 0, len = ul.length; i < len; i++) {
344 scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win;
345 v[FN].call(scope, EU.getEvent(e), v[OBJ]);
351 Ext.EventManager._unload();
353 doRemove(win, UNLOAD, EU._unload);
358 pub.on = pub.addListener;
359 pub.un = pub.removeListener;
360 if (doc && doc.body) {
363 doAdd(win, "load", pub._load);
365 doAdd(win, UNLOAD, pub._unload);