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

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

Issue 11280253: Fixing column widths in tables. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review fixes. Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/resources/shared/css/table.css » ('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 /** 5 /**
6 * FileManager constructor. 6 * FileManager constructor.
7 * 7 *
8 * FileManager objects encapsulate the functionality of the file selector 8 * FileManager objects encapsulate the functionality of the file selector
9 * dialogs, as well as the full screen file manager application (though the 9 * dialogs, as well as the full screen file manager application (though the
10 * latter is not yet implemented). 10 * latter is not yet implemented).
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 /** @type {cr.ui.List} */ 1008 /** @type {cr.ui.List} */
1009 this.currentList_ = this.grid_; 1009 this.currentList_ = this.grid_;
1010 this.dialogDom_.querySelector('#thumbnail-view').disabled = true; 1010 this.dialogDom_.querySelector('#thumbnail-view').disabled = true;
1011 this.dialogDom_.querySelector('#detail-view').disabled = false; 1011 this.dialogDom_.querySelector('#detail-view').disabled = false;
1012 } else { 1012 } else {
1013 throw new Error('Unknown list type: ' + type); 1013 throw new Error('Unknown list type: ' + type);
1014 } 1014 }
1015 1015
1016 this.listType_ = type; 1016 this.listType_ = type;
1017 this.updateStartupPrefs_(); 1017 this.updateStartupPrefs_();
1018 this.updateColumnModel_();
1019 this.onResize_(); 1018 this.onResize_();
1020 1019
1021 this.table_.list.endBatchUpdates(); 1020 this.table_.list.endBatchUpdates();
1022 this.grid_.endBatchUpdates(); 1021 this.grid_.endBatchUpdates();
1023 }; 1022 };
1024 1023
1025 /** 1024 /**
1026 * Initialize the file thumbnail grid. 1025 * Initialize the file thumbnail grid.
1027 */ 1026 */
1028 FileManager.prototype.initGrid_ = function() { 1027 FileManager.prototype.initGrid_ = function() {
(...skipping 20 matching lines...) Expand all
1049 1048
1050 var columns = [ 1049 var columns = [
1051 new cr.ui.table.TableColumn('name', str('NAME_COLUMN_LABEL'), 1050 new cr.ui.table.TableColumn('name', str('NAME_COLUMN_LABEL'),
1052 fullPage ? 470 : 324), 1051 fullPage ? 470 : 324),
1053 new cr.ui.table.TableColumn('size', str('SIZE_COLUMN_LABEL'), 1052 new cr.ui.table.TableColumn('size', str('SIZE_COLUMN_LABEL'),
1054 fullPage ? 110 : 92, true), 1053 fullPage ? 110 : 92, true),
1055 new cr.ui.table.TableColumn('type', str('TYPE_COLUMN_LABEL'), 1054 new cr.ui.table.TableColumn('type', str('TYPE_COLUMN_LABEL'),
1056 fullPage ? 200 : 160), 1055 fullPage ? 200 : 160),
1057 new cr.ui.table.TableColumn('modificationTime', 1056 new cr.ui.table.TableColumn('modificationTime',
1058 str('DATE_COLUMN_LABEL'), 1057 str('DATE_COLUMN_LABEL'),
1059 fullPage ? 150 : 210) 1058 fullPage ? 150 : 210),
1059 new cr.ui.table.TableColumn('offline',
1060 str('OFFLINE_COLUMN_LABEL'),
1061 150)
1060 ]; 1062 ];
1061 1063
1062 // TODO(dgozman): refactor render/update/display stuff. 1064 // TODO(dgozman): refactor render/update/display stuff.
1063 columns[0].renderFunction = this.renderName_.bind(this); 1065 columns[0].renderFunction = this.renderName_.bind(this);
1064 columns[1].renderFunction = this.renderSize_.bind(this); 1066 columns[1].renderFunction = this.renderSize_.bind(this);
1065 columns[1].defaultOrder = 'desc'; 1067 columns[1].defaultOrder = 'desc';
1066 columns[2].renderFunction = this.renderType_.bind(this); 1068 columns[2].renderFunction = this.renderType_.bind(this);
1067 columns[3].renderFunction = this.renderDate_.bind(this); 1069 columns[3].renderFunction = this.renderDate_.bind(this);
1068 columns[3].defaultOrder = 'desc'; 1070 columns[3].defaultOrder = 'desc';
1071 columns[4].renderFunction = this.renderOffline_.bind(this);
1069 1072
1070 if (this.showCheckboxes_) { 1073 if (this.showCheckboxes_) {
1071 columns[0].headerRenderFunction = 1074 columns[0].headerRenderFunction =
1072 this.renderNameColumnHeader_.bind(this, columns[0].name); 1075 this.renderNameColumnHeader_.bind(this, columns[0].name);
1073 } 1076 }
1074 1077
1075 this.regularColumnModel_ = new cr.ui.table.TableColumnModel(columns); 1078 var columnModel = new cr.ui.table.TableColumnModel(columns);
1076 1079 Object.defineProperty(columnModel, 'size', {
1080 get: function() {
1081 if (fullPage && this.isOnGData())
1082 return columns.length;
1083 else
1084 return columns.length - 1;
1085 }.bind(this)
1086 });
1077 if (fullPage) { 1087 if (fullPage) {
1078 columns.push(new cr.ui.table.TableColumn( 1088 var isOnDrive = function(entry) {
1079 'offline', str('OFFLINE_COLUMN_LABEL'), 150)); 1089 return PathUtil.getRootType(entry.fullPath) == RootType.GDATA;
1080 columns[4].renderFunction = this.renderOffline_.bind(this); 1090 };
1081 1091 var table = this.table_;
1082 this.gdataColumnModel_ = new cr.ui.table.TableColumnModel(columns); 1092 this.directoryModel_.addEventListener('directory-changed', function(e) {
1083 } else { 1093 if (isOnDrive(e.previousDirEntry) != isOnDrive(e.newDirEntry)) {
1084 this.gdataColumnModel_ = null; 1094 // Columns number changed.
1095 table.redraw();
1096 }
1097 });
1085 } 1098 }
1099 this.table_.columnModel = columnModel;
1086 1100
1087 this.table_.list.addEventListener('click', this.onDetailClick_.bind(this)); 1101 this.table_.list.addEventListener('click', this.onDetailClick_.bind(this));
1088 }; 1102 };
1089 1103
1090 FileManager.prototype.onCopyProgress_ = function(event) { 1104 FileManager.prototype.onCopyProgress_ = function(event) {
1091 if (event.reason === 'ERROR' && 1105 if (event.reason === 'ERROR' &&
1092 event.error.reason === 'FILESYSTEM_ERROR' && 1106 event.error.reason === 'FILESYSTEM_ERROR' &&
1093 event.error.data.toGDrive && 1107 event.error.data.toGDrive &&
1094 event.error.data.code == FileError.QUOTA_EXCEEDED_ERR) { 1108 event.error.data.code == FileError.QUOTA_EXCEEDED_ERR) {
1095 this.alert.showHtml( 1109 this.alert.showHtml(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 entry.name.length - 1); 1142 entry.name.length - 1);
1129 return dirPath == currentPath; 1143 return dirPath == currentPath;
1130 } 1144 }
1131 for (var i = 0; i < event.affectedEntries.length; i++) { 1145 for (var i = 0; i < event.affectedEntries.length; i++) {
1132 entry = event.affectedEntries[i]; 1146 entry = event.affectedEntries[i];
1133 if (inCurrentDirectory(entry)) 1147 if (inCurrentDirectory(entry))
1134 this.directoryModel_.onEntryChanged(entry.name); 1148 this.directoryModel_.onEntryChanged(entry.name);
1135 } 1149 }
1136 }; 1150 };
1137 1151
1138 FileManager.prototype.updateColumnModel_ = function() {
1139 if (this.listType_ != FileManager.ListType.DETAIL)
1140 return;
1141 this.table_.columnModel =
1142 (this.isOnGData() && this.gdataColumnModel_) ?
1143 this.gdataColumnModel_ :
1144 this.regularColumnModel_;
1145 };
1146
1147 /** 1152 /**
1148 * Fills the file type list or hides it. 1153 * Fills the file type list or hides it.
1149 */ 1154 */
1150 FileManager.prototype.initFileTypeFilter_ = function() { 1155 FileManager.prototype.initFileTypeFilter_ = function() {
1151 if (this.params_.includeAllFiles) { 1156 if (this.params_.includeAllFiles) {
1152 var option = this.document_.createElement('option'); 1157 var option = this.document_.createElement('option');
1153 option.innerText = str('ALL_FILES_FILTER'); 1158 option.innerText = str('ALL_FILES_FILTER');
1154 this.fileTypeSelector_.appendChild(option); 1159 this.fileTypeSelector_.appendChild(option);
1155 option.value = 0; 1160 option.value = 0;
1156 } 1161 }
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 searchBox.value = ''; 2418 searchBox.value = '';
2414 }, 2419 },
2415 2420
2416 /** 2421 /**
2417 * Update the UI when the current directory changes. 2422 * Update the UI when the current directory changes.
2418 * 2423 *
2419 * @param {cr.Event} event The directory-changed event. 2424 * @param {cr.Event} event The directory-changed event.
2420 */ 2425 */
2421 FileManager.prototype.onDirectoryChanged_ = function(event) { 2426 FileManager.prototype.onDirectoryChanged_ = function(event) {
2422 this.selectionHandler_.onSelectionChanged(); 2427 this.selectionHandler_.onSelectionChanged();
2423 this.updateColumnModel_();
2424 this.updateSearchBoxOnDirChange_(); 2428 this.updateSearchBoxOnDirChange_();
2425 2429
2426 util.updateAppState(event.initial, this.getCurrentDirectory()); 2430 util.updateAppState(event.initial, this.getCurrentDirectory());
2427 2431
2428 if (this.closeOnUnmount_ && !event.initial && 2432 if (this.closeOnUnmount_ && !event.initial &&
2429 PathUtil.getRootPath(event.previousDirEntry.fullPath) != 2433 PathUtil.getRootPath(event.previousDirEntry.fullPath) !=
2430 PathUtil.getRootPath(event.newDirEntry.fullPath)) { 2434 PathUtil.getRootPath(event.newDirEntry.fullPath)) {
2431 this.closeOnUnmount_ = false; 2435 this.closeOnUnmount_ = false;
2432 } 2436 }
2433 2437
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 return this.directoryModel_.getFileList(); 3380 return this.directoryModel_.getFileList();
3377 }; 3381 };
3378 3382
3379 /** 3383 /**
3380 * @return {cr.ui.List} Current list object. 3384 * @return {cr.ui.List} Current list object.
3381 */ 3385 */
3382 FileManager.prototype.getCurrentList = function() { 3386 FileManager.prototype.getCurrentList = function() {
3383 return this.currentList_; 3387 return this.currentList_;
3384 }; 3388 };
3385 })(); 3389 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/shared/css/table.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698