Chromium Code Reviews| Index: chrome/browser/resources/file_manager/js/ui/file_manager_dialog_base.js |
| diff --git a/chrome/browser/resources/file_manager/js/ui/file_manager_dialog_base.js b/chrome/browser/resources/file_manager/js/ui/file_manager_dialog_base.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a8e475210c9f86732beec905f20192fa9061e6ad |
| --- /dev/null |
| +++ b/chrome/browser/resources/file_manager/js/ui/file_manager_dialog_base.js |
| @@ -0,0 +1,110 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +'use strict'; |
| + |
| +/** |
| + * This class is an extended class, to manage the status of the dialogs. |
| + * |
| + * @param {HTMLElement} parentNode Parent node of the dialog. |
| + * @extends {cr.ui.dialogs.FileManagerDialogBase} |
| + * @constructor |
| + */ |
| +var FileManagerDialogBase = function(parentNode) { |
| + cr.ui.dialogs.BaseDialog.call(this, parentNode); |
| +}; |
| + |
| +FileManagerDialogBase.prototype = { |
| + __proto__: cr.ui.dialogs.BaseDialog.prototype |
| +}; |
| + |
| +/** |
| + * The FileManager object. |
| + * @type {FileManager} |
| + * @private |
| + */ |
| +FileManagerDialogBase.fileManager_ = null; |
| + |
| +/** |
| + * Setter of FileManagerDialogBase.fileManager_. |
| + * @param {FileManager} fileManager The fileManager object. |
| + */ |
| +FileManagerDialogBase.setFileManager = function(fileManager) { |
| + FileManagerDialogBase.fileManager_ = fileManager; |
| +}; |
| + |
| +/** |
| + * The flag if any dialog is shown. True if a dialog is visible, false |
| + * otherwise. |
| + * @type {boolean} |
| + */ |
| +FileManagerDialogBase.shown = false; |
| + |
| +/** |
| + * @param {string} title Title. |
| + * @param {string} message Message. |
| + * @param {function()} onOk Called when the OK buttun is pressed. |
| + * @param {function()} onCancel Called when the cancel button is pressed. |
| + * @return {boolean} True if the dialog can show successfully. False if the |
| + * dialog failed to show due to an exisiting dialog. |
| + */ |
| +FileManagerDialogBase.prototype.showOkCancelDialog = function( |
| + title, message, onOk, onCancel) { |
| + return this.showImpl_(title, message, onOk, onCancel); |
| +}; |
| + |
| +/** |
| + * @param {string} title Title. |
| + * @param {string} message Message. |
| + * @param {function()} onOk Called when the OK buttun is pressed. |
| + * @param {function()} onCancel Called when the cancel button is pressed. |
| + * @return {boolean} True if the dialog can show successfully. False if the |
| + * dialog failed to show due to an exisiting dialog. |
| + * @private |
| + */ |
| +FileManagerDialogBase.prototype.showImpl_ = function( |
| + title, message, onOk, onCancel) { |
| + if (FileManagerDialogBase.shown) |
| + return false; |
| + |
| + FileManagerDialogBase.shown = true; |
| + if (FileManagerDialogBase.fileManager_) |
| + FileManagerDialogBase.fileManager_.enableDragOnTitleArea_(false); |
|
hirono
2013/09/06 07:09:03
FileManagerDialogBase looks like one of the UI com
yoshiki
2013/09/06 07:48:02
I don't think so. FileManagerDialogBase is the bes
|
| + cr.ui.dialogs.BaseDialog.prototype.showWithTitle.call( |
| + this, title, message, onOk, onCancel, null); |
| + |
| + return true; |
| +}; |
| + |
| +/** |
| + * @return {boolean} True if the dialog can show successfully. False if the |
| + * dialog failed to show due to an exisiting dialog. |
| + */ |
| +FileManagerDialogBase.prototype.showBlankDialog = function() { |
| + return this.showImpl_('', '', null, null, null); |
| +}; |
| + |
| +/** |
| + * @param {string} title Title. |
| + * @return {boolean} True if the dialog can show successfully. False if the |
| + * dialog failed to show due to an exisiting dialog. |
| + */ |
| +FileManagerDialogBase.prototype.showTitleOnlyDialog = function(title) { |
| + return this.showImpl_(title, '', null, null, null); |
| +}; |
| + |
| +/** |
| + * @param {function()=} opt_onHide Called when the dialog is hidden. |
| + */ |
| +FileManagerDialogBase.prototype.hide = function(opt_onHide) { |
| + cr.ui.dialogs.BaseDialog.prototype.hide.call( |
| + this, |
| + function() { |
| + if (opt_onHide) |
| + opt_onHide(); |
| + if (FileManagerDialogBase.fileManager_) |
| + FileManagerDialogBase.fileManager_.enableDragOnTitleArea_(false); |
| + FileManagerDialogBase.shown = false; |
| + }); |
| +}; |