node-pluginhost-debug.js revision 1909339da3105dc509908ff39ecc298f2f94f446
YUI.add('node-pluginhost', function(Y) {
/**
* @module node
* @submodule node-pluginhost
*/
/**
* Registers plugins to be instantiated at the class level (plugins
* which should be plugged into every instance of Node by default).
*
* @method plug
* @static
* @for Node
* @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)
* @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin
*/
Y.Node.plug = function() {
var args = Y.Array(arguments);
args.unshift(Y.Node);
Y.Plugin.Host.plug.apply(Y.Base, args);
return Y.Node;
};
/**
* Unregisters any class level plugins which have been registered by the Node
*
* @method unplug
* @static
*
* @param {Function | Array} plugin The plugin class, or an array of plugin classes
*/
Y.Node.unplug = function() {
var args = Y.Array(arguments);
args.unshift(Y.Node);
Y.Plugin.Host.unplug.apply(Y.Base, args);
return Y.Node;
};
Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
// allow batching of plug/unplug via NodeList
// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
Y.NodeList.prototype.plug = function() {
var args = arguments;
Y.NodeList.each(this, function(node) {
Y.Node.prototype.plug.apply(Y.one(node), args);
});
};
Y.NodeList.prototype.unplug = function() {
var args = arguments;
Y.NodeList.each(this, function(node) {
Y.Node.prototype.unplug.apply(Y.one(node), args);
});
};
}, '@VERSION@' ,{requires:['node-base', 'pluginhost']});