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