OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.dart'; | 8 import 'package:observatory/service.dart'; |
9 import 'package:observatory/src/elements/helpers/tag.dart'; | 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
10 import 'package:observatory/src/elements/shims/binding.dart'; | 10 import 'package:observatory/src/elements/shims/binding.dart'; |
11 import 'package:observatory/src/elements/nav/library_menu.dart'; | 11 import 'package:observatory/src/elements/nav/library_menu.dart'; |
12 | 12 |
13 @bindable | 13 @bindable |
14 class NavLibraryMenuElementWrapper extends HtmlElement { | 14 class NavLibraryMenuElementWrapper extends HtmlElement { |
15 static const binder = const Binder<NavLibraryMenuElementWrapper>(const { | 15 static const binder = const Binder<NavLibraryMenuElementWrapper>(const { |
16 'last': #last, 'library': #library | 16 'last': #last, 'library': #library |
17 }); | 17 }); |
18 | 18 |
19 static const tag = | 19 static const tag = |
20 const Tag<NavLibraryMenuElementWrapper>('library-nav-menu'); | 20 const Tag<NavLibraryMenuElementWrapper>('library-nav-menu'); |
21 | 21 |
22 bool _last = false; | 22 bool _last = false; |
23 Library _library; | 23 Library _library; |
| 24 |
24 bool get last => _last; | 25 bool get last => _last; |
25 Library get library => _library; | 26 Library get library => _library; |
| 27 |
26 set last(bool value) { | 28 set last(bool value) { |
27 _last = value; render(); | 29 _last = value; |
| 30 render(); |
28 } | 31 } |
29 set library(Library value) { | 32 set library(Library value) { |
30 _library = value; render(); | 33 _library = value; |
| 34 render(); |
31 } | 35 } |
32 | 36 |
33 NavLibraryMenuElementWrapper.created() : super.created() { | 37 NavLibraryMenuElementWrapper.created() : super.created() { |
34 binder.registerCallback(this); | 38 binder.registerCallback(this); |
35 _last = _getBoolAttribute('last'); | 39 _last = _getBoolAttribute('last'); |
36 createShadowRoot(); | 40 createShadowRoot(); |
37 render(); | 41 render(); |
38 } | 42 } |
39 | 43 |
40 @override | 44 @override |
41 void attached() { | 45 void attached() { |
42 super.attached(); | 46 super.attached(); |
43 render(); | 47 render(); |
44 } | 48 } |
45 | 49 |
46 void render() { | 50 void render() { |
47 shadowRoot.children = []; | 51 shadowRoot.children = []; |
48 if (_library == null || _last == null) return; | 52 if (_library == null || _last == null) { |
| 53 return; |
| 54 } |
49 | 55 |
50 shadowRoot.children = [ | 56 shadowRoot.children = [ |
51 new NavLibraryMenuElement(library.isolate, library, last: last, | 57 new NavLibraryMenuElement(library.isolate, library, last: last, |
52 queue: ObservatoryApplication.app.queue) | 58 queue: ObservatoryApplication.app.queue) |
53 ..children = [new ContentElement()] | 59 ..children = [new ContentElement()] |
54 ]; | 60 ]; |
55 } | 61 } |
56 | 62 |
57 bool _getBoolAttribute(String name) { | 63 bool _getBoolAttribute(String name) { |
58 final String value = getAttribute(name); | 64 final String value = getAttribute(name); |
59 return !(value == null || value == 'false'); | 65 return !(value == null || value == 'false'); |
60 } | 66 } |
61 } | 67 } |
OLD | NEW |