4 * Copyright, Moxiecode Systems AB
5 * Released under LGPL License.
7 * License: http://www.tinymce.com/license
8 * Contributing: http://www.tinymce.com/contributing
12 * This class is used to create MessageBoxes like alerts/confirms etc.
14 * @class tinymce.ui.Window
15 * @extends tinymce.ui.FloatPanel
17 define("tinymce/ui/MessageBox", [
22 var MessageBox = Window.extend({
24 * Constructs a instance with the specified settings.
27 * @param {Object} settings Name/value object with settings.
29 init: function(settings) {
36 containerCls: 'panel',
38 buttons: {type: "button", text: "Ok", action: "ok"},
47 this._super(settings);
52 * Ok buttons constant.
61 * Ok/cancel buttons constant.
65 * @field {Number} OK_CANCEL
70 * yes/no buttons constant.
74 * @field {Number} YES_NO
79 * yes/no/cancel buttons constant.
83 * @field {Number} YES_NO_CANCEL
88 * Constructs a new message box and renders it to the body element.
92 * @param {Object} settings Name/value object with settings.
94 msgBox: function(settings) {
95 var buttons, callback = settings.callback || function() {};
97 switch (settings.buttons) {
98 case MessageBox.OK_CANCEL:
100 {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
101 e.control.parents()[1].close();
105 {type: "button", text: "Cancel", onClick: function(e) {
106 e.control.parents()[1].close();
112 case MessageBox.YES_NO:
114 {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
115 e.control.parents()[1].close();
121 case MessageBox.YES_NO_CANCEL:
123 {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
124 e.control.parents()[1].close();
131 {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
132 e.control.parents()[1].close();
148 title: settings.title,
156 onClose: settings.onClose
157 }).renderTo(document.body).reflow();
161 * Creates a new alert dialog.
164 * @param {Object} settings Settings for the alert dialog.
165 * @param {function} [callback] Callback to execute when the user makes a choice.
167 alert: function(settings, callback) {
168 if (typeof(settings) == "string") {
169 settings = {text: settings};
172 settings.callback = callback;
173 return MessageBox.msgBox(settings);
177 * Creates a new confirm dialog.
180 * @param {Object} settings Settings for the confirm dialog.
181 * @param {function} [callback] Callback to execute when the user makes a choice.
183 confirm: function(settings, callback) {
184 if (typeof(settings) == "string") {
185 settings = {text: settings};
188 settings.callback = callback;
189 settings.buttons = MessageBox.OK_CANCEL;
191 return MessageBox.msgBox(settings);