| 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 import 'dart:html'; | 5 import 'dart:html'; |
| 6 | 6 |
| 7 import 'package:observatory/app.dart'; | 7 import 'package:observatory/app.dart'; |
| 8 import 'package:observatory/service_html.dart' show Library; | 8 import 'package:observatory/service_html.dart' show Context; |
| 9 import 'package:observatory/src/elements/library_ref.dart'; | 9 import 'package:observatory/src/elements/context_ref.dart'; |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 11 import 'package:observatory/src/elements/shims/binding.dart'; | 11 import 'package:observatory/src/elements/shims/binding.dart'; |
| 12 | 12 |
| 13 @bindable | 13 @bindable |
| 14 class LibraryRefElementWrapper extends HtmlElement { | 14 class ContextRefElementWrapper extends HtmlElement { |
| 15 | 15 |
| 16 static const binder = const Binder<LibraryRefElementWrapper>(const { | 16 static const binder = const Binder<ContextRefElementWrapper>(const { |
| 17 'ref': #ref | 17 'ref': #ref |
| 18 }); | 18 }); |
| 19 | 19 |
| 20 static const tag = const Tag<LibraryRefElementWrapper>('library-ref'); | 20 static const tag = const Tag<ContextRefElementWrapper>('context-ref'); |
| 21 | 21 |
| 22 Library _library; | 22 Context _context; |
| 23 Library get ref => _library; | 23 Context get ref => _context; |
| 24 void set ref(Library ref) { _library = ref; render(); } | 24 void set ref(Context ref) { |
| 25 _context = ref; |
| 26 render(); |
| 27 } |
| 25 | 28 |
| 26 LibraryRefElementWrapper.created() : super.created() { | 29 ContextRefElementWrapper.created() : super.created() { |
| 27 binder.registerCallback(this); | 30 binder.registerCallback(this); |
| 28 createShadowRoot(); | 31 createShadowRoot(); |
| 29 render(); | 32 render(); |
| 30 } | 33 } |
| 31 | 34 |
| 32 @override | 35 @override |
| 33 void attached() { | 36 void attached() { |
| 34 super.attached(); | 37 super.attached(); |
| 35 render(); | 38 render(); |
| 36 } | 39 } |
| 37 | 40 |
| 38 void render() { | 41 void render() { |
| 39 shadowRoot.children = []; | 42 shadowRoot.children = []; |
| 40 if (ref == null) return; | 43 if (ref == null) return; |
| 41 | 44 |
| 42 shadowRoot.children = [ | 45 shadowRoot.children = [ |
| 43 new StyleElement() | 46 new StyleElement() |
| 44 ..text = ''' | 47 ..text = ''' |
| 45 library-ref-wrapped > a[href]:hover { | 48 context-ref-wrapped > a[href]:hover { |
| 46 text-decoration: underline; | 49 text-decoration: underline; |
| 47 } | 50 } |
| 48 library-ref-wrapped > a[href] { | 51 context-ref-wrapped > a[href] { |
| 49 color: #0489c3; | 52 color: #0489c3; |
| 50 text-decoration: none; | 53 text-decoration: none; |
| 54 } |
| 55 context-ref-wrapped .empathize { |
| 56 font-style: italic; |
| 51 }''', | 57 }''', |
| 52 new LibraryRefElement(_library.isolate, _library, | 58 new ContextRefElement(_context.isolate, _context, |
| 53 queue: ObservatoryApplication.app.queue) | 59 queue: ObservatoryApplication.app.queue) |
| 54 ]; | 60 ]; |
| 55 } | 61 } |
| 56 } | 62 } |
| OLD | NEW |