Simple status box for the sidebar.
[elgg_plugins.git] / yui / docs / Dom.js.html
blobaea7ef5711e3a2fc3a12516a57666016b947de54
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <title>API: dom Dom.js (YUI Library)</title>
5 <link rel="stylesheet" type="text/css" href="assets/api.css">
6 </head>
8 <body id="yahoo-com">
9 <div id="doc3" class="yui-t2">
11 <div id="hd">
12 <h1>Yahoo! UI Library</h1>
13 <h3>dom&nbsp; <span class="subtitle">2.2.0</span></h3>
14 <p>
15 <a href="./index.html">Yahoo! UI Library</a>
16 &gt; <a href="./module_dom.html">dom</a>
18 &gt; Dom.js (source view)
19 </p>
20 </div>
22 <div id="bd">
23 <div id="yui-main">
24 <div class="yui-b">
26 <div id="srcout">
27 <div class="highlight" ><pre><span class="c">/*</span>
28 <span class="c">Copyright (c) 2006, Yahoo! Inc. All rights reserved.</span>
29 <span class="c">Code licensed under the BSD License:</span>
30 <span class="c">http://developer.yahoo.net/yui/license.txt</span>
31 <span class="c">*/</span>
33 <span class="c">/**</span>
34 <span class="c"> * The dom module provides helper methods for manipulating Dom elements.</span>
35 <span class="c"> * @module dom</span>
36 <span class="c"> *</span>
37 <span class="c"> */</span>
39 <span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>
40 <span class="k">var</span> <span class="nx">Y</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">,</span> <span class="c">// internal shorthand</span>
41 <span class="c"></span> <span class="nx">getStyle</span><span class="o">,</span> <span class="c">// for load time browser branching</span>
42 <span class="c"></span> <span class="nx">setStyle</span><span class="o">,</span> <span class="c">// ditto</span>
43 <span class="c"></span> <span class="nx">id_counter</span> <span class="o">=</span> <span class="m">0</span><span class="o">,</span> <span class="c">// for use with generateId</span>
44 <span class="c"></span> <span class="nx">propertyCache</span> <span class="o">=</span> <span class="o">{};</span> <span class="c">// for faster hyphen converts</span>
45 <span class="c"></span>
46 <span class="c">// brower detection</span>
47 <span class="c"></span> <span class="k">var</span> <span class="nx">ua</span> <span class="o">=</span> <span class="nx">navigator</span><span class="o">.</span><span class="nx">userAgent</span><span class="o">.</span><span class="nx">toLowerCase</span><span class="o">(),</span>
48 <span class="nx">isOpera</span> <span class="o">=</span> <span class="o">(</span><span class="nx">ua</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;opera&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
49 <span class="nx">isSafari</span> <span class="o">=</span> <span class="o">(</span><span class="nx">ua</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;safari&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
50 <span class="nx">isGecko</span> <span class="o">=</span> <span class="o">(!</span><span class="nx">isOpera</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">isSafari</span> <span class="o">&amp;&amp;</span> <span class="nx">ua</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;gecko&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">),</span>
51 <span class="nx">isIE</span> <span class="o">=</span> <span class="o">(!</span><span class="nx">isOpera</span> <span class="o">&amp;&amp;</span> <span class="nx">ua</span><span class="o">.</span><span class="nx">indexOf</span><span class="o">(</span><span class="s1">&#39;msie&#39;</span><span class="o">)</span> <span class="o">&gt;</span> <span class="o">-</span><span class="m">1</span><span class="o">);</span>
53 <span class="c">// regex cache</span>
54 <span class="c"></span> <span class="k">var</span> <span class="nx">patterns</span> <span class="o">=</span> <span class="o">{</span>
55 <span class="nx">HYPHEN</span><span class="o">:</span> <span class="sr">/(-[a-z])/i</span>
56 <span class="o">};</span>
58 <span class="k">var</span> <span class="nx">logger</span> <span class="o">=</span> <span class="o">{};</span>
59 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">log</span><span class="o">.</span><span class="nx">apply</span><span class="o">(</span><span class="nb">window</span><span class="o">,</span> <span class="nx">arguments</span><span class="o">);</span> <span class="o">};</span>
61 <span class="k">var</span> <span class="nx">toCamel</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">property</span><span class="o">)</span> <span class="o">{</span>
62 <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="nx">patterns</span><span class="o">.</span><span class="nx">HYPHEN</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">property</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
63 <span class="k">return</span> <span class="nx">property</span><span class="o">;</span> <span class="c">// no hyphens</span>
64 <span class="c"></span> <span class="o">}</span>
66 <span class="k">if</span> <span class="o">(</span><span class="nx">propertyCache</span><span class="o">[</span><span class="nx">property</span><span class="o">])</span> <span class="o">{</span> <span class="c">// already converted</span>
67 <span class="c"></span> <span class="k">return</span> <span class="nx">propertyCache</span><span class="o">[</span><span class="nx">property</span><span class="o">];</span>
68 <span class="o">}</span>
70 <span class="k">while</span><span class="o">(</span> <span class="nx">patterns</span><span class="o">.</span><span class="nx">HYPHEN</span><span class="o">.</span><span class="nx">exec</span><span class="o">(</span><span class="nx">property</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
71 <span class="nx">property</span> <span class="o">=</span> <span class="nx">property</span><span class="o">.</span><span class="nx">replace</span><span class="o">(</span><span class="nb">RegExp</span><span class="o">.</span><span class="nx">$1</span><span class="o">,</span>
72 <span class="nb">RegExp</span><span class="o">.</span><span class="nx">$1</span><span class="o">.</span><span class="nx">substr</span><span class="o">(</span><span class="m">1</span><span class="o">).</span><span class="nx">toUpperCase</span><span class="o">());</span>
73 <span class="o">}</span>
75 <span class="nx">propertyCache</span><span class="o">[</span><span class="nx">property</span><span class="o">]</span> <span class="o">=</span> <span class="nx">property</span><span class="o">;</span>
76 <span class="k">return</span> <span class="nx">property</span><span class="o">;</span>
77 <span class="c">//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug</span>
78 <span class="c"></span> <span class="o">};</span>
80 <span class="c">// branching at load instead of runtime</span>
81 <span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">defaultView</span> <span class="o">&amp;&amp;</span> <span class="nb">document</span><span class="o">.</span><span class="nx">defaultView</span><span class="o">.</span><span class="nx">getComputedStyle</span><span class="o">)</span> <span class="o">{</span> <span class="c">// W3C DOM method</span>
82 <span class="c"></span> <span class="nx">getStyle</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">)</span> <span class="o">{</span>
83 <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
85 <span class="k">var</span> <span class="nx">computed</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">defaultView</span><span class="o">.</span><span class="nx">getComputedStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;&#39;</span><span class="o">);</span>
86 <span class="k">if</span> <span class="o">(</span><span class="nx">computed</span><span class="o">)</span> <span class="o">{</span> <span class="c">// test computed before touching for safari</span>
87 <span class="c"></span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">computed</span><span class="o">[</span><span class="nx">toCamel</span><span class="o">(</span><span class="nx">property</span><span class="o">)];</span>
88 <span class="o">}</span>
90 <span class="k">return</span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">[</span><span class="nx">property</span><span class="o">]</span> <span class="o">||</span> <span class="nx">value</span><span class="o">;</span>
91 <span class="o">};</span>
92 <span class="o">}</span> <span class="k">else</span> <span class="k">if</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">currentStyle</span> <span class="o">&amp;&amp;</span> <span class="nx">isIE</span><span class="o">)</span> <span class="o">{</span> <span class="c">// IE method</span>
93 <span class="c"></span> <span class="nx">getStyle</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">)</span> <span class="o">{</span>
94 <span class="nx">switch</span><span class="o">(</span> <span class="nx">toCamel</span><span class="o">(</span><span class="nx">property</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
95 <span class="nx">case</span> <span class="s1">&#39;opacity&#39;</span> <span class="o">:</span><span class="c">// IE opacity uses filter</span>
96 <span class="c"></span> <span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="m">100</span><span class="o">;</span>
97 <span class="k">try</span> <span class="o">{</span> <span class="c">// will error if no DXImageTransform</span>
98 <span class="c"></span> <span class="nx">val</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">filters</span><span class="o">[</span><span class="s1">&#39;DXImageTransform.Microsoft.Alpha&#39;</span><span class="o">].</span><span class="nx">opacity</span><span class="o">;</span>
100 <span class="o">}</span> <span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
101 <span class="k">try</span> <span class="o">{</span> <span class="c">// make sure its in the document</span>
102 <span class="c"></span> <span class="nx">val</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">filters</span><span class="o">(</span><span class="s1">&#39;alpha&#39;</span><span class="o">).</span><span class="nx">opacity</span><span class="o">;</span>
103 <span class="o">}</span> <span class="k">catch</span><span class="o">(</span><span class="nx">e</span><span class="o">)</span> <span class="o">{</span>
104 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getStyle: IE filter failed&#39;</span><span class="o">,</span>
105 <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
106 <span class="o">}</span>
107 <span class="o">}</span>
108 <span class="k">return</span> <span class="nx">val</span> <span class="o">/</span> <span class="m">100</span><span class="o">;</span>
109 <span class="k">break</span><span class="o">;</span>
110 <span class="nx">default</span><span class="o">:</span>
111 <span class="c">// test currentStyle before touching</span>
112 <span class="c"></span> <span class="k">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">currentStyle</span> <span class="o">?</span> <span class="nx">el</span><span class="o">.</span><span class="nx">currentStyle</span><span class="o">[</span><span class="nx">property</span><span class="o">]</span> <span class="o">:</span> <span class="kc">null</span><span class="o">;</span>
113 <span class="k">return</span> <span class="o">(</span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">[</span><span class="nx">property</span><span class="o">]</span> <span class="o">||</span> <span class="nx">value</span> <span class="o">);</span>
114 <span class="o">}</span>
115 <span class="o">};</span>
116 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// default to inline only</span>
117 <span class="c"></span> <span class="nx">getStyle</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">)</span> <span class="o">{</span> <span class="k">return</span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">[</span><span class="nx">property</span><span class="o">];</span> <span class="o">};</span>
118 <span class="o">}</span>
120 <span class="k">if</span> <span class="o">(</span><span class="nx">isIE</span><span class="o">)</span> <span class="o">{</span>
121 <span class="nx">setStyle</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
122 <span class="nx">switch</span> <span class="o">(</span><span class="nx">property</span><span class="o">)</span> <span class="o">{</span>
123 <span class="nx">case</span> <span class="s1">&#39;opacity&#39;</span><span class="o">:</span>
124 <span class="k">if</span> <span class="o">(</span> <span class="k">typeof</span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">filter</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// in case not appended</span>
125 <span class="c"></span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">filter</span> <span class="o">=</span> <span class="s1">&#39;alpha(opacity=&#39;</span> <span class="o">+</span> <span class="nx">val</span> <span class="o">*</span> <span class="m">100</span> <span class="o">+</span> <span class="s1">&#39;)&#39;</span><span class="o">;</span>
127 <span class="k">if</span> <span class="o">(!</span><span class="nx">el</span><span class="o">.</span><span class="nx">currentStyle</span> <span class="o">||</span> <span class="o">!</span><span class="nx">el</span><span class="o">.</span><span class="nx">currentStyle</span><span class="o">.</span><span class="nx">hasLayout</span><span class="o">)</span> <span class="o">{</span>
128 <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">zoom</span> <span class="o">=</span> <span class="m">1</span><span class="o">;</span> <span class="c">// when no layout or cant tell</span>
129 <span class="c"></span> <span class="o">}</span>
130 <span class="o">}</span>
131 <span class="k">break</span><span class="o">;</span>
132 <span class="nx">default</span><span class="o">:</span>
133 <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">[</span><span class="nx">property</span><span class="o">]</span> <span class="o">=</span> <span class="nx">val</span><span class="o">;</span>
134 <span class="o">}</span>
135 <span class="o">};</span>
136 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
137 <span class="nx">setStyle</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
138 <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">[</span><span class="nx">property</span><span class="o">]</span> <span class="o">=</span> <span class="nx">val</span><span class="o">;</span>
139 <span class="o">};</span>
140 <span class="o">}</span>
142 <span class="c">/**</span>
143 <span class="c"> * Provides helper methods for DOM elements.</span>
144 <span class="c"> * @namespace YAHOO.util</span>
145 <span class="c"> * @class Dom</span>
146 <span class="c"> */</span>
147 <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Dom</span> <span class="o">=</span> <span class="o">{</span>
148 <span class="c">/**</span>
149 <span class="c"> * Returns an HTMLElement reference.</span>
150 <span class="c"> * @method get</span>
151 <span class="c"> * @param {String | HTMLElement |Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.</span>
152 <span class="c"> * @return {HTMLElement | Array} A DOM reference to an HTML element or an array of HTMLElements.</span>
153 <span class="c"> */</span>
154 <span class="nx">get</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
155 <span class="k">if</span> <span class="o">(!</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span> <span class="k">return</span> <span class="kc">null</span><span class="o">;</span> <span class="o">}</span> <span class="c">// nothing to work with</span>
156 <span class="c"></span>
157 <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">el</span> <span class="o">!=</span> <span class="s1">&#39;string&#39;</span> <span class="o">&amp;&amp;</span> <span class="o">!(</span><span class="nx">el</span> <span class="k">instanceof</span> <span class="nb">Array</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// assuming HTMLElement or HTMLCollection, so pass back as is</span>
158 <span class="c"></span> <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;get(&#39;</span> <span class="o">+</span> <span class="nx">el</span> <span class="o">+</span> <span class="s1">&#39;) returning &#39;</span> <span class="o">+</span> <span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
159 <span class="k">return</span> <span class="nx">el</span><span class="o">;</span>
160 <span class="o">}</span>
162 <span class="k">if</span> <span class="o">(</span><span class="k">typeof</span> <span class="nx">el</span> <span class="o">==</span> <span class="s1">&#39;string&#39;</span><span class="o">)</span> <span class="o">{</span> <span class="c">// ID</span>
163 <span class="c"></span> <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;get(&quot;&#39;</span> <span class="o">+</span> <span class="nx">el</span> <span class="o">+</span> <span class="s1">&#39;&quot;) returning &#39;</span> <span class="o">+</span> <span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">el</span><span class="o">),</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
164 <span class="k">return</span> <span class="nb">document</span><span class="o">.</span><span class="nx">getElementById</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
165 <span class="o">}</span>
166 <span class="k">else</span> <span class="o">{</span> <span class="c">// array of ID&#39;s and/or elements</span>
167 <span class="c"></span> <span class="k">var</span> <span class="nx">collection</span> <span class="o">=</span> <span class="o">[];</span>
168 <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">len</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
169 <span class="nx">collection</span><span class="o">[</span><span class="nx">collection</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">el</span><span class="o">[</span><span class="nx">i</span><span class="o">]);</span>
170 <span class="o">}</span>
172 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;get(&quot;&#39;</span> <span class="o">+</span> <span class="nx">el</span> <span class="o">+</span> <span class="s1">&#39;&quot;) returning &#39;</span> <span class="o">+</span> <span class="nx">collection</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
173 <span class="k">return</span> <span class="nx">collection</span><span class="o">;</span>
174 <span class="o">}</span>
176 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;element &#39;</span> <span class="o">+</span> <span class="nx">el</span> <span class="o">+</span> <span class="s1">&#39; not found&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
177 <span class="k">return</span> <span class="kc">null</span><span class="o">;</span> <span class="c">// safety, should never happen</span>
178 <span class="c"></span> <span class="o">},</span>
180 <span class="c">/**</span>
181 <span class="c"> * Normalizes currentStyle and ComputedStyle.</span>
182 <span class="c"> * @method getStyle</span>
183 <span class="c"> * @param {String | HTMLElement |Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.</span>
184 <span class="c"> * @param {String} property The style property whose value is returned.</span>
185 <span class="c"> * @return {String | Array} The current value of the style property for the element(s).</span>
186 <span class="c"> */</span>
187 <span class="nx">getStyle</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">)</span> <span class="o">{</span>
188 <span class="nx">property</span> <span class="o">=</span> <span class="nx">toCamel</span><span class="o">(</span><span class="nx">property</span><span class="o">);</span>
190 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
191 <span class="k">return</span> <span class="nx">getStyle</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">property</span><span class="o">);</span>
192 <span class="o">};</span>
194 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
195 <span class="o">},</span>
197 <span class="c">/**</span>
198 <span class="c"> * Wrapper for setting style properties of HTMLElements. Normalizes &quot;opacity&quot; across modern browsers.</span>
199 <span class="c"> * @method setStyle</span>
200 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.</span>
201 <span class="c"> * @param {String} property The style property to be set.</span>
202 <span class="c"> * @param {String} val The value to apply to the given property.</span>
203 <span class="c"> */</span>
204 <span class="nx">setStyle</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">property</span><span class="o">,</span> <span class="nx">val</span><span class="o">)</span> <span class="o">{</span>
205 <span class="nx">property</span> <span class="o">=</span> <span class="nx">toCamel</span><span class="o">(</span><span class="nx">property</span><span class="o">);</span>
207 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">element</span><span class="o">)</span> <span class="o">{</span>
208 <span class="nx">setStyle</span><span class="o">(</span><span class="nx">element</span><span class="o">,</span> <span class="nx">property</span><span class="o">,</span> <span class="nx">val</span><span class="o">);</span>
209 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;setStyle setting &#39;</span> <span class="o">+</span> <span class="nx">property</span> <span class="o">+</span> <span class="s1">&#39; to &#39;</span> <span class="o">+</span> <span class="nx">val</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
211 <span class="o">};</span>
213 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
214 <span class="o">},</span>
216 <span class="c">/**</span>
217 <span class="c"> * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).</span>
218 <span class="c"> * @method getXY</span>
219 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements</span>
220 <span class="c"> * @return {Array} The XY position of the element(s)</span>
221 <span class="c"> */</span>
222 <span class="nx">getXY</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
223 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
225 <span class="c">// has to be part of document to have pageXY</span>
226 <span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">parentNode</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> <span class="nx">el</span><span class="o">.</span><span class="nx">offsetParent</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span>
227 <span class="k">this</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;display&#39;</span><span class="o">)</span> <span class="o">==</span> <span class="s1">&#39;none&#39;</span><span class="o">)</span> <span class="o">{</span>
228 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getXY failed: element not available&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
229 <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
230 <span class="o">}</span>
232 <span class="k">var</span> <span class="nx">parentNode</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
233 <span class="k">var</span> <span class="nx">pos</span> <span class="o">=</span> <span class="o">[];</span>
234 <span class="k">var</span> <span class="nx">box</span><span class="o">;</span>
236 <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">getBoundingClientRect</span><span class="o">)</span> <span class="o">{</span> <span class="c">// IE</span>
237 <span class="c"></span> <span class="nx">box</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">getBoundingClientRect</span><span class="o">();</span>
238 <span class="k">var</span> <span class="nx">doc</span> <span class="o">=</span> <span class="nb">document</span><span class="o">;</span>
239 <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">inDocument</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="nx">parent</span><span class="o">.</span><span class="nb">document</span> <span class="o">!=</span> <span class="nb">document</span><span class="o">)</span> <span class="o">{</span><span class="c">// might be in a frame, need to get its scroll</span>
240 <span class="c"></span> <span class="nx">doc</span> <span class="o">=</span> <span class="nx">parent</span><span class="o">.</span><span class="nb">document</span><span class="o">;</span>
242 <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nx">doc</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">,</span> <span class="nx">el</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
243 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getXY failed: element not available&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
244 <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
245 <span class="o">}</span>
247 <span class="o">}</span>
249 <span class="k">var</span> <span class="nx">scrollTop</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">doc</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">,</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">);</span>
250 <span class="k">var</span> <span class="nx">scrollLeft</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">doc</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollLeft</span><span class="o">,</span> <span class="nx">doc</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollLeft</span><span class="o">);</span>
252 <span class="k">return</span> <span class="o">[</span><span class="nx">box</span><span class="o">.</span><span class="nx">left</span> <span class="o">+</span> <span class="nx">scrollLeft</span><span class="o">,</span> <span class="nx">box</span><span class="o">.</span><span class="nx">top</span> <span class="o">+</span> <span class="nx">scrollTop</span><span class="o">];</span>
253 <span class="o">}</span>
254 <span class="k">else</span> <span class="o">{</span> <span class="c">// safari, opera, &amp; gecko</span>
255 <span class="c"></span> <span class="nx">pos</span> <span class="o">=</span> <span class="o">[</span><span class="nx">el</span><span class="o">.</span><span class="nx">offsetLeft</span><span class="o">,</span> <span class="nx">el</span><span class="o">.</span><span class="nx">offsetTop</span><span class="o">];</span>
256 <span class="nx">parentNode</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">offsetParent</span><span class="o">;</span>
257 <span class="k">if</span> <span class="o">(</span><span class="nx">parentNode</span> <span class="o">!=</span> <span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
258 <span class="k">while</span> <span class="o">(</span><span class="nx">parentNode</span><span class="o">)</span> <span class="o">{</span>
259 <span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">+=</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">offsetLeft</span><span class="o">;</span>
260 <span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">+=</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">offsetTop</span><span class="o">;</span>
261 <span class="nx">parentNode</span> <span class="o">=</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">offsetParent</span><span class="o">;</span>
262 <span class="o">}</span>
263 <span class="o">}</span>
264 <span class="k">if</span> <span class="o">(</span><span class="nx">isSafari</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;position&#39;</span><span class="o">)</span> <span class="o">==</span> <span class="s1">&#39;absolute&#39;</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// safari doubles in some cases</span>
265 <span class="c"></span> <span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">-=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">offsetLeft</span><span class="o">;</span>
266 <span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">-=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">offsetTop</span><span class="o">;</span>
267 <span class="o">}</span>
268 <span class="o">}</span>
270 <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">)</span> <span class="o">{</span> <span class="nx">parentNode</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span> <span class="o">}</span>
271 <span class="k">else</span> <span class="o">{</span> <span class="nx">parentNode</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span> <span class="o">}</span>
273 <span class="k">while</span> <span class="o">(</span><span class="nx">parentNode</span> <span class="o">&amp;&amp;</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s1">&#39;BODY&#39;</span> <span class="o">&amp;&amp;</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">!=</span> <span class="s1">&#39;HTML&#39;</span><span class="o">)</span>
274 <span class="o">{</span> <span class="c">// account for any scrolled ancestors</span>
275 <span class="c"></span> <span class="k">if</span> <span class="o">(</span><span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="nx">parentNode</span><span class="o">,</span> <span class="s1">&#39;display&#39;</span><span class="o">)</span> <span class="o">!=</span> <span class="s1">&#39;inline&#39;</span><span class="o">)</span> <span class="o">{</span> <span class="c">// work around opera inline scrollLeft/Top bug</span>
276 <span class="c"></span> <span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">-=</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">scrollLeft</span><span class="o">;</span>
277 <span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">-=</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">scrollTop</span><span class="o">;</span>
278 <span class="o">}</span>
280 <span class="k">if</span> <span class="o">(</span><span class="nx">parentNode</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">)</span> <span class="o">{</span>
281 <span class="nx">parentNode</span> <span class="o">=</span> <span class="nx">parentNode</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
282 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="nx">parentNode</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span> <span class="o">}</span>
283 <span class="o">}</span>
285 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getXY returning &#39;</span> <span class="o">+</span> <span class="nx">pos</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
287 <span class="k">return</span> <span class="nx">pos</span><span class="o">;</span>
288 <span class="o">};</span>
290 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
291 <span class="o">},</span>
293 <span class="c">/**</span>
294 <span class="c"> * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).</span>
295 <span class="c"> * @method getX</span>
296 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements</span>
297 <span class="c"> * @return {String | Array} The X position of the element(s)</span>
298 <span class="c"> */</span>
299 <span class="nx">getX</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
300 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
301 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getXY</span><span class="o">(</span><span class="nx">el</span><span class="o">)[</span><span class="m">0</span><span class="o">];</span>
302 <span class="o">};</span>
304 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
305 <span class="o">},</span>
307 <span class="c">/**</span>
308 <span class="c"> * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).</span>
309 <span class="c"> * @method getY</span>
310 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements</span>
311 <span class="c"> * @return {String | Array} The Y position of the element(s)</span>
312 <span class="c"> */</span>
313 <span class="nx">getY</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
314 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
315 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getXY</span><span class="o">(</span><span class="nx">el</span><span class="o">)[</span><span class="m">1</span><span class="o">];</span>
316 <span class="o">};</span>
318 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
319 <span class="o">},</span>
321 <span class="c">/**</span>
322 <span class="c"> * Set the position of an html element in page coordinates, regardless of how the element is positioned.</span>
323 <span class="c"> * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).</span>
324 <span class="c"> * @method setXY</span>
325 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements</span>
326 <span class="c"> * @param {Array} pos Contains X &amp; Y values for new position (coordinates are page-based)</span>
327 <span class="c"> * @param {Boolean} noRetry By default we try and set the position a second time if the first fails</span>
328 <span class="c"> */</span>
329 <span class="nx">setXY</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">pos</span><span class="o">,</span> <span class="nx">noRetry</span><span class="o">)</span> <span class="o">{</span>
330 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
331 <span class="k">var</span> <span class="nx">style_pos</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;position&#39;</span><span class="o">);</span>
332 <span class="k">if</span> <span class="o">(</span><span class="nx">style_pos</span> <span class="o">==</span> <span class="s1">&#39;static&#39;</span><span class="o">)</span> <span class="o">{</span> <span class="c">// default to relative</span>
333 <span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">setStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;position&#39;</span><span class="o">,</span> <span class="s1">&#39;relative&#39;</span><span class="o">);</span>
334 <span class="nx">style_pos</span> <span class="o">=</span> <span class="s1">&#39;relative&#39;</span><span class="o">;</span>
335 <span class="o">}</span>
337 <span class="k">var</span> <span class="nx">pageXY</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getXY</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
338 <span class="k">if</span> <span class="o">(</span><span class="nx">pageXY</span> <span class="o">===</span> <span class="kc">false</span><span class="o">)</span> <span class="o">{</span> <span class="c">// has to be part of doc to have pageXY</span>
339 <span class="c"></span> <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;setXY failed: element not available&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
340 <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
341 <span class="o">}</span>
343 <span class="k">var</span> <span class="nx">delta</span> <span class="o">=</span> <span class="o">[</span> <span class="c">// assuming pixels; if not we will have to retry</span>
344 <span class="c"></span> <span class="nb">parseInt</span><span class="o">(</span> <span class="k">this</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;left&#39;</span><span class="o">),</span> <span class="m">10</span> <span class="o">),</span>
345 <span class="nb">parseInt</span><span class="o">(</span> <span class="k">this</span><span class="o">.</span><span class="nx">getStyle</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="s1">&#39;top&#39;</span><span class="o">),</span> <span class="m">10</span> <span class="o">)</span>
346 <span class="o">];</span>
348 <span class="k">if</span> <span class="o">(</span> <span class="nb">isNaN</span><span class="o">(</span><span class="nx">delta</span><span class="o">[</span><span class="m">0</span><span class="o">])</span> <span class="o">)</span> <span class="o">{</span><span class="c">// in case of &#39;auto&#39;</span>
349 <span class="c"></span> <span class="nx">delta</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">=</span> <span class="o">(</span><span class="nx">style_pos</span> <span class="o">==</span> <span class="s1">&#39;relative&#39;</span><span class="o">)</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">offsetLeft</span><span class="o">;</span>
350 <span class="o">}</span>
351 <span class="k">if</span> <span class="o">(</span> <span class="nb">isNaN</span><span class="o">(</span><span class="nx">delta</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// in case of &#39;auto&#39;</span>
352 <span class="c"></span> <span class="nx">delta</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">=</span> <span class="o">(</span><span class="nx">style_pos</span> <span class="o">==</span> <span class="s1">&#39;relative&#39;</span><span class="o">)</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">offsetTop</span><span class="o">;</span>
353 <span class="o">}</span>
355 <span class="k">if</span> <span class="o">(</span><span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">left</span> <span class="o">=</span> <span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">-</span> <span class="nx">pageXY</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">+</span> <span class="nx">delta</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">+</span> <span class="s1">&#39;px&#39;</span><span class="o">;</span> <span class="o">}</span>
356 <span class="k">if</span> <span class="o">(</span><span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">!==</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span> <span class="nx">el</span><span class="o">.</span><span class="nx">style</span><span class="o">.</span><span class="nx">top</span> <span class="o">=</span> <span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">-</span> <span class="nx">pageXY</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">+</span> <span class="nx">delta</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">+</span> <span class="s1">&#39;px&#39;</span><span class="o">;</span> <span class="o">}</span>
358 <span class="k">if</span> <span class="o">(!</span><span class="nx">noRetry</span><span class="o">)</span> <span class="o">{</span>
359 <span class="k">var</span> <span class="nx">newXY</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getXY</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
361 <span class="c">// if retry is true, try one more time if we miss </span>
362 <span class="c"></span> <span class="k">if</span> <span class="o">(</span> <span class="o">(</span><span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&amp;&amp;</span> <span class="nx">newXY</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">!=</span> <span class="nx">pos</span><span class="o">[</span><span class="m">0</span><span class="o">])</span> <span class="o">||</span>
363 <span class="o">(</span><span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&amp;&amp;</span> <span class="nx">newXY</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">!=</span> <span class="nx">pos</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">)</span> <span class="o">{</span>
364 <span class="k">this</span><span class="o">.</span><span class="nx">setXY</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">pos</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
365 <span class="o">}</span>
366 <span class="o">}</span>
368 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;setXY setting position to &#39;</span> <span class="o">+</span> <span class="nx">pos</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
369 <span class="o">};</span>
371 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
372 <span class="o">},</span>
374 <span class="c">/**</span>
375 <span class="c"> * Set the X position of an html element in page coordinates, regardless of how the element is positioned.</span>
376 <span class="c"> * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).</span>
377 <span class="c"> * @method setX</span>
378 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.</span>
379 <span class="c"> * @param {Int} x The value to use as the X coordinate for the element(s).</span>
380 <span class="c"> */</span>
381 <span class="nx">setX</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">x</span><span class="o">)</span> <span class="o">{</span>
382 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">setXY</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="o">[</span><span class="nx">x</span><span class="o">,</span> <span class="kc">null</span><span class="o">]);</span>
383 <span class="o">},</span>
385 <span class="c">/**</span>
386 <span class="c"> * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.</span>
387 <span class="c"> * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).</span>
388 <span class="c"> * @method setY</span>
389 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.</span>
390 <span class="c"> * @param {Int} x To use as the Y coordinate for the element(s).</span>
391 <span class="c"> */</span>
392 <span class="nx">setY</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">y</span><span class="o">)</span> <span class="o">{</span>
393 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">setXY</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="o">[</span><span class="kc">null</span><span class="o">,</span> <span class="nx">y</span><span class="o">]);</span>
394 <span class="o">},</span>
396 <span class="c">/**</span>
397 <span class="c"> * Returns the region position of the given element.</span>
398 <span class="c"> * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).</span>
399 <span class="c"> * @method getRegion</span>
400 <span class="c"> * @param {String | HTMLElement | Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.</span>
401 <span class="c"> * @return {Region | Array} A Region or array of Region instances containing &quot;top, left, bottom, right&quot; member data.</span>
402 <span class="c"> */</span>
403 <span class="nx">getRegion</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
404 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
405 <span class="k">var</span> <span class="nx">region</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Region</span><span class="o">.</span><span class="nx">getRegion</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
406 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getRegion returning &#39;</span> <span class="o">+</span> <span class="nx">region</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
407 <span class="k">return</span> <span class="nx">region</span><span class="o">;</span>
408 <span class="o">};</span>
410 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
411 <span class="o">},</span>
413 <span class="c">/**</span>
414 <span class="c"> * Returns the width of the client (viewport).</span>
415 <span class="c"> * @method getClientWidth</span>
416 <span class="c"> * @deprecated Now using getViewportWidth. This interface left intact for back compat.</span>
417 <span class="c"> * @return {Int} The width of the viewable area of the page.</span>
418 <span class="c"> */</span>
419 <span class="nx">getClientWidth</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
420 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportWidth</span><span class="o">();</span>
421 <span class="o">},</span>
423 <span class="c">/**</span>
424 <span class="c"> * Returns the height of the client (viewport).</span>
425 <span class="c"> * @method getClientHeight</span>
426 <span class="c"> * @deprecated Now using getViewportHeight. This interface left intact for back compat.</span>
427 <span class="c"> * @return {Int} The height of the viewable area of the page.</span>
428 <span class="c"> */</span>
429 <span class="nx">getClientHeight</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
430 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportHeight</span><span class="o">();</span>
431 <span class="o">},</span>
433 <span class="c">/**</span>
434 <span class="c"> * Returns a array of HTMLElements with the given class.</span>
435 <span class="c"> * For optimized performance, include a tag and/or root node when possible.</span>
436 <span class="c"> * @method getElementsByClassName</span>
437 <span class="c"> * @param {String} className The class name to match against</span>
438 <span class="c"> * @param {String} tag (optional) The tag name of the elements being collected</span>
439 <span class="c"> * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point </span>
440 <span class="c"> * @return {Array} An array of elements that have the given class name</span>
441 <span class="c"> */</span>
442 <span class="nx">getElementsByClassName</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">className</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">root</span><span class="o">)</span> <span class="o">{</span>
443 <span class="k">var</span> <span class="nx">method</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span> <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">);</span> <span class="o">};</span>
444 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getElementsBy</span><span class="o">(</span><span class="nx">method</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">root</span><span class="o">);</span>
445 <span class="o">},</span>
447 <span class="c">/**</span>
448 <span class="c"> * Determines whether an HTMLElement has the given className.</span>
449 <span class="c"> * @method hasClass</span>
450 <span class="c"> * @param {String | HTMLElement | Array} el The element or collection to test</span>
451 <span class="c"> * @param {String} className the class name to search for</span>
452 <span class="c"> * @return {Boolean | Array} A boolean value or array of boolean values</span>
453 <span class="c"> */</span>
454 <span class="nx">hasClass</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">)</span> <span class="o">{</span>
455 <span class="k">var</span> <span class="nx">re</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="o">(</span><span class="s1">&#39;(?:^|\\s+)&#39;</span> <span class="o">+</span> <span class="nx">className</span> <span class="o">+</span> <span class="s1">&#39;(?:\\s+|$)&#39;</span><span class="o">);</span>
457 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
458 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;hasClass returning &#39;</span> <span class="o">+</span> <span class="nx">re</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">]),</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
459 <span class="k">return</span> <span class="nx">re</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">]);</span>
460 <span class="o">};</span>
462 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
463 <span class="o">},</span>
465 <span class="c">/**</span>
466 <span class="c"> * Adds a class name to a given element or collection of elements.</span>
467 <span class="c"> * @method addClass </span>
468 <span class="c"> * @param {String | HTMLElement | Array} el The element or collection to add the class to</span>
469 <span class="c"> * @param {String} className the class name to add to the class attribute</span>
470 <span class="c"> */</span>
471 <span class="nx">addClass</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">)</span> <span class="o">{</span>
472 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
473 <span class="k">if</span> <span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">))</span> <span class="o">{</span> <span class="k">return</span><span class="o">;</span> <span class="o">}</span> <span class="c">// already present</span>
474 <span class="c"></span>
475 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;addClass adding &#39;</span> <span class="o">+</span> <span class="nx">className</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
477 <span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">]</span> <span class="o">=</span> <span class="o">[</span><span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">],</span> <span class="nx">className</span><span class="o">].</span><span class="nx">join</span><span class="o">(</span><span class="s1">&#39; &#39;</span><span class="o">);</span>
478 <span class="o">};</span>
480 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
481 <span class="o">},</span>
483 <span class="c">/**</span>
484 <span class="c"> * Removes a class name from a given element or collection of elements.</span>
485 <span class="c"> * @method removeClass </span>
486 <span class="c"> * @param {String | HTMLElement | Array} el The element or collection to remove the class from</span>
487 <span class="c"> * @param {String} className the class name to remove from the class attribute</span>
488 <span class="c"> */</span>
489 <span class="nx">removeClass</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">)</span> <span class="o">{</span>
490 <span class="k">var</span> <span class="nx">re</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="o">(</span><span class="s1">&#39;(?:^|\\s+)&#39;</span> <span class="o">+</span> <span class="nx">className</span> <span class="o">+</span> <span class="s1">&#39;(?:\\s+|$)&#39;</span><span class="o">,</span> <span class="s1">&#39;g&#39;</span><span class="o">);</span>
492 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
493 <span class="k">if</span> <span class="o">(!</span><span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">))</span> <span class="o">{</span> <span class="k">return</span><span class="o">;</span> <span class="o">}</span> <span class="c">// not present</span>
494 <span class="c"></span>
495 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;removeClass removing &#39;</span> <span class="o">+</span> <span class="nx">className</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
497 <span class="k">var</span> <span class="nx">c</span> <span class="o">=</span> <span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">];</span>
498 <span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">]</span> <span class="o">=</span> <span class="nx">c</span><span class="o">.</span><span class="nx">replace</span><span class="o">(</span><span class="nx">re</span><span class="o">,</span> <span class="s1">&#39; &#39;</span><span class="o">);</span>
499 <span class="k">if</span> <span class="o">(</span> <span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// in case of multiple adjacent</span>
500 <span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">removeClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">className</span><span class="o">);</span>
501 <span class="o">}</span>
503 <span class="o">};</span>
505 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
506 <span class="o">},</span>
508 <span class="c">/**</span>
509 <span class="c"> * Replace a class with another class for a given element or collection of elements.</span>
510 <span class="c"> * If no oldClassName is present, the newClassName is simply added.</span>
511 <span class="c"> * @method replaceClass </span>
512 <span class="c"> * @param {String | HTMLElement | Array} el The element or collection to remove the class from</span>
513 <span class="c"> * @param {String} oldClassName the class name to be replaced</span>
514 <span class="c"> * @param {String} newClassName the class name that will be replacing the old class name</span>
515 <span class="c"> */</span>
516 <span class="nx">replaceClass</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oldClassName</span><span class="o">,</span> <span class="nx">newClassName</span><span class="o">)</span> <span class="o">{</span>
517 <span class="k">if</span> <span class="o">(</span><span class="nx">oldClassName</span> <span class="o">===</span> <span class="nx">newClassName</span><span class="o">)</span> <span class="o">{</span> <span class="c">// avoid infinite loop</span>
518 <span class="c"></span> <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
519 <span class="o">}</span>
521 <span class="k">var</span> <span class="nx">re</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">RegExp</span><span class="o">(</span><span class="s1">&#39;(?:^|\\s+)&#39;</span> <span class="o">+</span> <span class="nx">oldClassName</span> <span class="o">+</span> <span class="s1">&#39;(?:\\s+|$)&#39;</span><span class="o">,</span> <span class="s1">&#39;g&#39;</span><span class="o">);</span>
523 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
524 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;replaceClass replacing &#39;</span> <span class="o">+</span> <span class="nx">oldClassName</span> <span class="o">+</span> <span class="s1">&#39; with &#39;</span> <span class="o">+</span> <span class="nx">newClassName</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
526 <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oldClassName</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
527 <span class="k">this</span><span class="o">.</span><span class="nx">addClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">newClassName</span><span class="o">);</span> <span class="c">// just add it if nothing to replace</span>
528 <span class="c"></span> <span class="k">return</span><span class="o">;</span> <span class="c">// note return</span>
529 <span class="c"></span> <span class="o">}</span>
531 <span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">]</span> <span class="o">=</span> <span class="nx">el</span><span class="o">[</span><span class="s1">&#39;className&#39;</span><span class="o">].</span><span class="nx">replace</span><span class="o">(</span><span class="nx">re</span><span class="o">,</span> <span class="s1">&#39; &#39;</span> <span class="o">+</span> <span class="nx">newClassName</span> <span class="o">+</span> <span class="s1">&#39; &#39;</span><span class="o">);</span>
533 <span class="k">if</span> <span class="o">(</span> <span class="k">this</span><span class="o">.</span><span class="nx">hasClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oldClassName</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// in case of multiple adjacent</span>
534 <span class="c"></span> <span class="k">this</span><span class="o">.</span><span class="nx">replaceClass</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">oldClassName</span><span class="o">,</span> <span class="nx">newClassName</span><span class="o">);</span>
535 <span class="o">}</span>
536 <span class="o">};</span>
538 <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
539 <span class="o">},</span>
541 <span class="c">/**</span>
542 <span class="c"> * Generates a unique ID</span>
543 <span class="c"> * @method generateId </span>
544 <span class="c"> * @param {String | HTMLElement | Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present).</span>
545 <span class="c"> * @param {String} prefix (optional) an optional prefix to use (defaults to &quot;yui-gen&quot;).</span>
546 <span class="c"> * @return {String | Array} The generated ID, or array of generated IDs (or original ID if already present on an element)</span>
547 <span class="c"> */</span>
548 <span class="nx">generateId</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">prefix</span><span class="o">)</span> <span class="o">{</span>
549 <span class="nx">prefix</span> <span class="o">=</span> <span class="nx">prefix</span> <span class="o">||</span> <span class="s1">&#39;yui-gen&#39;</span><span class="o">;</span>
550 <span class="nx">el</span> <span class="o">=</span> <span class="nx">el</span> <span class="o">||</span> <span class="o">{};</span>
552 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
553 <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
554 <span class="nx">el</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
555 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
556 <span class="nx">el</span> <span class="o">=</span> <span class="o">{};</span> <span class="c">// just generating ID in this case</span>
557 <span class="c"></span> <span class="o">}</span>
559 <span class="k">if</span> <span class="o">(!</span><span class="nx">el</span><span class="o">.</span><span class="nx">id</span><span class="o">)</span> <span class="o">{</span>
560 <span class="nx">el</span><span class="o">.</span><span class="nx">id</span> <span class="o">=</span> <span class="nx">prefix</span> <span class="o">+</span> <span class="nx">id_counter</span><span class="o">++;</span>
561 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;generateId generating &#39;</span> <span class="o">+</span> <span class="nx">el</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
562 <span class="o">}</span> <span class="c">// dont override existing</span>
563 <span class="c"></span>
564 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;generateId returning &#39;</span> <span class="o">+</span> <span class="nx">el</span><span class="o">.</span><span class="nx">id</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
566 <span class="k">return</span> <span class="nx">el</span><span class="o">.</span><span class="nx">id</span><span class="o">;</span>
567 <span class="o">};</span>
569 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
570 <span class="o">},</span>
572 <span class="c">/**</span>
573 <span class="c"> * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy.</span>
574 <span class="c"> * @method isAncestor</span>
575 <span class="c"> * @param {String | HTMLElement} haystack The possible ancestor</span>
576 <span class="c"> * @param {String | HTMLElement} needle The possible descendent</span>
577 <span class="c"> * @return {Boolean} Whether or not the haystack is an ancestor of needle</span>
578 <span class="c"> */</span>
579 <span class="nx">isAncestor</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">haystack</span><span class="o">,</span> <span class="nx">needle</span><span class="o">)</span> <span class="o">{</span>
580 <span class="nx">haystack</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">haystack</span><span class="o">);</span>
581 <span class="k">if</span> <span class="o">(!</span><span class="nx">haystack</span> <span class="o">||</span> <span class="o">!</span><span class="nx">needle</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>
583 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">needle</span><span class="o">)</span> <span class="o">{</span>
584 <span class="k">if</span> <span class="o">(</span><span class="nx">haystack</span><span class="o">.</span><span class="nx">contains</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">isSafari</span><span class="o">)</span> <span class="o">{</span> <span class="c">// safari &quot;contains&quot; is broken</span>
585 <span class="c"></span> <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;isAncestor returning &#39;</span> <span class="o">+</span> <span class="nx">haystack</span><span class="o">.</span><span class="nx">contains</span><span class="o">(</span><span class="nx">needle</span><span class="o">),</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
586 <span class="k">return</span> <span class="nx">haystack</span><span class="o">.</span><span class="nx">contains</span><span class="o">(</span><span class="nx">needle</span><span class="o">);</span>
587 <span class="o">}</span>
588 <span class="k">else</span> <span class="k">if</span> <span class="o">(</span> <span class="nx">haystack</span><span class="o">.</span><span class="nx">compareDocumentPosition</span> <span class="o">)</span> <span class="o">{</span>
589 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;isAncestor returning &#39;</span> <span class="o">+</span> <span class="o">!!(</span><span class="nx">haystack</span><span class="o">.</span><span class="nx">compareDocumentPosition</span><span class="o">(</span><span class="nx">needle</span><span class="o">)</span> <span class="o">&amp;</span> <span class="m">16</span><span class="o">),</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
590 <span class="k">return</span> <span class="o">!!(</span><span class="nx">haystack</span><span class="o">.</span><span class="nx">compareDocumentPosition</span><span class="o">(</span><span class="nx">needle</span><span class="o">)</span> <span class="o">&amp;</span> <span class="m">16</span><span class="o">);</span>
591 <span class="o">}</span>
592 <span class="k">else</span> <span class="o">{</span> <span class="c">// loop up and test each parent</span>
593 <span class="c"></span> <span class="k">var</span> <span class="nx">parent</span> <span class="o">=</span> <span class="nx">needle</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
595 <span class="k">while</span> <span class="o">(</span><span class="nx">parent</span><span class="o">)</span> <span class="o">{</span>
596 <span class="k">if</span> <span class="o">(</span><span class="nx">parent</span> <span class="o">==</span> <span class="nx">haystack</span><span class="o">)</span> <span class="o">{</span>
597 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;isAncestor returning true&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
598 <span class="k">return</span> <span class="kc">true</span><span class="o">;</span>
599 <span class="o">}</span>
600 <span class="k">else</span> <span class="k">if</span> <span class="o">(!</span><span class="nx">parent</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">||</span> <span class="nx">parent</span><span class="o">.</span><span class="nx">tagName</span><span class="o">.</span><span class="nx">toUpperCase</span><span class="o">()</span> <span class="o">==</span> <span class="s1">&#39;HTML&#39;</span><span class="o">)</span> <span class="o">{</span>
601 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;isAncestor returning false&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
602 <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
603 <span class="o">}</span>
605 <span class="nx">parent</span> <span class="o">=</span> <span class="nx">parent</span><span class="o">.</span><span class="nx">parentNode</span><span class="o">;</span>
606 <span class="o">}</span>
607 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;isAncestor returning false&#39;</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
608 <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
609 <span class="o">}</span>
610 <span class="o">};</span>
612 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">needle</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
613 <span class="o">},</span>
615 <span class="c">/**</span>
616 <span class="c"> * Determines whether an HTMLElement is present in the current document.</span>
617 <span class="c"> * @method inDocument </span>
618 <span class="c"> * @param {String | HTMLElement} el The element to search for</span>
619 <span class="c"> * @return {Boolean} Whether or not the element is present in the current document</span>
620 <span class="c"> */</span>
621 <span class="nx">inDocument</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
622 <span class="k">var</span> <span class="nx">f</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
623 <span class="k">return</span> <span class="k">this</span><span class="o">.</span><span class="nx">isAncestor</span><span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">,</span> <span class="nx">el</span><span class="o">);</span>
624 <span class="o">};</span>
626 <span class="k">return</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">batch</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">f</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>
627 <span class="o">},</span>
629 <span class="c">/**</span>
630 <span class="c"> * Returns a array of HTMLElements that pass the test applied by supplied boolean method.</span>
631 <span class="c"> * For optimized performance, include a tag and/or root node when possible.</span>
632 <span class="c"> * @method getElementsBy</span>
633 <span class="c"> * @param {Function} method - A boolean method for testing elements which receives the element as its only argument.</span>
634 <span class="c"></span>
635 <span class="c"> * @param {String} tag (optional) The tag name of the elements being collected</span>
636 <span class="c"> * @param {String | HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point </span>
637 <span class="c"> * @return {Array} Array of HTMLElements</span>
638 <span class="c"> */</span>
639 <span class="nx">getElementsBy</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">method</span><span class="o">,</span> <span class="nx">tag</span><span class="o">,</span> <span class="nx">root</span><span class="o">)</span> <span class="o">{</span>
640 <span class="nx">tag</span> <span class="o">=</span> <span class="nx">tag</span> <span class="o">||</span> <span class="s1">&#39;*&#39;</span><span class="o">;</span>
642 <span class="k">var</span> <span class="nx">nodes</span> <span class="o">=</span> <span class="o">[];</span>
644 <span class="k">if</span> <span class="o">(</span><span class="nx">root</span><span class="o">)</span> <span class="o">{</span>
645 <span class="nx">root</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">root</span><span class="o">);</span>
646 <span class="k">if</span> <span class="o">(!</span><span class="nx">root</span><span class="o">)</span> <span class="o">{</span> <span class="c">// if no root node, then no children</span>
647 <span class="c"></span> <span class="k">return</span> <span class="nx">nodes</span><span class="o">;</span>
648 <span class="o">}</span>
649 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
650 <span class="nx">root</span> <span class="o">=</span> <span class="nb">document</span><span class="o">;</span>
651 <span class="o">}</span>
653 <span class="k">var</span> <span class="nx">elements</span> <span class="o">=</span> <span class="nx">root</span><span class="o">.</span><span class="nx">getElementsByTagName</span><span class="o">(</span><span class="nx">tag</span><span class="o">);</span>
655 <span class="k">if</span> <span class="o">(</span> <span class="o">!</span><span class="nx">elements</span><span class="o">.</span><span class="nx">length</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="nx">tag</span> <span class="o">==</span> <span class="s1">&#39;*&#39;</span> <span class="o">&amp;&amp;</span> <span class="nx">root</span><span class="o">.</span><span class="nx">all</span><span class="o">)</span> <span class="o">)</span> <span class="o">{</span>
656 <span class="nx">elements</span> <span class="o">=</span> <span class="nx">root</span><span class="o">.</span><span class="nx">all</span><span class="o">;</span> <span class="c">// IE &lt; 6</span>
657 <span class="c"></span> <span class="o">}</span>
659 <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">len</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
660 <span class="k">if</span> <span class="o">(</span> <span class="nx">method</span><span class="o">(</span><span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">])</span> <span class="o">)</span> <span class="o">{</span> <span class="nx">nodes</span><span class="o">[</span><span class="nx">nodes</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">elements</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span> <span class="o">}</span>
661 <span class="o">}</span>
663 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getElementsBy returning &#39;</span> <span class="o">+</span> <span class="nx">nodes</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
665 <span class="k">return</span> <span class="nx">nodes</span><span class="o">;</span>
666 <span class="o">},</span>
668 <span class="c">/**</span>
669 <span class="c"> * Returns an array of elements that have had the supplied method applied.</span>
670 <span class="c"> * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) ).</span>
671 <span class="c"> * @method batch</span>
672 <span class="c"> * @param {String | HTMLElement | Array} el (optional) An element or array of elements to apply the method to</span>
673 <span class="c"> * @param {Function} method The method to apply to the element(s)</span>
674 <span class="c"> * @param {Any} o (optional) An optional arg that is passed to the supplied method</span>
675 <span class="c"> * @param {Boolean} override (optional) Whether or not to override the scope of &quot;method&quot; with &quot;o&quot;</span>
676 <span class="c"> * @return {HTMLElement | Array} The element(s) with the method applied</span>
677 <span class="c"> */</span>
678 <span class="nx">batch</span><span class="o">:</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">method</span><span class="o">,</span> <span class="nx">o</span><span class="o">,</span> <span class="nx">override</span><span class="o">)</span> <span class="o">{</span>
679 <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">el</span><span class="o">;</span>
680 <span class="nx">el</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">get</span><span class="o">(</span><span class="nx">el</span><span class="o">);</span>
682 <span class="k">var</span> <span class="nx">scope</span> <span class="o">=</span> <span class="o">(</span><span class="nx">override</span><span class="o">)</span> <span class="o">?</span> <span class="nx">o</span> <span class="o">:</span> <span class="nb">window</span><span class="o">;</span>
684 <span class="k">if</span> <span class="o">(!</span><span class="nx">el</span> <span class="o">||</span> <span class="nx">el</span><span class="o">.</span><span class="nx">tagName</span> <span class="o">||</span> <span class="o">!</span><span class="nx">el</span><span class="o">.</span><span class="nx">length</span><span class="o">)</span> <span class="o">{</span> <span class="c">// is null or not a collection (tagName for SELECT and others that can be both an element and a collection)</span>
685 <span class="c"></span> <span class="k">if</span> <span class="o">(!</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span>
686 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">&#39; not available&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
687 <span class="k">return</span> <span class="kc">false</span><span class="o">;</span>
688 <span class="o">}</span>
689 <span class="k">return</span> <span class="nx">method</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">scope</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">o</span><span class="o">);</span>
690 <span class="o">}</span>
692 <span class="k">var</span> <span class="nx">collection</span> <span class="o">=</span> <span class="o">[];</span>
694 <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">len</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">length</span><span class="o">;</span> <span class="nx">i</span> <span class="o">&lt;</span> <span class="nx">len</span><span class="o">;</span> <span class="o">++</span><span class="nx">i</span><span class="o">)</span> <span class="o">{</span>
695 <span class="k">if</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>
696 <span class="nx">id</span> <span class="o">=</span> <span class="nx">el</span><span class="o">[</span><span class="nx">i</span><span class="o">];</span>
697 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="nx">id</span> <span class="o">+</span> <span class="s1">&#39; not available&#39;</span><span class="o">,</span> <span class="s1">&#39;error&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
698 <span class="o">}</span>
699 <span class="nx">collection</span><span class="o">[</span><span class="nx">collection</span><span class="o">.</span><span class="nx">length</span><span class="o">]</span> <span class="o">=</span> <span class="nx">method</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="nx">scope</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="nx">o</span><span class="o">);</span>
700 <span class="o">}</span>
702 <span class="k">return</span> <span class="nx">collection</span><span class="o">;</span>
703 <span class="o">},</span>
705 <span class="c">/**</span>
706 <span class="c"> * Returns the height of the document.</span>
707 <span class="c"> * @method getDocumentHeight</span>
708 <span class="c"> * @return {Int} The height of the actual document (which includes the body and its margin).</span>
709 <span class="c"> */</span>
710 <span class="nx">getDocumentHeight</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
711 <span class="k">var</span> <span class="nx">scrollHeight</span> <span class="o">=</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">compatMode</span> <span class="o">!=</span> <span class="s1">&#39;CSS1Compat&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollHeight</span> <span class="o">:</span> <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollHeight</span><span class="o">;</span>
713 <span class="k">var</span> <span class="nx">h</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">scrollHeight</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportHeight</span><span class="o">());</span>
714 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getDocumentHeight returning &#39;</span> <span class="o">+</span> <span class="nx">h</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
715 <span class="k">return</span> <span class="nx">h</span><span class="o">;</span>
716 <span class="o">},</span>
718 <span class="c">/**</span>
719 <span class="c"> * Returns the width of the document.</span>
720 <span class="c"> * @method getDocumentWidth</span>
721 <span class="c"> * @return {Int} The width of the actual document (which includes the body and its margin).</span>
722 <span class="c"> */</span>
723 <span class="nx">getDocumentWidth</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
724 <span class="k">var</span> <span class="nx">scrollWidth</span> <span class="o">=</span> <span class="o">(</span><span class="nb">document</span><span class="o">.</span><span class="nx">compatMode</span> <span class="o">!=</span> <span class="s1">&#39;CSS1Compat&#39;</span><span class="o">)</span> <span class="o">?</span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">scrollWidth</span> <span class="o">:</span> <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">scrollWidth</span><span class="o">;</span>
725 <span class="k">var</span> <span class="nx">w</span> <span class="o">=</span> <span class="nb">Math</span><span class="o">.</span><span class="nx">max</span><span class="o">(</span><span class="nx">scrollWidth</span><span class="o">,</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Dom</span><span class="o">.</span><span class="nx">getViewportWidth</span><span class="o">());</span>
726 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getDocumentWidth returning &#39;</span> <span class="o">+</span> <span class="nx">w</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
727 <span class="k">return</span> <span class="nx">w</span><span class="o">;</span>
728 <span class="o">},</span>
730 <span class="c">/**</span>
731 <span class="c"> * Returns the current height of the viewport.</span>
732 <span class="c"> * @method getViewportHeight</span>
733 <span class="c"> * @return {Int} The height of the viewable area of the page (excludes scrollbars).</span>
734 <span class="c"> */</span>
735 <span class="nx">getViewportHeight</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
736 <span class="k">var</span> <span class="nx">height</span> <span class="o">=</span> <span class="nx">self</span><span class="o">.</span><span class="nx">innerHeight</span><span class="o">;</span> <span class="c">// Safari, Opera</span>
737 <span class="c"></span> <span class="k">var</span> <span class="nx">mode</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">compatMode</span><span class="o">;</span>
739 <span class="k">if</span> <span class="o">(</span> <span class="o">(</span><span class="nx">mode</span> <span class="o">||</span> <span class="nx">isIE</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="nx">isOpera</span> <span class="o">)</span> <span class="o">{</span> <span class="c">// IE, Gecko</span>
740 <span class="c"></span> <span class="nx">height</span> <span class="o">=</span> <span class="o">(</span><span class="nx">mode</span> <span class="o">==</span> <span class="s1">&#39;CSS1Compat&#39;</span><span class="o">)</span> <span class="o">?</span>
741 <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">clientHeight</span> <span class="o">:</span> <span class="c">// Standards</span>
742 <span class="c"></span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">clientHeight</span><span class="o">;</span> <span class="c">// Quirks</span>
743 <span class="c"></span> <span class="o">}</span>
745 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getViewportHeight returning &#39;</span> <span class="o">+</span> <span class="nx">height</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
746 <span class="k">return</span> <span class="nx">height</span><span class="o">;</span>
747 <span class="o">},</span>
749 <span class="c">/**</span>
750 <span class="c"> * Returns the current width of the viewport.</span>
751 <span class="c"> * @method getViewportWidth</span>
752 <span class="c"> * @return {Int} The width of the viewable area of the page (excludes scrollbars).</span>
753 <span class="c"> */</span>
755 <span class="nx">getViewportWidth</span><span class="o">:</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
756 <span class="k">var</span> <span class="nx">width</span> <span class="o">=</span> <span class="nx">self</span><span class="o">.</span><span class="nx">innerWidth</span><span class="o">;</span> <span class="c">// Safari</span>
757 <span class="c"></span> <span class="k">var</span> <span class="nx">mode</span> <span class="o">=</span> <span class="nb">document</span><span class="o">.</span><span class="nx">compatMode</span><span class="o">;</span>
759 <span class="k">if</span> <span class="o">(</span><span class="nx">mode</span> <span class="o">||</span> <span class="nx">isIE</span><span class="o">)</span> <span class="o">{</span> <span class="c">// IE, Gecko, Opera</span>
760 <span class="c"></span> <span class="nx">width</span> <span class="o">=</span> <span class="o">(</span><span class="nx">mode</span> <span class="o">==</span> <span class="s1">&#39;CSS1Compat&#39;</span><span class="o">)</span> <span class="o">?</span>
761 <span class="nb">document</span><span class="o">.</span><span class="nx">documentElement</span><span class="o">.</span><span class="nx">clientWidth</span> <span class="o">:</span> <span class="c">// Standards</span>
762 <span class="c"></span> <span class="nb">document</span><span class="o">.</span><span class="nx">body</span><span class="o">.</span><span class="nx">clientWidth</span><span class="o">;</span> <span class="c">// Quirks</span>
763 <span class="c"></span> <span class="o">}</span>
764 <span class="nx">logger</span><span class="o">.</span><span class="nx">log</span><span class="o">(</span><span class="s1">&#39;getViewportWidth returning &#39;</span> <span class="o">+</span> <span class="nx">width</span><span class="o">,</span> <span class="s1">&#39;info&#39;</span><span class="o">,</span> <span class="s1">&#39;Dom&#39;</span><span class="o">);</span>
765 <span class="k">return</span> <span class="nx">width</span><span class="o">;</span>
766 <span class="o">}</span>
767 <span class="o">};</span>
768 <span class="o">})();</span>
769 </pre></div>
770 </div>
771 </div>
772 </div>
773 <div class="yui-b">
774 <div class="nav">
776 <div class="module">
777 <h4>Modules</h4>
778 <ul class="content">
780 <li class=""><a href="module_animation.html">animation</a></li>
782 <li class=""><a href="module_autocomplete.html">autocomplete</a></li>
784 <li class=""><a href="module_button.html">button</a></li>
786 <li class=""><a href="module_calendar.html">calendar</a></li>
788 <li class=""><a href="module_connection.html">connection</a></li>
790 <li class=""><a href="module_container.html">container</a></li>
792 <li class=""><a href="module_datasource.html">datasource</a></li>
794 <li class=""><a href="module_datatable.html">datatable</a></li>
796 <li class="selected"><a href="module_dom.html">dom</a></li>
798 <li class=""><a href="module_dragdrop.html">dragdrop</a></li>
800 <li class=""><a href="module_element.html">element</a></li>
802 <li class=""><a href="module_event.html">event</a></li>
804 <li class=""><a href="module_history.html">history</a></li>
806 <li class=""><a href="module_logger.html">logger</a></li>
808 <li class=""><a href="module_menu.html">menu</a></li>
810 <li class=""><a href="module_slider.html">slider</a></li>
812 <li class=""><a href="module_tabview.html">tabview</a></li>
814 <li class=""><a href="module_treeview.html">treeview</a></li>
816 <li class=""><a href="module_yahoo.html">yahoo</a></li>
817 </ul>
818 </div>
820 <div class="module">
821 <h4>Classes</h4>
822 <ul class="content">
823 <li class=""><a href="YAHOO.util.Dom.html">YAHOO.util.Dom</a></li>
824 <li class=""><a href="YAHOO.util.Point.html">YAHOO.util.Point</a></li>
825 <li class=""><a href="YAHOO.util.Region.html">YAHOO.util.Region</a></li>
826 </ul>
827 </div>
829 <div class="module">
830 <h4>Files</h4>
831 <ul class="content">
832 <li class="selected"><a href="Dom.js.html">Dom.js</a></li>
833 <li class=""><a href="Region.js.html">Region.js</a></li>
834 </ul>
835 </div>
841 </div>
842 </div>
843 </div>
844 <div id="ft">
845 <hr />
846 Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
847 </div>
848 </div>
849 </body>
850 </html>