| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview This implements a combobutton control. | 6 * @fileoverview This implements a combobutton control. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('cr.ui', function() { | 9 cr.define('cr.ui', function() { |
| 10 /** | 10 /** |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 defaultItem_: null, | 22 defaultItem_: null, |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * Truncates drop-down list. | 25 * Truncates drop-down list. |
| 26 */ | 26 */ |
| 27 clear: function() { | 27 clear: function() { |
| 28 this.menu.clear(); | 28 this.menu.clear(); |
| 29 this.multiple = false; | 29 this.multiple = false; |
| 30 }, | 30 }, |
| 31 | 31 |
| 32 /** |
| 33 * Adds item to drop-down list. |
| 34 * @param {Object} item Item to add. Should have label and iconURL fields. |
| 35 */ |
| 32 addItem: function(item) { | 36 addItem: function(item) { |
| 33 this.multiple = true; | 37 this.multiple = true; |
| 34 this.menu.addMenuItem(item).data = item; | 38 this.menu.addMenuItem(item).data = item; |
| 35 }, | 39 }, |
| 36 | 40 |
| 37 /** | 41 /** |
| 42 * Adds separator to drop-down list. |
| 43 */ |
| 44 addSeparator: function() { |
| 45 this.menu.addSeparator(); |
| 46 }, |
| 47 |
| 48 /** |
| 38 * Default item to fire on combobox click | 49 * Default item to fire on combobox click |
| 39 */ | 50 */ |
| 40 get defaultItem() { | 51 get defaultItem() { |
| 41 return this.defaultItem_; | 52 return this.defaultItem_; |
| 42 }, | 53 }, |
| 43 set defaultItem(defaultItem) { | 54 set defaultItem(defaultItem) { |
| 44 this.defaultItem_ = defaultItem; | 55 this.defaultItem_ = defaultItem; |
| 45 if (defaultItem.label) { | 56 if (defaultItem.label) { |
| 46 this.labelNode_.textContent = defaultItem.label; | 57 this.labelNode_.textContent = defaultItem.label; |
| 47 } else { | 58 } else { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 cr.defineProperty(ComboButton, 'disabled', cr.PropertyKind.BOOL_ATTR); | 141 cr.defineProperty(ComboButton, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 131 cr.defineProperty(ComboButton, 'multiple', cr.PropertyKind.BOOL_ATTR); | 142 cr.defineProperty(ComboButton, 'multiple', cr.PropertyKind.BOOL_ATTR); |
| 132 | 143 |
| 133 cr.defineProperty(ComboButton, 'label', cr.PropertyKind.ATTR); | 144 cr.defineProperty(ComboButton, 'label', cr.PropertyKind.ATTR); |
| 134 cr.defineProperty(ComboButton, 'iconUrl', cr.PropertyKind.ATTR); | 145 cr.defineProperty(ComboButton, 'iconUrl', cr.PropertyKind.ATTR); |
| 135 | 146 |
| 136 return { | 147 return { |
| 137 ComboButton: ComboButton | 148 ComboButton: ComboButton |
| 138 }; | 149 }; |
| 139 }); | 150 }); |
| OLD | NEW |