| 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. This is used to notify events of showing or hiding | |
| 24 * dialog to file manager. | |
| 25 * | |
| 26 * @type {FileManager} | |
| 27 * @private | |
| 28 */ | |
| 29 FileManagerDialogBase.fileManager_ = null; | |
| 30 | |
| 31 /** | |
| 32 * Setter of FileManagerDialogBase.fileManager_. | |
| 33 * @param {FileManager} fileManager The fileManager object. | |
| 34 */ | |
| 35 FileManagerDialogBase.setFileManager = function(fileManager) { | |
| 36 FileManagerDialogBase.fileManager_ = fileManager; | |
| 37 }; | |
| 38 | |
| 39 /** | |
| 40 * The flag if any dialog is shown. True if a dialog is visible, false | |
| 41 * otherwise. | |
| 42 * @type {boolean} | |
| 43 */ | |
| 44 FileManagerDialogBase.shown = false; | |
| 45 | |
| 46 /** | |
| 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. | |
| 53 */ | |
| 54 FileManagerDialogBase.prototype.showOkCancelDialog = function( | |
| 55 title, message, onOk, onCancel) { | |
| 56 return this.showImpl_(title, message, onOk, onCancel); | |
| 57 }; | |
| 58 | |
| 59 /** | |
| 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. | |
| 66 * @private | |
| 67 */ | |
| 68 FileManagerDialogBase.prototype.showImpl_ = function( | |
| 69 title, message, onOk, onCancel) { | |
| 70 if (FileManagerDialogBase.shown) | |
| 71 return false; | |
| 72 | |
| 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); | |
| 78 | |
| 79 return true; | |
| 80 }; | |
| 81 | |
| 82 /** | |
| 83 * @return {boolean} True if the dialog can show successfully. False if the | |
| 84 * dialog failed to show due to an existing dialog. | |
| 85 */ | |
| 86 FileManagerDialogBase.prototype.showBlankDialog = function() { | |
| 87 return this.showImpl_('', '', null, null, null); | |
| 88 }; | |
| 89 | |
| 90 /** | |
| 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. | |
| 94 */ | |
| 95 FileManagerDialogBase.prototype.showTitleOnlyDialog = function(title) { | |
| 96 return this.showImpl_(title, '', null, null, null); | |
| 97 }; | |
| 98 | |
| 99 /** | |
| 100 * @param {function()=} opt_onHide Called when the dialog is hidden. | |
| 101 */ | |
| 102 FileManagerDialogBase.prototype.hide = function(opt_onHide) { | |
| 103 cr.ui.dialogs.BaseDialog.prototype.hide.call( | |
| 104 this, | |
| 105 function() { | |
| 106 if (opt_onHide) | |
| 107 opt_onHide(); | |
| 108 if (FileManagerDialogBase.fileManager_) | |
| 109 FileManagerDialogBase.fileManager_.onDialogShownOrHidden(false); | |
| 110 FileManagerDialogBase.shown = false; | |
| 111 }); | |
| 112 }; | |
| OLD | NEW |