<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns:yui="http://yuilibrary.com/rdf/1.0/yui.rdf#">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>API: base Plugin.Host (YUI Library)</title>
<link rel="stylesheet" type="text/css" href="assets/reset-fonts-grids-min.css" />
<link rel="stylesheet" type="text/css" href="assets/api.css" />
<script type="text/javascript" src="assets/api-js"></script>
<script type="text/javascript" src="assets/ac-js"></script>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h1><a href="http://developer.yahoo.com/yui/" title="Yahoo! UI Library">Yahoo! UI Library</a></h1>
<h3>base <span class="subtitle">3.0.0b1</span></h3>
<a href="./index.html" title="Yahoo! UI Library">Yahoo! UI Library</a>
> <a href="./module_base.html" title="base">base</a>
> Plugin.Host
<form onsubmit="return false">
<div id="propertysearch">
Search: <input autocomplete="off" id="searchinput" />
<div id="searchresults">
</div>
</div>
</form>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form action="#" name="yui-classopts-form" method="get" id="yui-classopts-form">
<fieldset>
<legend>Filters</legend>
<span class="classopts"><input type="checkbox" name="show_private" id="show_private" /> <label for="show_private">Show Private</label></span>
<span class="classopts"><input type="checkbox" name="show_protected" id="show_protected" /> <label for="show_protected">Show Protected</label></span>
<span class="classopts"><input type="checkbox" name="show_deprecated" id="show_deprecated" /> <label for="show_deprecated">Show Deprecated</label></span>
</fieldset>
</form>
<h2>
Class <b property="yui:name">Plugin.Host</b>
<span class="extends">
</span>
</h2>
<!-- class tree goes here -->
<div class="summary description" property="yui:description">
<p>
An augmentable class, which provides the augmented class with the ability to host plugins.
It adds <a href="#method_plug">plug</a> and <a href="#method_unplug">unplug</a> methods to the augmented class, which can
be used to add or remove plugins from instances of the class.
</p>
<p>Plugins can also be added through the constructor configuration object passed to the host class' constructor using
the "plugins" property. Supported values for the "plugins" property are those defined by the <a href="#method_plug">plug</a> method.
For example the following code would add the AnimPlugin and IOPlugin to Overlay (the plugin host):
<xmp>
var o = new Overlay({plugins: [ AnimPlugin, {fn:IOPlugin, cfg:{section:"header"}}]});
</xmp>
</p>
<p>
Plug.Host's protected <a href="#method_initPlugins">_initPlugins</a> and <a href="#method_destroyPlugins">_destroyPlugins</a>
methods should be invoked by the host class at the appropriate point in the host's lifecyle. This is done by default for
the Base class, so developers extending Base or Widget don't need to do anything to enable plugin support.
</p>
</div>
<div rel="yui:properties" resource="#properties">
</div>
<div rel="yui:methods" resource="#methods">
<div class="section method details">
<h3 id="methods">Methods</h3>
<div class="content">
<div class="private" rel="yui:method" resource="#method__destroyPlugins">
<h4>
<a name="method__destroyPlugins">_destroyPlugins</a></h4>
<div class="detail" >
<code>
private
void
<strong property="yui:name">_destroyPlugins</strong>
(
)
</code>
<div class="description" property="yui:description">
Unplugs and destroys all plugins on the host
</div>
<div class="description">
<dl>
<dt>Returns:
<code property="yui:return">
void
</code></dt>
<dd property="yui:returnInfo"></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="private" rel="yui:method" resource="#method__initPlugins">
<h4>
<a name="method__initPlugins">_initPlugins</a></h4>
<div class="detail" >
<code>
private
void
<strong property="yui:name">_initPlugins</strong>
(
config
)
</code>
<div class="description" property="yui:description">
Initializes static plugins registered on the host (using the
Base.plug static method) and any plugins passed to the
instance through the "plugins" configuration property.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">config</span>
<<span property="yui:type">Config</span>>
</code>
<span property="yui:description"> The configuration object with property name/value pairs.</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
void
</code></dt>
<dd property="yui:returnInfo"></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="private" rel="yui:method" resource="#method__plug">
<h4>
<a name="method__plug">_plug</a></h4>
<div class="detail" >
<code>
private
void
<strong property="yui:name">_plug</strong>
(
PluginClass
,
config
)
</code>
<div class="description" property="yui:description">
Private method used to instantiate and attach plugins to the host
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">PluginClass</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> The plugin class to instantiate</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">config</span>
<<span property="yui:type">Object</span>>
</code>
<span property="yui:description"> The configuration object for the plugin</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
void
</code></dt>
<dd property="yui:returnInfo"></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="private" rel="yui:method" resource="#method__unplug">
<h4>
<a name="method__unplug">_unplug</a></h4>
<div class="detail" >
<code>
private
void
<strong property="yui:name">_unplug</strong>
(
plugin
)
</code>
<div class="description" property="yui:description">
Unplugs and destroys a plugin already instantiated with the host.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">plugin</span>
<<span property="yui:type">String | Function</span>>
</code>
<span property="yui:description"> The namespace for the plugin, or a plugin class with the static NS property defined.</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
void
</code></dt>
<dd property="yui:returnInfo"></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_hasPlugin">
<h4>
<a name="method_hasPlugin">hasPlugin</a></h4>
<div class="detail" >
<code>
boolean
<strong property="yui:name">hasPlugin</strong>
(
ns
)
</code>
<div class="description" property="yui:description">
Determines if a plugin has plugged into this host.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">ns</span>
<<span property="yui:type">String</span>>
</code>
<span property="yui:description"> The plugin's namespace</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
boolean
</code></dt>
<dd property="yui:returnInfo">returns true, if the plugin has been plugged into this host, false otherwise.</dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_plug">
<h4>
<a name="method_plug">plug</a></h4>
<div class="detail" >
<code>
Base
<strong property="yui:name">plug</strong>
(
p
,
config
)
</code>
<div class="description" property="yui:description">
Adds a plugin to the host object. This will instantiate the
plugin and attach it to the configured namespace on the host object.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">p</span>
<<span property="yui:type">Function | Object |Array</span>>
</code>
<span property="yui:description"> Accepts the plugin class, or an
object with a "fn" property specifying the plugin class and
a "cfg" property specifying the configuration for the Plugin.
<p>
Additionally an Array can also be passed in, with the above function or
object values, allowing the user to add multiple plugins in a single call.
</p></span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">config</span>
<<span property="yui:type">object</span>>
</code>
<span property="yui:description"> (Optional) If the first argument is the plugin class, the second argument
can be the configuration for the plugin.</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Base
</code></dt>
<dd property="yui:returnInfo">A reference to the host object</dd>
</dl>
<div class="chainable">
<strong>Chainable:</strong> This method is chainable.
</div>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Plugin.Host.plug">
<h4>
<a name="method_Plugin.Host.plug">Plugin.Host.plug</a></h4>
<div class="detail" >
<code>
static
void
<strong property="yui:name">Plugin.Host.plug</strong>
(
hostClass
,
plugin
,
config
)
</code>
<div class="description" property="yui:description">
Registers plugins to be instantiated at the class level (plugins
which should be plugged into every instance of the class by default).
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">hostClass</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> The host class on which to register the plugins</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">plugin</span>
<<span property="yui:type">Function | Array</span>>
</code>
<span property="yui:description"> Either the plugin class, an array of plugin classes or an array of objects (with fn and cfg properties defined)</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">config</span>
<<span property="yui:type">Object</span>>
</code>
<span property="yui:description"> (Optional) If plugin is the plugin class, the configuration for the plugin</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
void
</code></dt>
<dd property="yui:returnInfo"></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_Plugin.Host.unplug">
<h4>
<a name="method_Plugin.Host.unplug">Plugin.Host.unplug</a></h4>
<div class="detail" >
<code>
static
void
<strong property="yui:name">Plugin.Host.unplug</strong>
(
hostClass
,
plugin
)
</code>
<div class="description" property="yui:description">
Unregisters any class level plugins which have been registered by the host class, or any
other class in the hierarchy.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">hostClass</span>
<<span property="yui:type">Function</span>>
</code>
<span property="yui:description"> The host class from which to unregister the plugins</span>
</dd>
<dd rel="yui:parameter">
<code><span property="yui:name">plugin</span>
<<span property="yui:type">Function | Array</span>>
</code>
<span property="yui:description"> The plugin class, or an array of plugin classes</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
void
</code></dt>
<dd property="yui:returnInfo"></dd>
</dl>
</div>
</div>
<hr />
</div>
<div class="" rel="yui:method" resource="#method_unplug">
<h4>
<a name="method_unplug">unplug</a></h4>
<div class="detail" >
<code>
Base
<strong property="yui:name">unplug</strong>
(
plugin
)
</code>
<div class="description" property="yui:description">
Removes a plugin from the host object. This will destroy the
plugin instance and delete the namepsace from the host object.
</div>
<div class="description">
<dl rel="yui:parameters">
<dt>Parameters:</dt>
<dd rel="yui:parameter">
<code><span property="yui:name">plugin</span>
<<span property="yui:type">String | Function</span>>
</code>
<span property="yui:description"> The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided,
all registered plugins are unplugged.</span>
</dd>
</dl>
<dl>
<dt>Returns:
<code property="yui:return">
Base
</code></dt>
<dd property="yui:returnInfo">A reference to the host object</dd>
</dl>
<div class="chainable">
<strong>Chainable:</strong> This method is chainable.
</div>
</div>
</div>
<hr />
</div>
</div>
</div>
</div>
<div rel="yui:events" resource="#events">
</div>
<div rel="yui:attributes" resource="#configattributes">
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div id="moduleList" class="module">
<h4>Modules</h4>
<ul class="content">
<li class=""><a href="module_anim.html" title="anim">anim</a></li>
<li class=""><a href="module_attribute.html" title="attribute">attribute</a></li>
<li class="selected"><a href="module_base.html" title="base">base</a></li>
<li class=""><a href="module_cache.html" title="cache">cache</a></li>
<li class=""><a href="module_classnamemanager.html" title="classnamemanager">classnamemanager</a></li>
<li class=""><a href="module_collection.html" title="collection">collection</a></li>
<li class=""><a href="module_console.html" title="console">console</a></li>
<li class=""><a href="module_console-filters.html" title="console-filters">console-filters</a></li>
<li class=""><a href="module_cookie.html" title="cookie">cookie</a></li>
<li class=""><a href="module_dataschema.html" title="dataschema">dataschema</a></li>
<li class=""><a href="module_datasource.html" title="datasource">datasource</a></li>
<li class=""><a href="module_datatype.html" title="datatype">datatype</a></li>
<li class=""><a href="module_dd.html" title="dd">dd</a></li>
<li class=""><a href="module_dom.html" title="dom">dom</a></li>
<li class=""><a href="module_dump.html" title="dump">dump</a></li>
<li class=""><a href="module_event.html" title="event">event</a></li>
<li class=""><a href="module_event-custom.html" title="event-custom">event-custom</a></li>
<li class=""><a href="module_event-simulate.html" title="event-simulate">event-simulate</a></li>
<li class=""><a href="module_history.html" title="history">history</a></li>
<li class=""><a href="module_imageloader.html" title="imageloader">imageloader</a></li>
<li class=""><a href="module_io.html" title="io">io</a></li>
<li class=""><a href="module_json.html" title="json">json</a></li>
<li class=""><a href="module_node.html" title="node">node</a></li>
<li class=""><a href="module_node-focusmanager.html" title="node-focusmanager">node-focusmanager</a></li>
<li class=""><a href="module_node-menunav.html" title="node-menunav">node-menunav</a></li>
<li class=""><a href="module_oop.html" title="oop">oop</a></li>
<li class=""><a href="module_overlay.html" title="overlay">overlay</a></li>
<li class=""><a href="module_plugin.html" title="plugin">plugin</a></li>
<li class=""><a href="module_profiler.html" title="profiler">profiler</a></li>
<li class=""><a href="module_queue.html" title="queue">queue</a></li>
<li class=""><a href="module_slider.html" title="slider">slider</a></li>
<li class=""><a href="module_stylesheet.html" title="stylesheet">stylesheet</a></li>
<li class=""><a href="module_substitute.html" title="substitute">substitute</a></li>
<li class=""><a href="module_test.html" title="test">test</a></li>
<li class=""><a href="module_widget.html" title="widget">widget</a></li>
<li class=""><a href="module_widget-position.html" title="widget-position">widget-position</a></li>
<li class=""><a href="module_widget-position-ext.html" title="widget-position-ext">widget-position-ext</a></li>
<li class=""><a href="module_widget-stack.html" title="widget-stack">widget-stack</a></li>
<li class=""><a href="module_widget-stdmod.html" title="widget-stdmod">widget-stdmod</a></li>
<li class=""><a href="module_yui.html" title="yui">yui</a></li>
</ul>
</div>
<div id="classList" class="module">
<h4>Classes</h4>
<ul class="content">
<li class=""><a href="Base.html" title="Base">Base</a></li>
<li class="selected"><a href="Plugin.Host.html" title="Plugin.Host">Plugin.Host</a></li>
</ul>
</div>
<div id="fileList" class="module">
<h4>Files</h4>
<ul class="content">
<li class=""><a href="Base.js.html" title="Base.js">Base.js</a></li>
<li class=""><a href="BaseBuild.js.html" title="BaseBuild.js">BaseBuild.js</a></li>
<li class=""><a href="PluginHost.js.html" title="PluginHost.js">PluginHost.js</a></li>
</ul>
</div>
<div id="methodsList" class="module">
<h4>Methods</h4>
<ul class="content">
<li class="private"><a href="#method__destroyPlugins" title="_destroyPlugins">_destroyPlugins</a></li>
<li class="private"><a href="#method__initPlugins" title="_initPlugins">_initPlugins</a></li>
<li class="private"><a href="#method__plug" title="_plug">_plug</a></li>
<li class="private"><a href="#method__unplug" title="_unplug">_unplug</a></li>
<li class=""><a href="#method_hasPlugin" title="hasPlugin">hasPlugin</a></li>
<li class=""><a href="#method_plug" title="plug">plug</a></li>
<li class=""><a href="#method_Plugin.Host.plug" title="Plugin.Host.plug">Plugin.Host.plug</a></li>
<li class=""><a href="#method_Plugin.Host.unplug" title="Plugin.Host.unplug">Plugin.Host.unplug</a></li>
<li class=""><a href="#method_unplug" title="unplug">unplug</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2009 Yahoo! Inc. All rights reserved.
</div>
</div>
<script type="text/javascript">
ALL_YUI_PROPS = [{"access": "private", "host": "Plugin.Host", "name": "_destroyPlugins", "url": "Plugin.Host.html#method__destroyPlugins", "type": "method"}, {"access": "", "host": "Plugin.Host", "name": "hasPlugin", "url": "Plugin.Host.html#method_hasPlugin", "type": "method"}, {"access": "private", "host": "Plugin.Host", "name": "_initPlugins", "url": "Plugin.Host.html#method__initPlugins", "type": "method"}, {"access": "private", "host": "Plugin.Host", "name": "_plug", "url": "Plugin.Host.html#method__plug", "type": "method"}, {"access": "", "host": "Plugin.Host", "name": "plug", "url": "Plugin.Host.html#method_plug", "type": "method"}, {"access": "", "host": "Plugin.Host", "name": "Plugin.Host.plug", "url": "Plugin.Host.html#method_Plugin.Host.plug", "type": "method"}, {"access": "", "host": "Plugin.Host", "name": "Plugin.Host.unplug", "url": "Plugin.Host.html#method_Plugin.Host.unplug", "type": "method"}, {"access": "private", "host": "Plugin.Host", "name": "_unplug", "url": "Plugin.Host.html#method__unplug", "type": "method"}, {"access": "", "host": "Plugin.Host", "name": "unplug", "url": "Plugin.Host.html#method_unplug", "type": "method"}];
</script>
</body>
</html>