Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

node-pluginhost.js 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.4.0
  6. build: nightly
  7. */
  8. YUI.add('node-pluginhost', function(Y) {
  9. /**
  10. * @module node
  11. * @submodule node-pluginhost
  12. */
  13. /**
  14. * Registers plugins to be instantiated at the class level (plugins
  15. * which should be plugged into every instance of Node by default).
  16. *
  17. * @method plug
  18. * @static
  19. * @for Node
  20. * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)
  21. * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin
  22. */
  23. Y.Node.plug = function() {
  24. var args = Y.Array(arguments);
  25. args.unshift(Y.Node);
  26. Y.Plugin.Host.plug.apply(Y.Base, args);
  27. return Y.Node;
  28. };
  29. /**
  30. * Unregisters any class level plugins which have been registered by the Node
  31. *
  32. * @method unplug
  33. * @static
  34. *
  35. * @param {Function | Array} plugin The plugin class, or an array of plugin classes
  36. */
  37. Y.Node.unplug = function() {
  38. var args = Y.Array(arguments);
  39. args.unshift(Y.Node);
  40. Y.Plugin.Host.unplug.apply(Y.Base, args);
  41. return Y.Node;
  42. };
  43. Y.mix(Y.Node, Y.Plugin.Host, false, null, 1);
  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. Y.NodeList.prototype.unplug = function() {
  53. var args = arguments;
  54. Y.NodeList.each(this, function(node) {
  55. Y.Node.prototype.unplug.apply(Y.one(node), args);
  56. });
  57. };
  58. }, '3.4.0' ,{requires:['node-base', 'pluginhost']});