]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/node/node-pluginhost.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / node / node-pluginhost.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add('node-pluginhost', function(Y) {
9
10 /**
11  * Registers plugins to be instantiated at the class level (plugins 
12  * which should be plugged into every instance of Node by default).
13  *
14  * @method Node.plug
15  * @static
16  *
17  * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)
18  * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin
19  */
20 Y.Node.plug = function() {
21     var args = Y.Array(arguments);
22     args.unshift(Y.Node);
23     Y.Plugin.Host.plug.apply(Y.Base, args);
24     return Y.Node;
25 };
26
27 /**
28  * Unregisters any class level plugins which have been registered by the Node
29  *
30  * @method Node.unplug
31  * @static
32  *
33  * @param {Function | Array} plugin The plugin class, or an array of plugin classes
34  */
35 Y.Node.unplug = function() {
36     var args = Y.Array(arguments);
37     args.unshift(Y.Node);
38     Y.Plugin.Host.unplug.apply(Y.Base, args);
39     return Y.Node;
40 };
41
42 Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
43
44 // allow batching of plug/unplug via NodeList
45 // doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
46 Y.NodeList.prototype.plug = function() {
47     var args = arguments;
48     Y.NodeList.each(this, function(node) {
49         Y.Node.prototype.plug.apply(Y.one(node), args);
50     });
51 };
52
53 Y.NodeList.prototype.unplug = function() {
54     var args = arguments;
55     Y.NodeList.each(this, function(node) {
56         Y.Node.prototype.unplug.apply(Y.one(node), args);
57     });
58 };
59
60
61 }, '3.3.0' ,{requires:['node-base', 'pluginhost']});