X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/25ef3491bd9ae007ff1fc2b0d7943e6eaaccf775..b37ceabb82336ee82757cd32efe353cfab8ec267:/docs/source/Observable.html diff --git a/docs/source/Observable.html b/docs/source/Observable.html index 2309f74c..327b3876 100644 --- a/docs/source/Observable.html +++ b/docs/source/Observable.html @@ -1,22 +1,21 @@ + The source code
/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.2.2
+ * Copyright(c) 2006-2010 Ext JS, Inc.
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
 (function(){
 
 var EXTUTIL = Ext.util,
-    TOARRAY = Ext.toArray,
     EACH = Ext.each,
-    ISOBJECT = Ext.isObject,
     TRUE = true,
     FALSE = false;
 
/** @@ -39,7 +38,7 @@ Employee = Ext.extend(Ext.util.Observable, { this.listeners = config.listeners; // Call our superclass constructor to complete construction process. - Employee.superclass.constructor.call(config) + Employee.superclass.constructor.call(this, config) } });
@@ -136,11 +135,12 @@ EXTUTIL.Observable.prototype = { * @return {Boolean} returns false if any of the handlers return false otherwise it returns true. */ fireEvent : function(){ - var a = TOARRAY(arguments), + var a = Array.prototype.slice.call(arguments, 0), ename = a[0].toLowerCase(), me = this, ret = TRUE, ce = me.events[ename], + cc, q, c; if (me.eventsSuspended === TRUE) { @@ -148,20 +148,21 @@ EXTUTIL.Observable.prototype = { q.push(a); } } - else if(ISOBJECT(ce) && ce.bubble){ - if(ce.fire.apply(ce, a.slice(1)) === FALSE) { - return FALSE; - } - c = me.getBubbleTarget && me.getBubbleTarget(); - if(c && c.enableBubble) { - if(!c.events[ename] || !Ext.isObject(c.events[ename]) || !c.events[ename].bubble) { - c.enableBubble(ename); + else if(typeof ce == 'object') { + if (ce.bubble){ + if(ce.fire.apply(ce, a.slice(1)) === FALSE) { + return FALSE; + } + c = me.getBubbleTarget && me.getBubbleTarget(); + if(c && c.enableBubble) { + cc = c.events[ename]; + if(!cc || typeof cc != 'object' || !cc.bubble) { + c.enableBubble(ename); + } + return c.fireEvent.apply(c, a); } - return c.fireEvent.apply(c, a); } - } - else { - if (ISOBJECT(ce)) { + else { a.shift(); ret = ce.fire.apply(ce, a); } @@ -232,11 +233,11 @@ myGridPanel.on({ var me = this, e, oe, - isF, - ce; - if (ISOBJECT(eventName)) { + ce; + + if (typeof eventName == 'object') { o = eventName; - for (e in o){ + for (e in o) { oe = o[e]; if (!me.filterOptRe.test(e)) { me.addListener(e, oe.fn || oe, oe.scope || o.scope, oe.fn ? oe : o); @@ -245,10 +246,10 @@ myGridPanel.on({ } else { eventName = eventName.toLowerCase(); ce = me.events[eventName] || TRUE; - if (Ext.isBoolean(ce)) { + if (typeof ce == 'boolean') { me.events[eventName] = ce = new EXTUTIL.Event(me, eventName); } - ce.addListener(fn, scope, ISOBJECT(o) ? o : {}); + ce.addListener(fn, scope, typeof o == 'object' ? o : {}); } }, @@ -260,7 +261,7 @@ myGridPanel.on({ */ removeListener : function(eventName, fn, scope){ var ce = this.events[eventName.toLowerCase()]; - if (ISOBJECT(ce)) { + if (typeof ce == 'object') { ce.removeListener(fn, scope); } }, @@ -274,7 +275,7 @@ myGridPanel.on({ key; for(key in events){ evt = events[key]; - if(ISOBJECT(evt)){ + if(typeof evt == 'object'){ evt.clearListeners(); } } @@ -292,10 +293,12 @@ this.addEvents('storeloaded', 'storecleared'); addEvents : function(o){ var me = this; me.events = me.events || {}; - if (Ext.isString(o)) { - EACH(arguments, function(a) { - me.events[a] = me.events[a] || TRUE; - }); + if (typeof o == 'string') { + var a = arguments, + i = a.length; + while(i--) { + me.events[a[i]] = me.events[a[i]] || TRUE; + } } else { Ext.applyIf(me.events, o); } @@ -307,8 +310,8 @@ this.addEvents('storeloaded', 'storecleared'); * @return {Boolean} True if the event is being listened for, else false */ hasListener : function(eventName){ - var e = this.events[eventName]; - return ISOBJECT(e) && e.listeners.length > 0; + var e = this.events[eventName.toLowerCase()]; + return typeof e == 'object' && e.listeners.length > 0; },
/** @@ -371,31 +374,33 @@ EXTUTIL.Observable.releaseCapture = function(o){ function createTargeted(h, o, scope){ return function(){ if(o.target == arguments[0]){ - h.apply(scope, TOARRAY(arguments)); + h.apply(scope, Array.prototype.slice.call(arguments, 0)); } }; }; -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, Array.prototype.slice.call(arguments, 0)); }; -} +}; 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, Array.prototype.slice.call(arguments, 0)); }; }; @@ -420,7 +425,8 @@ EXTUTIL.Event.prototype = { }, createListener: function(fn, scope, o){ - o = o || {}, scope = scope || this.obj; + o = o || {}; + scope = scope || this.obj; var l = { fn: fn, scope: scope, @@ -430,29 +436,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; + + scope = scope || this.obj; + while(i--){ + l = list[i]; + if(l){ + if(l.fn == fn && l.scope == scope){ + return i; + } } - }, - this); - return ret; + } + return -1; }, isListening : function(fn, scope){ @@ -461,37 +471,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]; + 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; + var args = Array.prototype.slice.call(arguments, 0); + 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; } + }; -})(); +})(); + \ No newline at end of file