Chromium Code Reviews| Index: chrome/browser/resources/shared/js/cr/ui/table.js |
| diff --git a/chrome/browser/resources/shared/js/cr/ui/table.js b/chrome/browser/resources/shared/js/cr/ui/table.js |
| index c23a02a6cf6d786feaf92a7b28252e3964a811c2..dab47235cb6ffb239c0a3e3f581689a09f5399e9 100644 |
| --- a/chrome/browser/resources/shared/js/cr/ui/table.js |
| +++ b/chrome/browser/resources/shared/js/cr/ui/table.js |
| @@ -7,7 +7,7 @@ |
| */ |
| cr.define('cr.ui', function() { |
| - const TableSelectionModel = cr.ui.table.TableSelectionModel; |
| + const ListSelectionModel = cr.ui.ListSelectionModel; |
| const ListSelectionController = cr.ui.ListSelectionController; |
| const ArrayDataModel = cr.ui.ArrayDataModel; |
| const TableColumnModel = cr.ui.table.TableColumnModel; |
| @@ -30,25 +30,19 @@ cr.define('cr.ui', function() { |
| /** |
| * The table data model. |
| * |
| - * @type {cr.ui.table.TableDataModel} |
| + * @type {cr.ui.ArrayDataModel} |
| */ |
| get dataModel() { |
| return this.list_.dataModel; |
| }, |
| set dataModel(dataModel) { |
| if (this.list_.dataModel != dataModel) { |
| - this.list_.dataModel = dataModel; |
| if (this.list_.dataModel) { |
| - this.list_.dataModel.removeEventListener('splice', this.boundRedraw_); |
| this.list_.dataModel.removeEventListener('sorted', |
| this.boundHandleSorted_); |
| } |
| this.list_.dataModel = dataModel; |
| - this.list_.dataModel.table = this; |
| - |
| - |
| if (this.list_.dataModel) { |
| - this.list_.dataModel.addEventListener('splice', this.boundRedraw_); |
| this.list_.dataModel.addEventListener('sorted', |
| this.boundHandleSorted_); |
| } |
| @@ -66,17 +60,13 @@ cr.define('cr.ui', function() { |
| }, |
| set columnModel(columnModel) { |
| if (this.columnModel_ != columnModel) { |
| - if (this.columnModel_) { |
| - this.columnModel_.removeEventListener('change', this.boundRedraw_); |
| + if (this.columnModel_) |
| this.columnModel_.removeEventListener('resize', this.boundResize_); |
| - } |
| this.columnModel_ = columnModel; |
| - if (this.columnModel_) { |
| - this.columnModel_.addEventListener('change', this.boundRedraw_); |
| + if (this.columnModel_) |
| this.columnModel_.addEventListener('resize', this.boundResize_); |
| - } |
| - this.redraw(); |
| + this.invalidateAndRedraw(); |
| } |
| }, |
| @@ -84,7 +74,7 @@ cr.define('cr.ui', function() { |
| * The table selection model. |
| * |
| * @type |
| - * {cr.ui.table.TableSelectionModel|cr.ui.table.TableSingleSelectionModel} |
| + * {cr.ui.ListSelectionModel|cr.ui.table.ListSingleSelectionModel} |
| */ |
| get selectionModel() { |
| return this.list_.selectionModel; |
| @@ -94,7 +84,7 @@ cr.define('cr.ui', function() { |
| if (this.dataModel) |
| selectionModel.adjust(0, 0, this.dataModel.length); |
| this.list_.selectionModel = selectionModel; |
| - this.redraw(); |
| + this.invalidateAndRedraw(); |
| } |
| }, |
| @@ -114,7 +104,7 @@ cr.define('cr.ui', function() { |
| decorate: function() { |
| this.list_ = this.ownerDocument.createElement('list'); |
| TableList.decorate(this.list_); |
| - this.list_.selectionModel = new TableSelectionModel(this); |
| + this.list_.selectionModel = new ListSelectionModel(this); |
| this.list_.table = this; |
| this.header_ = this.ownerDocument.createElement('div'); |
| @@ -127,7 +117,6 @@ cr.define('cr.ui', function() { |
| this.ownerDocument.defaultView.addEventListener( |
| 'resize', this.header_.updateWidth.bind(this.header_)); |
| - this.boundRedraw_ = this.redraw.bind(this); |
| this.boundResize_ = this.resize.bind(this); |
| this.boundHandleSorted_ = this.handleSorted_.bind(this); |
| @@ -169,7 +158,7 @@ cr.define('cr.ui', function() { |
| * Redraws the table. |
| * This forces the list to remove all cached items. |
| */ |
| - redraw: function() { |
| + invalidateAndRedraw: function() { |
| this.list_.startBatchUpdates(); |
| if (this.list_.dataModel) { |
| for (var i = 0; i < this.list_.dataModel.length; i++) { |
|
rginda
2011/05/18 23:45:19
Apparently in chrome js code we're only supposed t
|
| @@ -183,19 +172,11 @@ cr.define('cr.ui', function() { |
| /** |
| * This handles data model 'sorted' event. |
| - * After sorting we need to |
| - * - adjust selection |
| - * - redraw all the items |
| - * - scroll the list to show selection. |
| + * After sorting we need to redraw header |
| * @param {Event} e The 'sorted' event. |
| */ |
| handleSorted_: function(e) { |
| - var sm = this.list_.selectionModel; |
| - sm.adjustToReordering(e.sortPermutation); |
| - |
| - this.redraw(); |
| - if (sm.leadIndex != -1) |
| - this.list_.scrollIndexIntoView(sm.leadIndex) |
| + this.header_.redraw(); |
| }, |
| /** |