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