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 2286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2297 // React on double click, but only if both clicks hit the same item. | 2297 // React on double click, but only if both clicks hit the same item. |
2298 // TODO(mtomasz): Simplify it, and use a double click handler if possible. | 2298 // TODO(mtomasz): Simplify it, and use a double click handler if possible. |
2299 var clickNumber = (this.lastClickedItem_ == listItem) ? 2 : undefined; | 2299 var clickNumber = (this.lastClickedItem_ == listItem) ? 2 : undefined; |
2300 this.lastClickedItem_ = listItem; | 2300 this.lastClickedItem_ = listItem; |
2301 | 2301 |
2302 if (event.detail != clickNumber) | 2302 if (event.detail != clickNumber) |
2303 return; | 2303 return; |
2304 | 2304 |
2305 var entry = selection.entries[0]; | 2305 var entry = selection.entries[0]; |
2306 if (entry.isDirectory) { | 2306 if (entry.isDirectory) { |
2307 this.onDirectoryAction(entry); | 2307 this.onDirectoryAction_(entry); |
2308 } else { | 2308 } else { |
2309 this.dispatchSelectionAction_(); | 2309 this.dispatchSelectionAction_(); |
2310 } | 2310 } |
2311 }; | 2311 }; |
2312 | 2312 |
2313 /** | 2313 /** |
2314 * @private | 2314 * @private |
2315 */ | 2315 */ |
2316 FileManager.prototype.dispatchSelectionAction_ = function() { | 2316 FileManager.prototype.dispatchSelectionAction_ = function() { |
2317 if (this.dialogType == DialogType.FULL_PAGE) { | 2317 if (this.dialogType == DialogType.FULL_PAGE) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2404 onCancelled(); | 2404 onCancelled(); |
2405 }); | 2405 }); |
2406 }.bind(this)); | 2406 }.bind(this)); |
2407 }; | 2407 }; |
2408 | 2408 |
2409 /** | 2409 /** |
2410 * Executes directory action (i.e. changes directory). | 2410 * Executes directory action (i.e. changes directory). |
2411 * | 2411 * |
2412 * @param {DirectoryEntry} entry Directory entry to which directory should be | 2412 * @param {DirectoryEntry} entry Directory entry to which directory should be |
2413 * changed. | 2413 * changed. |
| 2414 * @private |
2414 */ | 2415 */ |
2415 FileManager.prototype.onDirectoryAction = function(entry) { | 2416 FileManager.prototype.onDirectoryAction_ = function(entry) { |
2416 return this.directoryModel_.changeDirectory(entry.fullPath); | 2417 return this.directoryModel_.changeDirectory(entry.fullPath); |
2417 }; | 2418 }; |
2418 | 2419 |
2419 /** | 2420 /** |
2420 * Update the window title. | 2421 * Update the window title. |
2421 * @private | 2422 * @private |
2422 */ | 2423 */ |
2423 FileManager.prototype.updateTitle_ = function() { | 2424 FileManager.prototype.updateTitle_ = function() { |
2424 if (this.dialogType != DialogType.FULL_PAGE) | 2425 if (this.dialogType != DialogType.FULL_PAGE) |
2425 return; | 2426 return; |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3082 break; | 3083 break; |
3083 | 3084 |
3084 case '13': // Enter => Change directory or perform default action. | 3085 case '13': // Enter => Change directory or perform default action. |
3085 // TODO(dgozman): move directory action to dispatchSelectionAction. | 3086 // TODO(dgozman): move directory action to dispatchSelectionAction. |
3086 var selection = this.getSelection(); | 3087 var selection = this.getSelection(); |
3087 if (selection.totalCount == 1 && | 3088 if (selection.totalCount == 1 && |
3088 selection.entries[0].isDirectory && | 3089 selection.entries[0].isDirectory && |
3089 this.dialogType != DialogType.SELECT_FOLDER && | 3090 this.dialogType != DialogType.SELECT_FOLDER && |
3090 this.dialogType != DialogType.SELECT_UPLOAD_FOLDER) { | 3091 this.dialogType != DialogType.SELECT_UPLOAD_FOLDER) { |
3091 event.preventDefault(); | 3092 event.preventDefault(); |
3092 this.onDirectoryAction(selection.entries[0]); | 3093 this.onDirectoryAction_(selection.entries[0]); |
3093 } else if (this.dispatchSelectionAction_()) { | 3094 } else if (this.dispatchSelectionAction_()) { |
3094 event.preventDefault(); | 3095 event.preventDefault(); |
3095 } | 3096 } |
3096 break; | 3097 break; |
3097 } | 3098 } |
3098 | 3099 |
3099 switch (event.keyIdentifier) { | 3100 switch (event.keyIdentifier) { |
3100 case 'Home': | 3101 case 'Home': |
3101 case 'End': | 3102 case 'End': |
3102 case 'Up': | 3103 case 'Up': |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3763 if (!selectedItem || selectedItem.isHeaderItem) { | 3764 if (!selectedItem || selectedItem.isHeaderItem) { |
3764 var query = selectedItem ? | 3765 var query = selectedItem ? |
3765 selectedItem.searchQuery : this.searchBox_.value; | 3766 selectedItem.searchQuery : this.searchBox_.value; |
3766 this.search_(query); | 3767 this.search_(query); |
3767 return; | 3768 return; |
3768 } | 3769 } |
3769 | 3770 |
3770 var entry = selectedItem.entry; | 3771 var entry = selectedItem.entry; |
3771 // If the entry is a directory, just change the directory. | 3772 // If the entry is a directory, just change the directory. |
3772 if (entry.isDirectory) { | 3773 if (entry.isDirectory) { |
3773 this.onDirectoryAction(entry); | 3774 this.onDirectoryAction_(entry); |
3774 return; | 3775 return; |
3775 } | 3776 } |
3776 | 3777 |
3777 var urls = [entry.toURL()]; | 3778 var urls = [entry.toURL()]; |
3778 var self = this; | 3779 var self = this; |
3779 | 3780 |
3780 // To open a file, first get the mime type. | 3781 // To open a file, first get the mime type. |
3781 this.metadataCache_.get(urls, 'drive', function(props) { | 3782 this.metadataCache_.get(urls, 'drive', function(props) { |
3782 var mimeType = props[0].contentMimeType || ''; | 3783 var mimeType = props[0].contentMimeType || ''; |
3783 var mimeTypes = [mimeType]; | 3784 var mimeTypes = [mimeType]; |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3987 */ | 3988 */ |
3988 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3989 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
3989 this.ctrlKeyPressed_ = flag; | 3990 this.ctrlKeyPressed_ = flag; |
3990 // Before the DOM is constructed, the key event can be handled. | 3991 // Before the DOM is constructed, the key event can be handled. |
3991 var cacheClearCommand = | 3992 var cacheClearCommand = |
3992 this.document_.querySelector('#drive-clear-local-cache'); | 3993 this.document_.querySelector('#drive-clear-local-cache'); |
3993 if (cacheClearCommand) | 3994 if (cacheClearCommand) |
3994 cacheClearCommand.canExecuteChange(); | 3995 cacheClearCommand.canExecuteChange(); |
3995 }; | 3996 }; |
3996 })(); | 3997 })(); |
OLD | NEW |