X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/7a654f8d43fdb43d78b63d90528bed6e86b608cc..3789b528d8dd8aad4558e38e22d775bcab1cbd36:/docs/source/Observable.html diff --git a/docs/source/Observable.html b/docs/source/Observable.html index f96cba34..cb981401 100644 --- a/docs/source/Observable.html +++ b/docs/source/Observable.html @@ -1,11 +1,29 @@ -
/**
+
+
+
+
+ The source code
+
+
+
+
+
+
+ /**
* @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"
* with configured listeners defined.<br>
* For example:
* <pre><code>
-Employee = Ext.extend(Ext.util.Observable, {
+Ext.define('Employee', {
+ extend: 'Ext.util.Observable',
constructor: function(config){
this.name = config.name;
this.addEvents({
@@ -42,7 +60,7 @@ Ext.define('Ext.util.Observable', {
requires: ['Ext.util.Event'],
statics: {
- /**
+ /**
* Removes <b>all</b> added captures from the Observable.
* @param {Observable} o The Observable to release
* @static
@@ -51,7 +69,7 @@ Ext.define('Ext.util.Observable', {
o.fireEvent = this.prototype.fireEvent;
},
- /**
+ /**
* Starts capture on the specified Observable. All events will be passed
* to the supplied function with the event name + standard signature of the event
* <b>before</b> the event is fired. If the supplied function returns false,
@@ -65,7 +83,7 @@ Ext.define('Ext.util.Observable', {
o.fireEvent = Ext.Function.createInterceptor(o.fireEvent, fn, scope);
},
- /**
+ /**
Sets observability on the passed class constructor.
This makes any event fired on any instance of the passed class also fire a single event through
@@ -99,7 +117,7 @@ Usage:
/* End Definitions */
- /**
+ /**
* @cfg {Object} listeners (optional) <p>A config object containing one or more event handlers to be added to this
* object during initialization. This should be a valid listeners config object as specified in the
* {@link #addListener} example for attaching multiple handlers at once.</p>
@@ -151,7 +169,7 @@ new Ext.panel.Panel({
// @private
eventOptionsRe : /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|element|vertical|horizontal)$/,
- /**
+ /**
* <p>Adds listeners to any Observable object (or Element) which are automatically removed when this Component
* is destroyed.
* @param {Observable/Element} item The item to which to add a listener/listeners.
@@ -192,7 +210,7 @@ new Ext.panel.Panel({
}
},
- /**
+ /**
* Removes listeners that were added by the {@link #mon} method.
* @param {Observable|Element} item The item from which to remove a listener/listeners.
* @param {Object|String} ename The event name, or an object containing event name properties.
@@ -206,7 +224,6 @@ new Ext.panel.Panel({
options,
config,
managedListeners,
- managedListener,
length,
i;
@@ -223,18 +240,13 @@ new Ext.panel.Panel({
}
managedListeners = me.managedListeners ? me.managedListeners.slice() : [];
- length = managedListeners.length;
- for (i = 0; i < length; i++) {
- managedListener = managedListeners[i];
- if (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope)) {
- Ext.Array.remove(me.managedListeners, managedListener);
- item.un(managedListener.ename, managedListener.fn, managedListener.scope);
- }
+ for (i = 0, length = managedListeners.length; i < length; i++) {
+ me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope);
}
},
- /**
+ /**
* <p>Fires the specified event with the passed parameters (minus the event name).</p>
* <p>An event may be set to bubble up an Observable parent hierarchy (See {@link Ext.Component#getBubbleTarget})
* by calling {@link #enableBubble}.</p>
@@ -273,7 +285,7 @@ new Ext.panel.Panel({
return ret;
},
- /**
+ /**
* Appends an event handler to this object.
* @param {String} eventName The name of the event to listen for. May also be an object who's property names are event names. See
* @param {Function} handler The method the event invokes.
@@ -354,7 +366,7 @@ myGridPanel.on({
}
},
- /**
+ /**
* Removes an event handler.
* @param {String} eventName The type of event the handler was associated with.
* @param {Function} handler The handler to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
@@ -379,13 +391,13 @@ myGridPanel.on({
} else {
ename = ename.toLowerCase();
event = me.events[ename];
- if (event.isEvent) {
+ if (event && event.isEvent) {
event.removeListener(fn, scope);
}
}
},
- /**
+ /**
* Removes all listeners for this object including the managed listeners
*/
clearListeners: function() {
@@ -407,36 +419,54 @@ myGridPanel.on({
//<debug>
purgeListeners : function() {
- console.warn('Observable: purgeListeners has been deprecated. Please use clearListeners.');
+ if (Ext.global.console) {
+ Ext.global.console.warn('Observable: purgeListeners has been deprecated. Please use clearListeners.');
+ }
return this.clearListeners.apply(this, arguments);
},
//</debug>
- /**
+ /**
* Removes all managed listeners for this object.
*/
clearManagedListeners : function() {
var managedListeners = this.managedListeners || [],
i = 0,
- len = managedListeners.length,
- managedListener;
+ len = managedListeners.length;
for (; i < len; i++) {
- managedListener = managedListeners[i];
- managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope);
+ this.removeManagedListenerItem(true, managedListeners[i]);
}
this.managedListeners = [];
},
+
+ /**
+ * Remove a single managed listener item
+ * @private
+ * @param {Boolean} isClear True if this is being called during a clear
+ * @param {Object} managedListener The managed listener item
+ * See removeManagedListener for other args
+ */
+ removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope){
+ if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {
+ managedListener.item.un(managedListener.ename, managedListener.fn, managedListener.scope);
+ if (!isClear) {
+ Ext.Array.remove(this.managedListeners, managedListener);
+ }
+ }
+ },
//<debug>
purgeManagedListeners : function() {
- console.warn('Observable: purgeManagedListeners has been deprecated. Please use clearManagedListeners.');
+ if (Ext.global.console) {
+ Ext.global.console.warn('Observable: purgeManagedListeners has been deprecated. Please use clearManagedListeners.');
+ }
return this.clearManagedListeners.apply(this, arguments);
},
//</debug>
- /**
+ /**
* Adds the specified events to the list of events which this Observable may fire.
* @param {Object/String} o Either an object with event names as properties with a value of <code>true</code>
* or the first event name string if multiple event names are being passed as separate parameters.
@@ -464,7 +494,7 @@ this.addEvents('storeloaded', 'storecleared');
}
},
- /**
+ /**
* Checks to see if this object has any listeners for a specified event
* @param {String} eventName The name of the event to check for
* @return {Boolean} True if the event is being listened for, else false
@@ -474,7 +504,7 @@ this.addEvents('storeloaded', 'storecleared');
return event && event.isEvent === true && event.listeners.length > 0;
},
- /**
+ /**
* Suspend the firing of all events. (see {@link #resumeEvents})
* @param {Boolean} queueSuspended Pass as true to queue up suspended events to be fired
* after the {@link #resumeEvents} call instead of discarding all suspended events;
@@ -486,7 +516,7 @@ this.addEvents('storeloaded', 'storecleared');
}
},
- /**
+ /**
* Resume firing events. (see {@link #suspendEvents})
* If events were suspended using the <code><b>queueSuspended</b></code> parameter, then all
* events fired during event suspension will be sent to any listeners now.
@@ -504,7 +534,7 @@ this.addEvents('storeloaded', 'storecleared');
});
},
- /**
+ /**
* Relays selected events from the specified Observable as if the events were fired by <code><b>this</b></code>.
* @param {Object} origin The Observable whose events this object is to relay.
* @param {Array} events Array of event names to relay.
@@ -525,7 +555,7 @@ this.addEvents('storeloaded', 'storecleared');
}
},
- /**
+ /**
* @private
* Creates an event handling function which refires the event from this object as the passed event name.
* @param newName
@@ -538,7 +568,7 @@ this.addEvents('storeloaded', 'storecleared');
};
},
- /**
+ /**
* <p>Enables events fired by this Observable to bubble up an owner hierarchy by calling
* <code>this.getBubbleTarget()</code> if present. There is no implementation in the Observable base class.</p>
* <p>This is commonly used by Ext.Components to bubble events to owner Containers. See {@link Ext.Component#getBubbleTarget}. The default
@@ -592,7 +622,7 @@ listeners: {
}
}
}, function() {
- /**
+ /**
* Removes an event handler (shorthand for {@link #removeListener}.)
* @param {String} eventName The type of event the handler was associated with.
* @param {Function} handler The handler to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
@@ -600,7 +630,7 @@ listeners: {
* @method un
*/
- /**
+ /**
* Appends an event handler to this object (shorthand for {@link #addListener}.)
* @param {String} eventName The type of event to listen for
* @param {Function} handler The method the event invokes
@@ -735,4 +765,6 @@ listeners: {
};
}());
});
-
\ No newline at end of file
+
+
+