yui-ua.js revision ae1f7ed14ee90e037ce01ce4384fda0a7102b4f2
/*
* Provides information about the environment hosting YUI
* @module yui
* @submodule UA
*/
/**
* YUI user agent detection.
* Do not fork for a browser if it can be avoided. Use feature detection when
* you can. Use the user agent as a last resort. UA stores a version
* number for the browser engine, 0 otherwise. This value may or may not map
* to the version number of the browser using the engine. The value is
* presented as a float so that it can easily be used for boolean evaluation
* as well as for looking for a particular range of versions. Because of this,
* some of the granularity of the version info may be lost (e.g., Gecko 1.8.0.9
* reports 1.8).
* @class UA
* @static
*/
Y.UA = function() {
o = {
/**
* Internet Explorer version number or 0. Example: 6
* @property ie
* @type float
* @static
*/
ie: 0,
/**
* Opera version number or 0. Example: 9.2
* @property opera
* @type float
* @static
*/
opera: 0,
/**
* Gecko engine revision number. Will evaluate to 1 if Gecko
* is detected but the revision could not be found. Other browsers
* will be 0. Example: 1.8
* <pre>
* Firefox 1.0.0.4: 1.7.8 <-- Reports 1.7
* Firefox 1.5.0.9: 1.8.0.9 <-- Reports 1.8
* Firefox 2.0.0.3: 1.8.1.3 <-- Reports 1.8
* Firefox 3 alpha: 1.9a4 <-- Reports 1.9
* </pre>
* @property gecko
* @type float
* @static
*/
gecko: 0,
/**
* AppleWebKit version. KHTML browsers that are not WebKit browsers
* will evaluate to 1, other browsers 0. Example: 418.9
* <pre>
* Safari 1.3.2 (312.6): 312.8.1 <-- Reports 312.8 -- currently the
* latest available for Mac OSX 10.3.
* Safari 2.0.2: 416 <-- hasOwnProperty introduced
* Safari 2.0.4: 418 <-- preventDefault fixed
* Safari 2.0.4 (419.3): 418.9.1 <-- One version of Safari may run
* different versions of webkit
* Safari 2.0.4 (419.3): 419 <-- Tiger installations that have been
* updated, but not updated
* to the latest patch.
* Webkit 212 nightly: 522+ <-- Safari 3.0 precursor (with native SVG
* and many major issues fixed).
* Safari 3.0.4 (523.12) 523.12 <-- First Tiger release - automatic update
* from 2.x via the 10.4.11 OS patch
* Webkit nightly 1/2008:525+ <-- Supports DOMContentLoaded event.
* yahoo.com user agent hack removed.
* </pre>
* http://en.wikipedia.org/wiki/Safari_(web_browser)#Version_history
* @property webkit
* @type float
* @static
*/
webkit: 0,
/**
* The mobile property will be set to a string containing any relevant
* user agent information when a modern mobile browser is detected.
* devices with the WebKit-based browser, and Opera Mini.
* @property mobile
* @type string
* @static
*/
mobile: null,
/**
* Adobe AIR version number or 0. Only populated if webkit is detected.
* Example: 1.0
* @property air
* @type float
*/
air: 0,
/**
* Google Caja version number or 0.
* @property caja
* @type float
*/
/**
* Set to true if the page appears to be in SSL
* @property secure
* @type boolean
* @static
*/
secure: false,
/**
* The operating system. Currently only detecting windows or macintosh
* @property os
* @type string
* @static
*/
os: null
},
m;
if (ua) {
o.os = 'windows';
o.os = 'macintosh';
}
// Modern KHTML browsers should qualify as Safari X-Grade
o.webkit=1;
}
// Modern WebKit browsers are at least X-Grade
if (m&&m[1]) {
// Mobile browser check
if (/ Mobile\//.test(ua)) {
} else {
if (m) {
}
}
if (m) {
}
}
if (!o.webkit) { // not webkit
if (m&&m[1]) {
if (m) {
}
} else { // not opera or webkit
if (m&&m[1]) {
} else { // not opera, webkit, or ie
if (m) {
if (m&&m[1]) {
}
}
}
}
}
}
return o;
}();