| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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 library curly_block_element; | 5 library curly_block_element; |
| 6 | 6 |
| 7 import 'package:polymer/polymer.dart'; | 7 import 'package:polymer/polymer.dart'; |
| 8 | 8 |
| 9 @CustomTag('curly-block') | 9 @CustomTag('curly-block') |
| 10 class CurlyBlockElement extends PolymerElement { | 10 class CurlyBlockElement extends PolymerElement { |
| 11 CurlyBlockElement.created() : super.created(); | 11 CurlyBlockElement.created() : super.created(); |
| 12 | 12 |
| 13 @observable bool expanded = false; | 13 @observable bool expanded = false; |
| 14 @observable bool busy = false; | 14 @observable bool busy = false; |
| 15 @published var callback = null; | 15 @published var callback = null; |
| 16 | 16 |
| 17 void doneCallback() { | 17 void doneCallback() { |
| 18 print("done callback"); | |
| 19 expanded = !expanded; | 18 expanded = !expanded; |
| 20 busy = false; | 19 busy = false; |
| 21 } | 20 } |
| 22 | 21 |
| 23 void toggleExpand(var a, var b, var c) { | 22 void toggleExpand(var a, var b, var c) { |
| 24 if (busy) { | 23 if (busy) { |
| 25 return; | 24 return; |
| 26 } | 25 } |
| 27 if (callback != null) { | 26 if (callback != null) { |
| 28 busy = true; | 27 busy = true; |
| 29 callback(!expanded, doneCallback); | 28 callback(!expanded, doneCallback); |
| 30 } else { | 29 } else { |
| 31 expanded = !expanded; | 30 expanded = !expanded; |
| 32 } | 31 } |
| 33 } | 32 } |
| 34 } | 33 } |
| OLD | NEW |