| 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 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 */ var EventTarget = cr.EventTarget; | 10 /** @const */ var EventTarget = cr.EventTarget; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 TableColumn.prototype = { | 29 TableColumn.prototype = { |
| 30 __proto__: EventTarget.prototype, | 30 __proto__: EventTarget.prototype, |
| 31 | 31 |
| 32 defaultOrder_: 'asc', | 32 defaultOrder_: 'asc', |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Clones column. | 35 * Clones column. |
| 36 * @return {cr.ui.table.TableColumn} Clone of the given column. | 36 * @return {cr.ui.table.TableColumn} Clone of the given column. |
| 37 */ | 37 */ |
| 38 clone: function() { | 38 clone: function() { |
| 39 var tableColumn = new TableColumn(this.id_, this.name_, this.width_, | 39 var tableColumn = |
| 40 this.endAlign_); | 40 new TableColumn(this.id_, this.name_, this.width_, this.endAlign_); |
| 41 tableColumn.renderFunction = this.renderFunction_; | 41 tableColumn.renderFunction = this.renderFunction_; |
| 42 tableColumn.headerRenderFunction = this.headerRenderFunction_; | 42 tableColumn.headerRenderFunction = this.headerRenderFunction_; |
| 43 tableColumn.defaultOrder = this.defaultOrder_; | 43 tableColumn.defaultOrder = this.defaultOrder_; |
| 44 | 44 |
| 45 tableColumn.visible_ = this.visible_; | 45 tableColumn.visible_ = this.visible_; |
| 46 | 46 |
| 47 return tableColumn; | 47 return tableColumn; |
| 48 }, | 48 }, |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Renders table cell. This is the default render function. | 51 * Renders table cell. This is the default render function. |
| 52 * @param {*} dataItem The data item to be rendered. | 52 * @param {*} dataItem The data item to be rendered. |
| 53 * @param {string} columnId The column id. | 53 * @param {string} columnId The column id. |
| 54 * @param {cr.ui.Table} table The table. | 54 * @param {cr.ui.Table} table The table. |
| 55 * @return {HTMLElement} Rendered element. | 55 * @return {HTMLElement} Rendered element. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 68 * @return {Text} Rendered text node. | 68 * @return {Text} Rendered text node. |
| 69 */ | 69 */ |
| 70 headerRenderFunction_: function(table) { | 70 headerRenderFunction_: function(table) { |
| 71 return table.ownerDocument.createTextNode(this.name); | 71 return table.ownerDocument.createTextNode(this.name); |
| 72 }, | 72 }, |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * The width of the column. Hidden columns have zero width. | 75 * The width of the column. Hidden columns have zero width. |
| 76 * @type {number} | 76 * @type {number} |
| 77 */ | 77 */ |
| 78 get width() { | 78 get width() { return this.visible_ ? this.width_ : 0; }, |
| 79 return this.visible_ ? this.width_ : 0; | |
| 80 }, | |
| 81 | 79 |
| 82 /** | 80 /** |
| 83 * The width of the column, disregarding visibility. For hidden columns, | 81 * The width of the column, disregarding visibility. For hidden columns, |
| 84 * this would be the width of the column if it were to be made visible. | 82 * this would be the width of the column if it were to be made visible. |
| 85 * @type {number} | 83 * @type {number} |
| 86 */ | 84 */ |
| 87 get absoluteWidth() { | 85 get absoluteWidth() { return this.width_; }, |
| 88 return this.width_; | |
| 89 }, | |
| 90 }; | 86 }; |
| 91 | 87 |
| 92 /** | 88 /** |
| 93 * The column id. | 89 * The column id. |
| 94 * @type {string} | 90 * @type {string} |
| 95 */ | 91 */ |
| 96 cr.defineProperty(TableColumn, 'id'); | 92 cr.defineProperty(TableColumn, 'id'); |
| 97 | 93 |
| 98 /** | 94 /** |
| 99 * The column name | 95 * The column name |
| (...skipping 30 matching lines...) Expand all Loading... |
| 130 * @type {function(cr.ui.Table): Text} | 126 * @type {function(cr.ui.Table): Text} |
| 131 */ | 127 */ |
| 132 cr.defineProperty(TableColumn, 'headerRenderFunction'); | 128 cr.defineProperty(TableColumn, 'headerRenderFunction'); |
| 133 | 129 |
| 134 /** | 130 /** |
| 135 * Default sorting order for the column ('asc' or 'desc'). | 131 * Default sorting order for the column ('asc' or 'desc'). |
| 136 * @type {string} | 132 * @type {string} |
| 137 */ | 133 */ |
| 138 cr.defineProperty(TableColumn, 'defaultOrder'); | 134 cr.defineProperty(TableColumn, 'defaultOrder'); |
| 139 | 135 |
| 140 return { | 136 return {TableColumn: TableColumn}; |
| 141 TableColumn: TableColumn | |
| 142 }; | |
| 143 }); | 137 }); |
| OLD | NEW |