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/models.dart' as M show IsolateRef, LibraryRef; | 7 import 'package:observatory/models.dart' as M show IsolateRef, LibraryRef; |
8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.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/helpers/uris.dart'; | 10 import 'package:observatory/src/elements/helpers/uris.dart'; |
11 import 'package:observatory/src/elements/nav/menu.dart'; | 11 import 'package:observatory/src/elements/nav/menu.dart'; |
12 | 12 |
13 class NavLibraryMenuElement extends HtmlElement implements Renderable { | 13 class NavLibraryMenuElement extends HtmlElement implements Renderable { |
14 static const tag = const Tag<NavLibraryMenuElement>('nav-library-menu', | 14 static const tag = const Tag<NavLibraryMenuElement>('nav-library-menu', |
15 dependencies: const [NavMenuElement.tag]); | 15 dependencies: const [NavMenuElement.tag]); |
16 | 16 |
17 RenderingScheduler _r; | 17 RenderingScheduler _r; |
18 | 18 |
19 Stream<RenderedEvent<NavLibraryMenuElement>> get onRendered => _r.onRendered; | 19 Stream<RenderedEvent<NavLibraryMenuElement>> get onRendered => _r.onRendered; |
20 | 20 |
21 bool _last; | 21 bool _last; |
22 M.IsolateRef _isolate; | 22 M.IsolateRef _isolate; |
23 M.LibraryRef _library; | 23 M.LibraryRef _library; |
| 24 |
24 bool get last => _last; | 25 bool get last => _last; |
25 M.IsolateRef get isolate => _isolate; | 26 M.IsolateRef get isolate => _isolate; |
26 M.LibraryRef get library => _library; | 27 M.LibraryRef get library => _library; |
| 28 |
27 set last(bool value) => _last = _r.checkAndReact(_last, value); | 29 set last(bool value) => _last = _r.checkAndReact(_last, value); |
28 | 30 |
29 factory NavLibraryMenuElement(M.IsolateRef isolate, M.LibraryRef library, | 31 factory NavLibraryMenuElement(M.IsolateRef isolate, M.LibraryRef library, |
30 {bool last: false, RenderingQueue queue}) { | 32 {bool last: false, RenderingQueue queue}) { |
31 assert(isolate != null); | 33 assert(isolate != null); |
32 assert(library != null); | 34 assert(library != null); |
33 assert(last != null); | 35 assert(last != null); |
34 NavLibraryMenuElement e = document.createElement(tag.name); | 36 NavLibraryMenuElement e = document.createElement(tag.name); |
35 e._r = new RenderingScheduler(e, queue: queue); | 37 e._r = new RenderingScheduler(e, queue: queue); |
36 e._isolate = isolate; | 38 e._isolate = isolate; |
37 e._library = library; | 39 e._library = library; |
38 e._last = last; | 40 e._last = last; |
39 return e; | 41 return e; |
40 } | 42 } |
41 | 43 |
42 NavLibraryMenuElement.created() : super.created() { createShadowRoot(); } | 44 NavLibraryMenuElement.created() : super.created() { createShadowRoot(); } |
43 | 45 |
44 @override | 46 @override |
45 void attached() { super.attached(); _r.enable(); } | 47 void attached() { |
| 48 super.attached(); |
| 49 _r.enable(); |
| 50 } |
46 | 51 |
47 @override | 52 @override |
48 void detached() { | 53 void detached() { |
49 super.detached(); _r.disable(notify: true); | 54 super.detached(); |
| 55 _r.disable(notify: true); |
50 shadowRoot.children = []; | 56 shadowRoot.children = []; |
51 } | 57 } |
52 | 58 |
53 void render() { | 59 void render() { |
54 shadowRoot.children = [ | 60 shadowRoot.children = [ |
55 new NavMenuElement(library.name, last: last, queue: _r.queue, | 61 new NavMenuElement(library.name, last: last, queue: _r.queue, |
56 link: Uris.inspect(isolate, object: library).toString()) | 62 link: Uris.inspect(isolate, object: library).toString()) |
57 ..children = [new ContentElement()] | 63 ..children = [new ContentElement()] |
58 ]; | 64 ]; |
59 } | 65 } |
60 } | 66 } |
OLD | NEW |