jam-cloud/web/vendor/assets/javascripts/jquery.browser.js

112 lines
2.9 KiB
JavaScript
Raw Permalink Normal View History

2014-03-28 04:00:57 +00:00
/*!
2014-03-31 11:41:26 +00:00
* jQuery Browser Plugin v0.0.6
2014-03-28 04:00:57 +00:00
* https://github.com/gabceb/jquery-browser-plugin
*
* Original jquery-browser code Copyright 2005, 2013 jQuery Foundation, Inc. and other contributors
* http://jquery.org/license
*
* Modifications Copyright 2013 Gabriel Cebrian
* https://github.com/gabceb
*
* Released under the MIT license
*
* Date: 2013-07-29T17:23:27-07:00
*/
(function( jQuery, window, undefined ) {
"use strict";
var matched, browser;
jQuery.uaMatch = function( ua ) {
ua = ua.toLowerCase();
var match = /(opr)[\/]([\w.]+)/.exec( ua ) ||
/(chrome)[ \/]([\w.]+)/.exec( ua ) ||
2014-03-31 11:41:26 +00:00
/(version)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec( ua ) ||
2014-03-28 04:00:57 +00:00
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("trident") >= 0 && /(rv)(?::| )([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[];
var platform_match = /(ipad)/.exec( ua ) ||
/(iphone)/.exec( ua ) ||
/(android)/.exec( ua ) ||
2014-03-31 11:41:26 +00:00
/(windows phone)/.exec( ua ) ||
2014-03-28 04:00:57 +00:00
/(win)/.exec( ua ) ||
/(mac)/.exec( ua ) ||
/(linux)/.exec( ua ) ||
2014-03-31 11:41:26 +00:00
/(cros)/i.exec( ua ) ||
2014-03-28 04:00:57 +00:00
[];
return {
browser: match[ 3 ] || match[ 1 ] || "",
version: match[ 2 ] || "0",
2014-03-31 11:41:26 +00:00
platform: platform_match[ 0 ] || ""
2014-03-28 04:00:57 +00:00
};
};
matched = jQuery.uaMatch( window.navigator.userAgent );
browser = {};
if ( matched.browser ) {
browser[ matched.browser ] = true;
browser.version = matched.version;
browser.versionNumber = parseInt(matched.version);
}
if ( matched.platform ) {
browser[ matched.platform ] = true;
}
2014-03-31 11:41:26 +00:00
// These are all considered mobile platforms, meaning they run a mobile browser
2014-03-28 04:00:57 +00:00
if ( browser.android || browser.ipad || browser.iphone || browser[ "windows phone" ] ) {
browser.mobile = true;
}
2014-03-31 11:41:26 +00:00
// These are all considered desktop platforms, meaning they run a desktop browser
if ( browser.cros || browser.mac || browser.linux || browser.win ) {
2014-03-28 04:00:57 +00:00
browser.desktop = true;
}
2014-03-31 11:41:26 +00:00
// Chrome, Opera 15+ and Safari are webkit based browsers
2014-03-28 04:00:57 +00:00
if ( browser.chrome || browser.opr || browser.safari ) {
browser.webkit = true;
}
2014-03-31 11:41:26 +00:00
// IE11 has a new token so we will assign it msie to avoid breaking changes
2014-03-28 04:00:57 +00:00
if ( browser.rv )
{
2014-03-31 11:41:26 +00:00
var ie = "msie";
2014-03-28 04:00:57 +00:00
matched.browser = ie;
browser[ie] = true;
}
2014-03-31 11:41:26 +00:00
// Opera 15+ are identified as opr
2014-03-28 04:00:57 +00:00
if ( browser.opr )
{
2014-03-31 11:41:26 +00:00
var opera = "opera";
2014-03-28 04:00:57 +00:00
matched.browser = opera;
browser[opera] = true;
}
2014-03-31 11:41:26 +00:00
// Stock Android browsers are marked as Safari on Android.
2014-03-28 04:00:57 +00:00
if ( browser.safari && browser.android )
{
2014-03-31 11:41:26 +00:00
var android = "android";
2014-03-28 04:00:57 +00:00
matched.browser = android;
browser[android] = true;
}
2014-03-31 11:41:26 +00:00
// Assign the name and platform variable
2014-03-28 04:00:57 +00:00
browser.name = matched.browser;
browser.platform = matched.platform;
jQuery.browser = browser;
})( jQuery, window );