Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: runtime/observatory/lib/src/elements/curly_block_wrapper.dart

Issue 2160793004: Converted Observatory curly-block element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013, 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/src/elements/curly_block.dart';
9 import 'package:observatory/src/elements/helpers/tag.dart';
10 import 'package:observatory/src/elements/shims/binding.dart';
11
12 typedef _callback();
13 typedef CurlyBlockToggleCallback(bool a, _callback b);
14
15 class CurlyBlockElementWrapper extends HtmlElement {
16
17 static final binder = new Binder<CurlyBlockElementWrapper>(
18 const [const Binding('expand'), const Binding('busy'),
19 const Binding('expandKey'), const Binding('callback')]);
20
21 static const tag = const Tag<CurlyBlockElementWrapper>('curly-block');
22
23 bool _expand;
24 bool get expand => _expand;
25 set expand(bool expanded) {
26 _expand = !(expanded == null || expanded == false);
27 render();
28 }
29
30 bool _busy;
31 bool get busy => _busy;
32 set busy(bool busy) {
33 _busy = !(busy == null || busy == false);
34 render();
35 }
36
37 String _expandKey;
38 String get expandKey => _expandKey;
39 set expandKey(String expandKey) {
40 _expandKey = expandKey;
41 if (expandKey != null) {
42 var value = application.expansions[expandKey];
43 if (value != null && expand != value) {
44
45 }
46 }
47 render();
48 }
49
50 CurlyBlockToggleCallback _callback;
51 CurlyBlockToggleCallback get callback => _callback;
52 set callback(CurlyBlockToggleCallback callback) {
53 _callback = callback;
54 render();
55 }
56
57 CurlyBlockElementWrapper.created() : super.created() {
58 createShadowRoot();
59 }
60
61 @override
62 void attached() {
63 super.attached();
64 render();
65 }
66
67 @override
68 void attributeChanged(String name, String oldValue, String newValue){
69 super.attributeChanged(name, oldValue, newValue);
70 switch (name){
71 case 'expand':
72 expand = !(newValue == null || newValue == 'false');
73 break;
74 case 'busy':
75 busy = !(newValue == null || newValue == 'false');
76 break;
77 case 'expandKey':
78 busy = !(newValue == null || newValue == 'false');
79 break;
80 }
81 }
82
83
84 void render() {
85 shadowRoot.children = [
86 new CurlyBlockElement(expanded: expand, disabled: busy,
87 queue: ObservatoryApplication.app.queue)
88 ..children = [new ContentElement()]
89 ..onToggle.listen(_toggle)
90 ];
91 }
92
93 ObservatoryApplication get application => ObservatoryApplication.app;
94
95 void _toggle(CurlyBlockToggleEvent e) {
96 _expand = e.control.expanded;
97 if (callback != null) {
98 busy = true;
99 callback(expand, () {
100 if (expandKey != null) {
101 application.expansions[expandKey] = expand;
102 }
103 busy = false;
104 });
105 } else {
106 application.expansions[expandKey] = expand;
107 }
108 }
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698