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.
8 * This class is an extended class, to manage the status of the dialogs.
10 * @param {HTMLElement} parentNode Parent node of the dialog.
11 * @extends {cr.ui.dialogs.FileManagerDialogBase}
14 var FileManagerDialogBase = function(parentNode) {
15 cr.ui.dialogs.BaseDialog.call(this, parentNode);
18 FileManagerDialogBase.prototype = {
19 __proto__: cr.ui.dialogs.BaseDialog.prototype
23 * The FileManager object. This is used to notify events of showing or hiding
24 * dialog to file manager.
29 FileManagerDialogBase.fileManager_ = null;
32 * Setter of FileManagerDialogBase.fileManager_.
33 * @param {FileManager} fileManager The fileManager object.
35 FileManagerDialogBase.setFileManager = function(fileManager) {
36 FileManagerDialogBase.fileManager_ = fileManager;
40 * The flag if any dialog is shown. True if a dialog is visible, false
44 FileManagerDialogBase.shown = false;
47 * @param {string} title Title.
48 * @param {string} message Message.
49 * @param {function()} onOk Called when the OK button is pressed.
50 * @param {function()} onCancel Called when the cancel button is pressed.
51 * @return {boolean} True if the dialog can show successfully. False if the
52 * dialog failed to show due to an existing dialog.
54 FileManagerDialogBase.prototype.showOkCancelDialog = function(
55 title, message, onOk, onCancel) {
56 return this.showImpl_(title, message, onOk, onCancel);
60 * @param {string} title Title.
61 * @param {string} message Message.
62 * @param {function()} onOk Called when the OK button is pressed.
63 * @param {function()} onCancel Called when the cancel button is pressed.
64 * @return {boolean} True if the dialog can show successfully. False if the
65 * dialog failed to show due to an existing dialog.
68 FileManagerDialogBase.prototype.showImpl_ = function(
69 title, message, onOk, onCancel) {
70 if (FileManagerDialogBase.shown)
73 FileManagerDialogBase.shown = true;
74 if (FileManagerDialogBase.fileManager_)
75 FileManagerDialogBase.fileManager_.onDialogShownOrHidden(true);
76 cr.ui.dialogs.BaseDialog.prototype.showWithTitle.call(
77 this, title, message, onOk, onCancel, null);
83 * @return {boolean} True if the dialog can show successfully. False if the
84 * dialog failed to show due to an existing dialog.
86 FileManagerDialogBase.prototype.showBlankDialog = function() {
87 return this.showImpl_('', '', null, null, null);
91 * @param {string} title Title.
92 * @return {boolean} True if the dialog can show successfully. False if the
93 * dialog failed to show due to an existing dialog.
95 FileManagerDialogBase.prototype.showTitleOnlyDialog = function(title) {
96 return this.showImpl_(title, '', null, null, null);
100 * @param {string} title Title.
101 * @param {string} text Text to be shown in the dialog.
102 * @return {boolean} True if the dialog can show successfully. False if the
103 * dialog failed to show due to an existing dialog.
105 FileManagerDialogBase.prototype.showTitleAndTextDialog = function(title, text) {
106 this.buttons.style.display = 'none';
107 return this.showImpl_(title, text, null, null, null);
111 * @param {function()=} opt_onHide Called when the dialog is hidden.
113 FileManagerDialogBase.prototype.hide = function(opt_onHide) {
114 cr.ui.dialogs.BaseDialog.prototype.hide.call(
119 if (FileManagerDialogBase.fileManager_)
120 FileManagerDialogBase.fileManager_.onDialogShownOrHidden(false);
121 FileManagerDialogBase.shown = false;