OLD | NEW |
1 | 1 |
2 (function(scope) { | 2 (function(scope) { |
3 var MoreRouting = scope.MoreRouting = scope.MoreRouting || {}; | 3 var MoreRouting = scope.MoreRouting = scope.MoreRouting || {}; |
4 MoreRouting.PathDriver = PathDriver; | 4 MoreRouting.PathDriver = PathDriver; |
5 | 5 |
6 /** | 6 /** |
7 * TODO(nevir): Docs. | 7 * TODO(nevir): Docs. |
8 */ | 8 */ |
9 function PathDriver() { | 9 function PathDriver() { |
10 MoreRouting.Driver.apply(this, arguments); | 10 MoreRouting.Driver.apply(this, arguments); |
11 this._bindEvents(); | 11 this._bindEvents(); |
12 this._read(); | 12 this._read(); |
13 } | 13 } |
14 PathDriver.prototype = Object.create(MoreRouting.Driver.prototype); | 14 PathDriver.prototype = Object.create(MoreRouting.Driver.prototype); |
15 | 15 |
16 PathDriver.prototype.navigateToUrl = function navigateToUrl(url) { | 16 PathDriver.prototype.navigateToUrl = function navigateToUrl(url) { |
17 window.history.pushState({}, '', url); | 17 window.history.pushState({}, '', url); |
18 this._read(); | 18 this._read(); |
19 }; | 19 }; |
20 | 20 |
21 PathDriver.prototype._bindEvents = function _bindEvents() { | 21 PathDriver.prototype._bindEvents = function _bindEvents() { |
22 window.addEventListener('popstate', this._read.bind(this)); | 22 window.addEventListener('popstate', this._read.bind(this)); |
23 }; | 23 }; |
24 | 24 |
25 PathDriver.prototype._read = function _read() { | 25 PathDriver.prototype._read = function _read() { |
26 this.setCurrentPath(window.location.pathname); | 26 this.setCurrentPath(window.location.pathname); |
27 }; | 27 }; |
28 | 28 |
29 })(window); | 29 })(window); |
OLD | NEW |