| 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 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 * @private | 793 * @private |
| 794 */ | 794 */ |
| 795 FileManager.prototype.initDialogs_ = function() { | 795 FileManager.prototype.initDialogs_ = function() { |
| 796 var d = cr.ui.dialogs; | 796 var d = cr.ui.dialogs; |
| 797 d.BaseDialog.OK_LABEL = str('OK_LABEL'); | 797 d.BaseDialog.OK_LABEL = str('OK_LABEL'); |
| 798 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); | 798 d.BaseDialog.CANCEL_LABEL = str('CANCEL_LABEL'); |
| 799 this.error = new ErrorDialog(this.dialogDom_); | 799 this.error = new ErrorDialog(this.dialogDom_); |
| 800 this.alert = new d.AlertDialog(this.dialogDom_); | 800 this.alert = new d.AlertDialog(this.dialogDom_); |
| 801 this.confirm = new d.ConfirmDialog(this.dialogDom_); | 801 this.confirm = new d.ConfirmDialog(this.dialogDom_); |
| 802 this.prompt = new d.PromptDialog(this.dialogDom_); | 802 this.prompt = new d.PromptDialog(this.dialogDom_); |
| 803 |
| 804 FileManagerDialogBase.setFileManager(this); |
| 803 this.shareDialog_ = new ShareDialog(this.dialogDom_); | 805 this.shareDialog_ = new ShareDialog(this.dialogDom_); |
| 804 this.defaultTaskPicker = | 806 this.defaultTaskPicker = |
| 805 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); | 807 new cr.filebrowser.DefaultActionDialog(this.dialogDom_); |
| 806 this.suggestAppsDialog = | 808 this.suggestAppsDialog = |
| 807 new SuggestAppsDialog(this.dialogDom_); | 809 new SuggestAppsDialog(this.dialogDom_); |
| 808 }; | 810 }; |
| 809 | 811 |
| 810 /** | 812 /** |
| 811 * One-time initialization of various DOM nodes. Loads the additional DOM | 813 * One-time initialization of various DOM nodes. Loads the additional DOM |
| 812 * elements visible to the user. Initialize here elements, which are expensive | 814 * elements visible to the user. Initialize here elements, which are expensive |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2106 * Shows the share dialog for the selected file or directory. | 2108 * Shows the share dialog for the selected file or directory. |
| 2107 */ | 2109 */ |
| 2108 FileManager.prototype.shareSelection = function() { | 2110 FileManager.prototype.shareSelection = function() { |
| 2109 var entries = this.getSelection().entries; | 2111 var entries = this.getSelection().entries; |
| 2110 if (entries.length != 1) { | 2112 if (entries.length != 1) { |
| 2111 console.warn('Unable to share multiple items at once.'); | 2113 console.warn('Unable to share multiple items at once.'); |
| 2112 return; | 2114 return; |
| 2113 } | 2115 } |
| 2114 // Add the overlapped class to prevent the applicaiton window from | 2116 // Add the overlapped class to prevent the applicaiton window from |
| 2115 // captureing mouse events. | 2117 // captureing mouse events. |
| 2116 this.enableDragOnTitleArea_(false); | |
| 2117 this.shareDialog_.show(entries[0], function(result) { | 2118 this.shareDialog_.show(entries[0], function(result) { |
| 2118 this.enableDragOnTitleArea_(true); | |
| 2119 if (result == ShareDialog.Result.NETWORK_ERROR) | 2119 if (result == ShareDialog.Result.NETWORK_ERROR) |
| 2120 this.error.show(str('SHARE_ERROR')); | 2120 this.error.show(str('SHARE_ERROR')); |
| 2121 }.bind(this)); | 2121 }.bind(this)); |
| 2122 }; | 2122 }; |
| 2123 | 2123 |
| 2124 /** | 2124 /** |
| 2125 * Creates a folder shortcut. | 2125 * Creates a folder shortcut. |
| 2126 * @param {string} path A shortcut which refers to |path| to be created. | 2126 * @param {string} path A shortcut which refers to |path| to be created. |
| 2127 */ | 2127 */ |
| 2128 FileManager.prototype.createFolderShortcut = function(path) { | 2128 FileManager.prototype.createFolderShortcut = function(path) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 onFailure(); | 2326 onFailure(); |
| 2327 break; | 2327 break; |
| 2328 default: | 2328 default: |
| 2329 onCancelled(); | 2329 onCancelled(); |
| 2330 } | 2330 } |
| 2331 }); | 2331 }); |
| 2332 }.bind(this)); | 2332 }.bind(this)); |
| 2333 }; | 2333 }; |
| 2334 | 2334 |
| 2335 /** | 2335 /** |
| 2336 * Set a flag to show whether users can drag on the title area or not. | 2336 * Called when a dialog is shown or hidden. |
| 2337 * @param {boolean} flag True if users can drag on the title area. | 2337 * @param {boolean} flag True if a dialog is shown, false if hidden. */ |
| 2338 * @private | 2338 FileManager.prototype.onDialogShownOrHidden = function(show) { |
| 2339 */ | 2339 // Set/unset a flag to disable dragging on the title area. |
| 2340 FileManager.prototype.enableDragOnTitleArea_ = function(flag) { | 2340 this.dialogContainer_.classList.toggle('disable-header-drag', show); |
| 2341 this.dialogContainer_.classList.toggle('disable-header-drag', !flag); | |
| 2342 }; | 2341 }; |
| 2343 | 2342 |
| 2344 /** | 2343 /** |
| 2345 * Executes directory action (i.e. changes directory). | 2344 * Executes directory action (i.e. changes directory). |
| 2346 * | 2345 * |
| 2347 * @param {DirectoryEntry} entry Directory entry to which directory should be | 2346 * @param {DirectoryEntry} entry Directory entry to which directory should be |
| 2348 * changed. | 2347 * changed. |
| 2349 * @private | 2348 * @private |
| 2350 */ | 2349 */ |
| 2351 FileManager.prototype.onDirectoryAction_ = function(entry) { | 2350 FileManager.prototype.onDirectoryAction_ = function(entry) { |
| (...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3772 defaultIndex = i; | 3771 defaultIndex = i; |
| 3773 } | 3772 } |
| 3774 var item = { | 3773 var item = { |
| 3775 id: actions[i].id, | 3774 id: actions[i].id, |
| 3776 label: title, | 3775 label: title, |
| 3777 class: actions[i].class, | 3776 class: actions[i].class, |
| 3778 iconUrl: actions[i].icon100 | 3777 iconUrl: actions[i].icon100 |
| 3779 }; | 3778 }; |
| 3780 items.push(item); | 3779 items.push(item); |
| 3781 } | 3780 } |
| 3782 this.defaultTaskPicker.show( | 3781 var show = this.defaultTaskPicker.showOkCancelDialog( |
| 3783 str('CHANGE_DEFAULT_APP_BUTTON_LABEL'), | 3782 str('CHANGE_DEFAULT_APP_BUTTON_LABEL'), |
| 3784 '', | 3783 '', |
| 3785 items, | 3784 items, |
| 3786 defaultIndex, | 3785 defaultIndex, |
| 3787 function(action) { | 3786 function(action) { |
| 3788 ActionChoiceUtil.setRememberedActionId(action.id); | 3787 ActionChoiceUtil.setRememberedActionId(action.id); |
| 3789 }); | 3788 }); |
| 3789 if (!show) |
| 3790 console.error('DefaultTaskPicker can\'t be shown.'); |
| 3790 }.bind(this); | 3791 }.bind(this); |
| 3791 | 3792 |
| 3792 ActionChoiceUtil.getDefinedActions(loadTimeData, function(actions) { | 3793 ActionChoiceUtil.getDefinedActions(loadTimeData, function(actions) { |
| 3793 ActionChoiceUtil.getRememberedActionId(function(actionId) { | 3794 ActionChoiceUtil.getRememberedActionId(function(actionId) { |
| 3794 onActionsReady(actions, actionId); | 3795 onActionsReady(actions, actionId); |
| 3795 }); | 3796 }); |
| 3796 }); | 3797 }); |
| 3797 }; | 3798 }; |
| 3798 | 3799 |
| 3799 FileManager.prototype.decorateSplitter = function(splitterElement) { | 3800 FileManager.prototype.decorateSplitter = function(splitterElement) { |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3924 */ | 3925 */ |
| 3925 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { | 3926 FileManager.prototype.setCtrlKeyPressed_ = function(flag) { |
| 3926 this.ctrlKeyPressed_ = flag; | 3927 this.ctrlKeyPressed_ = flag; |
| 3927 // Before the DOM is constructed, the key event can be handled. | 3928 // Before the DOM is constructed, the key event can be handled. |
| 3928 var cacheClearCommand = | 3929 var cacheClearCommand = |
| 3929 this.document_.querySelector('#drive-clear-local-cache'); | 3930 this.document_.querySelector('#drive-clear-local-cache'); |
| 3930 if (cacheClearCommand) | 3931 if (cacheClearCommand) |
| 3931 cacheClearCommand.canExecuteChange(); | 3932 cacheClearCommand.canExecuteChange(); |
| 3932 }; | 3933 }; |
| 3933 })(); | 3934 })(); |
| OLD | NEW |