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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 _updateApplicationLocation(window.location.hash); | 47 _updateApplicationLocation(window.location.hash); |
48 _visit(); | 48 _visit(); |
49 } | 49 } |
50 | 50 |
51 /// Given an application url, generate an href link. | 51 /// Given an application url, generate an href link. |
52 String makeLink(String url) => '#$url'; | 52 String makeLink(String url) => '#$url'; |
53 | 53 |
54 /// Update the application location. After this function returns, | 54 /// Update the application location. After this function returns, |
55 /// [uri] and [debugArguments] will be updated. | 55 /// [uri] and [debugArguments] will be updated. |
56 _updateApplicationLocation(String url) { | 56 _updateApplicationLocation(String url) { |
| 57 if (url == makeLink('/vm-connect')) { |
| 58 // When we go to the vm-connect page, drop all notifications. |
| 59 _app.notifications.deleteAll(); |
| 60 } |
| 61 |
57 // Chop off leading '#'. | 62 // Chop off leading '#'. |
58 if (url.startsWith('#')) { | 63 if (url.startsWith('#')) { |
59 url = url.substring(1); | 64 url = url.substring(1); |
60 } | 65 } |
61 // Fall through handles '#/' | 66 // Fall through handles '#/' |
62 // Chop off leading '/'. | 67 // Chop off leading '/'. |
63 if (url.startsWith('/')) { | 68 if (url.startsWith('/')) { |
64 url = url.substring(1); | 69 url = url.substring(1); |
65 } | 70 } |
66 // Parse out debug arguments. | 71 // Parse out debug arguments. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 void go(String url, [bool addToBrowserHistory = true]) { | 113 void go(String url, [bool addToBrowserHistory = true]) { |
109 if ((url != makeLink('/vm-connect')) && | 114 if ((url != makeLink('/vm-connect')) && |
110 (_app.vm == null || _app.vm.isDisconnected)) { | 115 (_app.vm == null || _app.vm.isDisconnected)) { |
111 if (!window.confirm('Connection with VM has been lost. ' | 116 if (!window.confirm('Connection with VM has been lost. ' |
112 'Proceeding will lose current page.')) { | 117 'Proceeding will lose current page.')) { |
113 return; | 118 return; |
114 } | 119 } |
115 url = makeLink('/vm-connect'); | 120 url = makeLink('/vm-connect'); |
116 } | 121 } |
117 | 122 |
118 if (url == makeLink('/vm-connect')) { | |
119 // When we go to the vm-connect page, drop all notifications. | |
120 _app.notifications.clear(); | |
121 } | |
122 | |
123 if (addToBrowserHistory) { | 123 if (addToBrowserHistory) { |
124 _addToBrowserHistory(url); | 124 _addToBrowserHistory(url); |
125 } | 125 } |
126 _updateApplicationLocation(url); | 126 _updateApplicationLocation(url); |
127 _visit(); | 127 _visit(); |
128 } | 128 } |
129 | 129 |
130 /// Starting with the current uri path and queryParameters, update | 130 /// Starting with the current uri path and queryParameters, update |
131 /// queryParameters present in [updateParameters], then generate a new uri | 131 /// queryParameters present in [updateParameters], then generate a new uri |
132 /// and navigate to that. | 132 /// and navigate to that. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // let browser handle. | 167 // let browser handle. |
168 return; | 168 return; |
169 } | 169 } |
170 event.preventDefault(); | 170 event.preventDefault(); |
171 // 'currentTarget' is the dom element that would process the event. | 171 // 'currentTarget' is the dom element that would process the event. |
172 // 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. |
173 var target = event.currentTarget; | 173 var target = event.currentTarget; |
174 go(target.attributes['href']); | 174 go(target.attributes['href']); |
175 } | 175 } |
176 } | 176 } |
OLD | NEW |