X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..b37ceabb82336ee82757cd32efe353cfab8ec267:/src/ext-core/src/util/Observable.js diff --git a/src/ext-core/src/util/Observable.js b/src/ext-core/src/util/Observable.js index 6ba23d5d..3ddb1197 100644 --- a/src/ext-core/src/util/Observable.js +++ b/src/ext-core/src/util/Observable.js @@ -1,5 +1,5 @@ /*! - * Ext JS Library 3.2.0 + * Ext JS Library 3.2.2 * Copyright(c) 2006-2010 Ext JS, Inc. * licensing@extjs.com * http://www.extjs.com/license @@ -7,9 +7,7 @@ (function(){ var EXTUTIL = Ext.util, - TOARRAY = Ext.toArray, EACH = Ext.each, - ISOBJECT = Ext.isObject, TRUE = true, FALSE = false; /** @@ -129,11 +127,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) { @@ -141,20 +140,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); } @@ -225,11 +225,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); @@ -238,10 +238,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 : {}); } }, @@ -253,7 +253,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); } }, @@ -267,7 +267,7 @@ myGridPanel.on({ key; for(key in events){ evt = events[key]; - if(ISOBJECT(evt)){ + if(typeof evt == 'object'){ evt.clearListeners(); } } @@ -285,7 +285,7 @@ this.addEvents('storeloaded', 'storecleared'); addEvents : function(o){ var me = this; me.events = me.events || {}; - if (Ext.isString(o)) { + if (typeof o == 'string') { var a = arguments, i = a.length; while(i--) { @@ -303,7 +303,7 @@ this.addEvents('storeloaded', 'storecleared'); */ hasListener : function(eventName){ var e = this.events[eventName.toLowerCase()]; - return ISOBJECT(e) && e.listeners.length > 0; + return typeof e == 'object' && e.listeners.length > 0; }, /** @@ -366,7 +366,7 @@ 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)); } }; }; @@ -374,7 +374,7 @@ function createTargeted(h, o, scope){ function createBuffered(h, o, l, scope){ l.task = new EXTUTIL.DelayedTask(); return function(){ - l.task.delay(o.buffer, h, scope, TOARRAY(arguments)); + l.task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0)); }; }; @@ -392,7 +392,7 @@ function createDelayed(h, o, l, scope){ l.tasks = []; } l.tasks.push(task); - task.delay(o.delay || 10, h, scope, TOARRAY(arguments)); + task.delay(o.delay || 10, h, scope, Array.prototype.slice.call(arguments, 0)); }; }; @@ -417,7 +417,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, @@ -443,7 +444,7 @@ EXTUTIL.Event.prototype = { var list = this.listeners, i = list.length, l; - + scope = scope || this.obj; while(i--){ l = list[i]; @@ -500,7 +501,6 @@ EXTUTIL.Event.prototype = { fire : function(){ var me = this, - args = TOARRAY(arguments), listeners = me.listeners, len = listeners.length, i = 0, @@ -508,6 +508,7 @@ EXTUTIL.Event.prototype = { if(len > 0){ me.firing = TRUE; + 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) { @@ -518,5 +519,6 @@ EXTUTIL.Event.prototype = { me.firing = FALSE; return TRUE; } + }; -})(); \ No newline at end of file +})();