[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/node-pluginhost/ -> node-pluginhost-debug.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 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  // run PluginHost constructor on cached Node instances
  50  Y.Object.each(Y.Node._instances, function (node) {
  51      Y.Plugin.Host.apply(node);
  52  });
  53  
  54  // allow batching of plug/unplug via NodeList
  55  // doesn't use NodeList.importMethod because we need real Nodes (not tmpNode)
  56  /**
  57   * Adds a plugin to each node in the NodeList.
  58   * This will instantiate the plugin and attach it to the configured namespace on each node
  59   * @method plug
  60   * @for NodeList
  61   * @param P {Function | Object |Array} Accepts the plugin class, or an
  62   * object with a "fn" property specifying the plugin class and
  63   * a "cfg" property specifying the configuration for the Plugin.
  64   * <p>
  65   * Additionally an Array can also be passed in, with the above function or
  66   * object values, allowing the user to add multiple plugins in a single call.
  67   * </p>
  68   * @param config (Optional) If the first argument is the plugin class, the second argument
  69   * can be the configuration for the plugin.
  70   * @chainable
  71   */
  72  Y.NodeList.prototype.plug = function() {
  73      var args = arguments;
  74      Y.NodeList.each(this, function(node) {
  75          Y.Node.prototype.plug.apply(Y.one(node), args);
  76      });
  77      return this;
  78  };
  79  
  80  /**
  81   * Removes a plugin from all nodes in the NodeList. This will destroy the
  82   * plugin instance and delete the namespace each node.
  83   * @method unplug
  84   * @for NodeList
  85   * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,
  86   * all registered plugins are unplugged.
  87   * @chainable
  88   */
  89  Y.NodeList.prototype.unplug = function() {
  90      var args = arguments;
  91      Y.NodeList.each(this, function(node) {
  92          Y.Node.prototype.unplug.apply(Y.one(node), args);
  93      });
  94      return this;
  95  };
  96  
  97  
  98  }, '3.17.2', {"requires": ["node-base", "pluginhost"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1