Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 // require: listselectionmodel.js | 5 // require: listselectionmodel.js |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @fileoverview This implements a list control. | 8 * @fileoverview This implements a list control. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 | 339 |
| 340 /** | 340 /** |
| 341 * Callback from the selection model. We dispatch {@code change} events | 341 * Callback from the selection model. We dispatch {@code change} events |
| 342 * when the selection changes. | 342 * when the selection changes. |
| 343 * @param {!cr.Event} e Event with change info. | 343 * @param {!cr.Event} e Event with change info. |
| 344 * @private | 344 * @private |
| 345 */ | 345 */ |
| 346 handleOnChange_: function(ce) { | 346 handleOnChange_: function(ce) { |
| 347 ce.changes.forEach(function(change) { | 347 ce.changes.forEach(function(change) { |
| 348 var listItem = this.getListItemByIndex(change.index); | 348 var listItem = this.getListItemByIndex(change.index); |
| 349 if (listItem) | 349 if (listItem && listItem.selected != change.selected) { |
| 350 listItem.selected = change.selected; | 350 listItem.selected = change.selected; |
| 351 listItem.selectionChanged(); | |
|
arv (Not doing code reviews)
2010/12/17 20:07:34
You could just have made the selected setter virtu
James Hawkins
2010/12/17 21:32:40
Done.
| |
| 352 } | |
| 351 }, this); | 353 }, this); |
| 352 | 354 |
| 353 cr.dispatchSimpleEvent(this, 'change'); | 355 cr.dispatchSimpleEvent(this, 'change'); |
| 354 }, | 356 }, |
| 355 | 357 |
| 356 /** | 358 /** |
| 357 * Handles a change of the lead item from the selection model. | 359 * Handles a change of the lead item from the selection model. |
| 358 * @property {Event} pe The property change event. | 360 * @property {Event} pe The property change event. |
| 359 * @private | 361 * @private |
| 360 */ | 362 */ |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 576 if (listItem) { | 578 if (listItem) { |
| 577 var list = this; | 579 var list = this; |
| 578 window.setTimeout(function() { | 580 window.setTimeout(function() { |
| 579 if (listItem.parentNode == list) | 581 if (listItem.parentNode == list) |
| 580 list.itemHeight_ = measureItem(list, listItem); | 582 list.itemHeight_ = measureItem(list, listItem); |
| 581 }); | 583 }); |
| 582 } | 584 } |
| 583 }, | 585 }, |
| 584 | 586 |
| 585 /** | 587 /** |
| 586 * Redraws a single item | 588 * Redraws a single item. |
| 587 * @param {number} index The row index to redraw. | 589 * @param {number} index The row index to redraw. |
| 588 */ | 590 */ |
| 589 redrawItem: function(index) { | 591 redrawItem: function(index) { |
| 590 if (index >= this.firstIndex_ && index < this.lastIndex_) { | 592 if (index >= this.firstIndex_ && index < this.lastIndex_) { |
| 591 delete this.cachedItems_[index]; | 593 delete this.cachedItems_[index]; |
| 592 this.redraw(); | 594 this.redraw(); |
| 593 } | 595 } |
| 594 } | 596 }, |
| 595 }; | 597 }; |
| 596 | 598 |
| 597 cr.defineProperty(List, 'disabled', cr.PropertyKind.BOOL_ATTR); | 599 cr.defineProperty(List, 'disabled', cr.PropertyKind.BOOL_ATTR); |
| 598 | 600 |
| 599 return { | 601 return { |
| 600 List: List | 602 List: List |
| 601 } | 603 } |
| 602 }); | 604 }); |
| OLD | NEW |