PluginHost.js revision 1201815cf554ddd27ca4898d9623926cfe3c2ac9
/**
* Provides the base Widget class along with an augmentable PluginHost interface
*
* @module widget
*/
/**
* An augmentable class, which when added to a "Base" based class, allows
* the class to support Plugins, providing plug and unplug methods and performing
* instantiation and cleanup during the init and destroy lifecycle phases respectively.
*
* @class PluginHost
*/
var L = Y.Lang;
function PluginHost(config) {
this._plugins = {};
}
PluginHost.prototype = {
/**
* Register and instantiate a plugin with the Widget.
*
* @method plug
* @chainable
* @param p {String | Object |Array} Accepts the registered
* namespace for the Plugin or an object literal with an "fn" property
* specifying the Plugin class and a "cfg" property specifying
* the configuration for the Plugin.
* <p>
* Additionally an Array can also be passed in, with either the above String or
* Object literal values, allowing for multiple plugin registration in
* a single call.
* </p>
*/
if (p) {
if (L.isFunction(p)) {
} else if (L.isArray(p)) {
this.plug(p[i]);
}
} else {
}
}
return this;
},
/**
* Unregister and destroy a plugin already instantiated with the Widget.
*
* @method unplug
* @param {String} ns The namespace key for the Plugin. If not provided,
* all registered plugins are unplugged.
* @chainable
*/
if (ns) {
} else {
}
}
}
return this;
},
/**
* Determines if a plugin has been registered and instantiated
* for this widget.
*
* @method hasPlugin
* @public
* @return {Boolean} returns true, if the plugin has been applied
* to this widget.
*/
},
/**
* Initializes static plugins registered on the host (the
* "PLUGINS" static property) and any plugins passed in
* for the instance through the "plugins" configuration property.
*
* @method _initPlugins
* @param {Config} the user configuration object for the host.
* @private
*/
_initPlugins: function(config) {
// Class Configuration
constructor = classes[i];
if (constructor.PLUGINS) {
}
}
// User Configuration
}
},
/**
* Private method used to unplug and destroy all plugins on the host
* @method _destroyPlugins
* @private
*/
_destroyPlugins: function() {
this._unplug();
},
/**
* Private method used to instantiate and attach plugins to the host
* @method _plug
* @param {Function} PluginClass The plugin class to instantiate
* @param {Object} config The configuration object for the plugin
* @private
*/
// Update config
} else {
// Create new instance
}
}
},
/**
* Private method used to unregister and destroy a plugin already instantiated with the host.
*
* @method _unplug
* @private
* @param {String} ns The namespace key for the Plugin. If not provided,
* all registered plugins are unplugged.
*/
if (ns) {
if (this[ns]) {
delete this[ns];
}
}
}
}
};
Y.PluginHost = PluginHost;