| Index: runtime/observatory/lib/src/elements/curly_block.dart
|
| diff --git a/runtime/observatory/lib/src/elements/curly_block.dart b/runtime/observatory/lib/src/elements/curly_block.dart
|
| index 004a02e36422e64341a952da5b85692070fd4f7b..af33e634e5093d995f2ed43ee20896a961b41390 100644
|
| --- a/runtime/observatory/lib/src/elements/curly_block.dart
|
| +++ b/runtime/observatory/lib/src/elements/curly_block.dart
|
| @@ -4,52 +4,84 @@
|
|
|
| library curly_block_element;
|
|
|
| -import 'package:polymer/polymer.dart';
|
| -import 'observatory_element.dart';
|
| +import 'dart:async';
|
| +import 'dart:html';
|
| +import 'helpers/tag.dart';
|
|
|
| -@CustomTag('curly-block')
|
| -class CurlyBlockElement extends ObservatoryElement {
|
| - CurlyBlockElement.created() : super.created();
|
| +class CurlyBlockToggleEvent {
|
| + final CurlyBlockElement control;
|
|
|
| - @observable bool expanded = false;
|
| - @observable bool busy = false;
|
| - @published var callback = null;
|
| - @published bool expand = false;
|
| - @published String expandKey;
|
| + CurlyBlockToggleEvent(this.control);
|
| +}
|
| +
|
| +class CurlyBlockElement extends HtmlElement {
|
| + static final StyleElement _style = () {
|
| + var style = new StyleElement();
|
| + style.text = '.idle {'
|
| + ' display: inline-block;'
|
| + ' color: #0489c3;'
|
| + ' cursor: pointer;'
|
| + '}'
|
| + '.busy {'
|
| + ' display: inline-block;'
|
| + ' color: white;'
|
| + ' cursor: wait;'
|
| + '}';
|
| + return style;
|
| + }();
|
| +
|
| + static const tag = const Tag<CurlyBlockElement>('curly-block-wrapped');
|
|
|
| - void expandChanged(oldValue) {
|
| - expanded = expand;
|
| + bool expanded;
|
| + bool busy;
|
| +
|
| + final StreamController<CurlyBlockToggleEvent> _onToggle =
|
| + new StreamController<CurlyBlockToggleEvent>();
|
| + Stream<CurlyBlockToggleEvent> get onToggle => _onToggle.stream;
|
| +
|
| + factory CurlyBlockElement() {
|
| + return document.createElement(tag.name);
|
| }
|
|
|
| - void expandKeyChanged(oldValue) {
|
| - if (expandKey != null) {
|
| - var value = app.expansions[expandKey];
|
| - if (value != null) {
|
| - if (expanded != value) {
|
| - toggleExpand(null, null, null);
|
| - }
|
| - }
|
| - }
|
| + CurlyBlockElement.created() : super.created() {
|
| + createShadowRoot();
|
| }
|
|
|
| - void doneCallback() {
|
| + @override
|
| + void attached() {
|
| + super.attached();
|
| + render();
|
| + }
|
| +
|
| + void toggle() {
|
| expanded = !expanded;
|
| - if (expandKey != null) {
|
| - app.expansions[expandKey] = expanded;
|
| - }
|
| - busy = false;
|
| + _onToggle.add(new CurlyBlockToggleEvent(this));
|
| + render();
|
| }
|
|
|
| - void toggleExpand(var event, var b, var c) {
|
| - assert(callback == null || expand == false);
|
| + void render() {
|
| + List<Element> children = [
|
| + _style.clone(true),
|
| + new SpanElement()..text = '{'
|
| + ];
|
| + DivElement label = new DivElement()
|
| + ..classes = [busy ? 'busy' : 'idle']
|
| + ..innerHtml = expanded ?
|
| + ' ⊟ ' : ' ⊞ ';
|
| if (busy) {
|
| - return;
|
| - }
|
| - busy = true;
|
| - if (callback != null) {
|
| - callback(!expanded, doneCallback);
|
| + children.add(label);
|
| } else {
|
| - doneCallback();
|
| + children.add(new AnchorElement()
|
| + ..onClick.listen((_) { toggle(); })
|
| + ..children = [label]);
|
| + }
|
| + if (expanded) {
|
| + children.addAll([
|
| + new BRElement(),
|
| + new ContentElement()
|
| + ]);
|
| }
|
| + children.add(new SpanElement()..text = '}');
|
| + shadowRoot.children = children;
|
| }
|
| }
|
|
|