3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
7 YUI.add('node-pluginhost', function (Y, NAME) {
11 * @submodule node-pluginhost
15 * Registers plugins to be instantiated at the class level (plugins
16 * which should be plugged into every instance of Node by default).
21 * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)
22 * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin
24 Y.Node.plug = function() {
25 var args = Y.Array(arguments);
27 Y.Plugin.Host.plug.apply(Y.Base, args);
32 * Unregisters any class level plugins which have been registered by the Node
37 * @param {Function | Array} plugin The plugin class, or an array of plugin classes
39 Y.Node.unplug = function() {
40 var args = Y.Array(arguments);
42 Y.Plugin.Host.unplug.apply(Y.Base, args);
46 Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
48 // allow batching of plug/unplug via NodeList
49 // doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
51 * Adds a plugin to each node in the NodeList.
52 * This will instantiate the plugin and attach it to the configured namespace on each node
55 * @param P {Function | Object |Array} Accepts the plugin class, or an
56 * object with a "fn" property specifying the plugin class and
57 * a "cfg" property specifying the configuration for the Plugin.
59 * Additionally an Array can also be passed in, with the above function or
60 * object values, allowing the user to add multiple plugins in a single call.
62 * @param config (Optional) If the first argument is the plugin class, the second argument
63 * can be the configuration for the plugin.
66 Y.NodeList.prototype.plug = function() {
68 Y.NodeList.each(this, function(node) {
69 Y.Node.prototype.plug.apply(Y.one(node), args);
75 * Removes a plugin from all nodes in the NodeList. This will destroy the
76 * plugin instance and delete the namespace each node.
79 * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,
80 * all registered plugins are unplugged.
83 Y.NodeList.prototype.unplug = function() {
85 Y.NodeList.each(this, function(node) {
86 Y.Node.prototype.unplug.apply(Y.one(node), args);
92 }, '3.7.2', {"requires": ["node-base", "pluginhost"]});