Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: ui/webui/resources/js/cr/ui/grid.js

Issue 2603443002: Clang format JS: Disallow single line functions, conditionals, loops, and switch statements (Closed)
Patch Set: update c/b/r/ as well Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/webui/resources/js/cr/ui/focus_row.js ('k') | ui/webui/resources/js/cr/ui/list.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // require: list_selection_model.js 5 // require: list_selection_model.js
6 // require: list_selection_controller.js 6 // require: list_selection_controller.js
7 // require: list.js 7 // require: list.js
8 8
9 /** 9 /**
10 * @fileoverview This implements a grid control. Grid contains a bunch of 10 * @fileoverview This implements a grid control. Grid contains a bunch of
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 * @type {function(new:cr.ui.GridItem, *)} 66 * @type {function(new:cr.ui.GridItem, *)}
67 * @override 67 * @override
68 */ 68 */
69 itemConstructor_: GridItem, 69 itemConstructor_: GridItem,
70 70
71 /** 71 /**
72 * Whether or not the rows on list have various heights. 72 * Whether or not the rows on list have various heights.
73 * Shows a warning at the setter because cr.ui.Grid does not support this. 73 * Shows a warning at the setter because cr.ui.Grid does not support this.
74 * @type {boolean} 74 * @type {boolean}
75 */ 75 */
76 get fixedHeight() { return true; }, 76 get fixedHeight() {
77 return true;
78 },
77 set fixedHeight(fixedHeight) { 79 set fixedHeight(fixedHeight) {
78 if (!fixedHeight) 80 if (!fixedHeight)
79 console.warn('cr.ui.Grid does not support fixedHeight = false'); 81 console.warn('cr.ui.Grid does not support fixedHeight = false');
80 }, 82 },
81 83
82 /** 84 /**
83 * @return {number} The number of columns determined by width of the grid 85 * @return {number} The number of columns determined by width of the grid
84 * and width of the items. 86 * and width of the items.
85 * @private 87 * @private
86 */ 88 */
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 getItemTop: function(index) { 201 getItemTop: function(index) {
200 return Math.floor(index / this.columns) * this.getDefaultItemHeight_(); 202 return Math.floor(index / this.columns) * this.getDefaultItemHeight_();
201 }, 203 },
202 204
203 /** 205 /**
204 * @param {number} index The index of the item. 206 * @param {number} index The index of the item.
205 * @return {number} The row of the item. May vary in the case 207 * @return {number} The row of the item. May vary in the case
206 * of multiple columns. 208 * of multiple columns.
207 * @override 209 * @override
208 */ 210 */
209 getItemRow: function(index) { return Math.floor(index / this.columns); }, 211 getItemRow: function(index) {
212 return Math.floor(index / this.columns);
213 },
210 214
211 /** 215 /**
212 * @param {number} row The row. 216 * @param {number} row The row.
213 * @return {number} The index of the first item in the row. 217 * @return {number} The index of the first item in the row.
214 * @override 218 * @override
215 */ 219 */
216 getFirstItemInRow: function(row) { return row * this.columns; }, 220 getFirstItemInRow: function(row) {
221 return row * this.columns;
222 },
217 223
218 /** 224 /**
219 * Creates the selection controller to use internally. 225 * Creates the selection controller to use internally.
220 * @param {cr.ui.ListSelectionModel} sm The underlying selection model. 226 * @param {cr.ui.ListSelectionModel} sm The underlying selection model.
221 * @return {!cr.ui.ListSelectionController} The newly created selection 227 * @return {!cr.ui.ListSelectionController} The newly created selection
222 * controller. 228 * controller.
223 * @override 229 * @override
224 */ 230 */
225 createSelectionController: function(sm) { 231 createSelectionController: function(sm) {
226 return new GridSelectionController(sm, this); 232 return new GridSelectionController(sm, this);
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 index -= this.grid_.columns; 403 index -= this.grid_.columns;
398 return Math.max(index, 0); 404 return Math.max(index, 0);
399 }, 405 },
400 406
401 /** 407 /**
402 * Returns the index before (x axis) the given element. 408 * Returns the index before (x axis) the given element.
403 * @param {number} index The index to get the index before. 409 * @param {number} index The index to get the index before.
404 * @return {number} The index before or -1 if not found. 410 * @return {number} The index before or -1 if not found.
405 * @override 411 * @override
406 */ 412 */
407 getIndexBefore: function(index) { return index - 1; }, 413 getIndexBefore: function(index) {
414 return index - 1;
415 },
408 416
409 /** 417 /**
410 * Returns the index after (x axis) the given element. 418 * Returns the index after (x axis) the given element.
411 * @param {number} index The index to get the index after. 419 * @param {number} index The index to get the index after.
412 * @return {number} The index after or -1 if not found. 420 * @return {number} The index after or -1 if not found.
413 * @override 421 * @override
414 */ 422 */
415 getIndexAfter: function(index) { 423 getIndexAfter: function(index) {
416 if (index == this.getLastIndex()) { 424 if (index == this.getLastIndex()) {
417 return -1; 425 return -1;
418 } 426 }
419 return index + 1; 427 return index + 1;
420 } 428 }
421 }; 429 };
422 430
423 return { 431 return {
424 Grid: Grid, 432 Grid: Grid,
425 GridItem: GridItem, 433 GridItem: GridItem,
426 GridSelectionController: GridSelectionController 434 GridSelectionController: GridSelectionController
427 }; 435 };
428 }); 436 });
OLDNEW
« no previous file with comments | « ui/webui/resources/js/cr/ui/focus_row.js ('k') | ui/webui/resources/js/cr/ui/list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698