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

Side by Side Diff: chrome/browser/resources/file_manager/js/file_table.js

Issue 15029002: CrOS Files.app: fix the redraw logic on resize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | no next file » | 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Namespace for utility functions. 8 * Namespace for utility functions.
9 */ 9 */
10 var filelist = {}; 10 var filelist = {};
11 11
12 /** 12 /**
13 * Custom column model for advanced auto-resizing. 13 * Custom column model for advanced auto-resizing.
14 * 14 *
15 * @param {Array.<cr.ui.table.TableColumn>} tableColumns Table columns. 15 * @param {Array.<cr.ui.table.TableColumn>} tableColumns Table columns.
16 * @extends {cr.ui.table.TableColumnModel} 16 * @extends {cr.ui.table.TableColumnModel}
17 * @constructor 17 * @constructor
18 */ 18 */
19 function FileTableColumnModel(tableColumns) { 19 function FileTableColumnModel(tableColumns) {
20 cr.ui.table.TableColumnModel.call(this, tableColumns); 20 cr.ui.table.TableColumnModel.call(this, tableColumns);
21 } 21 }
22 22
23 /** 23 /**
24 * Inherits from cr.ui.Table. 24 * Inherits from cr.ui.Table.
25 */ 25 */
26 FileTableColumnModel.prototype.__proto__ = 26 FileTableColumnModel.prototype.__proto__ =
27 cr.ui.table.TableColumnModel.prototype; 27 cr.ui.table.TableColumnModel.prototype;
28 28
29 /** 29 /**
30 * Normalizes widths to make their sum 100%. Uses the proportional approach 30 * Normalizes widths to make their sum 100% if possible. Uses the proportional
31 * with some additional constraints. 31 * approach with some additional constraints.
32 * 32 *
33 * @param {number} contentWidth Target width. 33 * @param {number} contentWidth Target width.
34 * @override 34 * @override
35 */ 35 */
36 FileTableColumnModel.prototype.normalizeWidths = function(contentWidth) { 36 FileTableColumnModel.prototype.normalizeWidths = function(contentWidth) {
37 var fixedWidth = 0; 37 var fixedWidth = 0;
38 var flexibleWidth = 0; 38 var flexibleWidth = 0;
39 39
40 // Some columns have fixed width. 40 // Some columns have fixed width.
41 for (var index = 0; index < this.size; index++) { 41 for (var index = 0; index < this.size; index++) {
42 var column = this.columns_[index]; 42 var column = this.columns_[index];
43 if (column.id == 'selection') 43 if (column.id == 'selection')
44 fixedWidth += column.width; 44 fixedWidth += column.width;
45 else 45 else
46 flexibleWidth += column.width; 46 flexibleWidth += column.width;
47 } 47 }
48 48
49 var factor = (contentWidth - fixedWidth) / flexibleWidth; 49 var factor = Math.max(0, contentWidth - fixedWidth) / flexibleWidth;
50 for (var index = 0; index < this.size; index++) { 50 for (var index = 0; index < this.size; index++) {
51 var column = this.columns_[index]; 51 var column = this.columns_[index];
52 if (column.id == 'selection') 52 if (column.id == 'selection')
53 continue; 53 continue;
54 column.width = column.width * factor; 54 // Limits the minimum width to 1px to avoid flexibleWidth=0.
55 column.width = Math.max(1, column.width * factor);
55 } 56 }
56 }; 57 };
57 58
58 /** 59 /**
59 * File list Table View. 60 * File list Table View.
60 * @constructor 61 * @constructor
61 */ 62 */
62 function FileTable() { 63 function FileTable() {
63 throw new Error('Designed to decorate elements'); 64 throw new Error('Designed to decorate elements');
64 } 65 }
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 break; 807 break;
807 } 808 }
808 } 809 }
809 if (url) { 810 if (url) {
810 iconDiv.style.backgroundImage = 'url(' + url + ')'; 811 iconDiv.style.backgroundImage = 'url(' + url + ')';
811 } else { 812 } else {
812 iconDiv.style.backgroundImage = null; 813 iconDiv.style.backgroundImage = null;
813 } 814 }
814 } 815 }
815 }; 816 };
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/file_manager.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698