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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/file_table.js

Issue 926483003: Files.app: Make all columns resizable in table view. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/foreground/js/ui/file_table.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/file_table.js b/ui/file_manager/file_manager/foreground/js/ui/file_table.js
index 23c2e7c65ed910a3c3e3a57103146e70338801f5..6602bab9bb984fdd1b6309e5e5052b021eeb79fa 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/file_table.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/file_table.js
@@ -19,14 +19,6 @@ function FileTableColumnModel(tableColumns) {
}
/**
- * The columns whose index is less than the constant are resizable.
- * @const
- * @type {number}
- * @private
- */
-FileTableColumnModel.RESIZABLE_LENGTH_ = 4;
-
-/**
* Inherits from cr.ui.TableColumnModel.
*/
FileTableColumnModel.prototype.__proto__ =
@@ -61,7 +53,7 @@ FileTableColumnModel.prototype.applyColumnPositions_ = function(newPos) {
}
}
// Set the new width of columns
- for (var i = 0; i < FileTableColumnModel.RESIZABLE_LENGTH_; i++) {
+ for (var i = 0; i < this.columns_.length; i++) {
this.columns_[i].width = newPos[i + 1] - newPos[i];
}
};
@@ -75,22 +67,17 @@ FileTableColumnModel.prototype.applyColumnPositions_ = function(newPos) {
*/
FileTableColumnModel.prototype.normalizeWidths = function(contentWidth) {
var totalWidth = 0;
- var fixedWidth = 0;
// Some columns have fixed width.
for (var i = 0; i < this.columns_.length; i++) {
- if (i < FileTableColumnModel.RESIZABLE_LENGTH_)
- totalWidth += this.columns_[i].width;
- else
- fixedWidth += this.columns_[i].width;
+ totalWidth += this.columns_[i].width;
}
- var newTotalWidth = Math.max(contentWidth - fixedWidth, 0);
var positions = [0];
var sum = 0;
- for (var i = 0; i < FileTableColumnModel.RESIZABLE_LENGTH_; i++) {
+ for (var i = 0; i < this.columns_.length; i++) {
var column = this.columns_[i];
sum += column.width;
// Faster alternative to Math.floor for non-negative numbers.
- positions[i + 1] = ~~(newTotalWidth * sum / totalWidth);
+ positions[i + 1] = ~~(contentWidth * sum / totalWidth);
}
this.applyColumnPositions_(positions);
};
@@ -137,7 +124,7 @@ FileTableColumnModel.prototype.setWidthAndKeepTotal = function(
columnIndex, columnWidth) {
// Skip to resize 'selection' column
if (columnIndex < 0 ||
hirono 2015/02/13 06:46:22 nit: We can remove the check, or assert?
fukino 2015/02/13 06:54:41 Maybe we can use assert, but some investigation is
- columnIndex >= FileTableColumnModel.RESIZABLE_LENGTH_ ||
+ columnIndex >= this.columns_.length ||
!this.columnPos_) {
return;
}
@@ -147,13 +134,11 @@ FileTableColumnModel.prototype.setWidthAndKeepTotal = function(
this.columnPos_[columnIndex] + Math.max(columnWidth,
FileTableColumnModel.MIN_WIDTH_);
var newPos = [];
- var posEnd = this.columnPos_[FileTableColumnModel.RESIZABLE_LENGTH_];
+ var posEnd = this.columnPos_[this.columns_.length];
for (var i = 0; i < columnIndex + 1; i++) {
newPos[i] = this.columnPos_[i];
}
- for (var i = columnIndex + 1;
- i < FileTableColumnModel.RESIZABLE_LENGTH_;
- i++) {
+ for (var i = columnIndex + 1; i < this.columns_.length; i++) {
var posStart = this.columnPos_[columnIndex + 1];
newPos[i] = (posEnd - newPosStart) *
(this.columnPos_[i] - posStart) /
@@ -163,7 +148,7 @@ FileTableColumnModel.prototype.setWidthAndKeepTotal = function(
newPos[i] = ~~newPos[i];
}
newPos[columnIndex] = this.columnPos_[columnIndex];
- newPos[FileTableColumnModel.RESIZABLE_LENGTH_] = posEnd;
+ newPos[this.columns_.length] = posEnd;
this.applyColumnPositions_(newPos);
// Notifiy about resizing
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698