MCPcopy Index your code
hub / github.com/angular-ui/ui-router / $SnifferProvider

Function $SnifferProvider

test/angular/1.2/angular.js:14369–14444  ·  view source on GitHub ↗

* !!! This is an undocumented "private" service !!! * * @name $sniffer * @requires $window * @requires $document * * @property {boolean} history Does the browser support html5 history api ? * @property {boolean} hashchange Does the browser support hashchange event ? * @property {boolean} tra

()

Source from the content-addressed store, hash-verified

14367 * This is very simple implementation of testing browser's features.
14368 */
14369function $SnifferProvider() {
14370 this.$get = ['$window', '$document', function($window, $document) {
14371 var eventSupport = {},
14372 android =
14373 int((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
14374 boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
14375 document = $document[0] || {},
14376 documentMode = document.documentMode,
14377 vendorPrefix,
14378 vendorRegex = /^(Moz|webkit|O|ms)(?=[A-Z])/,
14379 bodyStyle = document.body && document.body.style,
14380 transitions = false,
14381 animations = false,
14382 match;
14383
14384 if (bodyStyle) {
14385 for(var prop in bodyStyle) {
14386 if(match = vendorRegex.exec(prop)) {
14387 vendorPrefix = match[0];
14388 vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1);
14389 break;
14390 }
14391 }
14392
14393 if(!vendorPrefix) {
14394 vendorPrefix = ('WebkitOpacity' in bodyStyle) && 'webkit';
14395 }
14396
14397 transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
14398 animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));
14399
14400 if (android && (!transitions||!animations)) {
14401 transitions = isString(document.body.style.webkitTransition);
14402 animations = isString(document.body.style.webkitAnimation);
14403 }
14404 }
14405
14406
14407 return {
14408 // Android has history.pushState, but it does not update location correctly
14409 // so let's not use the history API at all.
14410 // http://code.google.com/p/android/issues/detail?id=17471
14411 // https://github.com/angular/angular.js/issues/904
14412
14413 // older webkit browser (533.9) on Boxee box has exactly the same problem as Android has
14414 // so let's not use the history API also
14415 // We are purposefully using `!(android < 4)` to cover the case when `android` is undefined
14416 // jshint -W018
14417 history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee),
14418 // jshint +W018
14419 hashchange: 'onhashchange' in $window &&
14420 // IE8 compatible mode lies
14421 (!documentMode || documentMode > 7),
14422 hasEvent: function(event) {
14423 // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
14424 // it. In particular the event is not fired when backspace or delete key are pressed or
14425 // when cut operation is performed.
14426 if (event == 'input' && msie == 9) return false;

Callers

nothing calls this directly

Calls 5

intFunction · 0.70
lowercaseFunction · 0.70
isStringFunction · 0.70
isUndefinedFunction · 0.70
cspFunction · 0.70

Tested by

no test coverage detected