| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of app; | 5 part of app; |
| 6 | 6 |
| 7 class LocationManager extends Observable { | 7 class LocationManager extends Observable { |
| 8 final _defaultPath = '/vm'; | 8 final _defaultPath = '/vm'; |
| 9 | 9 |
| 10 final ObservatoryApplication _app; | 10 final ObservatoryApplication _app; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 // use the default. | 27 // use the default. |
| 28 applicationPath = makeLink(_defaultPath); | 28 applicationPath = makeLink(_defaultPath); |
| 29 } | 29 } |
| 30 // Update current application path. | 30 // Update current application path. |
| 31 window.history.replaceState(applicationPath, | 31 window.history.replaceState(applicationPath, |
| 32 document.title, | 32 document.title, |
| 33 applicationPath); | 33 applicationPath); |
| 34 _updateApplicationLocation(applicationPath); | 34 _updateApplicationLocation(applicationPath); |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool getBoolParameter(String name, bool defaultValue) { |
| 38 var value = uri.queryParameters[name]; |
| 39 if ("true" == value) return true; |
| 40 if ("false" == value) return false; |
| 41 return defaultValue; |
| 42 } |
| 43 |
| 37 /// Called whenever the browser changes the location bar (e.g. forward or | 44 /// Called whenever the browser changes the location bar (e.g. forward or |
| 38 /// back button press). | 45 /// back button press). |
| 39 void _onBrowserNavigation(PopStateEvent event) { | 46 void _onBrowserNavigation(PopStateEvent event) { |
| 40 _updateApplicationLocation(window.location.hash); | 47 _updateApplicationLocation(window.location.hash); |
| 41 _visit(); | 48 _visit(); |
| 42 } | 49 } |
| 43 | 50 |
| 44 /// Given an application url, generate an href link. | 51 /// Given an application url, generate an href link. |
| 45 String makeLink(String url) => '#$url'; | 52 String makeLink(String url) => '#$url'; |
| 46 | 53 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // let browser handle. | 167 // let browser handle. |
| 161 return; | 168 return; |
| 162 } | 169 } |
| 163 event.preventDefault(); | 170 event.preventDefault(); |
| 164 // 'currentTarget' is the dom element that would process the event. | 171 // 'currentTarget' is the dom element that would process the event. |
| 165 // If we use 'target' we might get an <em> element or somesuch. | 172 // If we use 'target' we might get an <em> element or somesuch. |
| 166 var target = event.currentTarget; | 173 var target = event.currentTarget; |
| 167 go(target.attributes['href']); | 174 go(target.attributes['href']); |
| 168 } | 175 } |
| 169 } | 176 } |
| OLD | NEW |