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