* !!! 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
()
| 17953 | * This is very simple implementation of testing browser's features. |
| 17954 | */ |
| 17955 | function $SnifferProvider() { |
| 17956 | this.$get = ['$window', '$document', function($window, $document) { |
| 17957 | var eventSupport = {}, |
| 17958 | android = |
| 17959 | toInt((/android (\d+)/.exec(lowercase(($window.navigator || {}).userAgent)) || [])[1]), |
| 17960 | boxee = /Boxee/i.test(($window.navigator || {}).userAgent), |
| 17961 | document = $document[0] || {}, |
| 17962 | vendorPrefix, |
| 17963 | vendorRegex = /^(Moz|webkit|ms)(?=[A-Z])/, |
| 17964 | bodyStyle = document.body && document.body.style, |
| 17965 | transitions = false, |
| 17966 | animations = false, |
| 17967 | match; |
| 17968 | |
| 17969 | if (bodyStyle) { |
| 17970 | for (var prop in bodyStyle) { |
| 17971 | if (match = vendorRegex.exec(prop)) { |
| 17972 | vendorPrefix = match[0]; |
| 17973 | vendorPrefix = vendorPrefix.substr(0, 1).toUpperCase() + vendorPrefix.substr(1); |
| 17974 | break; |
| 17975 | } |
| 17976 | } |
| 17977 | |
| 17978 | if (!vendorPrefix) { |
| 17979 | vendorPrefix = ('WebkitOpacity' in bodyStyle) && 'webkit'; |
| 17980 | } |
| 17981 | |
| 17982 | transitions = !!(('transition' in bodyStyle) || (vendorPrefix + 'Transition' in bodyStyle)); |
| 17983 | animations = !!(('animation' in bodyStyle) || (vendorPrefix + 'Animation' in bodyStyle)); |
| 17984 | |
| 17985 | if (android && (!transitions || !animations)) { |
| 17986 | transitions = isString(bodyStyle.webkitTransition); |
| 17987 | animations = isString(bodyStyle.webkitAnimation); |
| 17988 | } |
| 17989 | } |
| 17990 | |
| 17991 | |
| 17992 | return { |
| 17993 | // Android has history.pushState, but it does not update location correctly |
| 17994 | // so let's not use the history API at all. |
| 17995 | // http://code.google.com/p/android/issues/detail?id=17471 |
| 17996 | // https://github.com/angular/angular.js/issues/904 |
| 17997 | |
| 17998 | // older webkit browser (533.9) on Boxee box has exactly the same problem as Android has |
| 17999 | // so let's not use the history API also |
| 18000 | // We are purposefully using `!(android < 4)` to cover the case when `android` is undefined |
| 18001 | // jshint -W018 |
| 18002 | history: !!($window.history && $window.history.pushState && !(android < 4) && !boxee), |
| 18003 | // jshint +W018 |
| 18004 | hasEvent: function(event) { |
| 18005 | // IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have |
| 18006 | // it. In particular the event is not fired when backspace or delete key are pressed or |
| 18007 | // when cut operation is performed. |
| 18008 | // IE10+ implements 'input' event but it erroneously fires under various situations, |
| 18009 | // e.g. when placeholder changes, or a form is focused. |
| 18010 | if (event === 'input' && msie <= 11) return false; |
| 18011 | |
| 18012 | if (isUndefined(eventSupport[event])) { |
nothing calls this directly
no test coverage detected