X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..92c2b89db26be16707f4a805d3303ab2531006e1:/docs/source/Observable.html diff --git a/docs/source/Observable.html b/docs/source/Observable.html index 2309f74c..2640fd6a 100644 --- a/docs/source/Observable.html +++ b/docs/source/Observable.html @@ -1,17 +1,12 @@ - -
-/*! - * Ext JS Library 3.0.3 - * Copyright(c) 2006-2009 Ext JS, LLC - * licensing@extjs.com - * http://www.extjs.com/license - */ -(function(){ + + + ++ \ No newline at end of fileThe source code + + + + +(function(){ var EXTUTIL = Ext.util, TOARRAY = Ext.toArray, @@ -19,7 +14,7 @@ var EXTUTIL = Ext.util, ISOBJECT = Ext.isObject, TRUE = true, FALSE = false; -/** +/** * @class Ext.util.Observable * Base class that provides a common interface for publishing events. Subclasses are expected to * to have a property "events" with all the events defined, and, optionally, a property "listeners" @@ -293,9 +288,11 @@ this.addEvents('storeloaded', 'storecleared'); var me = this; me.events = me.events || {}; if (Ext.isString(o)) { - EACH(arguments, function(a) { - me.events[a] = me.events[a] || TRUE; - }); + var a = arguments, + i = a.length; + while(i--) { + me.events[a[i]] = me.events[a[i]] || TRUE; + } } else { Ext.applyIf(me.events, o); } @@ -376,26 +373,28 @@ function createTargeted(h, o, scope){ }; }; -function createBuffered(h, o, scope){ - var task = new EXTUTIL.DelayedTask(); +function createBuffered(h, o, l, scope){ + l.task = new EXTUTIL.DelayedTask(); return function(){ - task.delay(o.buffer, h, scope, TOARRAY(arguments)); + l.task.delay(o.buffer, h, scope, TOARRAY(arguments)); }; -} +}; function createSingle(h, e, fn, scope){ return function(){ e.removeListener(fn, scope); return h.apply(scope, arguments); }; -} +}; -function createDelayed(h, o, scope){ +function createDelayed(h, o, l, scope){ return function(){ - var args = TOARRAY(arguments); - (function(){ - h.apply(scope, args); - }).defer(o.delay || 10); + var task = new EXTUTIL.DelayedTask(); + if(!l.tasks) { + l.tasks = []; + } + l.tasks.push(task); + task.delay(o.delay || 10, h, scope, TOARRAY(arguments)); }; }; @@ -430,29 +429,33 @@ EXTUTIL.Event.prototype = { h = createTargeted(h, o, scope); } if(o.delay){ - h = createDelayed(h, o, scope); + h = createDelayed(h, o, l, scope); } if(o.single){ h = createSingle(h, this, fn, scope); } if(o.buffer){ - h = createBuffered(h, o, scope); + h = createBuffered(h, o, l, scope); } l.fireFn = h; return l; }, findListener : function(fn, scope){ - var s, ret = -1; - EACH(this.listeners, function(l, i) { - s = l.scope; - if(l.fn == fn && (s == scope || s == this.obj)){ - ret = i; - return FALSE; + var list = this.listeners, + i = list.length, + l, + s; + while(i--) { + l = list[i]; + if(l) { + s = l.scope; + if(l.fn == fn && (s == scope || s == this.obj)){ + return i; + } } - }, - this); - return ret; + } + return -1; }, isListening : function(fn, scope){ @@ -461,37 +464,63 @@ EXTUTIL.Event.prototype = { removeListener : function(fn, scope){ var index, + l, + k, me = this, ret = FALSE; if((index = me.findListener(fn, scope)) != -1){ if (me.firing) { me.listeners = me.listeners.slice(0); } + l = me.listeners[index]; + if(l.task) { + l.task.cancel(); + delete l.task; + } + k = l.tasks && l.tasks.length; + if(k) { + while(k--) { + l.tasks[k].cancel(); + } + delete l.tasks; + } me.listeners.splice(index, 1); ret = TRUE; } return ret; }, + // Iterate to stop any buffered/delayed events clearListeners : function(){ - this.listeners = []; + var me = this, + l = me.listeners, + i = l.length; + while(i--) { + me.removeListener(l[i].fn, l[i].scope); + } }, fire : function(){ var me = this, args = TOARRAY(arguments), - ret = TRUE; + listeners = me.listeners, + len = listeners.length, + i = 0, + l; - EACH(me.listeners, function(l) { + if(len > 0){ me.firing = TRUE; - if (l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) { - return ret = me.firing = FALSE; + for (; i < len; i++) { + l = listeners[i]; + if(l && l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) { + return (me.firing = FALSE); + } } - }); + } me.firing = FALSE; - return ret; + return TRUE; } }; -})();- +})();