| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 /** | 5 /** |
| 6 * A graphical picker for a set of predefined values. | 6 * A graphical picker for a set of predefined values. |
| 7 */ | 7 */ |
| 8 class ValuePicker extends Picker { | 8 class ValuePicker extends Picker { |
| 9 | 9 |
| 10 int _height; | 10 int _height; |
| 11 int _margin; | 11 int _margin; |
| 12 List<String> _values; | 12 List<String> _values; |
| 13 | 13 |
| 14 ValuePicker(DivElement root, this._values) : super("value-picker") { | 14 ValuePicker(DivElement root, this._values) : super("value-picker") { |
| 15 root.classes = ["value-picker", "fadeOut"]; | 15 root.classes = ["value-picker", "fadeOut"]; |
| 16 | 16 |
| 17 Document doc = root.document; | 17 Document doc = root.document; |
| 18 Element _ul = doc.createElement("ul"); | 18 Element _ul = new Element.tag("ul"); |
| 19 _ul.attributes["class"] = "value-picker-ul"; | 19 _ul.attributes["class"] = "value-picker-ul"; |
| 20 root.nodes.add(_ul); | 20 root.nodes.add(_ul); |
| 21 | 21 |
| 22 // Use the <ul> as the parent node | 22 // Use the <ul> as the parent node |
| 23 setParent(_ul); | 23 setParent(_ul); |
| 24 | 24 |
| 25 int idx = 0; | 25 int idx = 0; |
| 26 for (int i = 0; i < _values.length; i++) { | 26 for (int i = 0; i < _values.length; i++) { |
| 27 LIElement li = doc.createElement("li"); | 27 LIElement li = new Element.tag("li"); |
| 28 li.classes = ["value-picker-item", "value-picker-item-enabled"]; | 28 li.classes = ["value-picker-item", "value-picker-item-enabled"]; |
| 29 li.id = "value-picker-${i}"; | 29 li.id = "value-picker-${i}"; |
| 30 li.text = _values[i]; | 30 li.text = _values[i]; |
| 31 li.on.click.add(_clickHandler); | 31 li.on.click.add(_clickHandler); |
| 32 _ul.nodes.add(li); | 32 _ul.nodes.add(li); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 } | 35 } |
| OLD | NEW |