aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/navigator/router.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/components/navigator/router.js')
-rw-r--r--server/sonar-web/src/main/js/components/navigator/router.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/components/navigator/router.js b/server/sonar-web/src/main/js/components/navigator/router.js
new file mode 100644
index 00000000000..8792dd519c7
--- /dev/null
+++ b/server/sonar-web/src/main/js/components/navigator/router.js
@@ -0,0 +1,29 @@
+define([
+ 'backbone'
+], function (Backbone) {
+
+ return Backbone.Router.extend({
+ routeSeparator: '|',
+
+ routes: {
+ '': 'index',
+ ':query': 'index'
+ },
+
+ initialize: function (options) {
+ this.options = options;
+ this.listenTo(this.options.app.state, 'change:query', this.updateRoute);
+ },
+
+ index: function (query) {
+ query = this.options.app.controller.parseQuery(query);
+ this.options.app.state.setQuery(query);
+ },
+
+ updateRoute: function () {
+ var route = this.options.app.controller.getRoute();
+ this.navigate(route);
+ }
+ });
+
+});