日期:2014-05-16 浏览次数:20327 次
var E = Ext.lib.Event; Ext.EventObjectImpl = function(e){ if(e){ this.setEvent(e.browserEvent || e);//注意这里 } }
Ext.EventObjectImpl.prototype = { /** @private */ setEvent : function(e){ var me = this; if(e == me || (e && e.browserEvent)){ // already wrapped return e; } me.browserEvent = e; if(e){ // normalize buttons me.button = e.button ? btnMap[e.button] : (e.which ? e.which - 1 : -1); if(e.type == 'click' && me.button == -1){ me.button = 0; } me.type = e.type; me.shiftKey = e.shiftKey; // mac metaKey behaves like ctrlKey me.ctrlKey = e.ctrlKey || e.metaKey || false; me.altKey = e.altKey; // in getKey these will be normalized for the mac me.keyCode = e.keyCode; me.charCode = e.charCode; // cache the target for the delayed and or buffered events me.target = E.getTarget(e); // same for XY me.xy = E.getXY(e); }else{ me.button = -1; me.shiftKey = false; me.ctrlKey = false; me.altKey = false; me.keyCode = 0; me.charCode = 0; me.target = null; me.xy = [0, 0]; } return me; } }
Ext.EventObject = function(){ var E = Ext.lib.Event, // safari keypress events for special keys return bad keycodes safariKeys = { }, // normalize button clicks btnMap = Ext.isIE ? {1:0,4:1,2:2} : (Ext.isWebKit ? {1:0,2:1,3:2} : {0:0,1:1,2:2}); Ext.EventObjectImpl = function(e){ if(e){ this.setEvent(e.browserEvent || e); } }; Ext.EventObjectImpl.prototype = { /** @private */ setEvent : function(e){ }, 。。。。。。。。 } return new Ext.EventObjectImpl(); }
Ext.EventManager = function(){ var .......//一堆变量/常量的定义 E = Ext.lib.Event,//这俩个变量要注意 D = Ext.lib.Dom,// ..............////一堆变量/常量的定义 //接下来一堆的 function ...................... //接下来是返回对象,也就是这个对象为外部提供接口 var pub = { addListener : function(element, eventName, fn, scope, options){}, removeListener : function(el, eventName, fn, scope){}, removeAll : function(el){}, getListeners : function(el, eventName) {}, purgeElement : function(el, recurse, eventName) {}, _unload : function() {}, onDocumentReady : function(fn, scope, options){} }; pub.stoppedMouseDownEvent = new Ext.util.Event(); return pub; }