2011-06-23 18:01:25 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
2012-03-26 22:43:56 +00:00
|
|
|
* !!! This is an undocumented "private" service !!!
|
|
|
|
|
*
|
2012-06-12 06:49:24 +00:00
|
|
|
* @name ng.$sniffer
|
2011-06-23 18:01:25 +00:00
|
|
|
* @requires $window
|
2012-08-09 17:20:39 +00:00
|
|
|
* @requires $document
|
2011-06-23 18:01:25 +00:00
|
|
|
*
|
|
|
|
|
* @property {boolean} history Does the browser support html5 history api ?
|
|
|
|
|
* @property {boolean} hashchange Does the browser support hashchange event ?
|
|
|
|
|
*
|
|
|
|
|
* @description
|
|
|
|
|
* This is very simple implementation of testing browser's features.
|
|
|
|
|
*/
|
2012-04-02 19:26:57 +00:00
|
|
|
function $SnifferProvider() {
|
2012-08-09 17:20:39 +00:00
|
|
|
this.$get = ['$window', '$document', function($window, $document) {
|
2012-05-14 21:14:52 +00:00
|
|
|
var eventSupport = {},
|
2012-08-09 17:20:39 +00:00
|
|
|
android = int((/android (\d+)/.exec(lowercase($window.navigator.userAgent)) || [])[1]),
|
|
|
|
|
document = $document[0];
|
2012-04-02 19:26:57 +00:00
|
|
|
|
2011-11-02 23:32:46 +00:00
|
|
|
return {
|
2012-05-14 21:14:52 +00:00
|
|
|
// Android has history.pushState, but it does not update location correctly
|
|
|
|
|
// so let's not use the history API at all.
|
|
|
|
|
// http://code.google.com/p/android/issues/detail?id=17471
|
|
|
|
|
// https://github.com/angular/angular.js/issues/904
|
|
|
|
|
history: !!($window.history && $window.history.pushState && !(android < 4)),
|
2011-11-02 23:32:46 +00:00
|
|
|
hashchange: 'onhashchange' in $window &&
|
|
|
|
|
// IE8 compatible mode lies
|
2012-08-09 17:20:39 +00:00
|
|
|
(!document.documentMode || document.documentMode > 7),
|
2012-04-02 19:26:57 +00:00
|
|
|
hasEvent: function(event) {
|
2012-05-06 16:27:10 +00:00
|
|
|
// IE9 implements 'input' event it's so fubared that we rather pretend that it doesn't have
|
|
|
|
|
// it. In particular the event is not fired when backspace or delete key are pressed or
|
|
|
|
|
// when cut operation is performed.
|
|
|
|
|
if (event == 'input' && msie == 9) return false;
|
|
|
|
|
|
2012-04-02 19:26:57 +00:00
|
|
|
if (isUndefined(eventSupport[event])) {
|
2012-08-09 17:20:39 +00:00
|
|
|
var divElm = document.createElement('div');
|
2012-04-02 19:26:57 +00:00
|
|
|
eventSupport[event] = 'on' + event in divElm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return eventSupport[event];
|
2012-04-27 22:20:54 +00:00
|
|
|
},
|
2012-11-14 23:49:19 +00:00
|
|
|
csp: document.securityPolicy ? document.securityPolicy.isActive : false
|
2011-11-02 23:32:46 +00:00
|
|
|
};
|
|
|
|
|
}];
|
|
|
|
|
}
|