From d0f459c56fdb3dae692c359a2915acb2fd063c79 Mon Sep 17 00:00:00 2001 From: Vojta Jina Date: Thu, 23 Jun 2011 20:01:25 +0200 Subject: feat($sniffer): basic implementation of browser feature testing This only extracts our 'hashchange' event and html5 history api detection from $browser. Closes #400 --- src/service/sniffer.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/service/sniffer.js (limited to 'src/service') diff --git a/src/service/sniffer.js b/src/service/sniffer.js new file mode 100644 index 00000000..c71a9bde --- /dev/null +++ b/src/service/sniffer.js @@ -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']); -- cgit v1.2.3