};\r
\r
/// There is some jquery work around stuff here that isn't needed in Ext Core.\r
- function addListener(el, ename, fn, wrap, scope){\r
+ function addListener(el, ename, fn, task, wrap, scope){\r
el = Ext.getDom(el);\r
var id = getId(el),\r
es = Ext.elCache[id].events,\r
\r
wfn = E.on(el, ename, wrap);\r
es[ename] = es[ename] || [];\r
- es[ename].push([fn, wrap, scope, wfn]);\r
+\r
+ /* 0 = Original Function,\r
+ 1 = Event Manager Wrapped Function,\r
+ 2 = Scope,\r
+ 3 = Adapter Wrapped Function,\r
+ 4 = Buffered Task\r
+ */\r
+ es[ename].push([fn, wrap, scope, wfn, task]);\r
\r
// this is a workaround for jQuery and should somehow be removed from Ext Core in the future\r
// without breaking ExtJS.\r
- if(ename == "mousewheel" && el.addEventListener){ // workaround for jQuery\r
+\r
+ // workaround for jQuery\r
+ if(el.addEventListener && ename == "mousewheel"){\r
var args = ["DOMMouseScroll", wrap, false];\r
el.addEventListener.apply(el, args);\r
Ext.EventManager.addListener(WINDOW, 'unload', function(){\r
el.removeEventListener.apply(el, args);\r
});\r
}\r
- if(ename == "mousedown" && el == document){ // fix stopped mousedowns on the document\r
+\r
+ // fix stopped mousedowns on the document\r
+ if(el == DOC && ename == "mousedown"){\r
Ext.EventManager.stoppedMouseDownEvent.addListener(wrap);\r
}\r
};\r
};\r
};\r
\r
- function createBuffered(h, o, fn){\r
- fn.task = new Ext.util.DelayedTask(h);\r
- var w = function(e){\r
+ function createBuffered(h, o, task){\r
+ return function(e){\r
// create new event object impl so new events don't wipe out properties\r
- fn.task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);\r
+ task.delay(o.buffer, h, null, [new Ext.EventObjectImpl(e)]);\r
};\r
- return w;\r
};\r
\r
function createSingle(h, el, ename, fn, scope){\r
\r
function listen(element, ename, opt, fn, scope){\r
var o = !Ext.isObject(opt) ? {} : opt,\r
- el = Ext.getDom(element);\r
+ el = Ext.getDom(element), task;\r
\r
fn = fn || o.fn;\r
scope = scope || o.scope;\r
h = createSingle(h, el, ename, fn, scope);\r
}\r
if(o.buffer){\r
- h = createBuffered(h, o, fn);\r
+ task = new Ext.util.DelayedTask(h);\r
+ h = createBuffered(h, o, task);\r
}\r
\r
- addListener(el, ename, fn, h, scope);\r
+ addListener(el, ename, fn, task, h, scope);\r
return h;\r
};\r
\r
el = Ext.getDom(el);\r
var id = getId(el),\r
f = el && (Ext.elCache[id].events)[eventName] || [],\r
- wrap, i, l, k, wf;\r
+ wrap, i, l, k, len, fnc;\r
\r
for (i = 0, len = f.length; i < len; i++) {\r
- if (Ext.isArray(f[i]) && f[i][0] == fn && (!scope || f[i][2] == scope)) {\r
- if(fn.task) {\r
- fn.task.cancel();\r
- delete fn.task;\r
+\r
+ /* 0 = Original Function,\r
+ 1 = Event Manager Wrapped Function,\r
+ 2 = Scope,\r
+ 3 = Adapter Wrapped Function,\r
+ 4 = Buffered Task\r
+ */\r
+ if (Ext.isArray(fnc = f[i]) && fnc[0] == fn && (!scope || fnc[2] == scope)) {\r
+ if(fnc[4]) {\r
+ fnc[4].cancel();\r
}\r
k = fn.tasks && fn.tasks.length;\r
if(k) {\r
}\r
delete fn.tasks;\r
}\r
- wf = wrap = f[i][1];\r
- if (E.extAdapter) {\r
- wf = f[i][3];\r
+ wrap = fnc[1];\r
+ E.un(el, eventName, E.extAdapter ? fnc[3] : wrap);\r
+\r
+ // jQuery workaround that should be removed from Ext Core\r
+ if(wrap && el.addEventListener && eventName == "mousewheel"){\r
+ el.removeEventListener("DOMMouseScroll", wrap, false);\r
+ }\r
+\r
+ // fix stopped mousedowns on the document\r
+ if(wrap && el == DOC && eventName == "mousedown"){\r
+ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);\r
}\r
- E.un(el, eventName, wf);\r
- f.splice(i,1);\r
+\r
+ f.splice(i, 1);\r
if (f.length === 0) {\r
delete Ext.elCache[id].events[eventName];\r
}\r
return false;\r
}\r
}\r
-\r
- // jQuery workaround that should be removed from Ext Core\r
- if(eventName == "mousewheel" && el.addEventListener && wrap){\r
- el.removeEventListener("DOMMouseScroll", wrap, false);\r
- }\r
-\r
- if(eventName == "mousedown" && el == DOC && wrap){ // fix stopped mousedowns on the document\r
- Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);\r
- }\r
},\r
\r
<div id="method-Ext.EventManager-removeAll"></div>/**\r
var id = getId(el),\r
ec = Ext.elCache[id] || {},\r
es = ec.events || {},\r
- f, i, len, ename, fn, k;\r
+ f, i, len, ename, fn, k, wrap;\r
\r
for(ename in es){\r
if(es.hasOwnProperty(ename)){\r
f = es[ename];\r
+ /* 0 = Original Function,\r
+ 1 = Event Manager Wrapped Function,\r
+ 2 = Scope,\r
+ 3 = Adapter Wrapped Function,\r
+ 4 = Buffered Task\r
+ */\r
for (i = 0, len = f.length; i < len; i++) {\r
- fn = f[i][0];\r
- if(fn.task) {\r
- fn.task.cancel();\r
- delete fn.task;\r
+ fn = f[i];\r
+ if(fn[4]) {\r
+ fn[4].cancel();\r
}\r
- if(fn.tasks && (k = fn.tasks.length)) {\r
+ if(fn[0].tasks && (k = fn[0].tasks.length)) {\r
while(k--) {\r
- fn.tasks[k].cancel();\r
+ fn[0].tasks[k].cancel();\r
}\r
delete fn.tasks;\r
}\r
- E.un(el, ename, E.extAdapter ? f[i][3] : f[i][1]);\r
+ wrap = fn[1];\r
+ E.un(el, ename, E.extAdapter ? fn[3] : wrap);\r
+\r
+ // jQuery workaround that should be removed from Ext Core\r
+ if(el.addEventListener && wrap && ename == "mousewheel"){\r
+ el.removeEventListener("DOMMouseScroll", wrap, false);\r
+ }\r
+\r
+ // fix stopped mousedowns on the document\r
+ if(wrap && el == DOC && ename == "mousedown"){\r
+ Ext.EventManager.stoppedMouseDownEvent.removeListener(wrap);\r
+ }\r
}\r
}\r
}\r
for (el in Ext.elCache) {\r
Ext.EventManager.removeAll(el);\r
}\r
+ delete Ext.elCache;\r
+ delete Ext.Element._flyweights;\r
},\r
<div id="method-Ext.EventManager-onDocumentReady"></div>/**\r
* Adds a listener to be notified when the document is ready (before onload and before images are loaded). Can be\r
\r
return new Ext.EventObjectImpl();\r
}();\r
-\r
</pre> \r
</body>\r
</html>
\ No newline at end of file