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 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:observatory/src/elements/helpers/tag.dart'; | 7 import 'package:observatory/src/elements/helpers/tag.dart'; |
8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
9 | 9 |
10 class NavMenuItemElement extends HtmlElement implements Renderable { | 10 class NavMenuItemElement extends HtmlElement implements Renderable { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 static const tag = const Tag<NavMenuItemElement>('nav-menu-item-wrapped'); | 50 static const tag = const Tag<NavMenuItemElement>('nav-menu-item-wrapped'); |
51 | 51 |
52 RenderingScheduler _r; | 52 RenderingScheduler _r; |
53 | 53 |
54 Stream<RenderedEvent<NavMenuItemElement>> get onRendered => _r.onRendered; | 54 Stream<RenderedEvent<NavMenuItemElement>> get onRendered => _r.onRendered; |
55 | 55 |
56 String _label; | 56 String _label; |
57 String _link; | 57 String _link; |
58 String get label => _label; | 58 String get label => _label; |
59 String get link => _link; | 59 String get link => _link; |
60 set label(String value) { | 60 set label(String value) => _label = _r.checkAndReact(_label, value); |
61 if (_label != value) { | 61 set link(String value) => _link = _r.checkAndReact(_link, value); |
62 _label = value; | |
63 _r.dirty(); | |
64 } else { | |
65 _r.scheduleNotification(); | |
66 } | |
67 } | |
68 set link(String value) { | |
69 if (_link != value) { | |
70 _link = value; | |
71 _r.dirty(); | |
72 } else { | |
73 _r.scheduleNotification(); | |
74 } | |
75 } | |
76 | 62 |
77 | 63 |
78 factory NavMenuItemElement(String label, {String link, | 64 factory NavMenuItemElement(String label, {String link, |
79 RenderingQueue queue}) { | 65 RenderingQueue queue}) { |
80 assert(label != null); | 66 assert(label != null); |
81 NavMenuItemElement e = document.createElement(tag.name); | 67 NavMenuItemElement e = document.createElement(tag.name); |
82 e._r = new RenderingScheduler(e, queue: queue); | 68 e._r = new RenderingScheduler(e, queue: queue); |
83 e._label = label; | 69 e._label = label; |
84 e._link = link; | 70 e._link = link; |
85 return e; | 71 return e; |
(...skipping 19 matching lines...) Expand all Loading... |
105 new AnchorElement(href: '#$link') | 91 new AnchorElement(href: '#$link') |
106 ..text = label, | 92 ..text = label, |
107 new UListElement() | 93 new UListElement() |
108 ..children = [ | 94 ..children = [ |
109 new ContentElement() | 95 new ContentElement() |
110 ] | 96 ] |
111 ] | 97 ] |
112 ]; | 98 ]; |
113 } | 99 } |
114 } | 100 } |
OLD | NEW |