OLD | NEW |
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 Loading... |
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 }; |
OLD | NEW |