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 * @param {FileManager} fileManager FileManager instance. | 7 * @param {FileManager} fileManager FileManager instance. |
8 * @param {Array.<number>} indexes Selected indexes. | 8 * @param {Array.<number>} indexes Selected indexes. |
9 */ | 9 */ |
10 function Selection(fileManager, indexes) { | 10 function Selection(fileManager, indexes) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 this.filenameInput_.value != this.selection.entries[0].name) { | 184 this.filenameInput_.value != this.selection.entries[0].name) { |
185 this.filenameInput_.value = this.selection.entries[0].name; | 185 this.filenameInput_.value = this.selection.entries[0].name; |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 this.updateOkButton(); | 189 this.updateOkButton(); |
190 | 190 |
191 if (this.selectionUpdateTimer_) { | 191 if (this.selectionUpdateTimer_) { |
192 clearTimeout(this.selectionUpdateTimer_); | 192 clearTimeout(this.selectionUpdateTimer_); |
193 this.selectionUpdateTimer_ = null; | 193 this.selectionUpdateTimer_ = null; |
194 | |
195 // The selection is changing quicker than we can update the UI. | |
196 // Clear the UI. | |
197 this.clearUI(); | |
198 } | 194 } |
199 | 195 |
200 if (!indexes.length) { | 196 if (!indexes.length) { |
201 this.updatePreviewPanelVisibility_(); | 197 this.updatePreviewPanelVisibility_(); |
202 this.updatePreviewPanelText_(); | 198 this.updatePreviewPanelText_(); |
203 this.fileManager_.updateContextMenuActionItems(null, false); | 199 this.fileManager_.updateContextMenuActionItems(null, false); |
204 return; | 200 return; |
205 } | 201 } |
206 | 202 |
207 this.previewText_.textContent = str('COMPUTING_SELECTION'); | |
208 this.hideCalculating_(); | 203 this.hideCalculating_(); |
209 | 204 |
210 // The rest of the selection properties are computed via (sometimes lengthy) | 205 // The rest of the selection properties are computed via (sometimes lengthy) |
211 // asynchronous calls. We initiate these calls after a timeout. If the | 206 // asynchronous calls. We initiate these calls after a timeout. If the |
212 // selection is changing quickly we only do this once when it slows down. | 207 // selection is changing quickly we only do this once when it slows down. |
213 | 208 |
214 var updateDelay = 200; | 209 var updateDelay = 200; |
mtomasz
2013/01/15 01:41:08
This should work fine, since label is updated afte
| |
215 var now = Date.now(); | 210 var now = Date.now(); |
216 if (now > (this.lastSelectionTime_ || 0) + updateDelay) { | 211 if (now > (this.lastSelectionTime_ || 0) + updateDelay) { |
217 // The previous selection change happened a while ago. Update the UI soon. | 212 // The previous selection change happened a while ago. Update the UI soon. |
218 updateDelay = 0; | 213 updateDelay = 0; |
219 } | 214 } |
220 this.lastSelectionTime_ = now; | 215 this.lastSelectionTime_ = now; |
221 | 216 |
222 this.selectionUpdateTimer_ = setTimeout(function() { | 217 this.selectionUpdateTimer_ = setTimeout(function() { |
223 this.selectionUpdateTimer_ = null; | 218 this.selectionUpdateTimer_ = null; |
224 if (this.selection == selection) | 219 if (this.selection == selection) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); | 459 var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); |
465 for (var i = 0; i < commands.length; i++) | 460 for (var i = 0; i < commands.length; i++) |
466 commands[i].canExecuteChange(); | 461 commands[i].canExecuteChange(); |
467 | 462 |
468 // Update the summary information. | 463 // Update the summary information. |
469 var onBytes = function() { | 464 var onBytes = function() { |
470 if (this.selection != selection) return; | 465 if (this.selection != selection) return; |
471 this.updatePreviewPanelText_(); | 466 this.updatePreviewPanelText_(); |
472 }.bind(this); | 467 }.bind(this); |
473 selection.computeBytes(onBytes); | 468 selection.computeBytes(onBytes); |
474 this.updatePreviewPanelText_(); | 469 this.updatePreviewPanelText_(); |
mtomasz
2013/01/15 01:41:08
Here.
| |
475 | 470 |
476 // Inform tests it's OK to click buttons now. | 471 // Inform tests it's OK to click buttons now. |
477 chrome.test.sendMessage('selection-change-complete'); | 472 chrome.test.sendMessage('selection-change-complete'); |
478 | 473 |
479 // Show thumbnails. | 474 // Show thumbnails. |
480 this.showPreviewThumbnails_(selection); | 475 this.showPreviewThumbnails_(selection); |
481 }; | 476 }; |
482 | 477 |
483 /** | 478 /** |
484 * Renders preview thumbnails in preview panel. | 479 * Renders preview thumbnails in preview panel. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 style.left = (boxWidth - imageWidth) / 2 + 'px'; | 659 style.left = (boxWidth - imageWidth) / 2 + 'px'; |
665 style.top = (boxHeight - imageHeight) / 2 + 'px'; | 660 style.top = (boxHeight - imageHeight) / 2 + 'px'; |
666 style.position = 'relative'; | 661 style.position = 'relative'; |
667 | 662 |
668 util.applyTransform(largeImage, transform); | 663 util.applyTransform(largeImage, transform); |
669 | 664 |
670 largeImageBox.appendChild(largeImage); | 665 largeImageBox.appendChild(largeImage); |
671 largeImageBox.style.zIndex = 1000; | 666 largeImageBox.style.zIndex = 1000; |
672 return true; | 667 return true; |
673 }; | 668 }; |
OLD | NEW |