OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 cr.define('cr.ui', function() { |
| 6 |
| 7 /** |
| 8 * Creates a new list item element. |
| 9 * @param {string} opt_label The text label for the item. |
| 10 * @constructor |
| 11 * @extends {HTMLLIElement} |
| 12 */ |
| 13 var ListItem = cr.ui.define('li'); |
| 14 |
| 15 ListItem.prototype = { |
| 16 __proto__: HTMLLIElement.prototype, |
| 17 |
| 18 /** |
| 19 * Plain text label. |
| 20 * @type {string} |
| 21 */ |
| 22 get label() { |
| 23 return this.textContent; |
| 24 }, |
| 25 set label(label) { |
| 26 this.textContent = label; |
| 27 }, |
| 28 |
| 29 /** |
| 30 * Whether the item is the lead in a selection. Setting this does not update |
| 31 * the underlying selection model. This is only used for display purpose. |
| 32 * @type {boolean} |
| 33 */ |
| 34 get lead() { |
| 35 return this.hasAttribute('lead'); |
| 36 }, |
| 37 set lead(lead) { |
| 38 if (lead) { |
| 39 this.setAttribute('lead', ''); |
| 40 this.scrollIntoViewIfNeeded(false); |
| 41 } else { |
| 42 this.removeAttribute('lead'); |
| 43 } |
| 44 }, |
| 45 |
| 46 /** |
| 47 * Called when an element is decorated as a list item. |
| 48 */ |
| 49 decorate: function() { |
| 50 } |
| 51 }; |
| 52 |
| 53 cr.defineProperty(ListItem, 'selected', cr.PropertyKind.BOOL_ATTR); |
| 54 |
| 55 return { |
| 56 ListItem: ListItem |
| 57 }; |
| 58 }); |
OLD | NEW |