2011-09-26 23:58:18 +00:00
|
|
|
/*!
|
|
|
|
* Bowser - a browser detector
|
|
|
|
* https://github.com/ded/bowser
|
2014-02-21 16:37:47 +00:00
|
|
|
* MIT License | (c) Dustin Diaz 2014
|
2011-09-26 23:58:18 +00:00
|
|
|
*/
|
2013-08-16 20:03:14 +00:00
|
|
|
|
2011-09-26 23:58:18 +00:00
|
|
|
!function (name, definition) {
|
2014-01-27 22:01:01 +00:00
|
|
|
if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition()
|
|
|
|
else if (typeof define == 'function') define(definition)
|
2011-09-26 23:58:18 +00:00
|
|
|
else this[name] = definition()
|
|
|
|
}('bowser', function () {
|
2011-04-27 22:14:35 +00:00
|
|
|
/**
|
2014-02-20 22:17:59 +00:00
|
|
|
* See useragents.js for examples of navigator.userAgent
|
2012-04-17 01:54:24 +00:00
|
|
|
*/
|
2011-04-27 22:14:35 +00:00
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
var t = true,
|
|
|
|
v /* temporary placeholder for versions. */
|
2011-05-02 20:33:54 +00:00
|
|
|
|
2014-02-21 00:23:58 +00:00
|
|
|
function getVersion(ua, regex, matchedIdx) {
|
|
|
|
var match = ua.match(regex);
|
|
|
|
return (match && match.length > matchedIdx && match[matchedIdx]) || 0;
|
|
|
|
}
|
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
function detect(ua) {
|
2011-04-27 22:14:35 +00:00
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
var ie = /(msie|trident)/i.test(ua)
|
2014-02-24 21:55:24 +00:00
|
|
|
, chrome = /chrome|crios|crmo/i.test(ua)
|
2014-02-20 22:17:59 +00:00
|
|
|
, phantom = /phantom/i.test(ua)
|
|
|
|
, iphone = /iphone/i.test(ua)
|
|
|
|
, ipad = /ipad/i.test(ua)
|
|
|
|
, ipod = /ipod/i.test(ua)
|
|
|
|
, silk = /silk/i.test(ua)
|
|
|
|
, safari = /safari/i.test(ua) && !chrome && !phantom && !silk
|
|
|
|
, android = /android/i.test(ua)
|
|
|
|
, opera = /opera/i.test(ua) || /opr/i.test(ua)
|
2014-02-25 00:06:37 +00:00
|
|
|
, firefox = /(firefox|iceweasel)/i.test(ua)
|
2014-02-20 22:17:59 +00:00
|
|
|
, gecko = /gecko\//i.test(ua)
|
|
|
|
, seamonkey = /seamonkey\//i.test(ua)
|
2014-02-24 00:16:33 +00:00
|
|
|
, webos = /(?:web|hpw)os/i.test(ua)
|
2014-02-24 21:55:24 +00:00
|
|
|
, touchpad = /touchpad\//i.test(ua)
|
2014-02-20 22:17:59 +00:00
|
|
|
, windowsphone = /windows phone/i.test(ua)
|
2014-02-24 21:55:24 +00:00
|
|
|
, blackberry = /(blackberry|\bbb\d+)/i.test(ua)
|
|
|
|
, rimtablet = /rim\stablet/i.test(ua)
|
2014-02-24 23:47:02 +00:00
|
|
|
, bada = /bada\//i.test(ua)
|
2014-02-20 22:17:59 +00:00
|
|
|
, webkitVersion = /version\/(\d+(\.\d+)?)/i
|
2014-02-25 00:06:37 +00:00
|
|
|
, firefoxVersion = /(?:firefox|iceweasel)[ \/](\d+(\.\d+)?)/i
|
2014-02-24 21:55:24 +00:00
|
|
|
, mobile = /mobi/i.test(ua)
|
|
|
|
, tablet = /tablet/i.test(ua)
|
2014-02-20 22:17:59 +00:00
|
|
|
, o = {}
|
|
|
|
|
2014-02-20 23:02:13 +00:00
|
|
|
if (ipod) iphone = false
|
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
if (windowsphone) o = {
|
|
|
|
name: 'Windows Phone'
|
|
|
|
, windowsphone: t
|
2014-02-21 12:56:57 +00:00
|
|
|
, msie: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version: getVersion(ua, /iemobile\/(\d+(\.\d+)?)/i, 1)
|
2013-08-16 19:58:39 +00:00
|
|
|
}
|
2014-02-20 22:17:59 +00:00
|
|
|
else if (opera) {
|
2014-02-21 00:23:58 +00:00
|
|
|
v = getVersion(ua, webkitVersion, 1) ||
|
|
|
|
getVersion(ua, /opr\/(\d+(\.\d+)?)/i, 1) ||
|
|
|
|
getVersion(ua, /opera[ \/](\d+(\.\d+)?)/i, 1);
|
2014-02-20 22:17:59 +00:00
|
|
|
o = {
|
2013-12-05 20:00:02 +00:00
|
|
|
name: 'Opera'
|
|
|
|
, opera: t
|
2014-02-20 22:17:59 +00:00
|
|
|
, version: v
|
|
|
|
}
|
|
|
|
if (android) {
|
2014-02-20 23:02:13 +00:00
|
|
|
o.android = t
|
2014-02-20 22:17:59 +00:00
|
|
|
}
|
|
|
|
if (chrome) {
|
2014-02-20 23:02:13 +00:00
|
|
|
o.webkit = t
|
2013-08-16 19:58:39 +00:00
|
|
|
}
|
2014-02-21 00:23:58 +00:00
|
|
|
}
|
|
|
|
else if (ie) o = {
|
2014-02-20 22:17:59 +00:00
|
|
|
name: 'Internet Explorer'
|
|
|
|
, msie: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version: getVersion(ua, /(msie |rv:)(\d+(\.\d+)?)/i, 2)
|
2014-02-20 22:17:59 +00:00
|
|
|
}
|
2014-02-21 12:56:57 +00:00
|
|
|
else if (chrome) {
|
|
|
|
o = {
|
2013-12-05 20:00:02 +00:00
|
|
|
name: 'Chrome'
|
|
|
|
, webkit: t
|
2011-09-26 23:58:18 +00:00
|
|
|
, chrome: t
|
2014-02-24 21:55:24 +00:00
|
|
|
, version: getVersion(ua, /(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i, 1)
|
2013-08-16 19:58:39 +00:00
|
|
|
}
|
2014-02-21 12:56:57 +00:00
|
|
|
if (android) o.android = t
|
|
|
|
if (ipad || ipod || iphone) {
|
|
|
|
o[iphone ? 'iphone' : ipad ? 'ipad' : 'ipod'] = t
|
|
|
|
o.ios = t
|
|
|
|
}
|
|
|
|
}
|
2014-02-20 22:17:59 +00:00
|
|
|
else if (phantom) o = {
|
2013-12-05 20:00:02 +00:00
|
|
|
name: 'PhantomJS'
|
|
|
|
, webkit: t
|
2012-07-18 17:45:20 +00:00
|
|
|
, phantom: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version: getVersion(ua, /phantomjs\/(\d+(\.\d+)?)/i, 1)
|
2013-08-16 19:58:39 +00:00
|
|
|
}
|
2014-02-20 22:17:59 +00:00
|
|
|
else if (silk) o = {
|
|
|
|
name: 'Amazon Silk'
|
2014-02-24 00:16:33 +00:00
|
|
|
, silk: t
|
2014-02-20 22:17:59 +00:00
|
|
|
, webkit: t
|
|
|
|
, android: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version : getVersion(ua, /silk\/(\d+(\.\d+)?)/i, 1)
|
2014-02-20 22:17:59 +00:00
|
|
|
}
|
|
|
|
else if (iphone || ipad || ipod) {
|
2012-01-24 09:58:00 +00:00
|
|
|
o = {
|
2014-02-19 17:16:06 +00:00
|
|
|
name : iphone ? 'iPhone' : ipad ? 'iPad' : 'iPod'
|
2013-12-05 20:00:02 +00:00
|
|
|
, webkit: t
|
2013-08-16 19:58:39 +00:00
|
|
|
, ios: t
|
2012-01-24 09:58:00 +00:00
|
|
|
}
|
2014-02-21 12:56:57 +00:00
|
|
|
o[iphone ? 'iphone' : ipad ? 'ipad' : 'ipod'] = t
|
2012-01-24 09:58:00 +00:00
|
|
|
// WTF: version is not part of user agent in web apps
|
|
|
|
if (webkitVersion.test(ua)) {
|
2014-02-21 00:23:58 +00:00
|
|
|
o.version = getVersion(ua, webkitVersion, 1)
|
2012-01-24 09:58:00 +00:00
|
|
|
}
|
2011-04-27 22:14:35 +00:00
|
|
|
}
|
2014-02-24 21:55:24 +00:00
|
|
|
else if (blackberry || rimtablet) {
|
2014-02-20 22:17:59 +00:00
|
|
|
o = {
|
|
|
|
name: 'BlackBerry'
|
|
|
|
, blackberry: t
|
|
|
|
}
|
2014-02-21 00:23:58 +00:00
|
|
|
if ((v = getVersion(ua, webkitVersion, 1))) {
|
|
|
|
o.version = v
|
2014-02-20 22:17:59 +00:00
|
|
|
o.webkit = t
|
|
|
|
} else {
|
2014-02-21 00:23:58 +00:00
|
|
|
o.version = getVersion(ua, /blackberry[\d]+\/(\d+(\.\d+)?)/i, 1)
|
2014-02-20 22:17:59 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-24 00:16:33 +00:00
|
|
|
else if (webos) {
|
|
|
|
o = {
|
2014-02-20 22:17:59 +00:00
|
|
|
name: 'WebOS'
|
|
|
|
, webkit: t
|
|
|
|
, webos: t
|
2014-02-24 00:16:33 +00:00
|
|
|
, version: (getVersion(ua, webkitVersion, 1) || getVersion(ua, /w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i, 1))
|
|
|
|
};
|
2014-02-24 21:55:24 +00:00
|
|
|
touchpad && (o.touchpad = t)
|
2014-02-24 00:16:33 +00:00
|
|
|
}
|
2014-02-24 23:47:02 +00:00
|
|
|
else if (bada) {
|
|
|
|
o = {
|
|
|
|
name: 'Bada'
|
|
|
|
, webkit: t
|
|
|
|
, bada: t
|
|
|
|
, version: getVersion(ua, /dolfin\/(\d+(\.\d+)?)/i, 1)
|
|
|
|
};
|
|
|
|
}
|
2014-02-20 22:17:59 +00:00
|
|
|
else if (gecko) {
|
2012-01-24 09:58:00 +00:00
|
|
|
o = {
|
2013-12-05 20:00:02 +00:00
|
|
|
name: 'Gecko'
|
|
|
|
, gecko: t
|
2013-08-16 19:58:39 +00:00
|
|
|
, mozilla: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version: getVersion(ua, firefoxVersion, 1)
|
2011-04-27 22:14:35 +00:00
|
|
|
}
|
2014-02-20 23:30:09 +00:00
|
|
|
if (seamonkey) {
|
|
|
|
o.name = 'SeaMonkey'
|
|
|
|
o.seamonkey = t
|
2014-02-21 00:23:58 +00:00
|
|
|
o.version = getVersion(ua, /seamonkey\/(\d+(\.\d+)?)/i, 1)
|
2014-02-20 23:30:09 +00:00
|
|
|
} else if (firefox) {
|
|
|
|
o.name = 'Firefox'
|
|
|
|
o.firefox = t
|
2013-12-05 20:00:02 +00:00
|
|
|
}
|
2014-02-20 23:02:13 +00:00
|
|
|
if (android) {
|
|
|
|
o.android = t
|
2014-02-21 23:48:51 +00:00
|
|
|
} else if (!android && firefox && /\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(ua)) {
|
2014-02-21 00:23:58 +00:00
|
|
|
o.firefoxos = t
|
2014-02-20 23:02:13 +00:00
|
|
|
}
|
2011-04-27 22:14:35 +00:00
|
|
|
}
|
2014-02-20 23:02:13 +00:00
|
|
|
else if (android) o = {
|
|
|
|
name: 'Android'
|
|
|
|
, webkit: t
|
|
|
|
, android: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version: getVersion(ua, webkitVersion, 1)
|
2014-02-20 23:02:13 +00:00
|
|
|
}
|
|
|
|
else if (safari) o = {
|
|
|
|
name: 'Safari'
|
|
|
|
, webkit: t
|
|
|
|
, safari: t
|
2014-02-21 00:23:58 +00:00
|
|
|
, version: getVersion(ua, webkitVersion, 1)
|
2014-02-20 23:02:13 +00:00
|
|
|
}
|
2011-04-27 22:14:35 +00:00
|
|
|
|
2014-02-24 21:55:24 +00:00
|
|
|
|
|
|
|
// OS version extraction
|
2014-02-21 12:56:57 +00:00
|
|
|
var osVersion;
|
|
|
|
if (android) {
|
2014-02-24 21:55:24 +00:00
|
|
|
osVersion = getVersion(ua, /android[ \/-](\d+(\.\d+)*)/i, 1);
|
2014-02-21 12:56:57 +00:00
|
|
|
if (osVersion) {
|
|
|
|
o.osversion = osVersion;
|
|
|
|
}
|
|
|
|
} else if (iphone || ipad || ipod) {
|
|
|
|
osVersion = getVersion(ua, /os (\d+([_\s]\d+)*) like mac os x/i, 1);
|
2014-02-24 00:16:33 +00:00
|
|
|
osVersion = (osVersion || "").replace(/[_\s]/g, '.');
|
2014-02-21 12:56:57 +00:00
|
|
|
} else if (windowsphone) {
|
|
|
|
osVersion = getVersion(ua, /windows phone (?:os)?\s?(\d+(\.\d+)*)/i, 1);
|
2014-02-24 00:16:33 +00:00
|
|
|
} else if (webos) {
|
|
|
|
osVersion = getVersion(ua, /(?:web|hpw)os\/(\d+(\.\d+)*)/i, 1);
|
2014-02-24 21:55:24 +00:00
|
|
|
} else if (rimtablet) {
|
|
|
|
osVersion = getVersion(ua, /rim\stablet\sos\s(\d+(\.\d+)*)/i, 1);
|
2014-02-24 23:47:02 +00:00
|
|
|
} else if (bada) {
|
|
|
|
osVersion = getVersion(ua, /bada\/(\d+(\.\d+)*)/i, 1);
|
2014-02-24 00:16:33 +00:00
|
|
|
}
|
|
|
|
if (osVersion) {
|
|
|
|
o.osversion = osVersion;
|
2014-02-21 12:56:57 +00:00
|
|
|
}
|
|
|
|
|
2014-02-24 21:55:24 +00:00
|
|
|
// device type extraction
|
2014-02-24 23:47:02 +00:00
|
|
|
var osMajorVersion = (osVersion || '').split('.')[0];
|
|
|
|
if (tablet || ipad || (android && (osMajorVersion == 3 || (osMajorVersion == 4 && !mobile))) || rimtablet || silk || touchpad) {
|
2014-02-24 21:55:24 +00:00
|
|
|
o.tablet = t
|
2014-02-24 23:47:02 +00:00
|
|
|
} else if (iphone || ipod || (android && mobile) || windowsphone || blackberry || webos || bada || mobile) {
|
2014-02-24 21:55:24 +00:00
|
|
|
o.mobile = t
|
|
|
|
}
|
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
// Graded Browser Support
|
|
|
|
// http://developer.yahoo.com/yui/articles/gbs
|
|
|
|
if ((o.msie && o.version >= 9) ||
|
|
|
|
(o.chrome && o.version >= 20) ||
|
|
|
|
(o.firefox && o.version >= 10.0) ||
|
|
|
|
(o.safari && o.version >= 5) ||
|
2014-02-21 12:56:57 +00:00
|
|
|
(o.opera && o.version >= 10.0) ||
|
|
|
|
(o.ios && o.osversion && o.osversion.split(".")[0] >= 6)
|
|
|
|
) {
|
2014-02-20 22:17:59 +00:00
|
|
|
o.a = t;
|
|
|
|
}
|
2011-05-10 16:50:28 +00:00
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
else if ((o.msie && o.version < 9) ||
|
|
|
|
(o.chrome && o.version < 20) ||
|
|
|
|
(o.firefox && o.version < 10.0) ||
|
|
|
|
(o.safari && o.version < 5) ||
|
2014-02-21 12:56:57 +00:00
|
|
|
(o.opera && o.version < 10.0) ||
|
|
|
|
(o.ios && o.osversion && o.osversion.split(".")[0] < 6)
|
|
|
|
) {
|
2014-02-20 22:17:59 +00:00
|
|
|
o.c = t
|
|
|
|
} else o.x = t
|
|
|
|
|
|
|
|
return o
|
2011-05-10 16:50:28 +00:00
|
|
|
}
|
|
|
|
|
2014-02-20 22:17:59 +00:00
|
|
|
var bowser = detect(typeof navigator !== 'undefined' ? navigator.userAgent : '')
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set our detect method to the main bowser object so we can
|
|
|
|
* reuse it to test other user agents.
|
|
|
|
* This is needed to implement future tests.
|
|
|
|
*/
|
|
|
|
bowser._detect = detect;
|
2011-04-27 22:14:35 +00:00
|
|
|
|
2011-09-26 23:58:18 +00:00
|
|
|
return bowser
|
2013-12-03 22:46:08 +00:00
|
|
|
});
|