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/src/elements/helpers/tag.dart'; | 8 import 'package:observatory/src/elements/helpers/tag.dart'; |
9 import 'package:observatory/src/elements/shims/binding.dart'; | 9 import 'package:observatory/src/elements/shims/binding.dart'; |
10 import 'package:observatory/src/elements/nav/top_menu.dart'; | 10 import 'package:observatory/src/elements/nav/top_menu.dart'; |
11 | 11 |
12 @bindable | 12 @bindable |
13 class NavTopMenuElementWrapper extends HtmlElement { | 13 class NavTopMenuElementWrapper extends HtmlElement { |
14 static const binder = const Binder<NavTopMenuElementWrapper>(const { | 14 static const binder = const Binder<NavTopMenuElementWrapper>(const { |
15 'last': #last | 15 'last': #last |
16 }); | 16 }); |
17 | 17 |
18 static const tag = const Tag<NavTopMenuElementWrapper>('top-nav-menu'); | 18 static const tag = const Tag<NavTopMenuElementWrapper>('top-nav-menu'); |
19 | 19 |
20 bool _last = false; | 20 bool _last = false; |
| 21 |
21 bool get last => _last; | 22 bool get last => _last; |
| 23 |
22 set last(bool value) { | 24 set last(bool value) { |
23 _last = value; render(); | 25 _last = value; |
| 26 render(); |
24 } | 27 } |
25 | 28 |
26 NavTopMenuElementWrapper.created() : super.created() { | 29 NavTopMenuElementWrapper.created() : super.created() { |
27 binder.registerCallback(this); | 30 binder.registerCallback(this); |
28 _last = _getBoolAttribute('last'); | 31 _last = _getBoolAttribute('last'); |
29 createShadowRoot(); | 32 createShadowRoot(); |
30 render(); | 33 render(); |
31 } | 34 } |
32 | 35 |
33 @override | 36 @override |
34 void attached() { | 37 void attached() { |
35 super.attached(); | 38 super.attached(); |
36 render(); | 39 render(); |
37 } | 40 } |
38 | 41 |
39 void render() { | 42 void render() { |
40 shadowRoot.children = []; | 43 shadowRoot.children = []; |
41 if (_last == null) return; | 44 if (_last == null) { |
| 45 return; |
| 46 } |
42 | 47 |
43 shadowRoot.children = [ | 48 shadowRoot.children = [ |
44 new NavTopMenuElement(last: last, queue: ObservatoryApplication.app.queue) | 49 new NavTopMenuElement(last: last, queue: ObservatoryApplication.app.queue) |
45 ..children = [new ContentElement()] | 50 ..children = [new ContentElement()] |
46 ]; | 51 ]; |
47 } | 52 } |
48 | 53 |
49 bool _getBoolAttribute(String name) { | 54 bool _getBoolAttribute(String name) { |
50 final String value = getAttribute(name); | 55 final String value = getAttribute(name); |
51 return !(value == null || value == 'false'); | 56 return !(value == null || value == 'false'); |
52 } | 57 } |
53 } | 58 } |
OLD | NEW |