Base.js.html revision eb9b6f817df5c660be9f00fc5d27fe33479fdc98
<html>
<head>
</head>
<body id="yahoo-com">
<div id="doc3" class="yui-t2">
<div id="hd">
<h3>base <span class="subtitle">3.00PR1</span></h3>
<p>
> Base.js (source view)
</p>
</div>
<div id="bd">
<div id="yui-main">
<div class="yui-b">
<form name="yui-classopts-form">
<span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> Show Private</span>
<span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> Show Protected</span>
<span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> Show Deprecated</span>
</form>
<div id="srcout">
<style>
#doc3 #classopts { display:none; }
</style>
<div class="highlight" ><pre> <span class="c">/**</span>
<span class="c"> * Base class support for objects requiring</span>
<span class="c"> * managed attributes and acting as event targets</span>
<span class="c"> *</span>
<span class="c"> * @module base</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">L</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Lang</span><span class="o">,</span>
<span class="nx">O</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Object</span><span class="o">,</span>
<span class="nx">SEP</span> <span class="o">=</span> <span class="s2">":"</span><span class="o">,</span>
<span class="nx">DESTROY</span> <span class="o">=</span> <span class="s2">"destroy"</span><span class="o">,</span>
<span class="nx">INIT</span> <span class="o">=</span> <span class="s2">"init"</span><span class="o">,</span>
<span class="nx">VALUE</span> <span class="o">=</span> <span class="s2">"value"</span><span class="o">,</span>
<span class="nx">INITIALIZED</span> <span class="o">=</span> <span class="s2">"initialized"</span><span class="o">,</span>
<span class="nx">DESTROYED</span> <span class="o">=</span> <span class="s2">"destroyed"</span><span class="o">,</span>
<span class="nx">INITIALIZER</span> <span class="o">=</span> <span class="s2">"initializer"</span><span class="o">,</span>
<span class="nx">DESTRUCTOR</span> <span class="o">=</span> <span class="s2">"destructor"</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">ETP</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Event</span><span class="o">.</span><span class="nx">Target</span><span class="o">.</span><span class="nx">prototype</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Provides a base class for managed attribute based</span>
<span class="c"> * objects, which automates chaining of init and destroy</span>
<span class="c"> * lifecycle methods and automatic instantiation of</span>
<span class="c"> * registered Attributes, through the static ATTRS property</span>
<span class="c"> * @constructor</span>
<span class="c"> * @class Base</span>
<span class="c"> * @uses Attribute</span>
<span class="c"> *</span>
<span class="c"> * @param {Object} config Object literal of configuration property name/value pairs</span>
<span class="c"> */</span>
<span class="k">var</span> <span class="nx">Base</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'constructor called'</span><span class="o">,</span> <span class="s1">'life'</span><span class="o">,</span> <span class="s1">'Base'</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Attribute</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">init</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
<span class="o">};</span>
<span class="c">/**</span>
<span class="c"> * Name string to be used to identify instances of </span>
<span class="c"> * this class, for example in prefixing events.</span>
<span class="c"> *</span>
<span class="c"> * Classes extending Base, should define their own</span>
<span class="c"> * static NAME property.</span>
<span class="c"> *</span>
<span class="c"> * @property NAME</span>
<span class="c"> * @type String</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">Base</span><span class="o">.</span><span class="nx">NAME</span> <span class="o">=</span> <span class="s1">'base'</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * Object literal defining the set of attributes which</span>
<span class="c"> * will be available for instances of this class, and </span>
<span class="c"> * how they are configured. See Attributes addAtt method</span>
<span class="c"> * for a description of configuration options available </span>
<span class="c"> * for each attribute.</span>
<span class="c"> *</span>
<span class="c"> * @property ATTRS</span>
<span class="c"> * @type Object</span>
<span class="c"> * @static</span>
<span class="c"> */</span>
<span class="nx">Base</span><span class="o">.</span><span class="nx">ATTRS</span> <span class="o">=</span> <span class="o">{</span>
<span class="c">/**</span>
<span class="c"> * Flag indicating whether or not this object</span>
<span class="c"> * has been through the init lifecycle phase.</span>
<span class="c"> *</span>
<span class="c"> * @attribute initialized</span>
<span class="c"> * @readonly</span>
<span class="c"> * @default false</span>
<span class="c"> * @type boolean</span>
<span class="c"> */</span>
<span class="nx">intialized</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">readOnly</span><span class="o">:</span><span class="kc">true</span><span class="o">,</span>
<span class="nx">value</span><span class="o">:</span><span class="kc">false</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Flag indicating whether or not this object</span>
<span class="c"> * has been through the destroy lifecycle phase.</span>
<span class="c"> *</span>
<span class="c"> * @attribute destroyed</span>
<span class="c"> * @readonly</span>
<span class="c"> * @default false</span>
<span class="c"> * @type boolean</span>
<span class="c"> */</span>
<span class="nx">destroyed</span><span class="o">:</span> <span class="o">{</span>
<span class="nx">readOnly</span><span class="o">:</span><span class="kc">true</span><span class="o">,</span>
<span class="nx">value</span><span class="o">:</span><span class="kc">false</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="k">var</span> <span class="nx">_instances</span> <span class="o">=</span> <span class="o">{};</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Builds a constructor function (class) from the</span>
<span class="c"> * main function, and array of extension functions</span>
<span class="c"> * provided.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * The cfg object literal supports the following properties</span>
<span class="c"> * </p></span>
<span class="c"> * <dl></span>
<span class="c"> * <dt>dynamic {boolean}</dt></span>
<span class="c"> * <dd></span>
<span class="c"> * <p>If true, a completely new class</span>
<span class="c"> * is created which extends the main class, and acts as the </span>
<span class="c"> * host on which the extension classes are augmented.</p></span>
<span class="c"> * <p>If false, the extensions classes are augmented directly to</span>
<span class="c"> * the main class, modifying the main class.</p></span>
<span class="c"> * </dd></span>
<span class="c"> * <dt>aggregates {String[]}</dt></span>
<span class="c"> * <dd>An array of static property names, which will get aggregated</span>
<span class="c"> * on to the built class in addition to the default properties build </span>
<span class="c"> * will always aggregate - "ATTRS" and "PLUGINS", as defined by </span>
<span class="c"> * </dl></span>
<span class="c"> *</span>
<span class="c"> * @method build</span>
<span class="c"> * @static</span>
<span class="c"> * @param {Function} main The main class on which to base the built class</span>
<span class="c"> * @param {Function[]} extensions The set of extension classes which will be</span>
<span class="c"> * @param {Object} cfg</span>
<span class="c"> */</span>
<span class="nx">Base</span><span class="o">.</span><span class="nx">build</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">main</span><span class="o">,</span> <span class="nx">extensions</span><span class="o">,</span> <span class="nx">cfg</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">build</span> <span class="o">=</span> <span class="nx">Base</span><span class="o">.</span><span class="nx">build</span><span class="o">,</span>
<span class="nx">builtClass</span><span class="o">,</span>
<span class="nx">extClass</span><span class="o">,</span>
<span class="nx">aggregates</span><span class="o">,</span>
<span class="nx">dynamic</span><span class="o">,</span>
<span class="nx">key</span> <span class="o">=</span> <span class="nx">main</span><span class="o">.</span><span class="nx">NAME</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">cfg</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">aggregates</span> <span class="o">=</span> <span class="nx">cfg</span><span class="o">.</span><span class="nx">aggregates</span><span class="o">;</span>
<span class="nx">dynamic</span> <span class="o">=</span> <span class="nx">cfg</span><span class="o">.</span><span class="nx">dynamic</span><span class="o">;</span>
<span class="o">}</span>
<span class="c">// Create dynamic class or just modify main class</span>
<span class="c"></span> <span class="nx">builtClass</span> <span class="o">=</span> <span class="o">(</span><span class="nx">dynamic</span><span class="o">)</span> <span class="o">?</span> <span class="nx">build</span><span class="o">.</span><span class="nx">_template</span><span class="o">(</span><span class="nx">main</span><span class="o">)</span> <span class="o">:</span> <span class="nx">main</span><span class="o">;</span>
<span class="nx">builtClass</span><span class="o">.</span><span class="nx">_yuibuild</span> <span class="o">=</span> <span class="o">{</span>
<span class="nx">id</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
<span class="nx">exts</span> <span class="o">:</span> <span class="o">[],</span>
<span class="nx">dynamic</span> <span class="o">:</span> <span class="nx">dynamic</span>
<span class="o">};</span>
<span class="nx">aggregates</span> <span class="o">=</span> <span class="o">(</span><span class="nx">aggregates</span><span class="o">)</span> <span class="o">?</span> <span class="nx">build</span><span class="o">.</span><span class="nx">AGGREGATES</span><span class="o">.</span><span class="nx">concat</span><span class="o">(</span><span class="nx">aggregates</span><span class="o">)</span> <span class="o">:</span> <span class="nx">build</span><span class="o">.</span><span class="nx">AGGREGATES</span><span class="o">;</span>
<span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">extensions</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
<span class="nx">al</span> <span class="o">=</span> <span class="nx">aggregates</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
<span class="nx">i</span><span class="o">;</span>
<span class="c">// Shallow isolate aggregates</span>
<span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">dynamic</span> <span class="o">&&</span> <span class="nx">aggregates</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">al</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="nx">aggregates</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">O</span><span class="o">.</span><span class="nx">owns</span><span class="o">(</span><span class="nx">main</span><span class="o">,</span> <span class="nx">val</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">builtClass</span><span class="o">[</span><span class="nx">val</span><span class="o">]</span> <span class="o">=</span> <span class="nx">L</span><span class="o">.</span><span class="nx">isArray</span><span class="o">(</span><span class="nx">main</span><span class="o">[</span><span class="nx">val</span><span class="o">])</span> <span class="o">?</span> <span class="o">[]</span> <span class="o">:</span> <span class="o">{};</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">aggregate</span><span class="o">(</span><span class="nx">builtClass</span><span class="o">,</span> <span class="nx">main</span><span class="o">,</span> <span class="kc">true</span><span class="o">,</span> <span class="nx">aggregates</span><span class="o">);</span>
<span class="o">}</span>
<span class="c"></span> <span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">el</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nx">extClass</span> <span class="o">=</span> <span class="nx">extensions</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">aggregates</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">aggregate</span><span class="o">(</span><span class="nx">builtClass</span><span class="o">,</span> <span class="nx">extClass</span><span class="o">,</span> <span class="kc">true</span><span class="o">,</span> <span class="nx">aggregates</span><span class="o">);</span>
<span class="o">}</span>
<span class="c">// Old augment</span>
<span class="c"></span> <span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">builtClass</span><span class="o">,</span> <span class="nx">extClass</span><span class="o">,</span> <span class="kc">true</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
<span class="nx">builtClass</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">exts</span><span class="o">.</span><span class="nx">push</span><span class="o">(</span><span class="nx">extClass</span><span class="o">);</span>
<span class="nx">key</span> <span class="o">=</span> <span class="nx">key</span> <span class="o">+</span> <span class="s2">":"</span> <span class="o">+</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="nx">extClass</span><span class="o">);</span>
<span class="o">}</span>
<span class="nx">builtClass</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">key</span><span class="o">;</span>
<span class="nx">builtClass</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">hasImpl</span> <span class="o">=</span> <span class="nx">build</span><span class="o">.</span><span class="nx">_hasImpl</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">dynamic</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">builtClass</span><span class="o">.</span><span class="nx">NAME</span> <span class="o">=</span> <span class="nx">main</span><span class="o">.</span><span class="nx">NAME</span><span class="o">;</span>
<span class="nx">builtClass</span><span class="o">.</span><span class="nx">prototype</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">=</span> <span class="nx">builtClass</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">builtClass</span><span class="o">;</span>
<span class="o">};</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">Base</span><span class="o">.</span><span class="nx">build</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">AGGREGATES</span> <span class="o">:</span> <span class="o">[</span><span class="s2">"ATTRS"</span><span class="o">,</span> <span class="s2">"PLUGINS"</span><span class="o">],</span>
<span class="nx">_template</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">main</span><span class="o">)</span> <span class="o">{</span>
<span class="k">function</span> <span class="nx">BuiltClass</span><span class="o">()</span> <span class="o">{</span>
<span class="nx">BuiltClass</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="nx">BuiltClass</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">exts</span><span class="o">,</span>
<span class="nx">l</span> <span class="o">=</span> <span class="nx">f</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">l</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="nx">f</span><span class="o">[</span><span class="nx">i</span><span class="o">].</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">return</span> <span class="k">this</span><span class="o">;</span>
<span class="o">}</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">BuiltClass</span><span class="o">,</span> <span class="nx">main</span><span class="o">);</span>
<span class="k">return</span> <span class="nx">BuiltClass</span><span class="o">;</span>
<span class="o">},</span>
<span class="nx">_hasImpl</span> <span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">extClass</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">exts</span><span class="o">,</span>
<span class="nx">l</span> <span class="o">=</span> <span class="nx">f</span><span class="o">.</span><span class="nx">length</span><span class="o">,</span>
<span class="nx">i</span><span class="o">;</span>
<span class="k">for</span> <span class="o">(</span><span class="nx">i</span> <span class="o">=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">l</span><span class="o">;</span> <span class="nx">i</span><span class="o">++)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">f</span><span class="o">[</span><span class="nx">i</span><span class="o">]</span> <span class="o">===</span> <span class="nx">extClass</span><span class="o">)</span> <span class="o">{</span>
<span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">});</span>
<span class="c">/**</span>
<span class="c"> * @method create</span>
<span class="c"> * @static</span>
<span class="c"> *</span>
<span class="c"> * @param {Function} main </span>
<span class="c"> * @param {Array} extensions</span>
<span class="c"> * @param {Any*} args </span>
<span class="c"> */</span>
<span class="nx">Base</span><span class="o">.</span><span class="nx">create</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">main</span><span class="o">,</span> <span class="nx">extensions</span><span class="o">,</span> <span class="nx">args</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">Base</span><span class="o">.</span><span class="nx">build</span><span class="o">(</span><span class="nx">main</span><span class="o">,</span> <span class="nx">extensions</span><span class="o">,</span> <span class="o">{</span><span class="nx">dynamic</span><span class="o">:</span><span class="kc">true</span><span class="o">}),</span>
<span class="nx">cArgs</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nb">Array</span><span class="o">(</span><span class="nx">arguments</span><span class="o">,</span> <span class="m">2</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="k">function</span> <span class="nx">F</span><span class="o">(){}</span>
<span class="nx">F</span><span class="o">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">prototype</span><span class="o">;</span>
<span class="k">return</span> <span class="nx">c</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">new</span> <span class="nx">F</span><span class="o">(),</span> <span class="nx">cArgs</span><span class="o">);</span>
<span class="o">};</span>
<span class="nx">Base</span><span class="o">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="o">{</span>
<span class="c">/**</span>
<span class="c"> * Init lifecycle method, invoked during construction.</span>
<span class="c"> * Fires the init event prior to invoking initializers on</span>
<span class="c"> * the class hierarchy.</span>
<span class="c"> * </span>
<span class="c"> * @method init</span>
<span class="c"> * @final</span>
<span class="c"> * @param {Object} config Object literal of configuration property name/value pairs</span>
<span class="c"> */</span>
<span class="nx">init</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">config</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'init called'</span><span class="o">,</span> <span class="s1">'life'</span><span class="o">,</span> <span class="s1">'Base'</span><span class="o">);</span>
<span class="c">/**</span>
<span class="c"> * The name string to be used to identify </span>
<span class="c"> * this instance of object. </span>
<span class="c"> * @property name</span>
<span class="c"> * @type String</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">name</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">NAME</span><span class="o">;</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Init event, fired prior to initialization. Invoking</span>
<span class="c"> * the preventDefault method on the EventFacade provided </span>
<span class="c"> * to subscribers will prevent initialization from occuring.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * Subscribers to the after momemt of this event, will be notified</span>
<span class="c"> * after initialization of the object is complete (and therefore</span>
<span class="c"> * cannot prevent initialization).</span>
<span class="c"> * </p></span>
<span class="c"> *</span>
<span class="c"> * @event init</span>
<span class="c"> * @param {EventFacade} e Event object</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">publish</span><span class="o">(</span><span class="nx">INIT</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">queuable</span><span class="o">:</span><span class="kc">false</span><span class="o">,</span>
<span class="nx">defaultFn</span><span class="o">:</span><span class="k">this</span><span class="o">.</span><span class="nx">_defInitFn</span>
<span class="o">});</span>
<span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">INIT</span><span class="o">,</span> <span class="nx">config</span><span class="o">);</span>
<span class="k">return</span> <span class="k">this</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Destroy lifecycle method. Fires the destroy</span>
<span class="c"> * event, prior to invoking destructors for the</span>
<span class="c"> * class heirarchy.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * Subscribers to the destroy</span>
<span class="c"> * event can preventDefault to prevent destruction</span>
<span class="c"> * from proceeding.</span>
<span class="c"> * </p></span>
<span class="c"> * @method destroy</span>
<span class="c"> * @final</span>
<span class="c"> */</span>
<span class="nx">destroy</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">'destroy called'</span><span class="o">,</span> <span class="s1">'life'</span><span class="o">,</span> <span class="s1">'Base'</span><span class="o">);</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Destroy event, fired prior to destruction. Invoking</span>
<span class="c"> * the preventDefault method on the EventFacade provided </span>
<span class="c"> * to subscribers will prevent destruction from proceeding.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * Subscribers to the after momemt of this event, will be notified</span>
<span class="c"> * after destruction is complete (and as a result cannot prevent</span>
<span class="c"> * destruction).</span>
<span class="c"> * </p></span>
<span class="c"> * @event destroy</span>
<span class="c"> * @param {EventFacade} e Event object</span>
<span class="c"> */</span>
<span class="k">this</span><span class="o">.</span><span class="nx">publish</span><span class="o">(</span><span class="nx">DESTROY</span><span class="o">,</span> <span class="o">{</span>
<span class="nx">queuable</span><span class="o">:</span><span class="kc">false</span><span class="o">,</span>
<span class="nx">defaultFn</span><span class="o">:</span> <span class="k">this</span><span class="o">.</span><span class="nx">_defDestroyFn</span>
<span class="o">});</span>
<span class="k">this</span><span class="o">.</span><span class="nx">fire</span><span class="o">(</span><span class="nx">DESTROY</span><span class="o">);</span>
<span class="k">return</span> <span class="k">this</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Default init event handler</span>
<span class="c"> *</span>
<span class="c"> * @method _defInitFn</span>
<span class="c"> * @protected</span>
<span class="c"> */</span>
<span class="nx">_defInitFn</span> <span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">config</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">_instances</span><span class="o">[</span><span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)]</span> <span class="o">=</span> <span class="k">this</span><span class="o">;</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_initHierarchy</span><span class="o">(</span><span class="nx">config</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_conf</span><span class="o">.</span><span class="nx">remove</span><span class="o">(</span><span class="nx">INITIALIZED</span><span class="o">,</span> <span class="nx">VALUE</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="nx">INITIALIZED</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Default destroy event handler</span>
<span class="c"> *</span>
<span class="c"> * @method _defDestroyFn</span>
<span class="c"> * @protected</span>
<span class="c"> */</span>
<span class="nx">_defDestroyFn</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_destroyHierarchy</span><span class="o">();</span>
<span class="nx">delete</span> <span class="nx">_instances</span><span class="o">[</span><span class="k">this</span><span class="o">.</span><span class="nx">_yuid</span><span class="o">];</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_conf</span><span class="o">.</span><span class="nx">remove</span><span class="o">(</span><span class="nx">DESTROYED</span><span class="o">,</span> <span class="nx">VALUE</span><span class="o">);</span>
<span class="k">this</span><span class="o">.</span><span class="nx">set</span><span class="o">(</span><span class="nx">DESTROYED</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Returns the top down class heirarchy for this object,</span>
<span class="c"> * with Base being the first class in the array</span>
<span class="c"> *</span>
<span class="c"> * @protected</span>
<span class="c"> * @return {Array} array of classes</span>
<span class="c"> */</span>
<span class="nx">_getClasses</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">_classes</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">constructor</span><span class="o">,</span>
<span class="nx">classes</span> <span class="o">=</span> <span class="o">[];</span>
<span class="k">while</span> <span class="o">(</span><span class="nx">c</span> <span class="o">&&</span> <span class="nx">c</span><span class="o">.</span><span class="nx">prototype</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">classes</span><span class="o">.</span><span class="nx">unshift</span><span class="o">(</span><span class="nx">c</span><span class="o">);</span>
<span class="nx">c</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">superclass</span> <span class="o">?</span> <span class="nx">c</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_classes</span> <span class="o">=</span> <span class="nx">classes</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">_classes</span><span class="o">.</span><span class="nx">concat</span><span class="o">();</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Initializes the class hierarchy rooted at this base class,</span>
<span class="c"> * which includes initializing attributes for each class defined </span>
<span class="c"> * in the class's static ATTRS property and invoking the initializer </span>
<span class="c"> * method on the prototype of each class in the hierarchy.</span>
<span class="c"> * </span>
<span class="c"> * @method _initHierarchy</span>
<span class="c"> * @param {Object} userConf Config hash containing attribute name/value pairs</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_initHierarchy</span> <span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">userConf</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">constr</span><span class="o">,</span>
<span class="nx">classes</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getClasses</span><span class="o">();</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">ci</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="nx">cl</span> <span class="o">=</span> <span class="nx">classes</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">ci</span> <span class="o"><</span> <span class="nx">cl</span><span class="o">;</span> <span class="nx">ci</span><span class="o">++)</span> <span class="o">{</span>
<span class="nx">constr</span> <span class="o">=</span> <span class="nx">classes</span><span class="o">[</span><span class="nx">ci</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">constr</span><span class="o">.</span><span class="nx">_yuibuild</span> <span class="o">&&</span> <span class="nx">constr</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">exts</span> <span class="o">&&</span> <span class="o">!</span><span class="nx">constr</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">dynamic</span><span class="o">)</span> <span class="o">{</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">ei</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="nx">el</span> <span class="o">=</span> <span class="nx">constr</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">exts</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">ei</span> <span class="o"><</span> <span class="nx">el</span><span class="o">;</span> <span class="nx">ei</span><span class="o">++)</span> <span class="o">{</span>
<span class="nx">constr</span><span class="o">.</span><span class="nx">_yuibuild</span><span class="o">.</span><span class="nx">exts</span><span class="o">[</span><span class="nx">ei</span><span class="o">].</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="k">this</span><span class="o">.</span><span class="nx">_initAtts</span><span class="o">(</span><span class="nx">constr</span><span class="o">.</span><span class="nx">ATTRS</span><span class="o">,</span> <span class="nx">userConf</span><span class="o">);</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">O</span><span class="o">.</span><span class="nx">owns</span><span class="o">(</span><span class="nx">constr</span><span class="o">.</span><span class="nx">prototype</span><span class="o">,</span> <span class="nx">INITIALIZER</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">constr</span><span class="o">.</span><span class="nx">prototype</span><span class="o">[</span><span class="nx">INITIALIZER</span><span class="o">].</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Destroys the class hierarchy rooted at this base class by invoking</span>
<span class="c"> * the descructor method on the prototype of each class in the hierarchy.</span>
<span class="c"> *</span>
<span class="c"> * @method _destroyHierarchy</span>
<span class="c"> * @private</span>
<span class="c"> */</span>
<span class="nx">_destroyHierarchy</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">constr</span><span class="o">,</span>
<span class="nx">classes</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_getClasses</span><span class="o">();</span>
<span class="k">for</span> <span class="o">(</span><span class="k">var</span> <span class="nx">ci</span> <span class="o">=</span> <span class="nx">classes</span><span class="o">.</span><span class="nx">length</span><span class="o">-</span><span class="m">1</span><span class="o">;</span> <span class="nx">ci</span> <span class="o">>=</span> <span class="m">0</span><span class="o">;</span> <span class="nx">ci</span><span class="o">--)</span> <span class="o">{</span>
<span class="nx">constr</span> <span class="o">=</span> <span class="nx">classes</span><span class="o">[</span><span class="nx">ci</span><span class="o">];</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">O</span><span class="o">.</span><span class="nx">owns</span><span class="o">(</span><span class="nx">constr</span><span class="o">.</span><span class="nx">prototype</span><span class="o">,</span> <span class="nx">DESTRUCTOR</span><span class="o">))</span> <span class="o">{</span>
<span class="nx">constr</span><span class="o">.</span><span class="nx">prototype</span><span class="o">[</span><span class="nx">DESTRUCTOR</span><span class="o">].</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span>
<span class="o">}</span>
<span class="o">}</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Default toString implementation</span>
<span class="c"> * @method toString</span>
<span class="c"> */</span>
<span class="nx">toString</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">NAME</span> <span class="o">+</span> <span class="s2">"["</span> <span class="o">+</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">stamp</span><span class="o">(</span><span class="k">this</span><span class="o">)</span> <span class="o">+</span> <span class="s2">"]"</span><span class="o">;</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Subscribe to a custom event hosted by this object.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * of the instance to the event type, if absent.</span>
<span class="c"> * </p></span>
<span class="c"> * </span>
<span class="c"> * @method subscribe</span>
<span class="c"> * @param {String} type The type of event to subscribe to. If </span>
<span class="c"> * the type string does not contain a prefix ("prefix:eventType"), </span>
<span class="c"> * the name property of the instance will be used as the default prefix.</span>
<span class="c"> * @param {Function} fn The callback, invoked when the event is fired.</span>
<span class="c"> * @param {Object} context The execution context</span>
<span class="c"> * </span>
<span class="c"> */</span>
<span class="nx">subscribe</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">arguments</span><span class="o">;</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="k">return</span> <span class="nx">ETP</span><span class="o">.</span><span class="nx">subscribe</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Fire a custom event by name. The callback functions will be executed</span>
<span class="c"> * from the context specified when the event was created, and with the </span>
<span class="c"> * following parameters.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * of the instance to the event type, if absent.</span>
<span class="c"> * </p></span>
<span class="c"> * @method fire</span>
<span class="c"> * @param {String|Object} type The type of the event, or an object that contains</span>
<span class="c"> * a 'type' property. If the type does not contain a prefix ("prefix:eventType"),</span>
<span class="c"> * the name property of the instance will be used as the default prefix.</span>
<span class="c"> * @param {Object*} arguments an arbitrary set of parameters to pass to </span>
<span class="c"> * the handler.</span>
<span class="c"> *</span>
<span class="c"> */</span>
<span class="nx">fire</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">arguments</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">L</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]))</span> <span class="o">{</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">type</span><span class="o">){</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">type</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">].</span><span class="nx">type</span><span class="o">);</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">ETP</span><span class="o">.</span><span class="nx">fire</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Creates a new custom event of the specified type. If a custom event</span>
<span class="c"> * by that name already exists, it will not be re-created. In either</span>
<span class="c"> * case the custom event is returned. </span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * of the instance to the event type, if absent.</span>
<span class="c"> * </p></span>
<span class="c"> *</span>
<span class="c"> * @method publish</span>
<span class="c"> * @param {String} type The type, or name of the event. If the type does not </span>
<span class="c"> * contain a prefix ("prefix:eventType"), the name property of the instance will </span>
<span class="c"> * be used as the default prefix.</span>
<span class="c"> * @param {Object} opts Optional config params (see Event.Target publish for details)</span>
<span class="c"> */</span>
<span class="nx">publish</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">arguments</span><span class="o">;</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="k">return</span> <span class="nx">ETP</span><span class="o">.</span><span class="nx">publish</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Subscribe to a custom event hosted by this object. The</span>
<span class="c"> * supplied callback will execute <em>after</em> any listeners added</span>
<span class="c"> * via the subscribe method, and after the default function,</span>
<span class="c"> * if configured for the event, has executed.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * of the instance to the event type, if absent.</span>
<span class="c"> * </p></span>
<span class="c"> * @method after</span>
<span class="c"> * @param {String} type The type of event to subscribe to. If </span>
<span class="c"> * the type string does not contain a prefix ("prefix:eventType"), </span>
<span class="c"> * the name property of the instance will be used as the default prefix.</span>
<span class="c"> * @param {Function} fn The callback</span>
<span class="c"> * @param {Object} context The execution context</span>
<span class="c"> */</span>
<span class="nx">after</span> <span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">arguments</span><span class="o">;</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="k">return</span> <span class="nx">ETP</span><span class="o">.</span><span class="nx">after</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Unsubscribes one or more listeners the from the specified event.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * of the instance to the event type, if absent.</span>
<span class="c"> * </p></span>
<span class="c"> * @method unsubscribe</span>
<span class="c"> * @param type {String|Object} Either the handle to the subscriber or the </span>
<span class="c"> * type of event. If the type</span>
<span class="c"> * is not specified, it will attempt to remove</span>
<span class="c"> * the listener from all hosted events. If </span>
<span class="c"> * the type string does not contain a prefix </span>
<span class="c"> * ("prefix:eventType"), the name property of the </span>
<span class="c"> * instance will be used as the default prefix.</span>
<span class="c"> * @param fn {Function} The subscribed function to unsubscribe, if not</span>
<span class="c"> * supplied, all subscribers will be removed.</span>
<span class="c"> * @param context {Object} The custom object passed to subscribe. This is</span>
<span class="c"> * optional, but if supplied will be used to</span>
<span class="c"> * disambiguate multiple listeners that are the same</span>
<span class="c"> * that lives on the prototype)</span>
<span class="c"> * @return {boolean} true if the subscriber was found and detached.</span>
<span class="c"> */</span>
<span class="nx">unsubscribe</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">,</span> <span class="nx">fn</span><span class="o">,</span> <span class="nx">context</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">arguments</span><span class="o">;</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">L</span><span class="o">.</span><span class="nx">isString</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]))</span> <span class="o">{</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">ETP</span><span class="o">.</span><span class="nx">unsubscribe</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * <p></span>
<span class="c"> * Removes all listeners from the specified event. If the event type</span>
<span class="c"> * is not specified, all listeners from all hosted custom events will</span>
<span class="c"> * be removed.</span>
<span class="c"> * </p></span>
<span class="c"> * <p></span>
<span class="c"> * Overrides Event.Target's unsubscribeAll method, to add the name prefix </span>
<span class="c"> * of the instance to the event type, if absent.</span>
<span class="c"> * </p></span>
<span class="c"> * @method unsubscribeAll</span>
<span class="c"> * @param type {String} The type, or name of the event. If </span>
<span class="c"> * the type string does not contain a prefix ("prefix:eventType"), </span>
<span class="c"> * the name property of the instance will be used as the default prefix.</span>
<span class="c"> */</span>
<span class="nx">unsubscribeAll</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">)</span> <span class="o">{</span>
<span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="nx">arguments</span><span class="o">;</span>
<span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">_prefixEvtType</span><span class="o">(</span><span class="nx">a</span><span class="o">[</span><span class="m">0</span><span class="o">]);</span>
<span class="k">return</span> <span class="nx">ETP</span><span class="o">.</span><span class="nx">unsubscribeAll</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">a</span><span class="o">);</span>
<span class="o">},</span>
<span class="c">/**</span>
<span class="c"> * Utility method to prefix the event name with the</span>
<span class="c"> * name property of the instance, if absent</span>
<span class="c"> *</span>
<span class="c"> * @method _prefixEvtType</span>
<span class="c"> * @private</span>
<span class="c"> * @param {String} type The event name</span>
<span class="c"> */</span>
<span class="nx">_prefixEvtType</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">type</span><span class="o">)</span> <span class="o">{</span>
<span class="k">if</span> <span class="o">(</span><span class="nx">type</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="nx">SEP</span><span class="o">)</span> <span class="o">===</span> <span class="o">-</span><span class="m">1</span> <span class="o">&&</span> <span class="k">this</span><span class="o">.</span><span class="nx">name</span><span class="o">)</span> <span class="o">{</span>
<span class="nx">type</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">name</span> <span class="o">+</span> <span class="s2">":"</span> <span class="o">+</span> <span class="nx">type</span><span class="o">;</span>
<span class="o">}</span>
<span class="k">return</span> <span class="nx">type</span><span class="o">;</span>
<span class="o">}</span>
<span class="o">};</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">mix</span><span class="o">(</span><span class="nx">Base</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Attribute</span><span class="o">,</span> <span class="kc">false</span><span class="o">,</span> <span class="kc">null</span><span class="o">,</span> <span class="m">1</span><span class="o">);</span>
<span class="nx">Y</span><span class="o">.</span><span class="nx">Base</span> <span class="o">=</span> <span class="nx">Base</span><span class="o">;</span>
</pre></div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div class="module">
<h4>Modules</h4>
<ul class="content">
</ul>
</div>
<div class="module">
<h4>Classes</h4>
<ul class="content">
</ul>
</div>
<div class="module">
<h4>Files</h4>
<ul class="content">
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2008 Yahoo! Inc. All rights reserved.
</div>
</div>
</body>
</html>