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 table control. | 6 * @fileoverview This implements a table control. |
7 */ | 7 */ |
8 | 8 |
9 cr.define('cr.ui', function() { | 9 cr.define('cr.ui', function() { |
10 /** @const */ var ListSelectionModel = cr.ui.ListSelectionModel; | 10 /** @const */ var ListSelectionModel = cr.ui.ListSelectionModel; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 * @param {number} Column width. | 160 * @param {number} Column width. |
161 */ | 161 */ |
162 setColumnWidth: function(index, width) { | 162 setColumnWidth: function(index, width) { |
163 this.columnWidths_[index] = width; | 163 this.columnWidths_[index] = width; |
164 }, | 164 }, |
165 | 165 |
166 /** | 166 /** |
167 * Initializes the element. | 167 * Initializes the element. |
168 */ | 168 */ |
169 decorate: function() { | 169 decorate: function() { |
| 170 this.header_ = this.ownerDocument.createElement('div'); |
170 this.list_ = this.ownerDocument.createElement('list'); | 171 this.list_ = this.ownerDocument.createElement('list'); |
| 172 |
| 173 this.appendChild(this.header_); |
| 174 this.appendChild(this.list_); |
| 175 |
171 TableList.decorate(this.list_); | 176 TableList.decorate(this.list_); |
172 this.list_.selectionModel = new ListSelectionModel(this); | 177 this.list_.selectionModel = new ListSelectionModel(this); |
173 this.list_.table = this; | 178 this.list_.table = this; |
174 | 179 |
175 this.header_ = this.ownerDocument.createElement('div'); | |
176 TableHeader.decorate(this.header_); | 180 TableHeader.decorate(this.header_); |
177 this.header_.table = this; | 181 this.header_.table = this; |
178 | 182 |
179 this.classList.add('table'); | 183 this.classList.add('table'); |
180 this.appendChild(this.header_); | |
181 this.appendChild(this.list_); | |
182 this.ownerDocument.defaultView.addEventListener( | 184 this.ownerDocument.defaultView.addEventListener( |
183 'resize', this.header_.updateWidth.bind(this.header_)); | 185 'resize', this.header_.updateWidth.bind(this.header_)); |
184 | 186 |
185 this.boundResize_ = this.resize.bind(this); | 187 this.boundResize_ = this.resize.bind(this); |
186 this.boundHandleSorted_ = this.handleSorted_.bind(this); | 188 this.boundHandleSorted_ = this.handleSorted_.bind(this); |
187 this.boundHandleChangeList_ = this.handleChangeList_.bind(this); | 189 this.boundHandleChangeList_ = this.handleChangeList_.bind(this); |
188 | 190 |
189 // The contained list should be focusable, not the table itself. | 191 // The contained list should be focusable, not the table itself. |
190 if (this.hasAttribute('tabindex')) { | 192 if (this.hasAttribute('tabindex')) { |
191 this.list_.setAttribute('tabindex', this.getAttribute('tabindex')); | 193 this.list_.setAttribute('tabindex', this.getAttribute('tabindex')); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 * because table contents can contain controls that can be focused, and for | 323 * because table contents can contain controls that can be focused, and for |
322 * some purposes (e.g., styling), the table can still be conceptually focused | 324 * some purposes (e.g., styling), the table can still be conceptually focused |
323 * at that point even though it doesn't actually have the page focus. | 325 * at that point even though it doesn't actually have the page focus. |
324 */ | 326 */ |
325 cr.defineProperty(Table, 'hasElementFocus', cr.PropertyKind.BOOL_ATTR); | 327 cr.defineProperty(Table, 'hasElementFocus', cr.PropertyKind.BOOL_ATTR); |
326 | 328 |
327 return { | 329 return { |
328 Table: Table | 330 Table: Table |
329 }; | 331 }; |
330 }); | 332 }); |
OLD | NEW |