| 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 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * FileManager constructor. | 8 * FileManager constructor. |
| 9 * | 9 * |
| 10 * FileManager objects encapsulate the functionality of the file selector | 10 * FileManager objects encapsulate the functionality of the file selector |
| (...skipping 3531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3542 if (!this.isOnDrive()) | 3542 if (!this.isOnDrive()) |
| 3543 return; | 3543 return; |
| 3544 | 3544 |
| 3545 // Remember the most recent query. If there is an other request in progress, | 3545 // Remember the most recent query. If there is an other request in progress, |
| 3546 // then it's result will be discarded and it will call a new request for | 3546 // then it's result will be discarded and it will call a new request for |
| 3547 // this query. | 3547 // this query. |
| 3548 this.lastAutocompleteQuery_ = query; | 3548 this.lastAutocompleteQuery_ = query; |
| 3549 if (this.autocompleteSuggestionsBusy_) | 3549 if (this.autocompleteSuggestionsBusy_) |
| 3550 return; | 3550 return; |
| 3551 | 3551 |
| 3552 // The autocomplete list should be resized and repositioned here as the | |
| 3553 // search box is resized when it's focused. | |
| 3554 this.autocompleteList_.syncWidthAndPositionToInput(); | |
| 3555 | |
| 3556 if (!query) { | 3552 if (!query) { |
| 3557 this.autocompleteList_.suggestions = []; | 3553 this.autocompleteList_.suggestions = []; |
| 3558 return; | 3554 return; |
| 3559 } | 3555 } |
| 3560 | 3556 |
| 3561 var headerItem = {isHeaderItem: true, searchQuery: query}; | 3557 var headerItem = {isHeaderItem: true, searchQuery: query}; |
| 3562 if (!this.autocompleteList_.dataModel || | 3558 if (!this.autocompleteList_.dataModel || |
| 3563 this.autocompleteList_.dataModel.length == 0) | 3559 this.autocompleteList_.dataModel.length == 0) |
| 3564 this.autocompleteList_.suggestions = [headerItem]; | 3560 this.autocompleteList_.suggestions = [headerItem]; |
| 3565 else | 3561 else |
| 3566 // Updates only the head item to prevent a flickering on typing. | 3562 // Updates only the head item to prevent a flickering on typing. |
| 3567 this.autocompleteList_.dataModel.splice(0, 1, headerItem); | 3563 this.autocompleteList_.dataModel.splice(0, 1, headerItem); |
| 3568 | 3564 |
| 3565 // The autocomplete list should be resized and repositioned here as the |
| 3566 // search box is resized when it's focused. |
| 3567 this.autocompleteList_.syncWidthAndPositionToInput(); |
| 3568 |
| 3569 this.autocompleteSuggestionsBusy_ = true; | 3569 this.autocompleteSuggestionsBusy_ = true; |
| 3570 | 3570 |
| 3571 var searchParams = { | 3571 var searchParams = { |
| 3572 'query': query, | 3572 'query': query, |
| 3573 'types': 'ALL', | 3573 'types': 'ALL', |
| 3574 'maxResults': 4 | 3574 'maxResults': 4 |
| 3575 }; | 3575 }; |
| 3576 chrome.fileBrowserPrivate.searchDriveMetadata( | 3576 chrome.fileBrowserPrivate.searchDriveMetadata( |
| 3577 searchParams, | 3577 searchParams, |
| 3578 function(suggestions) { | 3578 function(suggestions) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3759 callback(this.preferences_); | 3759 callback(this.preferences_); |
| 3760 return; | 3760 return; |
| 3761 } | 3761 } |
| 3762 | 3762 |
| 3763 chrome.fileBrowserPrivate.getPreferences(function(prefs) { | 3763 chrome.fileBrowserPrivate.getPreferences(function(prefs) { |
| 3764 this.preferences_ = prefs; | 3764 this.preferences_ = prefs; |
| 3765 callback(prefs); | 3765 callback(prefs); |
| 3766 }.bind(this)); | 3766 }.bind(this)); |
| 3767 }; | 3767 }; |
| 3768 })(); | 3768 })(); |
| OLD | NEW |