OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 'use strict'; | |
6 | |
7 /** | |
8 * This class is an extended class, to manage the status of the dialogs. | |
9 * | |
10 * @param {HTMLElement} parentNode Parent node of the dialog. | |
11 * @extends {cr.ui.dialogs.FileManagerDialogBase} | |
12 * @constructor | |
13 */ | |
14 var FileManagerDialogBase = function(parentNode) { | |
15 cr.ui.dialogs.BaseDialog.call(this, parentNode); | |
16 }; | |
17 | |
18 FileManagerDialogBase.prototype = { | |
19 __proto__: cr.ui.dialogs.BaseDialog.prototype | |
20 }; | |
21 | |
22 /** | |
23 * The FileManager object. | |
hirono
2013/09/06 08:30:14
nit: Could you please add the description about wh
yoshiki
2013/09/09 01:50:42
Done.
| |
24 * @type {FileManager} | |
25 * @private | |
26 */ | |
27 FileManagerDialogBase.fileManager_ = null; | |
28 | |
29 /** | |
30 * Setter of FileManagerDialogBase.fileManager_. | |
31 * @param {FileManager} fileManager The fileManager object. | |
32 */ | |
33 FileManagerDialogBase.setFileManager = function(fileManager) { | |
34 FileManagerDialogBase.fileManager_ = fileManager; | |
35 }; | |
36 | |
37 /** | |
38 * The flag if any dialog is shown. True if a dialog is visible, false | |
39 * otherwise. | |
40 * @type {boolean} | |
41 */ | |
42 FileManagerDialogBase.shown = false; | |
43 | |
44 /** | |
45 * @param {string} title Title. | |
46 * @param {string} message Message. | |
47 * @param {function()} onOk Called when the OK buttun is pressed. | |
48 * @param {function()} onCancel Called when the cancel button is pressed. | |
49 * @return {boolean} True if the dialog can show successfully. False if the | |
50 * dialog failed to show due to an exisiting dialog. | |
51 */ | |
52 FileManagerDialogBase.prototype.showOkCancelDialog = function( | |
53 title, message, onOk, onCancel) { | |
54 return this.showImpl_(title, message, onOk, onCancel); | |
55 }; | |
56 | |
57 /** | |
58 * @param {string} title Title. | |
59 * @param {string} message Message. | |
60 * @param {function()} onOk Called when the OK buttun is pressed. | |
61 * @param {function()} onCancel Called when the cancel button is pressed. | |
62 * @return {boolean} True if the dialog can show successfully. False if the | |
63 * dialog failed to show due to an exisiting dialog. | |
64 * @private | |
65 */ | |
66 FileManagerDialogBase.prototype.showImpl_ = function( | |
67 title, message, onOk, onCancel) { | |
68 if (FileManagerDialogBase.shown) | |
69 return false; | |
70 | |
71 FileManagerDialogBase.shown = true; | |
72 if (FileManagerDialogBase.fileManager_) | |
73 FileManagerDialogBase.fileManager_.onDialogShownOrHidden(true); | |
74 cr.ui.dialogs.BaseDialog.prototype.showWithTitle.call( | |
75 this, title, message, onOk, onCancel, null); | |
76 | |
77 return true; | |
78 }; | |
79 | |
80 /** | |
81 * @return {boolean} True if the dialog can show successfully. False if the | |
82 * dialog failed to show due to an exisiting dialog. | |
83 */ | |
84 FileManagerDialogBase.prototype.showBlankDialog = function() { | |
85 return this.showImpl_('', '', null, null, null); | |
86 }; | |
87 | |
88 /** | |
89 * @param {string} title Title. | |
90 * @return {boolean} True if the dialog can show successfully. False if the | |
91 * dialog failed to show due to an exisiting dialog. | |
92 */ | |
93 FileManagerDialogBase.prototype.showTitleOnlyDialog = function(title) { | |
94 return this.showImpl_(title, '', null, null, null); | |
95 }; | |
96 | |
97 /** | |
98 * @param {function()=} opt_onHide Called when the dialog is hidden. | |
99 */ | |
100 FileManagerDialogBase.prototype.hide = function(opt_onHide) { | |
101 cr.ui.dialogs.BaseDialog.prototype.hide.call( | |
102 this, | |
103 function() { | |
104 if (opt_onHide) | |
105 opt_onHide(); | |
106 if (FileManagerDialogBase.fileManager_) | |
107 FileManagerDialogBase.fileManager_.onDialogShownOrHidden(false); | |
108 FileManagerDialogBase.shown = false; | |
109 }); | |
110 }; | |
OLD | NEW |