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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 * @private | 784 * @private |
785 */ | 785 */ |
786 FileManager.prototype.initDialogs_ = function() { | 786 FileManager.prototype.initDialogs_ = function() { |
787 var d = cr.ui.dialogs; | 787 var d = cr.ui.dialogs; |
788 d.BaseDialog.OK_LABEL = str('OK_LABEL'); | 788 d.BaseDialog.OK_LABEL = str('OK_LABEL'); |
789 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); | 789 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); |
790 this.error = new ErrorDialog(this.dialogDom_); | 790 this.error = new ErrorDialog(this.dialogDom_); |
791 this.alert = new d.AlertDialog(this.dialogDom_); | 791 this.alert = new d.AlertDialog(this.dialogDom_); |
792 this.confirm = new d.ConfirmDialog(this.dialogDom_); | 792 this.confirm = new d.ConfirmDialog(this.dialogDom_); |
793 this.prompt = new d.PromptDialog(this.dialogDom_); | 793 this.prompt = new d.PromptDialog(this.dialogDom_); |
| 794 |
| 795 FileManagerDialogBase.setFileManager(this); |
794 this.shareDialog_ = new ShareDialog(this.dialogDom_); | 796 this.shareDialog_ = new ShareDialog(this.dialogDom_); |
795 this.defaultTaskPicker = | 797 this.defaultTaskPicker = |
796 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); | 798 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); |
797 this.suggestAppsDialog = | 799 this.suggestAppsDialog = |
798 new SuggestAppsDialog(this.dialogDom_); | 800 new SuggestAppsDialog(this.dialogDom_); |
799 }; | 801 }; |
800 | 802 |
801 /** | 803 /** |
802 * One-time initialization of various DOM nodes. Loads the additional DOM | 804 * One-time initialization of various DOM nodes. Loads the additional DOM |
803 * elements visible to the user. Initialize here elements, which are expensive | 805 * elements visible to the user. Initialize here elements, which are expensive |
(...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 * Shows the share dialog for the selected file or directory. | 2109 * Shows the share dialog for the selected file or directory. |
2108 */ | 2110 */ |
2109 FileManager.prototype.shareSelection = function() { | 2111 FileManager.prototype.shareSelection = function() { |
2110 var entries = this.getSelection().entries; | 2112 var entries = this.getSelection().entries; |
2111 if (entries.length != 1) { | 2113 if (entries.length != 1) { |
2112 console.warn('Unable to share multiple items at once.'); | 2114 console.warn('Unable to share multiple items at once.'); |
2113 return; | 2115 return; |
2114 } | 2116 } |
2115 // Add the overlapped class to prevent the applicaiton window from | 2117 // Add the overlapped class to prevent the applicaiton window from |
2116 // captureing mouse events. | 2118 // captureing mouse events. |
2117 this.enableDragOnTitleArea_(false); | |
2118 this.shareDialog_.show(entries[0], function(result) { | 2119 this.shareDialog_.show(entries[0], function(result) { |
2119 this.enableDragOnTitleArea_(true); | |
2120 if (result == ShareDialog.Result.NETWORK_ERROR) | 2120 if (result == ShareDialog.Result.NETWORK_ERROR) |
2121 this.error.show(str('SHARE_ERROR')); | 2121 this.error.show(str('SHARE_ERROR')); |
2122 }.bind(this)); | 2122 }.bind(this)); |
2123 }; | 2123 }; |
2124 | 2124 |
2125 /** | 2125 /** |
2126 * Folder shared feature is under development and hidden behind flag. This | 2126 * Folder shared feature is under development and hidden behind flag. This |
2127 * method returns if the feature is explicitly enabled by the flag or not. | 2127 * method returns if the feature is explicitly enabled by the flag or not. |
2128 * TODO(yoshiki): Remove this after launching folder feature feature. | 2128 * TODO(yoshiki): Remove this after launching folder feature feature. |
2129 * | 2129 * |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 onFailure(); | 2339 onFailure(); |
2340 break; | 2340 break; |
2341 default: | 2341 default: |
2342 onCancelled(); | 2342 onCancelled(); |
2343 } | 2343 } |
2344 }); | 2344 }); |
2345 }.bind(this)); | 2345 }.bind(this)); |
2346 }; | 2346 }; |
2347 | 2347 |
2348 /** | 2348 /** |
2349 * Set a flag to show whether users can drag on the title area or not. | 2349 * Called when a dialog is shown or hidden. |
2350 * @param {boolean} flag True if users can drag on the title area. | 2350 * @param {boolean} flag True if a dialog is shown, false if hidden. */ |
2351 * @private | 2351 FileManager.prototype.onDialogShownOrHidden = function(show) { |
2352 */ | 2352 // Set/unset a flag to disable dragging on the title area. |
2353 FileManager.prototype.enableDragOnTitleArea_ = function(flag) { | 2353 this.dialogContainer_.classList.toggle('disable-header-drag', show); |
2354 this.dialogContainer_.classList.toggle('disable-header-drag', !flag); | |
2355 }; | 2354 }; |
2356 | 2355 |
2357 /** | 2356 /** |
2358 * Executes directory action (i.e. changes directory). | 2357 * Executes directory action (i.e. changes directory). |
2359 * | 2358 * |
2360 * @param {DirectoryEntry} entry Directory entry to which directory should be | 2359 * @param {DirectoryEntry} entry Directory entry to which directory should be |
2361 * changed. | 2360 * changed. |
2362 * @private | 2361 * @private |
2363 */ | 2362 */ |
2364 FileManager.prototype.onDirectoryAction_ = function(entry) { | 2363 FileManager.prototype.onDirectoryAction_ = function(entry) { |
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3784 defaultIndex = i; | 3783 defaultIndex = i; |
3785 } | 3784 } |
3786 var item = { | 3785 var item = { |
3787 id: actions[i].id, | 3786 id: actions[i].id, |
3788 label: title, | 3787 label: title, |
3789 class: actions[i].class, | 3788 class: actions[i].class, |
3790 iconUrl: actions[i].icon100 | 3789 iconUrl: actions[i].icon100 |
3791 }; | 3790 }; |
3792 items.push(item); | 3791 items.push(item); |
3793 } | 3792 } |
3794 this.defaultTaskPicker.show( | 3793 var show = this.defaultTaskPicker.showOkCancelDialog( |
3795 str('CHANGE_DEFAULT_APP_BUTTON_LABEL'), | 3794 str('CHANGE_DEFAULT_APP_BUTTON_LABEL'), |
3796 '', | 3795 '', |
3797 items, | 3796 items, |
3798 defaultIndex, | 3797 defaultIndex, |
3799 function(action) { | 3798 function(action) { |
3800 ActionChoiceUtil.setRememberedActionId(action.id); | 3799 ActionChoiceUtil.setRememberedActionId(action.id); |
3801 }); | 3800 }); |
| 3801 if (!show) |
| 3802 console.error('DefaultTaskPicker can\'t be shown.'); |
3802 }.bind(this); | 3803 }.bind(this); |
3803 | 3804 |
3804 ActionChoiceUtil.getDefinedActions(loadTimeData, function(actions) { | 3805 ActionChoiceUtil.getDefinedActions(loadTimeData, function(actions) { |
3805 ActionChoiceUtil.getRememberedActionId(function(actionId) { | 3806 ActionChoiceUtil.getRememberedActionId(function(actionId) { |
3806 onActionsReady(actions, actionId); | 3807 onActionsReady(actions, actionId); |
3807 }); | 3808 }); |
3808 }); | 3809 }); |
3809 }; | 3810 }; |
3810 | 3811 |
3811 FileManager.prototype.decorateSplitter = function(splitterElement) { | 3812 FileManager.prototype.decorateSplitter = function(splitterElement) { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3936 */ | 3937 */ |
3937 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3938 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
3938 this.ctrlKeyPressed_ = flag; | 3939 this.ctrlKeyPressed_ = flag; |
3939 // Before the DOM is constructed, the key event can be handled. | 3940 // Before the DOM is constructed, the key event can be handled. |
3940 var cacheClearCommand = | 3941 var cacheClearCommand = |
3941 this.document_.querySelector('#drive-clear-local-cache'); | 3942 this.document_.querySelector('#drive-clear-local-cache'); |
3942 if (cacheClearCommand) | 3943 if (cacheClearCommand) |
3943 cacheClearCommand.canExecuteChange(); | 3944 cacheClearCommand.canExecuteChange(); |
3944 }; | 3945 }; |
3945 })(); | 3946 })(); |
OLD | NEW |