mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-22 10:49:24 +08:00
feat($sniffer): basic implementation of browser feature testing
This only extracts our 'hashchange' event and html5 history api detection from $browser. Closes #400
This commit is contained in:
@@ -2,15 +2,14 @@
|
||||
|
||||
var browserSingleton;
|
||||
|
||||
angularService('$browser', function($log){
|
||||
angularService('$browser', function($log, $sniffer) {
|
||||
if (!browserSingleton) {
|
||||
// TODO(vojta): inject $sniffer service when implemented
|
||||
browserSingleton = new Browser(window, jqLite(window.document), jqLite(window.document.body),
|
||||
XHR, $log, {});
|
||||
XHR, $log, $sniffer);
|
||||
browserSingleton.bind();
|
||||
}
|
||||
return browserSingleton;
|
||||
}, {$inject:['$log']});
|
||||
}, {$inject: ['$log', '$sniffer']});
|
||||
|
||||
|
||||
extend(angular, {
|
||||
|
||||
1
src/angular-bootstrap.js
vendored
1
src/angular-bootstrap.js
vendored
@@ -115,6 +115,7 @@
|
||||
'service/resource.js',
|
||||
'service/route.js',
|
||||
'service/routeParams.js',
|
||||
'service/sniffer.js',
|
||||
'service/window.js',
|
||||
'service/xhr.bulk.js',
|
||||
'service/xhr.cache.js',
|
||||
|
||||
24
src/service/sniffer.js
Normal file
24
src/service/sniffer.js
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @workInProgress
|
||||
* @ngdoc service
|
||||
* @name angular.service.$sniffer
|
||||
* @requires $window
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
angularServiceInject('$sniffer', function($window) {
|
||||
if ($window.Modernizr) return $window.Modernizr;
|
||||
|
||||
return {
|
||||
history: !!($window.history && $window.history.pushState),
|
||||
hashchange: 'onhashchange' in $window &&
|
||||
// IE8 compatible mode lies
|
||||
(!$window.document.documentMode || $window.document.documentMode > 7)
|
||||
};
|
||||
}, ['$window']);
|
||||
Reference in New Issue
Block a user