<!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: animations-plugin Anim.js (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://neyric.github.com/wireit" title="WireItLibrary">WireItLibrary</a></h1>
<h3>animations-plugin <span class="subtitle">0.6.0</span></h3>
<a href="./index.html" title="WireItLibrary">WireItLibrary</a>
> <a href="./module_animations-plugin.html" title="animations-plugin">animations-plugin</a>
> Anim.js (source view)
<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>
<div id="srcout">
<style>
#doc3 .classopts { display:none; }
</style>
<div class="highlight"><pre><span class="c">/**</span>
<span class="c"> * Some utility classes to provide animations in WireIt</span>
<span class="c"> * @module animations-plugin</span>
<span class="c"> */</span>
<span class="c">/**</span>
<span class="c"> * WireIt.util.Anim is a wrapper class for YAHOO.util.Anim, to redraw the wires associated with the given terminals while running the animation.</span>
<span class="c"> * @class Anim</span>
<span class="c"> * @namespace WireIt.util</span>
<span class="c"> * @extends YAHOO.util.Anim</span>
<span class="c"> * @constructor</span>
<span class="c"> * @param {Array} terminals List of WireIt.Terminal objects associated within the animated element</span>
<span class="c"> * @params {String} id Parameter of YAHOO.util.Anim</span>
<span class="c"> * @params {String} sGroup Parameter of YAHOO.util.Anim</span>
<span class="c"> * @params {Object} config Parameter of YAHOO.util.Anim</span>
<span class="c"> */</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Anim</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span> <span class="nx">terminals</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">attributes</span><span class="o">,</span> <span class="nx">duration</span><span class="o">,</span> <span class="nx">method</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">terminals</span><span class="p">)</span> <span class="p">{</span>
<span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">"WireIt.util.Anim needs at least terminals and id"</span><span class="p">);</span>
<span class="p">}</span>
<span class="c">/**</span>
<span class="c"> * List of the contained terminals</span>
<span class="c"> * @property _WireItTerminals</span>
<span class="c"> * @type {Array}</span>
<span class="c"> */</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_WireItTerminals</span> <span class="o">=</span> <span class="nx">terminals</span><span class="o">;</span>
<span class="nx">WireIt</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Anim</span><span class="p">.</span><span class="nx">superclass</span><span class="p">.</span><span class="nx">constructor</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">attributes</span><span class="o">,</span> <span class="nx">duration</span><span class="o">,</span> <span class="nx">method</span><span class="p">);</span>
<span class="c">// Subscribe the onTween event to move the wires</span>
<span class="k">this</span><span class="p">.</span><span class="nx">onTween</span><span class="p">.</span><span class="nx">subscribe</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">moveWireItWires</span><span class="o">,</span> <span class="k">this</span><span class="o">,</span> <span class="kc">true</span><span class="p">);</span>
<span class="p">};</span>
<span class="nx">YAHOO</span><span class="p">.</span><span class="nx">extend</span><span class="p">(</span><span class="nx">WireIt</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Anim</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">util</span><span class="p">.</span><span class="nx">Anim</span><span class="o">,</span> <span class="p">{</span>
<span class="c">/**</span>
<span class="c"> * Listen YAHOO.util.Anim.onTween events to redraw the wires</span>
<span class="c"> * @method moveWireItWires</span>
<span class="c"> */</span>
<span class="nx">moveWireItWires</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
<span class="c">// Make sure terminalList is an array</span>
<span class="kd">var</span> <span class="nx">terminalList</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="p">.</span><span class="nx">lang</span><span class="p">.</span><span class="nx">isArray</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_WireItTerminals</span><span class="p">)</span> <span class="o">?</span> <span class="k">this</span><span class="p">.</span><span class="nx">_WireItTerminals</span> <span class="o">:</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_WireItTerminals</span><span class="p">.</span><span class="nx">isWireItTerminal</span> <span class="o">?</span> <span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">_WireItTerminals</span><span class="p">]</span> <span class="o">:</span> <span class="p">[]);</span>
<span class="c">// Redraw all the wires</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">0</span> <span class="o">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">terminalList</span><span class="p">.</span><span class="nx">length</span> <span class="o">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="k">if</span><span class="p">(</span><span class="nx">terminalList</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">wires</span><span class="p">)</span> <span class="p">{</span>
<span class="k">for</span><span class="p">(</span><span class="kd">var</span> <span class="nx">k</span> <span class="o">=</span> <span class="mi">0</span> <span class="o">;</span> <span class="nx">k</span> <span class="o"><</span> <span class="nx">terminalList</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">wires</span><span class="p">.</span><span class="nx">length</span> <span class="o">;</span> <span class="nx">k</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">terminalList</span><span class="p">[</span><span class="nx">i</span><span class="p">].</span><span class="nx">wires</span><span class="p">[</span><span class="nx">k</span><span class="p">].</span><span class="nx">redraw</span><span class="p">();</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="p">}</span><span class="o">,</span>
<span class="c">/**</span>
<span class="c"> * In case you change the terminals since you created the WireIt.util.Anim:</span>
<span class="c"> * @method setTerminals</span>
<span class="c"> * @param {Array} terminals</span>
<span class="c"> */</span>
<span class="nx">setTerminals</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">terminals</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_WireItTerminals</span> <span class="o">=</span> <span class="nx">terminals</span><span class="o">;</span>
<span class="p">}</span>
<span class="p">});</span>
</pre></div>
</div>
</div>
</div>
<div class="yui-b">
<div class="nav">
<div id="moduleList" class="module">
<h4>Modules</h4>
<ul class="content">
<li class="selected"><a href="module_animations-plugin.html" title="animations-plugin">animations-plugin</a></li>
<li class=""><a href="module_composable-plugin.html" title="composable-plugin">composable-plugin</a></li>
<li class=""><a href="module_editor-plugin.html" title="editor-plugin">editor-plugin</a></li>
<li class=""><a href="module_inputex-plugin.html" title="inputex-plugin">inputex-plugin</a></li>
<li class=""><a href="module_layout-plugin.html" title="layout-plugin">layout-plugin</a></li>
<li class=""><a href="module_wireit.html" title="WireIt">WireIt</a></li>
</ul>
</div>
<div id="classList" class="module">
<h4>Classes</h4>
<ul class="content">
<li class=""><a href="WireIt.util.Anim.html" title="WireIt.util.Anim">WireIt.util.Anim</a></li>
</ul>
</div>
<div id="fileList" class="module">
<h4>Files</h4>
<ul class="content">
<li class="selected"><a href="Anim.js.html" title="Anim.js">Anim.js</a></li>
<li class=""><a href="ComposableWiringEditor.js.html" title="ComposableWiringEditor.js">ComposableWiringEditor.js</a></li>
<li class=""><a href="Layer.js.html" title="Layer.js">Layer.js</a></li>
</ul>
</div>
</div>
</div>
</div>
<div id="ft">
<hr />
Copyright © 2010 Eric Abouaf All rights reserved.
</div>
</div>
<script type="text/javascript">
var ALL_YUI_PROPS = [{"url": "WireIt.util.Anim.html#method_clearExplode", "access": "", "host": "WireIt.util.Anim", "type": "method", "name": "clearExplode"}, {"url": "WireIt.util.Anim.html#method_moveWireItWires", "access": "", "host": "WireIt.util.Anim", "type": "method", "name": "moveWireItWires"}, {"url": "WireIt.util.Anim.html#method_setTerminals", "access": "", "host": "WireIt.util.Anim", "type": "method", "name": "setTerminals"}, {"url": "WireIt.util.Anim.html#property__WireItTerminals", "access": "", "host": "WireIt.util.Anim", "type": "property", "name": "_WireItTerminals"}];
</script>
</body>
</html>