// this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)\r
// allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call\r
// private\r
function getMethodEvent(method){\r
var e = (this.methodEvents = this.methodEvents ||\r
{})[method], returnValue, v, cancel, obj = this;\r
// this is considered experimental (along with beforeMethod, afterMethod, removeMethodListener?)\r
// allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call\r
// private\r
function getMethodEvent(method){\r
var e = (this.methodEvents = this.methodEvents ||\r
{})[method], returnValue, v, cancel, obj = this;\r
var makeCall = function(fn, scope, args){\r
if (!Ext.isEmpty(v = fn.apply(scope || obj, args))) {\r
if (Ext.isObject(v)) {\r
returnValue = !Ext.isEmpty(v.returnValue) ? v.returnValue : v;\r
cancel = !!v.cancel;\r
}\r
var makeCall = function(fn, scope, args){\r
if (!Ext.isEmpty(v = fn.apply(scope || obj, args))) {\r
if (Ext.isObject(v)) {\r
returnValue = !Ext.isEmpty(v.returnValue) ? v.returnValue : v;\r
cancel = !!v.cancel;\r
}\r
this[method] = function(){\r
var args = Ext.toArray(arguments);\r
returnValue = v = undefined;\r
cancel = false;\r
this[method] = function(){\r
var args = Ext.toArray(arguments);\r
returnValue = v = undefined;\r
cancel = false;\r
Ext.each(e.before, function(b){\r
makeCall(b.fn, b.scope, args);\r
if (cancel) {\r
return returnValue;\r
}\r
});\r
Ext.each(e.before, function(b){\r
makeCall(b.fn, b.scope, args);\r
if (cancel) {\r
return returnValue;\r
}\r
});\r
return {\r
// these are considered experimental\r
// allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call\r
return {\r
// these are considered experimental\r
// allows for easier interceptor and sequences, including cancelling and overwriting the return value of the call\r
- // adds an "interceptor" called before the original method\r
- beforeMethod: function(method, fn, scope){\r
+ // adds an 'interceptor' called before the original method\r
+ beforeMethod : function(method, fn, scope){\r
- \r
- // adds a "sequence" called after the original method\r
- afterMethod: function(method, fn, scope){\r
+\r
+ // adds a 'sequence' called after the original method\r
+ afterMethod : function(method, fn, scope){\r
removeMethodListener: function(method, fn, scope){\r
var e = getMethodEvent.call(this, method), found = false;\r
Ext.each(e.before, function(b, i, arr){\r
removeMethodListener: function(method, fn, scope){\r
var e = getMethodEvent.call(this, method), found = false;\r
Ext.each(e.before, function(b, i, arr){\r
/**\r
* Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>.\r
* @param {Object} o The Observable whose events this object is to relay.\r
* @param {Array} events Array of event names to relay.\r
*/\r
/**\r
* Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>.\r
* @param {Object} o The Observable whose events this object is to relay.\r
* @param {Array} events Array of event names to relay.\r
*/\r
/**\r
* <p>Enables events fired by this Observable to bubble up an owner hierarchy by calling\r
* <code>this.getBubbleTarget()</code> if present. There is no implementation in the Observable base class.</p>\r
/**\r
* <p>Enables events fired by this Observable to bubble up an owner hierarchy by calling\r
* <code>this.getBubbleTarget()</code> if present. There is no implementation in the Observable base class.</p>\r
* access the required target more quickly.</p>\r
* <p>Example:</p><pre><code>\r
Ext.override(Ext.form.Field, {\r
* access the required target more quickly.</p>\r
* <p>Example:</p><pre><code>\r
Ext.override(Ext.form.Field, {\r
-// Add functionality to Field's initComponent to enable the change event to bubble\r
- initComponent: Ext.form.Field.prototype.initComponent.createSequence(function() {\r
+ // Add functionality to Field's initComponent to enable the change event to bubble\r
+ initComponent : Ext.form.Field.prototype.initComponent.createSequence(function() {\r
-// We know that we want Field's events to bubble directly to the FormPanel.\r
- getBubbleTarget: function() {\r
+ // We know that we want Field's events to bubble directly to the FormPanel.\r
+ getBubbleTarget : function() {\r
-// Title goes red if form has been modified.\r
- myForm.header.setStyle("color", "red");\r
+ // Title goes red if form has been modified.\r
+ myForm.header.setStyle('color', 'red');\r
* to the supplied function with the event name + standard signature of the event\r
* <b>before</b> the event is fired. If the supplied function returns false,\r
* the event will not fire.\r
* to the supplied function with the event name + standard signature of the event\r
* <b>before</b> the event is fired. If the supplied function returns false,\r
* the event will not fire.\r
- * @param {Observable} o The Observable to capture\r
- * @param {Function} fn The function to call\r
- * @param {Object} scope (optional) The scope (this object) for the fn\r
+ * @param {Observable} o The Observable to capture events from.\r
+ * @param {Function} fn The function to call when an event is fired.\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the function is executed. Defaults to the Observable firing the event.\r
* <p>Usage:</p><pre><code>\r
Ext.util.Observable.observeClass(Ext.data.Connection);\r
Ext.data.Connection.on('beforerequest', function(con, options) {\r
* <p>Usage:</p><pre><code>\r
Ext.util.Observable.observeClass(Ext.data.Connection);\r
Ext.data.Connection.on('beforerequest', function(con, options) {\r
-Ext.util.Observable.observeClass = function(c){\r
- Ext.apply(c, new Ext.util.Observable());\r
- c.prototype.fireEvent = function(){\r
- return (c.fireEvent.apply(c, arguments) !== false) &&\r
- (Ext.util.Observable.prototype.fireEvent.apply(this, arguments) !== false);\r
- };\r
+Ext.util.Observable.observeClass = function(c, listeners){\r
+ if(c){\r
+ if(!c.fireEvent){\r
+ Ext.apply(c, new Ext.util.Observable());\r
+ Ext.util.Observable.capture(c.prototype, c.fireEvent, c);\r
+ }\r
+ if(Ext.isObject(listeners)){\r
+ c.on(listeners);\r
+ }\r
+ return c;\r
+ }\r