116 lines
2.1 KiB
JavaScript
116 lines
2.1 KiB
JavaScript
|
(function(w, d, n) {
|
||
|
|
||
|
var cl = "bx-core";
|
||
|
var ht = d.documentElement;
|
||
|
var htc = ht ? ht.className : undefined;
|
||
|
if (htc === undefined || htc.indexOf(cl) !== -1)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var ua = n.userAgent;
|
||
|
if (/(iPad;)|(iPhone;)/i.test(ua))
|
||
|
{
|
||
|
cl += " bx-ios";
|
||
|
}
|
||
|
else if (/Android/i.test(ua))
|
||
|
{
|
||
|
cl += " bx-android";
|
||
|
}
|
||
|
|
||
|
cl += (/(ipad|iphone|android|mobile|touch)/i.test(ua) ? " bx-touch" : " bx-no-touch");
|
||
|
|
||
|
cl += w.devicePixelRatio && w.devicePixelRatio >= 2
|
||
|
? " bx-retina"
|
||
|
: " bx-no-retina";
|
||
|
|
||
|
var ieVersion = -1;
|
||
|
if (/AppleWebKit/.test(ua))
|
||
|
{
|
||
|
cl += " bx-chrome";
|
||
|
}
|
||
|
else if ((ieVersion = getIeVersion()) > 0)
|
||
|
{
|
||
|
cl += " bx-ie bx-ie" + ieVersion;
|
||
|
if (ieVersion > 7 && ieVersion < 10 && !isDoctype())
|
||
|
{
|
||
|
cl += " bx-quirks";
|
||
|
}
|
||
|
}
|
||
|
else if (/Opera/.test(ua))
|
||
|
{
|
||
|
cl += " bx-opera";
|
||
|
}
|
||
|
else if (/Gecko/.test(ua))
|
||
|
{
|
||
|
cl += " bx-firefox";
|
||
|
}
|
||
|
|
||
|
if (/Macintosh/i.test(ua))
|
||
|
{
|
||
|
cl += " bx-mac";
|
||
|
}
|
||
|
|
||
|
ht.className = htc ? htc + " " + cl : cl;
|
||
|
|
||
|
function isDoctype()
|
||
|
{
|
||
|
if (d.compatMode)
|
||
|
{
|
||
|
return d.compatMode == "CSS1Compat";
|
||
|
}
|
||
|
|
||
|
return d.documentElement && d.documentElement.clientHeight;
|
||
|
}
|
||
|
|
||
|
function getIeVersion()
|
||
|
{
|
||
|
if (/Opera/i.test(ua) || /Webkit/i.test(ua) || /Firefox/i.test(ua) || /Chrome/i.test(ua))
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
|
||
|
var rv = -1;
|
||
|
if (!!(w.MSStream) && !(w.ActiveXObject) && ("ActiveXObject" in w))
|
||
|
{
|
||
|
rv = 11;
|
||
|
}
|
||
|
else if (!!d.documentMode && d.documentMode >= 10)
|
||
|
{
|
||
|
rv = 10;
|
||
|
}
|
||
|
else if (!!d.documentMode && d.documentMode >= 9)
|
||
|
{
|
||
|
rv = 9;
|
||
|
}
|
||
|
else if (d.attachEvent && !/Opera/.test(ua))
|
||
|
{
|
||
|
rv = 8;
|
||
|
}
|
||
|
|
||
|
if (rv == -1 || rv == 8)
|
||
|
{
|
||
|
var re;
|
||
|
if (n.appName == "Microsoft Internet Explorer")
|
||
|
{
|
||
|
re = new RegExp("MSIE ([0-9]+[\.0-9]*)");
|
||
|
if (re.exec(ua) != null)
|
||
|
{
|
||
|
rv = parseFloat(RegExp.$1);
|
||
|
}
|
||
|
}
|
||
|
else if (n.appName == "Netscape")
|
||
|
{
|
||
|
rv = 11;
|
||
|
re = new RegExp("Trident/.*rv:([0-9]+[\.0-9]*)");
|
||
|
if (re.exec(ua) != null)
|
||
|
{
|
||
|
rv = parseFloat(RegExp.$1);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return rv;
|
||
|
}
|
||
|
|
||
|
})(window, document, navigator);
|