0
@@ -79,8 +79,8 @@ YUI.add('plugin', function(Y) {
0
* @param {Object} config Configuration object with property name/value pairs.
0
initializer : function(config) {
0
if (!this.get("host")) { Y.log('No host defined for plugin ' + this, 'warn', 'Plugin');}
0
Y.log('Initializing: ' + this.constructor.NAME, 'info', 'Plugin');
0
@@ -106,24 +106,20 @@ YUI.add('plugin', function(Y) {
0
- * @param s
Fn {String} The event to listen for, or method to inject logic before.
0
+ * @param s
trMethod {String} The event to listen for, or method to inject logic before.
0
* @param fn {Function} The handler function. For events, the "on" moment listener. For methods, the function to execute before the given method is executed.
0
* @param context {Object} An optional context to call the handler with. The default context is the plugin instance.
0
* @return handle {EventHandle} The detach handle for the handler.
0
- doBefore: function(sFn, fn, context) {
0
- var host = this.get("host"),
0
- context = context || this;
0
+ doBefore: function(strMethod, fn, context) {
0
+ var host = this.get("host"), handle;
0
- if (sFn in host) { // method
0
- handle = Y.Do.before(fn, host, sFn, context);
0
+ if (strMethod in host) { // method
0
+ handle = this.beforeHostMethod(strMethod, fn, context);
0
} else if (host.on) { // event
0
- handle =
host.on(sFn, fn, context);
0
+ handle =
this.onHostEvent(strMethod, fn, context);
0
- this._handles.push(handle);
0
@@ -133,23 +129,87 @@ YUI.add('plugin', function(Y) {
0
- * @param s
Fn {String} The event to listen for, or method to inject logic after.
0
+ * @param s
trMethod {String} The event to listen for, or method to inject logic after.
0
* @param fn {Function} The handler function. For events, the "after" moment listener. For methods, the function to execute after the given method is executed.
0
* @param context {Object} An optional context to call the handler with. The default context is the plugin instance.
0
- * @return handle {EventHandle} The detach handle for the
handler.
0
+ * @return handle {EventHandle} The detach handle for the
listener.
0
- doAfter: function(sFn, fn, context) {
0
- var host = this.get("host"),
0
+ doAfter: function(strMethod, fn, context) {
0
+ var host = this.get("host"), handle;
0
- context = context || this;
0
- if (sFn in host) { // method
0
- handle = Y.Do.after(fn, host, sFn, context);
0
+ if (strMethod in host) { // method
0
+ handle = this.afterHostMethod(strMethod, fn, context);
0
} else if (host.after) { // event
0
- handle =
host.after(sFn, fn, context);
0
+ handle =
this.afterHostEvent(strMethod, fn, context);
0
+ * Listens for the "on" moment of events fired by the host object.
0
+ * Listeners attached through this method will be detached when the plugin is unplugged.
0
+ * @param {String | Object} type The event type.
0
+ * @param {Function} fn The listener.
0
+ * @param {Object} context The execution context. Defaults to the plugin instance.
0
+ * @return handle {EventHandle} The detach handle for the listener.
0
+ onHostEvent : function(type, fn, context) {
0
+ var handle = this.get("host").after(type, fn, context || this);
0
+ this._handles.push(handle);
0
+ * Listens for the "after" moment of events fired by the host object.
0
+ * Listeners attached through this method will be detached when the plugin is unplugged.
0
+ * @method afterHostEvent
0
+ * @param {String | Object} type The event type.
0
+ * @param {Function} fn The listener.
0
+ * @param {Object} context The execution context. Defaults to the plugin instance.
0
+ * @return handle {EventHandle} The detach handle for the listener.
0
+ afterHostEvent : function(type, fn, context) {
0
+ var handle = this.get("host").after(type, fn, context || this);
0
+ this._handles.push(handle);
0
+ * Injects a function to be executed before a given method on host object.
0
+ * The function will be detached when the plugin is unplugged.
0
+ * @method beforeHostMethod
0
+ * @param {String} The name of the method to inject the function before.
0
+ * @param {Function} fn The function to inject.
0
+ * @param {Object} context The execution context. Defaults to the plugin instance.
0
+ * @return handle {EventHandle} The detach handle for the injected function.
0
+ beforeHostMethod : function(strMethod, fn, context) {
0
+ var handle = Y.Do.before(fn, this.get("host"), strMethod, context || this);
0
+ this._handles.push(handle);
0
+ * Injects a function to be executed after a given method on host object.
0
+ * The function will be detached when the plugin is unplugged.
0
+ * @method afterHostMethod
0
+ * @param {String} The name of the method to inject the function after.
0
+ * @param {Function} fn The function to inject.
0
+ * @param {Object} context The execution context. Defaults to the plugin instance.
0
+ * @return handle {EventHandle} The detach handle for the injected function.
0
+ afterHostMethod : function(strMethod, fn, context) {
0
+ var handle = Y.Do.after(fn, this.get("host"), strMethod, context || this);
0
this._handles.push(handle);