source: cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/api/yui-ua.js.html @ 5259

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/branches/cows-vis/cows/pylons/project_templates/cows_server/+package+/public/js/yui/api/yui-ua.js.html@5259
Revision 5259, 18.7 KB checked in by domlowe, 11 years ago (diff)

adding yui javascript

Line 
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: yui   yui-ua.js  (YUI Library)</title>
5        <link rel="stylesheet" type="text/css" href="assets/api.css">
6    <script type="text/javascript" src="assets/api-js"></script>
7    <script type="text/javascript" src="assets/ac-js"></script>
8</head>
9
10<body id="yahoo-com">
11
12<div id="doc3" class="yui-t2">
13
14        <div id="hd">
15        <a href="http://developer.yahoo.com/yui/"><h1>Yahoo! UI Library</h1></a>
16        <h3>yui&nbsp; <span class="subtitle">3.0.0pr1</span></h3>
17        <p>
18        <a href="./index.html">Yahoo! UI Library</a> 
19            &gt; <a href="./module_yui.html">yui</a>
20               
21                 &gt; yui-ua.js (source view)
22            </p>
23
24
25        </div>
26
27        <div id="bd">
28                <div id="yui-main">
29                        <div class="yui-b">
30            <form name="yui-classopts-form">
31    <span id="classopts"><input type="checkbox" name="showprivate" id="showprivate" /> <label for="showprivate">Show Private</label></span>
32    <span id="classopts"><input type="checkbox" name="showprotected" id="showprotected" /> <label for="showprotected">Show Protected</label></span>
33    <span id="classopts"><input type="checkbox" name="showdeprecated" id="showdeprecated" /> <label for="showdeprecated">Show Deprecated</label></span>
34            </form>
35
36                    <div id="srcout">
37                        <style>
38                            #doc3 #classopts { display:none; }
39                        </style>
40<div class="highlight" ><pre><span class="c">/*</span>
41<span class="c"> * YUI user agent detection</span>
42<span class="c"> * @module yui</span>
43<span class="c"> * @submodule ua</span>
44<span class="c"> */</span>
45<span class="nx">YUI</span><span class="o">.</span><span class="nx">add</span><span class="o">(</span><span class="s2">&quot;ua&quot;</span><span class="o">,</span> <span class="k">function</span><span class="o">(</span><span class="nx">Y</span><span class="o">)</span> <span class="o">{</span>
46
47    <span class="c">/**</span>
48<span class="c">     * Browser/platform detection</span>
49<span class="c">     * @class UA</span>
50<span class="c">     * @static</span>
51<span class="c">     */</span>
52    <span class="nx">Y</span><span class="o">.</span><span class="nx">UA</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
53
54        <span class="k">var</span> <span class="nx">o</span><span class="o">={</span>
55
56            <span class="c">/**</span>
57<span class="c">             * Internet Explorer version number or 0.  Example: 6</span>
58<span class="c">             * @property ie</span>
59<span class="c">             * @type float</span>
60<span class="c">             * @static</span>
61<span class="c">             */</span>
62            <span class="nx">ie</span><span class="o">:</span><span class="m">0</span><span class="o">,</span>
63
64            <span class="c">/**</span>
65<span class="c">             * Opera version number or 0.  Example: 9.2</span>
66<span class="c">             * @property opera</span>
67<span class="c">             * @type float</span>
68<span class="c">             * @static</span>
69<span class="c">             */</span>
70            <span class="nx">opera</span><span class="o">:</span><span class="m">0</span><span class="o">,</span>
71
72            <span class="c">/**</span>
73<span class="c">             * Gecko engine revision number.  Will evaluate to 1 if Gecko </span>
74<span class="c">             * is detected but the revision could not be found. Other browsers</span>
75<span class="c">             * will be 0.  Example: 1.8</span>
76<span class="c">             * &lt;pre&gt;</span>
77<span class="c">             * Firefox 1.0.0.4: 1.7.8   &lt;-- Reports 1.7</span>
78<span class="c">             * Firefox 1.5.0.9: 1.8.0.9 &lt;-- Reports 1.8</span>
79<span class="c">             * Firefox 2.0.0.3: 1.8.1.3 &lt;-- Reports 1.8</span>
80<span class="c">             * Firefox 3 alpha: 1.9a4   &lt;-- Reports 1.9</span>
81<span class="c">             * &lt;/pre&gt;</span>
82<span class="c">             * @property gecko</span>
83<span class="c">             * @type float</span>
84<span class="c">             * @static</span>
85<span class="c">             */</span>
86            <span class="nx">gecko</span><span class="o">:</span><span class="m">0</span><span class="o">,</span>
87
88            <span class="c">/**</span>
89<span class="c">             * AppleWebKit version.  KHTML browsers that are not WebKit browsers </span>
90<span class="c">             * will evaluate to 1, other browsers 0.  Example: 418.9.1</span>
91<span class="c">             * &lt;pre&gt;</span>
92<span class="c">             * Safari 1.3.2 (312.6): 312.8.1 &lt;-- Reports 312.8 -- currently the </span>
93<span class="c">             *                                   latest available for Mac OSX 10.3.</span>
94<span class="c">             * Safari 2.0.2:         416     &lt;-- hasOwnProperty introduced</span>
95<span class="c">             * Safari 2.0.4:         418     &lt;-- preventDefault fixed</span>
96<span class="c">             * Safari 2.0.4 (419.3): 418.9.1 &lt;-- One version of Safari may run</span>
97<span class="c">             *                                   different versions of webkit</span>
98<span class="c">             * Safari 2.0.4 (419.3): 419     &lt;-- Tiger installations that have been</span>
99<span class="c">             *                                   updated, but not updated</span>
100<span class="c">             *                                   to the latest patch.</span>
101<span class="c">             * Webkit 212 nightly:   522+    &lt;-- Safari 3.0 precursor (with native SVG</span>
102<span class="c">             *                                   and many major issues fixed).</span>
103<span class="c">             * Safari 3.0.4 (523.12) 523.12  &lt;-- First Tiger release - automatic update</span>
104<span class="c">             *                                   from 2.x via the 10.4.11 OS patch</span>
105<span class="c">             *                                   </span>
106<span class="c">             * &lt;/pre&gt;</span>
107<span class="c">             * http://developer.apple.com/internet/safari/uamatrix.html</span>
108<span class="c">             * @property webkit</span>
109<span class="c">             * @type float</span>
110<span class="c">             * @static</span>
111<span class="c">             */</span>
112            <span class="nx">webkit</span><span class="o">:</span><span class="m">0</span><span class="o">,</span>
113
114            <span class="c">/**</span>
115<span class="c">             * The mobile property will be set to a string containing any relevant</span>
116<span class="c">             * user agent information when a modern mobile browser is detected.</span>
117<span class="c">             * Currently limited to Safari on the iPhone/iPod Touch, Nokia N-series</span>
118<span class="c">             * devices with the WebKit-based browser, and Opera Mini.  </span>
119<span class="c">             * @property mobile </span>
120<span class="c">             * @type string</span>
121<span class="c">             * @static</span>
122<span class="c">             */</span>
123            <span class="nx">mobile</span><span class="o">:</span> <span class="kc">null</span> 
124        <span class="o">};</span>
125
126        <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">m</span><span class="o">;</span>
127
128        <span class="c">// Modern KHTML browsers should qualify as Safari X-Grade</span>
129<span class="c"></span>        <span class="k">if</span> <span class="o">((</span><span class="sr">/KHTML/</span><span class="o">).</span><span class="nx">test</span><span class="o">(</span><span class="nx">ua</span><span class="o">))</span> <span class="o">{</span>
130            <span class="nx">o</span><span class="o">.</span><span class="nx">webkit</span><span class="o">=</span><span class="m">1</span><span class="o">;</span>
131        <span class="o">}</span>
132        <span class="c">// Modern WebKit browsers are at least X-Grade</span>
133<span class="c"></span>        <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/AppleWebKit\/([^\s]*)/</span><span class="o">);</span>
134        <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">&amp;&amp;</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">{</span>
135            <span class="nx">o</span><span class="o">.</span><span class="nx">webkit</span><span class="o">=</span><span class="nb">parseFloat</span><span class="o">(</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]);</span>
136
137            <span class="c">// Mobile browser check</span>
138<span class="c"></span>            <span class="k">if</span> <span class="o">(</span><span class="sr">/ Mobile\//</span><span class="o">.</span><span class="nx">test</span><span class="o">(</span><span class="nx">ua</span><span class="o">))</span> <span class="o">{</span>
139                <span class="nx">o</span><span class="o">.</span><span class="nx">mobile</span> <span class="o">=</span> <span class="s2">&quot;Apple&quot;</span><span class="o">;</span> <span class="c">// iPhone or iPod Touch</span>
140<span class="c"></span>            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
141                <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/NokiaN[^\/]*/</span><span class="o">);</span>
142                <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">)</span> <span class="o">{</span>
143                    <span class="nx">o</span><span class="o">.</span><span class="nx">mobile</span> <span class="o">=</span> <span class="nx">m</span><span class="o">[</span><span class="m">0</span><span class="o">];</span> <span class="c">// Nokia N-series, ex: NokiaN95</span>
144<span class="c"></span>                <span class="o">}</span>
145            <span class="o">}</span>
146
147        <span class="o">}</span>
148
149        <span class="k">if</span> <span class="o">(!</span><span class="nx">o</span><span class="o">.</span><span class="nx">webkit</span><span class="o">)</span> <span class="o">{</span> <span class="c">// not webkit</span>
150<span class="c"></span>            <span class="c">// @todo check Opera/8.01 (J2ME/MIDP; Opera Mini/2.0.4509/1316; fi; U; ssr)</span>
151<span class="c"></span>            <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/Opera[\s\/]([^\s]*)/</span><span class="o">);</span>
152            <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">&amp;&amp;</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">{</span>
153                <span class="nx">o</span><span class="o">.</span><span class="nx">opera</span><span class="o">=</span><span class="nb">parseFloat</span><span class="o">(</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]);</span>
154                <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/Opera Mini[^;]*/</span><span class="o">);</span>
155                <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">)</span> <span class="o">{</span>
156                    <span class="nx">o</span><span class="o">.</span><span class="nx">mobile</span> <span class="o">=</span> <span class="nx">m</span><span class="o">[</span><span class="m">0</span><span class="o">];</span> <span class="c">// ex: Opera Mini/2.0.4509/1316</span>
157<span class="c"></span>                <span class="o">}</span>
158            <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// not opera or webkit</span>
159<span class="c"></span>                <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/MSIE\s([^;]*)/</span><span class="o">);</span>
160                <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">&amp;&amp;</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">{</span>
161                    <span class="nx">o</span><span class="o">.</span><span class="nx">ie</span><span class="o">=</span><span class="nb">parseFloat</span><span class="o">(</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]);</span>
162                <span class="o">}</span> <span class="k">else</span> <span class="o">{</span> <span class="c">// not opera, webkit, or ie</span>
163<span class="c"></span>                    <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/Gecko\/([^\s]*)/</span><span class="o">);</span>
164                    <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">)</span> <span class="o">{</span>
165                        <span class="nx">o</span><span class="o">.</span><span class="nx">gecko</span><span class="o">=</span><span class="m">1</span><span class="o">;</span> <span class="c">// Gecko detected, look for revision</span>
166<span class="c"></span>                        <span class="nx">m</span><span class="o">=</span><span class="nx">ua</span><span class="o">.</span><span class="nx">match</span><span class="o">(</span><span class="sr">/rv:([^\s\)]*)/</span><span class="o">);</span>
167                        <span class="k">if</span> <span class="o">(</span><span class="nx">m</span><span class="o">&amp;&amp;</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">])</span> <span class="o">{</span>
168                            <span class="nx">o</span><span class="o">.</span><span class="nx">gecko</span><span class="o">=</span><span class="nb">parseFloat</span><span class="o">(</span><span class="nx">m</span><span class="o">[</span><span class="m">1</span><span class="o">]);</span>
169                        <span class="o">}</span>
170                    <span class="o">}</span>
171                <span class="o">}</span>
172            <span class="o">}</span>
173        <span class="o">}</span>
174       
175        <span class="k">return</span> <span class="nx">o</span><span class="o">;</span>
176    <span class="o">}();</span>
177<span class="o">},</span> <span class="s2">&quot;@VERSION@&quot;</span><span class="o">);</span>
178</pre></div>
179                    </div>
180                        </div>
181                </div>
182                <div class="yui-b">
183            <div class="nav">
184
185                    <div class="module">
186                        <h4>Modules</h4>
187                        <ul class="content">
188
189                                <li class=""><a href="module_anim.html">anim</a></li>
190
191                                <li class=""><a href="module_attribute.html">attribute</a></li>
192
193                                <li class=""><a href="module_base.html">base</a></li>
194
195                                <li class=""><a href="module_cookie.html">cookie</a></li>
196
197                                <li class=""><a href="module_dd.html">dd</a></li>
198
199                                <li class=""><a href="module_dd-plugin.html">dd-plugin</a></li>
200
201                                <li class=""><a href="module_dom.html">dom</a></li>
202
203                                <li class=""><a href="module_dump.html">dump</a></li>
204
205                                <li class=""><a href="module_event.html">event</a></li>
206
207                                <li class=""><a href="module_io.html">io</a></li>
208
209                                <li class=""><a href="module_json.html">json</a></li>
210
211                                <li class=""><a href="module_node.html">node</a></li>
212
213                                <li class=""><a href="module_oop.html">oop</a></li>
214
215                                <li class=""><a href="module_queue.html">queue</a></li>
216
217                                <li class=""><a href="module_substitute.html">substitute</a></li>
218
219                                <li class="selected"><a href="module_yui.html">yui</a></li>
220                        </ul>
221                    </div>
222
223                    <div class="module">
224                        <h4>Classes</h4>
225                        <ul class="content">
226                                <li class=""><a href="Get.html">Get</a></li>
227                                <li class=""><a href="Lang.html">Lang</a></li>
228                                <li class=""><a href="Loader.html">Loader</a></li>
229                                <li class=""><a href="UA.html">UA</a></li>
230                                <li class=""><a href="YUI.html">YUI</a></li>
231                                <li class=""><a href="YUI~array.html">YUI~array</a></li>
232                                <li class=""><a href="YUI~object.html">YUI~object</a></li>
233                        </ul>
234                    </div>
235
236                    <div class="module">
237                        <h4>Files</h4>
238                        <ul class="content">       
239                                <li class=""><a href="get.js.html">get.js</a></li>
240                                <li class=""><a href="loader.js.html">loader.js</a></li>
241                                <li class=""><a href="yui-array.js.html">yui-array.js</a></li>
242                                <li class=""><a href="yui-core.js.html">yui-core.js</a></li>
243                                <li class=""><a href="yui-dump.js.html">yui-dump.js</a></li>
244                                <li class=""><a href="yui-init.js.html">yui-init.js</a></li>
245                                <li class=""><a href="yui-lang.js.html">yui-lang.js</a></li>
246                                <li class=""><a href="yui-later.js.html">yui-later.js</a></li>
247                                <li class=""><a href="yui-log.js.html">yui-log.js</a></li>
248                                <li class=""><a href="yui-object.js.html">yui-object.js</a></li>
249                                <li class="selected"><a href="yui-ua.js.html">yui-ua.js</a></li>
250                                <li class=""><a href="yui.js.html">yui.js</a></li>
251                        </ul>
252                    </div>
253
254
255
256
257
258            </div>
259                </div>
260        </div>
261        <div id="ft">
262        <hr />
263        Copyright &copy; 2008 Yahoo! Inc. All rights reserved.
264        </div>
265</div>
266</body>
267</html>
Note: See TracBrowser for help on using the repository browser.