OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 cr.define('cr.ui', function() { | 5 cr.define('cr.ui', function() { |
6 /** | 6 /** |
7 * A class to manage grid of focusable elements in a 2D grid. For example, | 7 * A class to manage grid of focusable elements in a 2D grid. For example, |
8 * given this grid: | 8 * given this grid: |
9 * | 9 * |
10 * focusable [focused] focusable (row: 0, col: 1) | 10 * focusable [focused] focusable (row: 0, col: 1) |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (this.rows[i].root == root) | 102 if (this.rows[i].root == root) |
103 return this.rows[i]; | 103 return this.rows[i]; |
104 } | 104 } |
105 return null; | 105 return null; |
106 }, | 106 }, |
107 | 107 |
108 /** | 108 /** |
109 * Adds |row| to the end of this list. | 109 * Adds |row| to the end of this list. |
110 * @param {!cr.ui.FocusRow} row The row that needs to be added to this grid. | 110 * @param {!cr.ui.FocusRow} row The row that needs to be added to this grid. |
111 */ | 111 */ |
112 addRow: function(row) { | 112 addRow: function(row) { this.addRowBefore(row, null); }, |
113 this.addRowBefore(row, null); | |
114 }, | |
115 | 113 |
116 /** | 114 /** |
117 * Adds |row| before |nextRow|. If |nextRow| is not in the list or it's | 115 * Adds |row| before |nextRow|. If |nextRow| is not in the list or it's |
118 * null, |row| is added to the end. | 116 * null, |row| is added to the end. |
119 * @param {!cr.ui.FocusRow} row The row that needs to be added to this grid. | 117 * @param {!cr.ui.FocusRow} row The row that needs to be added to this grid. |
120 * @param {cr.ui.FocusRow} nextRow The row that should follow |row|. | 118 * @param {cr.ui.FocusRow} nextRow The row that should follow |row|. |
121 */ | 119 */ |
122 addRowBefore: function(row, nextRow) { | 120 addRowBefore: function(row, nextRow) { |
123 row.delegate = row.delegate || this; | 121 row.delegate = row.delegate || this; |
124 | 122 |
(...skipping 28 matching lines...) Expand all Loading... |
153 } | 151 } |
154 | 152 |
155 this.rows[0].makeActive(true); | 153 this.rows[0].makeActive(true); |
156 }, | 154 }, |
157 }; | 155 }; |
158 | 156 |
159 return { | 157 return { |
160 FocusGrid: FocusGrid, | 158 FocusGrid: FocusGrid, |
161 }; | 159 }; |
162 }); | 160 }); |
OLD | NEW |