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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 Ext.lib.Event = function() {
16 var loadComplete = false,
32 SCROLLLEFT = 'scrollLeft',
33 SCROLLTOP = 'scrollTop',
35 MOUSEOVER = 'mouseover',
36 MOUSEOUT = 'mouseout',
40 if (win.addEventListener) {
41 ret = function(el, eventName, fn, capture) {
42 if (eventName == 'mouseenter') {
43 fn = fn.createInterceptor(checkRelatedTarget);
44 el.addEventListener(MOUSEOVER, fn, (capture));
45 } else if (eventName == 'mouseleave') {
46 fn = fn.createInterceptor(checkRelatedTarget);
47 el.addEventListener(MOUSEOUT, fn, (capture));
49 el.addEventListener(eventName, fn, (capture));
53 } else if (win.attachEvent) {
54 ret = function(el, eventName, fn, capture) {
55 el.attachEvent("on" + eventName, fn);
64 doRemove = function(){
66 if (win.removeEventListener) {
67 ret = function (el, eventName, fn, capture) {
68 if (eventName == 'mouseenter') {
69 eventName = MOUSEOVER;
70 } else if (eventName == 'mouseleave') {
73 el.removeEventListener(eventName, fn, (capture));
75 } else if (win.detachEvent) {
76 ret = function (el, eventName, fn) {
77 el.detachEvent("on" + eventName, fn);
85 function checkRelatedTarget(e) {
86 return !elContains(e.currentTarget, pub.getRelatedTarget(e));
89 function elContains(parent, child) {
90 if(parent && parent.firstChild){
92 if(child === parent) {
95 child = child.parentNode;
96 if(child && (child.nodeType != 1)) {
105 function _tryPreloadAttach() {
108 element, i, v, override,
109 tryAgain = !loadComplete || (retryCount > 0);
114 for(i = 0; i < onAvailStack.length; ++i){
116 if(v && (element = doc.getElementById(v.id))){
117 if(!v.checkReady || loadComplete || element.nextSibling || (doc && doc.body)) {
118 override = v.override;
119 element = override ? (override === true ? v.obj : override) : element;
120 v.fn.call(element, v.obj);
121 onAvailStack.remove(v);
129 retryCount = (notAvail.length === 0) ? 0 : retryCount - 1;
134 clearInterval(_interval);
137 ret = !(locked = false);
143 function startInterval() {
145 var callback = function() {
148 _interval = setInterval(callback, POLL_INTERVAL);
153 function getScroll() {
154 var dd = doc.documentElement,
156 if(dd && (dd[SCROLLTOP] || dd[SCROLLLEFT])){
157 return [dd[SCROLLLEFT], dd[SCROLLTOP]];
159 return [db[SCROLLLEFT], db[SCROLLTOP]];
166 function getPageCoord (ev, xy) {
167 ev = ev.browserEvent || ev;
168 var coord = ev['page' + xy];
169 if (!coord && coord !== 0) {
170 coord = ev['client' + xy] || 0;
173 coord += getScroll()[xy == "X" ? 0 : 1];
182 onAvailable : function(p_id, p_fn, p_obj, p_override) {
187 override: p_override,
188 checkReady: false });
190 retryCount = POLL_RETRYS;
194 // This function should ALWAYS be called from Ext.EventManager
195 addListener: function(el, eventName, fn) {
198 if (eventName == UNLOAD) {
199 if (unloadListeners[el.id] === undefined) {
200 unloadListeners[el.id] = [];
202 unloadListeners[el.id].push([eventName, fn]);
205 return doAdd(el, eventName, fn, false);
210 // This function should ALWAYS be called from Ext.EventManager
211 removeListener: function(el, eventName, fn) {
215 if(eventName == UNLOAD){
216 if((lis = unloadListeners[el.id]) !== undefined){
217 for(i = 0, len = lis.length; i < len; i++){
218 if((li = lis[i]) && li[TYPE] == eventName && li[FN] == fn){
219 unloadListeners[el.id].splice(i, 1);
225 doRemove(el, eventName, fn, false);
229 getTarget : function(ev) {
230 ev = ev.browserEvent || ev;
231 return this.resolveTextNode(ev.target || ev.srcElement);
234 resolveTextNode : Ext.isGecko ? function(node){
238 // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
239 var s = HTMLElement.prototype.toString.call(node);
240 if(s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]'){
243 return node.nodeType == 3 ? node.parentNode : node;
245 return node && node.nodeType == 3 ? node.parentNode : node;
248 getRelatedTarget : function(ev) {
249 ev = ev.browserEvent || ev;
250 return this.resolveTextNode(ev.relatedTarget ||
251 (/(mouseout|mouseleave)/.test(ev.type) ? ev.toElement :
252 /(mouseover|mouseenter)/.test(ev.type) ? ev.fromElement : null));
255 getPageX : function(ev) {
256 return getPageCoord(ev, "X");
259 getPageY : function(ev) {
260 return getPageCoord(ev, "Y");
264 getXY : function(ev) {
265 return [this.getPageX(ev), this.getPageY(ev)];
268 stopEvent : function(ev) {
269 this.stopPropagation(ev);
270 this.preventDefault(ev);
273 stopPropagation : function(ev) {
274 ev = ev.browserEvent || ev;
275 if (ev.stopPropagation) {
276 ev.stopPropagation();
278 ev.cancelBubble = true;
282 preventDefault : function(ev) {
283 ev = ev.browserEvent || ev;
284 if (ev.preventDefault) {
287 ev.returnValue = false;
291 getEvent : function(e) {
294 var c = this.getEvent.caller;
297 if (e && Event == e.constructor) {
306 getCharCode : function(ev) {
307 ev = ev.browserEvent || ev;
308 return ev.charCode || ev.keyCode || 0;
311 //clearCache: function() {},
312 // deprecated, call from EventManager
313 getListeners : function(el, eventName) {
314 Ext.EventManager.getListeners(el, eventName);
317 // deprecated, call from EventManager
318 purgeElement : function(el, recurse, eventName) {
319 Ext.EventManager.purgeElement(el, recurse, eventName);
322 _load : function(e) {
325 if (Ext.isIE && e !== true) {
326 // IE8 complains that _load is null or not an object
327 // so lets remove self via arguments.callee
328 doRemove(win, "load", arguments.callee);
332 _unload : function(e) {
333 var EU = Ext.lib.Event,
334 i, v, ul, id, len, scope;
336 for (id in unloadListeners) {
337 ul = unloadListeners[id];
338 for (i = 0, len = ul.length; i < len; i++) {
342 scope = v[ADJ_SCOPE] ? (v[ADJ_SCOPE] === true ? v[OBJ] : v[ADJ_SCOPE]) : win;
343 v[FN].call(scope, EU.getEvent(e), v[OBJ]);
349 Ext.EventManager._unload();
351 doRemove(win, UNLOAD, EU._unload);
356 pub.on = pub.addListener;
357 pub.un = pub.removeListener;
358 if (doc && doc.body) {
361 doAdd(win, "load", pub._load);
363 doAdd(win, UNLOAD, pub._unload);