X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..10a866c12701c0a0afd0ac85dcdcf32a421514ac:/docs/source/Observable.html diff --git a/docs/source/Observable.html b/docs/source/Observable.html index 2309f74c..8f351aef 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, @@ -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,10 +373,10 @@ function createTargeted(h, o, scope){ }; }; -function createBuffered(h, o, scope){ - var task = new EXTUTIL.DelayedTask(); +function createBuffered(h, o, fn, scope){ + fn.task = new EXTUTIL.DelayedTask(); return function(){ - task.delay(o.buffer, h, scope, TOARRAY(arguments)); + fn.task.delay(o.buffer, h, scope, TOARRAY(arguments)); }; } @@ -390,12 +387,14 @@ function createSingle(h, e, fn, scope){ }; } -function createDelayed(h, o, scope){ +function createDelayed(h, o, fn, scope){ return function(){ - var args = TOARRAY(arguments); - (function(){ - h.apply(scope, args); - }).defer(o.delay || 10); + var task = new EXTUTIL.DelayedTask(); + if(!fn.tasks) { + fn.tasks = []; + } + fn.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, fn, scope); } if(o.single){ h = createSingle(h, this, fn, scope); } if(o.buffer){ - h = createBuffered(h, o, scope); + h = createBuffered(h, o, fn, 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,65 @@ 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].fn; + // Cancel buffered tasks + if(l.task) { + l.task.cancel(); + delete l.task; + } + // Cancel delayed tasks + 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; } }; -})();- +})();