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 * This variable is checked in SelectFileDialogExtensionBrowserTest. | 8 * This variable is checked in SelectFileDialogExtensionBrowserTest. |
9 * @type {number} | 9 * @type {number} |
10 */ | 10 */ |
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 // | 892 // |
893 // 1) The user selects an item A with up/down keys (item A is highlighted) | 893 // 1) The user selects an item A with up/down keys (item A is highlighted) |
894 // 2) Then the user moves the cursor to another item B | 894 // 2) Then the user moves the cursor to another item B |
895 // | 895 // |
896 // If we just change the color of moused over element (item B), both | 896 // If we just change the color of moused over element (item B), both |
897 // the item A and B are highlighted. This is bad. We should change the | 897 // the item A and B are highlighted. This is bad. We should change the |
898 // selection so only the item B is highlighted. | 898 // selection so only the item B is highlighted. |
899 if (event.target.itemInfo) | 899 if (event.target.itemInfo) |
900 autocompleteList.selectedItem = event.target.itemInfo; | 900 autocompleteList.selectedItem = event.target.itemInfo; |
901 }.bind(this)); | 901 }.bind(this)); |
902 autocompleteList.attachToInput = function(input) { | |
yoshiki
2013/05/10 06:06:15
Ideally, it's better to create a separate class wh
hirono
2013/05/13 08:14:14
I just removed these codes.
| |
903 cr.ui.AutocompleteList.prototype.attachToInput.call(this, input); | |
904 this.shiftPosition(16); | |
905 }; | |
906 autocompleteList.syncWidthAndPositionToInput = function() { | |
907 cr.ui.AutocompleteList.prototype.syncWidthAndPositionToInput.call(this); | |
908 this.shiftPosition(16); | |
909 }; | |
910 autocompleteList.shiftPosition = function(offset) { | |
911 var leftNumber = parseInt(this.style.left.replace(/[^0-9]/g, '')); | |
912 this.style.left = (leftNumber + offset) + 'px'; | |
yoshiki
2013/05/10 06:06:15
This seems hacky. How about adding a CSS class to
hirono
2013/05/13 08:14:14
Done.
| |
913 }; | |
902 | 914 |
903 var container = this.document_.querySelector('.dialog-header'); | 915 var container = this.document_.querySelector('.dialog-header'); |
904 container.appendChild(autocompleteList); | 916 container.appendChild(autocompleteList); |
905 this.autocompleteList_ = autocompleteList; | 917 this.autocompleteList_ = autocompleteList; |
906 | 918 |
907 this.searchBox_.addEventListener('focus', function(event) { | 919 this.searchBox_.addEventListener('focus', function(event) { |
908 this.autocompleteList_.attachToInput(this.searchBox_); | 920 this.autocompleteList_.attachToInput(this.searchBox_); |
909 }.bind(this)); | 921 }.bind(this)); |
910 this.searchBox_.addEventListener('blur', function(event) { | 922 this.searchBox_.addEventListener('blur', function(event) { |
911 this.autocompleteList_.detach(); | 923 this.autocompleteList_.detach(); |
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2174 var rootPath = PathUtil.getRootPath(path); | 2186 var rootPath = PathUtil.getRootPath(path); |
2175 this.document_.title = PathUtil.getRootLabel(rootPath) + | 2187 this.document_.title = PathUtil.getRootLabel(rootPath) + |
2176 path.substring(rootPath.length); | 2188 path.substring(rootPath.length); |
2177 }; | 2189 }; |
2178 | 2190 |
2179 /** | 2191 /** |
2180 * Updates search box value when directory gets changed. | 2192 * Updates search box value when directory gets changed. |
2181 * @private | 2193 * @private |
2182 */ | 2194 */ |
2183 FileManager.prototype.updateSearchBoxOnDirChange_ = function() { | 2195 FileManager.prototype.updateSearchBoxOnDirChange_ = function() { |
2184 if (!this.searchBox_.disabled) | 2196 if (!this.searchBox_.disabled) { |
2185 this.searchBox_.value = ''; | 2197 this.searchBox_.value = ''; |
2198 this.updateSearchBoxClass_(); | |
2199 } | |
2186 }; | 2200 }; |
2187 | 2201 |
2188 /** | 2202 /** |
2189 * Update the gear menu. | 2203 * Update the gear menu. |
2190 * @private | 2204 * @private |
2191 */ | 2205 */ |
2192 FileManager.prototype.updateGearMenu_ = function() { | 2206 FileManager.prototype.updateGearMenu_ = function() { |
2193 var hideItemsForDrive = !this.isOnDrive(); | 2207 var hideItemsForDrive = !this.isOnDrive(); |
2194 this.syncButton.hidden = hideItemsForDrive; | 2208 this.syncButton.hidden = hideItemsForDrive; |
2195 this.hostedButton.hidden = hideItemsForDrive; | 2209 this.hostedButton.hidden = hideItemsForDrive; |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3247 | 3261 |
3248 /** | 3262 /** |
3249 * Invoked when the search box is changed. | 3263 * Invoked when the search box is changed. |
3250 * | 3264 * |
3251 * @param {Event} event The 'changed' event. | 3265 * @param {Event} event The 'changed' event. |
3252 * @private | 3266 * @private |
3253 */ | 3267 */ |
3254 FileManager.prototype.onSearchBoxUpdate_ = function(event) { | 3268 FileManager.prototype.onSearchBoxUpdate_ = function(event) { |
3255 var searchString = this.searchBox_.value; | 3269 var searchString = this.searchBox_.value; |
3256 | 3270 |
3271 this.updateSearchBoxClass_(); | |
3257 if (this.isOnDrive()) { | 3272 if (this.isOnDrive()) { |
3258 // When the search text is changed, finishes the search and showes back | 3273 // When the search text is changed, finishes the search and showes back |
3259 // the last directory by passing an empty string to | 3274 // the last directory by passing an empty string to |
3260 // {@code DirectoryModel.search()}. | 3275 // {@code DirectoryModel.search()}. |
3261 if (this.directoryModel_.isSearching() && | 3276 if (this.directoryModel_.isSearching() && |
3262 this.lastSearchQuery_ != searchString) { | 3277 this.lastSearchQuery_ != searchString) { |
3263 this.doSearch(''); | 3278 this.doSearch(''); |
3264 } | 3279 } |
3265 | 3280 |
3266 // On drive, incremental search is not invoked since we have an auto- | 3281 // On drive, incremental search is not invoked since we have an auto- |
3267 // complete suggestion instead. | 3282 // complete suggestion instead. |
3268 return; | 3283 return; |
3269 } | 3284 } |
3270 | 3285 |
3271 this.search_(searchString); | 3286 this.search_(searchString); |
3272 }; | 3287 }; |
3273 | 3288 |
3274 /** | 3289 /** |
3290 * Updates search box's CSS classes. | |
3291 * These classes are refered from CSS. | |
3292 * | |
3293 * @private | |
3294 */ | |
3295 FileManager.prototype.updateSearchBoxClass_ = function() { | |
3296 if (this.searchBox_.value) { | |
yoshiki
2013/05/10 06:06:15
nit: Remove braces.
hirono
2013/05/13 08:14:14
I removed the if statement.
| |
3297 this.searchBox_.classList.add('has-text'); | |
3298 } else { | |
3299 this.searchBox_.classList.remove('has-text'); | |
3300 } | |
3301 }; | |
3302 | |
3303 /** | |
3275 * Search files and update the list with the search result. | 3304 * Search files and update the list with the search result. |
3276 * | 3305 * |
3277 * @param {string} searchString String to be searched with. | 3306 * @param {string} searchString String to be searched with. |
3278 * @private | 3307 * @private |
3279 */ | 3308 */ |
3280 FileManager.prototype.search_ = function(searchString) { | 3309 FileManager.prototype.search_ = function(searchString) { |
3281 var noResultsDiv = this.document_.getElementById('no-search-results'); | 3310 var noResultsDiv = this.document_.getElementById('no-search-results'); |
3282 | 3311 |
3283 var reportEmptySearchResults = function() { | 3312 var reportEmptySearchResults = function() { |
3284 if (this.directoryModel_.getFileList().length === 0) { | 3313 if (this.directoryModel_.getFileList().length === 0) { |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3649 * Set the flag expressing whether the ctrl key is pressed or not. | 3678 * Set the flag expressing whether the ctrl key is pressed or not. |
3650 * @param {boolean} flag New value of the flag | 3679 * @param {boolean} flag New value of the flag |
3651 * @private | 3680 * @private |
3652 */ | 3681 */ |
3653 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3682 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
3654 this.ctrlKeyPressed_ = flag; | 3683 this.ctrlKeyPressed_ = flag; |
3655 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange(); | 3684 this.document_.querySelector('#drive-clear-local-cache').canExecuteChange(); |
3656 this.document_.querySelector('#drive-reload').canExecuteChange(); | 3685 this.document_.querySelector('#drive-reload').canExecuteChange(); |
3657 }; | 3686 }; |
3658 })(); | 3687 })(); |
OLD | NEW |