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

Function $SnifferProvider

lib/test/angular/1.4.3/angular.js:17396–17467  ·  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} transitions Does the browser support CSS transition events ? * @property {boolea

()

Source from the content-addressed store, hash-verified

17394 * This is very simple implementation of testing browser's features.
17395 */
17396function $SnifferProvider() {
17397 this.$get = ['$window', '$document', function($window, $document) {
17398 var eventSupport = {},
17399 android =
17400 toInt((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]),
17401 boxee = /Boxee/i.test(($window.navigator || {}).userAgent),
17402 document = $document[0] || {},
17403 vendorPrefix,
17404 vendorRegex = /^(Moz|webkit|ms)(?=[A-Z])/,
17405 bodyStyle = document.body && document.body.style,
17406 transitions = false,
17407 animations = false,
17408 match;
17409
17410 if (bodyStyle) {
17411 for (var prop in bodyStyle) {
17412 if (match = vendorRegex.exec(prop)) {
17413 vendorPrefix = match[0];
17414 vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1);
17415 break;
17416 }
17417 }
17418
17419 if (!vendorPrefix) {
17420 vendorPrefix = ('WebkitOpacity' in bodyStyle) && 'webkit';
17421 }
17422
17423 transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle));
17424 animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle));
17425
17426 if (android && (!transitions || !animations)) {
17427 transitions = isString(bodyStyle.webkitTransition);
17428 animations = isString(bodyStyle.webkitAnimation);
17429 }
17430 }
17431
17432
17433 return {
17434 // Android has history.pushState, but it does not update location correctly
17435 // so let's not use the history API at all.
17436 // http://code.google.com/p/android/issues/detail?id=17471
17437 // https://github.com/angular/angular.js/issues/904
17438
17439 // older webkit browser (533.9) on Boxee box has exactly the same problem as Android has
17440 // so let's not use the history API also
17441 // We are purposefully using `!(android < 4)` to cover the case when `android` is undefined
17442 // jshint -W018
17443 history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee),
17444 // jshint +W018
17445 hasEvent: function(event) {
17446 // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
17447 // it. In particular the event is not fired when backspace or delete key are pressed or
17448 // when cut operation is performed.
17449 // IE10+ implements 'input' event but it erroneously fires under various situations,
17450 // e.g. when placeholder changes, or a form is focused.
17451 if (event === 'input' && msie <= 11) return false;
17452
17453 if (isUndefined(eventSupport[event])) {

Callers

nothing calls this directly

Calls 5

toIntFunction · 0.70
lowercaseFunction · 0.70
isStringFunction · 0.70
isUndefinedFunction · 0.70
cspFunction · 0.70

Tested by

no test coverage detected