aboutsummaryrefslogtreecommitdiffstats
path: root/src/service/sniffer.js
diff options
context:
space:
mode:
authorVojta Jina2011-06-23 20:01:25 +0200
committerVojta Jina2011-09-08 20:37:28 +0200
commitd0f459c56fdb3dae692c359a2915acb2fd063c79 (patch)
tree302a6a0aea894a9b496c950d106214af01e4e58a /src/service/sniffer.js
parentcbedf556416522a0a4b08abd3101e856e59c6a6a (diff)
downloadangular.js-d0f459c56fdb3dae692c359a2915acb2fd063c79.tar.bz2
feat($sniffer): basic implementation of browser feature testing
This only extracts our 'hashchange' event and html5 history api detection from $browser. Closes #400
Diffstat (limited to 'src/service/sniffer.js')
-rw-r--r--src/service/sniffer.js24
1 files changed, 24 insertions, 0 deletions
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']);