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

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
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';
1069 1071
1070 if (this.showCheckboxes_) { 1072 if (this.showCheckboxes_) {
1071 columns[0].headerRenderFunction = 1073 columns[0].headerRenderFunction =
1072 this.renderNameColumnHeader_.bind(this, columns[0].name); 1074 this.renderNameColumnHeader_.bind(this, columns[0].name);
1073 } 1075 }
1074 1076
1075 this.regularColumnModel_ = new cr.ui.table.TableColumnModel(columns); 1077 columns[4].renderFunction = this.renderOffline_.bind(this);
1076 1078
1079 var columnModel = new cr.ui.table.TableColumnModel(columns);
1080 Object.defineProperty(columnModel, 'size', { get: function() {
arv (Not doing code reviews) 2012/12/03 15:53:48 { get:
SeRya 2012/12/03 16:59:36 Done.
1081 if (fullPage && this.isOnGData())
1082 return columns.length;
1083 else
1084 return columns.length - 1;
1085 }.bind(this) });
1077 if (fullPage) { 1086 if (fullPage) {
1078 columns.push(new cr.ui.table.TableColumn( 1087 var isOnDrive = function(entry) {
1079 'offline', str('OFFLINE_COLUMN_LABEL'), 150)); 1088 return PathUtil.getRootType(entry.fullPath) == RootType.GDATA;
1080 columns[4].renderFunction = this.renderOffline_.bind(this); 1089 }
arv (Not doing code reviews) 2012/12/03 15:53:48 missing ;
SeRya 2012/12/03 16:59:36 Done.
1081 1090 var table = this.table_;
1082 this.gdataColumnModel_ = new cr.ui.table.TableColumnModel(columns); 1091 this.directoryModel_.addEventListener('directory-changed', function(e) {
1083 } else { 1092 if (isOnDrive(e.previousDirEntry) != isOnDrive(e.newDirEntry)) {
1084 this.gdataColumnModel_ = null; 1093 // Columns number changed.
1094 table.redraw();
1095 }
1096 });
1085 } 1097 }
1098 this.table_.columnModel = columnModel;
1086 1099
1087 this.table_.list.addEventListener('click', this.onDetailClick_.bind(this)); 1100 this.table_.list.addEventListener('click', this.onDetailClick_.bind(this));
1088 }; 1101 };
1089 1102
1090 FileManager.prototype.onCopyProgress_ = function(event) { 1103 FileManager.prototype.onCopyProgress_ = function(event) {
1091 if (event.reason === 'ERROR' && 1104 if (event.reason === 'ERROR' &&
1092 event.error.reason === 'FILESYSTEM_ERROR' && 1105 event.error.reason === 'FILESYSTEM_ERROR' &&
1093 event.error.data.toGDrive && 1106 event.error.data.toGDrive &&
1094 event.error.data.code == FileError.QUOTA_EXCEEDED_ERR) { 1107 event.error.data.code == FileError.QUOTA_EXCEEDED_ERR) {
1095 this.alert.showHtml( 1108 this.alert.showHtml(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 entry.name.length - 1); 1141 entry.name.length - 1);
1129 return dirPath == currentPath; 1142 return dirPath == currentPath;
1130 } 1143 }
1131 for (var i = 0; i < event.affectedEntries.length; i++) { 1144 for (var i = 0; i < event.affectedEntries.length; i++) {
1132 entry = event.affectedEntries[i]; 1145 entry = event.affectedEntries[i];
1133 if (inCurrentDirectory(entry)) 1146 if (inCurrentDirectory(entry))
1134 this.directoryModel_.onEntryChanged(entry.name); 1147 this.directoryModel_.onEntryChanged(entry.name);
1135 } 1148 }
1136 }; 1149 };
1137 1150
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 /** 1151 /**
1148 * Fills the file type list or hides it. 1152 * Fills the file type list or hides it.
1149 */ 1153 */
1150 FileManager.prototype.initFileTypeFilter_ = function() { 1154 FileManager.prototype.initFileTypeFilter_ = function() {
1151 if (this.params_.includeAllFiles) { 1155 if (this.params_.includeAllFiles) {
1152 var option = this.document_.createElement('option'); 1156 var option = this.document_.createElement('option');
1153 option.innerText = str('ALL_FILES_FILTER'); 1157 option.innerText = str('ALL_FILES_FILTER');
1154 this.fileTypeSelector_.appendChild(option); 1158 this.fileTypeSelector_.appendChild(option);
1155 option.value = 0; 1159 option.value = 0;
1156 } 1160 }
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 searchBox.value = ''; 2417 searchBox.value = '';
2414 }, 2418 },
2415 2419
2416 /** 2420 /**
2417 * Update the UI when the current directory changes. 2421 * Update the UI when the current directory changes.
2418 * 2422 *
2419 * @param {cr.Event} event The directory-changed event. 2423 * @param {cr.Event} event The directory-changed event.
2420 */ 2424 */
2421 FileManager.prototype.onDirectoryChanged_ = function(event) { 2425 FileManager.prototype.onDirectoryChanged_ = function(event) {
2422 this.selectionHandler_.onSelectionChanged(); 2426 this.selectionHandler_.onSelectionChanged();
2423 this.updateColumnModel_();
2424 this.updateSearchBoxOnDirChange_(); 2427 this.updateSearchBoxOnDirChange_();
2425 2428
2426 util.updateAppState(event.initial, this.getCurrentDirectory()); 2429 util.updateAppState(event.initial, this.getCurrentDirectory());
2427 2430
2428 if (this.closeOnUnmount_ && !event.initial && 2431 if (this.closeOnUnmount_ && !event.initial &&
2429 PathUtil.getRootPath(event.previousDirEntry.fullPath) != 2432 PathUtil.getRootPath(event.previousDirEntry.fullPath) !=
2430 PathUtil.getRootPath(event.newDirEntry.fullPath)) { 2433 PathUtil.getRootPath(event.newDirEntry.fullPath)) {
2431 this.closeOnUnmount_ = false; 2434 this.closeOnUnmount_ = false;
2432 } 2435 }
2433 2436
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after
3376 return this.directoryModel_.getFileList(); 3379 return this.directoryModel_.getFileList();
3377 }; 3380 };
3378 3381
3379 /** 3382 /**
3380 * @return {cr.ui.List} Current list object. 3383 * @return {cr.ui.List} Current list object.
3381 */ 3384 */
3382 FileManager.prototype.getCurrentList = function() { 3385 FileManager.prototype.getCurrentList = function() {
3383 return this.currentList_; 3386 return this.currentList_;
3384 }; 3387 };
3385 })(); 3388 })();
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/shared/css/table.css » ('j') | chrome/browser/resources/shared/js/cr/ui/table.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698