| 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 collapsible_content_element; | 5 library collapsible_content_element; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
| 9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
| 10 | 10 |
| 11 /// An element which conditionally displays its children elements. | 11 /// An element which conditionally displays its children elements. |
| 12 @CustomTag('collapsible-content') | 12 @CustomTag('collapsible-content') |
| 13 class CollapsibleContentElement extends ObservatoryElement { | 13 class CollapsibleContentElement extends ObservatoryElement { |
| 14 static const String _openIconClass = 'glyphicon glyphicon-chevron-down'; | 14 static const String _openIconClass = 'glyphicon glyphicon-chevron-down'; |
| 15 static const String _closeIconClass = 'glyphicon glyphicon-chevron-up'; | 15 static const String _closeIconClass = 'glyphicon glyphicon-chevron-up'; |
| 16 | 16 |
| 17 @observable String get iconClass => __$iconClass; String __$iconClass = _openI
conClass; set iconClass(String value) { __$iconClass = notifyPropertyChange(#ico
nClass, __$iconClass, value); } | 17 @observable String iconClass = _openIconClass; |
| 18 @observable String get displayValue => __$displayValue; String __$displayValue
= 'none'; set displayValue(String value) { __$displayValue = notifyPropertyChan
ge(#displayValue, __$displayValue, value); } | 18 @observable String displayValue = 'none'; |
| 19 | 19 |
| 20 bool _collapsed = true; | 20 bool _collapsed = true; |
| 21 bool get collapsed => _collapsed; | 21 bool get collapsed => _collapsed; |
| 22 set collapsed(bool r) { | 22 set collapsed(bool r) { |
| 23 _collapsed = r; | 23 _collapsed = r; |
| 24 _refresh(); | 24 _refresh(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 CollapsibleContentElement.created() : super.created(); |
| 28 |
| 29 void enteredView() { |
| 30 super.enteredView(); |
| 31 _refresh(); |
| 32 } |
| 33 |
| 27 void toggleDisplay(Event e, var detail, Node target) { | 34 void toggleDisplay(Event e, var detail, Node target) { |
| 28 collapsed = !collapsed; | 35 collapsed = !collapsed; |
| 29 _refresh(); | 36 _refresh(); |
| 30 } | 37 } |
| 31 | 38 |
| 32 void inserted() { | 39 |
| 33 super.inserted(); | |
| 34 _refresh(); | |
| 35 } | |
| 36 | 40 |
| 37 void _refresh() { | 41 void _refresh() { |
| 38 if (_collapsed) { | 42 if (_collapsed) { |
| 39 iconClass = _openIconClass; | 43 iconClass = _openIconClass; |
| 40 displayValue = 'none'; | 44 displayValue = 'none'; |
| 41 } else { | 45 } else { |
| 42 iconClass = _closeIconClass; | 46 iconClass = _closeIconClass; |
| 43 displayValue = 'block'; | 47 displayValue = 'block'; |
| 44 } | 48 } |
| 45 } | 49 } |
| 46 } | 50 } |
| OLD | NEW |