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

Side by Side Diff: ui/file_manager/file_manager/foreground/js/file_selection.js

Issue 884183006: Files.app: Add UI to toggle and clear item selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. 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 unified diff | Download patch
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 * The current selection object. 6 * The current selection object.
7 * 7 *
8 * @param {!FileManager} fileManager FileManager instance. 8 * @param {!FileManager} fileManager FileManager instance.
9 * @param {!Array.<number>} indexes Selected indexes. 9 * @param {!Array.<number>} indexes Selected indexes.
10 * @constructor 10 * @constructor
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 /** 229 /**
230 * Calculates async selection stats and updates secondary UI elements. 230 * Calculates async selection stats and updates secondary UI elements.
231 * 231 *
232 * @param {FileSelection} selection The selection object. 232 * @param {FileSelection} selection The selection object.
233 * @private 233 * @private
234 */ 234 */
235 FileSelectionHandler.prototype.updateFileSelectionAsync_ = function(selection) { 235 FileSelectionHandler.prototype.updateFileSelectionAsync_ = function(selection) {
236 if (this.selection !== selection) 236 if (this.selection !== selection)
237 return; 237 return;
238 238
239 // Update the label "x files selected." on the header.
240 // TODO(fukino): Make presenter class which listen to the FileSelection's
241 // events and update the UI components accordingly.
242 if (selection.totalCount === 0) {
243 this.fileManager_.ui.filesSelectedLabel.textContent = '';
244 this.fileManager_.ui.filesSelectedLabel.hidden = true;
245 } else {
246 var text;
247 if (selection.directoryCount == 0)
248 text = strf('MANY_FILES_SELECTED', selection.fileCount);
249 else if (selection.fileCount == 0)
250 text = strf('MANY_DIRECTORIES_SELECTED', selection.directoryCount);
251 else
252 text = strf('MANY_ENTRIES_SELECTED', selection.totalCount);
253 this.fileManager_.ui.filesSelectedLabel.textContent = text;
254 this.fileManager_.ui.filesSelectedLabel.hidden = false;
255 }
256
257 // Hide search box if one or more items are selected.
258 // TODO(fukino): Make presenter class which listen to the FileSelection's
259 // events and update the UI components accordingly.
260 this.fileManager_.ui.searchBox.setHidden(selection.totalCount !== 0);
261
262 // Sync the commands availability. 239 // Sync the commands availability.
263 if (this.fileManager_.commandHandler) 240 if (this.fileManager_.commandHandler)
264 this.fileManager_.commandHandler.updateAvailability(); 241 this.fileManager_.commandHandler.updateAvailability();
265 242
266 cr.dispatchSimpleEvent(this, FileSelectionHandler.EventType.CHANGE_THROTTLED); 243 cr.dispatchSimpleEvent(this, FileSelectionHandler.EventType.CHANGE_THROTTLED);
267 }; 244 };
268 245
269 /** 246 /**
270 * Returns whether all the selected files are available currently or not. 247 * Returns whether all the selected files are available currently or not.
271 * Should be called after the selection initialized. 248 * Should be called after the selection initialized.
272 * @return {boolean} 249 * @return {boolean}
273 */ 250 */
274 FileSelectionHandler.prototype.isAvailable = function() { 251 FileSelectionHandler.prototype.isAvailable = function() {
275 return !this.fileManager_.isOnDrive() || 252 return !this.fileManager_.isOnDrive() ||
276 this.fileManager_.volumeManager.getDriveConnectionState().type !== 253 this.fileManager_.volumeManager.getDriveConnectionState().type !==
277 VolumeManagerCommon.DriveConnectionType.OFFLINE || 254 VolumeManagerCommon.DriveConnectionType.OFFLINE ||
278 this.selection.allDriveFilesPresent; 255 this.selection.allDriveFilesPresent;
279 }; 256 };
OLDNEW
« no previous file with comments | « ui/file_manager/file_manager/foreground/js/file_manager.js ('k') | ui/file_manager/file_manager/foreground/js/main_scripts.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698