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 model | 6 * @fileoverview This is a table column model |
7 */ | 7 */ |
8 cr.define('cr.ui.table', function() { | 8 cr.define('cr.ui.table', function() { |
9 /** @const */ var EventTarget = cr.EventTarget; | 9 /** @const */ var EventTarget = cr.EventTarget; |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 * @param {number} index The index of the column. | 50 * @param {number} index The index of the column. |
51 * @return {string} Column name. | 51 * @return {string} Column name. |
52 */ | 52 */ |
53 getName: function(index) { | 53 getName: function(index) { |
54 return this.columns_[index].name; | 54 return this.columns_[index].name; |
55 }, | 55 }, |
56 | 56 |
57 /** | 57 /** |
58 * Sets name of column at the given index. | 58 * Sets name of column at the given index. |
59 * @param {number} index The index of the column. | 59 * @param {number} index The index of the column. |
60 * @param {string} Column name. | 60 * @param {string} name Column name. |
61 */ | 61 */ |
62 setName: function(index, name) { | 62 setName: function(index, name) { |
63 if (index < 0 || index >= this.columns_.size - 1) | 63 if (index < 0 || index >= this.columns_.size - 1) |
64 return; | 64 return; |
65 if (name != this.columns_[index].name) | 65 if (name != this.columns_[index].name) |
66 return; | 66 return; |
67 | 67 |
68 this.columns_[index].name = name; | 68 this.columns_[index].name = name; |
69 cr.dispatchSimpleEvent(this, 'change'); | 69 cr.dispatchSimpleEvent(this, 'change'); |
70 }, | 70 }, |
(...skipping 12 matching lines...) Expand all Loading... |
83 * @param {number} index The index of the column. | 83 * @param {number} index The index of the column. |
84 * @return {boolean} True if the column is aligned to end. | 84 * @return {boolean} True if the column is aligned to end. |
85 */ | 85 */ |
86 isEndAlign: function(index) { | 86 isEndAlign: function(index) { |
87 return this.columns_[index].endAlign; | 87 return this.columns_[index].endAlign; |
88 }, | 88 }, |
89 | 89 |
90 /** | 90 /** |
91 * Sets width of column at the given index. | 91 * Sets width of column at the given index. |
92 * @param {number} index The index of the column. | 92 * @param {number} index The index of the column. |
93 * @param {number} Column width. | 93 * @param {number} width Column width. |
94 */ | 94 */ |
95 setWidth: function(index, width) { | 95 setWidth: function(index, width) { |
96 if (index < 0 || index >= this.columns_.size - 1) | 96 if (index < 0 || index >= this.columns_.size - 1) |
97 return; | 97 return; |
98 | 98 |
99 width = Math.max(width, MIMIMAL_WIDTH); | 99 width = Math.max(width, MIMIMAL_WIDTH); |
100 if (width == this.columns_[index].width) | 100 if (width == this.columns_[index].width) |
101 return; | 101 return; |
102 | 102 |
103 this.columns_[index].width = width; | 103 this.columns_[index].width = width; |
(...skipping 20 matching lines...) Expand all Loading... |
124 if (renderFunction !== this.columns_[index].renderFunction) | 124 if (renderFunction !== this.columns_[index].renderFunction) |
125 return; | 125 return; |
126 | 126 |
127 this.columns_[index].renderFunction = renderFunction; | 127 this.columns_[index].renderFunction = renderFunction; |
128 cr.dispatchSimpleEvent(this, 'change'); | 128 cr.dispatchSimpleEvent(this, 'change'); |
129 }, | 129 }, |
130 | 130 |
131 /** | 131 /** |
132 * Render the column header. | 132 * Render the column header. |
133 * @param {number} index The index of the column. | 133 * @param {number} index The index of the column. |
134 * @param {cr.ui.Table} Owner table. | 134 * @param {cr.ui.Table} table Owner table. |
135 */ | 135 */ |
136 renderHeader: function(index, table) { | 136 renderHeader: function(index, table) { |
137 var c = this.columns_[index]; | 137 var c = this.columns_[index]; |
138 return c.headerRenderFunction.call(c, table); | 138 return c.headerRenderFunction.call(c, table); |
139 }, | 139 }, |
140 | 140 |
141 /** | 141 /** |
142 * The total width of the columns. | 142 * The total width of the columns. |
143 * @type {number} | 143 * @type {number} |
144 */ | 144 */ |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 return i; | 180 return i; |
181 } | 181 } |
182 return -1; | 182 return -1; |
183 }, | 183 }, |
184 }; | 184 }; |
185 | 185 |
186 return { | 186 return { |
187 TableColumnModel: TableColumnModel | 187 TableColumnModel: TableColumnModel |
188 }; | 188 }; |
189 }); | 189 }); |
OLD | NEW |