|
525
|
1 |
/* |
|
|
2 |
YUI 3.10.3 (build 2fb5187) |
|
|
3 |
Copyright 2013 Yahoo! Inc. All rights reserved. |
|
|
4 |
Licensed under the BSD License. |
|
|
5 |
http://yuilibrary.com/license/ |
|
|
6 |
*/ |
|
|
7 |
|
|
|
8 |
YUI.add('node-pluginhost', function (Y, NAME) { |
|
|
9 |
|
|
|
10 |
/** |
|
|
11 |
* @module node |
|
|
12 |
* @submodule node-pluginhost |
|
|
13 |
*/ |
|
|
14 |
|
|
|
15 |
/** |
|
|
16 |
* Registers plugins to be instantiated at the class level (plugins |
|
|
17 |
* which should be plugged into every instance of Node by default). |
|
|
18 |
* |
|
|
19 |
* @method plug |
|
|
20 |
* @static |
|
|
21 |
* @for Node |
|
|
22 |
* @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined) |
|
|
23 |
* @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin |
|
|
24 |
*/ |
|
|
25 |
Y.Node.plug = function() { |
|
|
26 |
var args = Y.Array(arguments); |
|
|
27 |
args.unshift(Y.Node); |
|
|
28 |
Y.Plugin.Host.plug.apply(Y.Base, args); |
|
|
29 |
return Y.Node; |
|
|
30 |
}; |
|
|
31 |
|
|
|
32 |
/** |
|
|
33 |
* Unregisters any class level plugins which have been registered by the Node |
|
|
34 |
* |
|
|
35 |
* @method unplug |
|
|
36 |
* @static |
|
|
37 |
* |
|
|
38 |
* @param {Function | Array} plugin The plugin class, or an array of plugin classes |
|
|
39 |
*/ |
|
|
40 |
Y.Node.unplug = function() { |
|
|
41 |
var args = Y.Array(arguments); |
|
|
42 |
args.unshift(Y.Node); |
|
|
43 |
Y.Plugin.Host.unplug.apply(Y.Base, args); |
|
|
44 |
return Y.Node; |
|
|
45 |
}; |
|
|
46 |
|
|
|
47 |
Y.mix(Y.Node, Y.Plugin.Host, false, null, 1); |
|
|
48 |
|
|
|
49 |
// allow batching of plug/unplug via NodeList |
|
|
50 |
// doesn't use NodeList.importMethod because we need real Nodes (not tmpNode) |
|
|
51 |
/** |
|
|
52 |
* Adds a plugin to each node in the NodeList. |
|
|
53 |
* This will instantiate the plugin and attach it to the configured namespace on each node |
|
|
54 |
* @method plug |
|
|
55 |
* @for NodeList |
|
|
56 |
* @param P {Function | Object |Array} Accepts the plugin class, or an |
|
|
57 |
* object with a "fn" property specifying the plugin class and |
|
|
58 |
* a "cfg" property specifying the configuration for the Plugin. |
|
|
59 |
* <p> |
|
|
60 |
* Additionally an Array can also be passed in, with the above function or |
|
|
61 |
* object values, allowing the user to add multiple plugins in a single call. |
|
|
62 |
* </p> |
|
|
63 |
* @param config (Optional) If the first argument is the plugin class, the second argument |
|
|
64 |
* can be the configuration for the plugin. |
|
|
65 |
* @chainable |
|
|
66 |
*/ |
|
|
67 |
Y.NodeList.prototype.plug = function() { |
|
|
68 |
var args = arguments; |
|
|
69 |
Y.NodeList.each(this, function(node) { |
|
|
70 |
Y.Node.prototype.plug.apply(Y.one(node), args); |
|
|
71 |
}); |
|
|
72 |
return this; |
|
|
73 |
}; |
|
|
74 |
|
|
|
75 |
/** |
|
|
76 |
* Removes a plugin from all nodes in the NodeList. This will destroy the |
|
|
77 |
* plugin instance and delete the namespace each node. |
|
|
78 |
* @method unplug |
|
|
79 |
* @for NodeList |
|
|
80 |
* @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided, |
|
|
81 |
* all registered plugins are unplugged. |
|
|
82 |
* @chainable |
|
|
83 |
*/ |
|
|
84 |
Y.NodeList.prototype.unplug = function() { |
|
|
85 |
var args = arguments; |
|
|
86 |
Y.NodeList.each(this, function(node) { |
|
|
87 |
Y.Node.prototype.unplug.apply(Y.one(node), args); |
|
|
88 |
}); |
|
|
89 |
return this; |
|
|
90 |
}; |
|
|
91 |
|
|
|
92 |
|
|
|
93 |
}, '3.10.3', {"requires": ["node-base", "pluginhost"]}); |