| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 is a table column representation | 6 * @fileoverview This is a table column representation |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 cr.define('cr.ui.table', function() { | 9 cr.define('cr.ui.table', function() { |
| 10 const EventTarget = cr.EventTarget; | 10 const EventTarget = cr.EventTarget; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 TableColumn.prototype = { | 25 TableColumn.prototype = { |
| 26 __proto__: EventTarget.prototype, | 26 __proto__: EventTarget.prototype, |
| 27 | 27 |
| 28 id_: null, | 28 id_: null, |
| 29 | 29 |
| 30 name_: null, | 30 name_: null, |
| 31 | 31 |
| 32 width_: null, | 32 width_: null, |
| 33 | 33 |
| 34 renderFunction_: null, | |
| 35 | |
| 36 /** | 34 /** |
| 37 * Clones column. | 35 * Clones column. |
| 38 * @return {cr.ui.table.TableColumn} Clone of the given column. | 36 * @return {cr.ui.table.TableColumn} Clone of the given column. |
| 39 */ | 37 */ |
| 40 clone: function() { | 38 clone: function() { |
| 41 var tableColumn = new TableColumn(this.id_, this.name_, this.width_); | 39 var tableColumn = new TableColumn(this.id_, this.name_, this.width_); |
| 42 tableColumn.renderFunction = this.renderFunction_; | 40 tableColumn.renderFunction = this.renderFunction_; |
| 41 tableColumn.headerRenderFunction = this.headerRenderFunction_; |
| 43 return tableColumn; | 42 return tableColumn; |
| 44 }, | 43 }, |
| 45 | 44 |
| 46 /** | 45 /** |
| 47 * Renders table cell. This is the default render function. | 46 * Renders table cell. This is the default render function. |
| 48 * @param {*} dataItem The data item to be rendered. | 47 * @param {*} dataItem The data item to be rendered. |
| 49 * @param {string} columnId The column id. | 48 * @param {string} columnId The column id. |
| 50 * @param {cr.ui.Table} table The table. | 49 * @param {cr.ui.Table} table The table. |
| 51 * @return {HTMLElement} Rendered element. | 50 * @return {HTMLElement} Rendered element. |
| 52 */ | 51 */ |
| 53 renderFunction_: function(dataItem, columnId, table) { | 52 renderFunction_: function(dataItem, columnId, table) { |
| 54 var div = table.ownerDocument.createElement('div'); | 53 var div = table.ownerDocument.createElement('div'); |
| 55 div.textContent = dataItem[columnId]; | 54 div.textContent = dataItem[columnId]; |
| 56 return div; | 55 return div; |
| 57 }, | 56 }, |
| 57 |
| 58 /** |
| 59 * Renders table header. This is the default render function. |
| 60 * @param {cr.ui.Table} table The table. |
| 61 * @return {HTMLElement} Rendered element. |
| 62 */ |
| 63 headerRenderFunction_: function(table) { |
| 64 return table.ownerDocument.createTextNode(this.name); |
| 65 }, |
| 58 }; | 66 }; |
| 59 | 67 |
| 60 /** | 68 /** |
| 61 * The column id. | 69 * The column id. |
| 62 * @type {string} | 70 * @type {string} |
| 63 */ | 71 */ |
| 64 cr.defineProperty(TableColumn, 'id'); | 72 cr.defineProperty(TableColumn, 'id'); |
| 65 | 73 |
| 66 /** | 74 /** |
| 67 * The column name | 75 * The column name |
| 68 * @type {string} | 76 * @type {string} |
| 69 */ | 77 */ |
| 70 cr.defineProperty(TableColumn, 'name'); | 78 cr.defineProperty(TableColumn, 'name'); |
| 71 | 79 |
| 72 /** | 80 /** |
| 73 * The column width. | 81 * The column width. |
| 74 * @type {number} | 82 * @type {number} |
| 75 */ | 83 */ |
| 76 cr.defineProperty(TableColumn, 'width'); | 84 cr.defineProperty(TableColumn, 'width'); |
| 77 | 85 |
| 78 /** | 86 /** |
| 79 * The column render function. | 87 * The column render function. |
| 80 * @type {Function(*, string, cr.ui.Table): HTMLElement} | 88 * @type {Function(*, string, cr.ui.Table): HTMLElement} |
| 81 */ | 89 */ |
| 82 cr.defineProperty(TableColumn, 'renderFunction'); | 90 cr.defineProperty(TableColumn, 'renderFunction'); |
| 83 | 91 |
| 92 /** |
| 93 * The column header render function. |
| 94 * @type {Function(cr.ui.Table): HTMLElement} |
| 95 */ |
| 96 cr.defineProperty(TableColumn, 'headerRenderFunction'); |
| 97 |
| 84 return { | 98 return { |
| 85 TableColumn: TableColumn | 99 TableColumn: TableColumn |
| 86 }; | 100 }; |
| 87 }); | 101 }); |
| OLD | NEW |