]> git.sur5r.net Git - bacula/bacula/blob - gui/baculum/debian/missing-sources/framework/Web/Javascripts/source/tinymce-405/classes/ui/MessageBox.js
baculum: Add missing-sources directory in debian metadata structure
[bacula/bacula] / gui / baculum / debian / missing-sources / framework / Web / Javascripts / source / tinymce-405 / classes / ui / MessageBox.js
1 /**
2  * MessageBox.js
3  *
4  * Copyright, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://www.tinymce.com/license
8  * Contributing: http://www.tinymce.com/contributing
9  */
10
11 /**
12  * This class is used to create MessageBoxes like alerts/confirms etc.
13  *
14  * @class tinymce.ui.Window
15  * @extends tinymce.ui.FloatPanel
16  */
17 define("tinymce/ui/MessageBox", [
18         "tinymce/ui/Window"
19 ], function(Window) {
20         "use strict";
21
22         var MessageBox = Window.extend({
23                 /**
24                  * Constructs a instance with the specified settings.
25                  *
26                  * @constructor
27                  * @param {Object} settings Name/value object with settings.
28                  */
29                 init: function(settings) {
30                         settings = {
31                                 border: 1,
32                                 padding: 20,
33                                 layout: 'flex',
34                                 pack: "center",
35                                 align: "center",
36                                 containerCls: 'panel',
37                                 autoScroll: true,
38                                 buttons: {type: "button", text: "Ok", action: "ok"},
39                                 items: {
40                                         type: "label",
41                                         multiline: true,
42                                         maxWidth: 500,
43                                         maxHeight: 200
44                                 }
45                         };
46
47                         this._super(settings);
48                 },
49
50                 Statics: {
51                         /**
52                          * Ok buttons constant.
53                          *
54                          * @static
55                          * @final
56                          * @field {Number} OK
57                          */
58                         OK: 1,
59
60                         /**
61                          * Ok/cancel buttons constant.
62                          *
63                          * @static
64                          * @final
65                          * @field {Number} OK_CANCEL
66                          */
67                         OK_CANCEL: 2,
68
69                         /**
70                          * yes/no buttons constant.
71                          *
72                          * @static
73                          * @final
74                          * @field {Number} YES_NO
75                          */
76                         YES_NO: 3,
77
78                         /**
79                          * yes/no/cancel buttons constant.
80                          *
81                          * @static
82                          * @final
83                          * @field {Number} YES_NO_CANCEL
84                          */
85                         YES_NO_CANCEL: 4,
86
87                         /**
88                          * Constructs a new message box and renders it to the body element.
89                          *
90                          * @static
91                          * @method msgBox
92                          * @param {Object} settings Name/value object with settings.
93                          */
94                         msgBox: function(settings) {
95                                 var buttons, callback = settings.callback || function() {};
96
97                                 switch (settings.buttons) {
98                                         case MessageBox.OK_CANCEL:
99                                                 buttons = [
100                                                         {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
101                                                                 e.control.parents()[1].close();
102                                                                 callback(true);
103                                                         }},
104
105                                                         {type: "button", text: "Cancel", onClick: function(e) {
106                                                                 e.control.parents()[1].close();
107                                                                 callback(false);
108                                                         }}
109                                                 ];
110                                                 break;
111
112                                         case MessageBox.YES_NO:
113                                                 buttons = [
114                                                         {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
115                                                                 e.control.parents()[1].close();
116                                                                 callback(true);
117                                                         }}
118                                                 ];
119                                                 break;
120
121                                         case MessageBox.YES_NO_CANCEL:
122                                                 buttons = [
123                                                         {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
124                                                                 e.control.parents()[1].close();
125                                                         }}
126                                                 ];
127                                                 break;
128
129                                         default:
130                                                 buttons = [
131                                                         {type: "button", text: "Ok", subtype: "primary", onClick: function(e) {
132                                                                 e.control.parents()[1].close();
133                                                         }}
134                                                 ];
135                                                 break;
136                                 }
137
138                                 return new Window({
139                                         padding: 20,
140                                         x: settings.x,
141                                         y: settings.y,
142                                         minWidth: 300,
143                                         minHeight: 100,
144                                         layout: "flex",
145                                         pack: "center",
146                                         align: "center",
147                                         buttons: buttons,
148                                         title: settings.title,
149                                         items: {
150                                                 type: "label",
151                                                 multiline: true,
152                                                 maxWidth: 500,
153                                                 maxHeight: 200,
154                                                 text: settings.text
155                                         },
156                                         onClose: settings.onClose
157                                 }).renderTo(document.body).reflow();
158                         },
159
160                         /**
161                          * Creates a new alert dialog.
162                          *
163                          * @method alert
164                          * @param {Object} settings Settings for the alert dialog.
165                          * @param {function} [callback] Callback to execute when the user makes a choice.
166                          */
167                         alert: function(settings, callback) {
168                                 if (typeof(settings) == "string") {
169                                         settings = {text: settings};
170                                 }
171
172                                 settings.callback = callback;
173                                 return MessageBox.msgBox(settings);
174                         },
175
176                         /**
177                          * Creates a new confirm dialog.
178                          *
179                          * @method confirm
180                          * @param {Object} settings Settings for the confirm dialog.
181                          * @param {function} [callback] Callback to execute when the user makes a choice.
182                          */
183                         confirm: function(settings, callback) {
184                                 if (typeof(settings) == "string") {
185                                         settings = {text: settings};
186                                 }
187
188                                 settings.callback = callback;
189                                 settings.buttons = MessageBox.OK_CANCEL;
190
191                                 return MessageBox.msgBox(settings);
192                         }
193                 }
194         });
195
196         return MessageBox;
197 });