| 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 library observatory_element; | 5 library observatory_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:observatory/app.dart'; | 9 import 'package:observatory/app.dart'; |
| 10 import 'package:observatory/service.dart'; | 10 import 'package:observatory/service.dart'; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 void insertLinkIntoShadowRoot(String label, String href, [String title]) { | 189 void insertLinkIntoShadowRoot(String label, String href, [String title]) { |
| 190 var anchorElement = new AnchorElement(); | 190 var anchorElement = new AnchorElement(); |
| 191 anchorElement.href = href; | 191 anchorElement.href = href; |
| 192 anchorElement.text = label; | 192 anchorElement.text = label; |
| 193 if (title != null) { | 193 if (title != null) { |
| 194 anchorElement.title = title; | 194 anchorElement.title = title; |
| 195 } | 195 } |
| 196 anchorElement.onClick.listen(onClickGoto); | 196 anchorElement.onClick.listen(onClickGoto); |
| 197 shadowRoot.children.add(anchorElement); | 197 shadowRoot.children.add(anchorElement); |
| 198 } | 198 } |
| 199 |
| 200 |
| 201 var _onCopySubscription; |
| 202 /// Exclude nodes from being copied, for example the line numbers and |
| 203 /// breakpoint toggles in script insets. Must be called after [root]'s |
| 204 /// children have been added, and only supports one node at a time. |
| 205 void makeCssClassUncopyable(Element root, String className) { |
| 206 var noCopyNodes = root.getElementsByClassName(className); |
| 207 for (var node in noCopyNodes) { |
| 208 node.style.setProperty('-moz-user-select', 'none'); |
| 209 node.style.setProperty('-khtml-user-select', 'none'); |
| 210 node.style.setProperty('-webkit-user-select', 'none'); |
| 211 node.style.setProperty('-ms-user-select', 'none'); |
| 212 node.style.setProperty('user-select', 'none'); |
| 213 } |
| 214 if (_onCopySubscription != null) { |
| 215 _onCopySubscription.cancel(); |
| 216 } |
| 217 _onCopySubscription = root.onCopy.listen((event) { |
| 218 // Mark the nodes as hidden before the copy happens, then mark them as |
| 219 // visible on the next event loop turn. |
| 220 for (var node in noCopyNodes) { |
| 221 node.style.visibility = 'hidden'; |
| 222 } |
| 223 Timer.run(() { |
| 224 for (var node in noCopyNodes) { |
| 225 node.style.visibility = 'visible'; |
| 226 } |
| 227 }); |
| 228 }); |
| 229 } |
| 199 } | 230 } |
| OLD | NEW |