Upgrade to ExtJS 3.1.0 - Released 12/16/2009
[extjs.git] / src / widgets / MessageBox.js
1 /*!
2  * Ext JS Library 3.1.0
3  * Copyright(c) 2006-2009 Ext JS, LLC
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**\r
8  * @class Ext.MessageBox\r
9  * <p>Utility class for generating different styles of message boxes.  The alias Ext.Msg can also be used.<p/>\r
10  * <p>Note that the MessageBox is asynchronous.  Unlike a regular JavaScript <code>alert</code> (which will halt\r
11  * browser execution), showing a MessageBox will not cause the code to stop.  For this reason, if you have code\r
12  * that should only run <em>after</em> some user feedback from the MessageBox, you must use a callback function\r
13  * (see the <code>function</code> parameter for {@link #show} for more details).</p>\r
14  * <p>Example usage:</p>\r
15  *<pre><code>\r
16 // Basic alert:\r
17 Ext.Msg.alert('Status', 'Changes saved successfully.');\r
18 \r
19 // Prompt for user data and process the result using a callback:\r
20 Ext.Msg.prompt('Name', 'Please enter your name:', function(btn, text){\r
21     if (btn == 'ok'){\r
22         // process text value and close...\r
23     }\r
24 });\r
25 \r
26 // Show a dialog using config options:\r
27 Ext.Msg.show({\r
28    title:'Save Changes?',\r
29    msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',\r
30    buttons: Ext.Msg.YESNOCANCEL,\r
31    fn: processResult,\r
32    animEl: 'elId',\r
33    icon: Ext.MessageBox.QUESTION\r
34 });\r
35 </code></pre>\r
36  * @singleton\r
37  */\r
38 Ext.MessageBox = function(){\r
39     var dlg, opt, mask, waitTimer,\r
40         bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,\r
41         buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',\r
42         buttonNames = ['ok', 'yes', 'no', 'cancel'];\r
43 \r
44     // private\r
45     var handleButton = function(button){\r
46         buttons[button].blur();\r
47         if(dlg.isVisible()){\r
48             dlg.hide();\r
49             handleHide();\r
50             Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value, opt], 1);\r
51         }\r
52     };\r
53 \r
54     // private\r
55     var handleHide = function(){\r
56         if(opt && opt.cls){\r
57             dlg.el.removeClass(opt.cls);\r
58         }\r
59         progressBar.reset();        \r
60     };\r
61 \r
62     // private\r
63     var handleEsc = function(d, k, e){\r
64         if(opt && opt.closable !== false){\r
65             dlg.hide();\r
66             handleHide();\r
67         }\r
68         if(e){\r
69             e.stopEvent();\r
70         }\r
71     };\r
72 \r
73     // private\r
74     var updateButtons = function(b){\r
75         var width = 0,\r
76             cfg;\r
77         if(!b){\r
78             Ext.each(buttonNames, function(name){\r
79                 buttons[name].hide();\r
80             });\r
81             return width;\r
82         }\r
83         dlg.footer.dom.style.display = '';\r
84         Ext.iterate(buttons, function(name, btn){\r
85             cfg = b[name];\r
86             if(cfg){\r
87                 btn.show();\r
88                 btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);\r
89                 width += btn.getEl().getWidth() + 15;\r
90             }else{\r
91                 btn.hide();\r
92             }\r
93         });\r
94         return width;\r
95     };\r
96 \r
97     return {\r
98         /**\r
99          * Returns a reference to the underlying {@link Ext.Window} element\r
100          * @return {Ext.Window} The window\r
101          */\r
102         getDialog : function(titleText){\r
103            if(!dlg){\r
104                 var btns = [];\r
105                 \r
106                 buttons = {};\r
107                 Ext.each(buttonNames, function(name){\r
108                     btns.push(buttons[name] = new Ext.Button({\r
109                         text: this.buttonText[name],\r
110                         handler: handleButton.createCallback(name),\r
111                         hideMode: 'offsets'\r
112                     }));\r
113                 }, this);\r
114                 dlg = new Ext.Window({\r
115                     autoCreate : true,\r
116                     title:titleText,\r
117                     resizable:false,\r
118                     constrain:true,\r
119                     constrainHeader:true,\r
120                     minimizable : false,\r
121                     maximizable : false,\r
122                     stateful: false,\r
123                     modal: true,\r
124                     shim:true,\r
125                     buttonAlign:"center",\r
126                     width:400,\r
127                     height:100,\r
128                     minHeight: 80,\r
129                     plain:true,\r
130                     footer:true,\r
131                     closable:true,\r
132                     close : function(){\r
133                         if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){\r
134                             handleButton("no");\r
135                         }else{\r
136                             handleButton("cancel");\r
137                         }\r
138                     },\r
139                     fbar: new Ext.Toolbar({\r
140                         items: btns,\r
141                         enableOverflow: false\r
142                     })\r
143                 });\r
144                 dlg.render(document.body);\r
145                 dlg.getEl().addClass('x-window-dlg');\r
146                 mask = dlg.mask;\r
147                 bodyEl = dlg.body.createChild({\r
148                     html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><div class="ext-mb-fix-cursor"><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div></div>'\r
149                 });\r
150                 iconEl = Ext.get(bodyEl.dom.firstChild);\r
151                 var contentEl = bodyEl.dom.childNodes[1];\r
152                 msgEl = Ext.get(contentEl.firstChild);\r
153                 textboxEl = Ext.get(contentEl.childNodes[2].firstChild);\r
154                 textboxEl.enableDisplayMode();\r
155                 textboxEl.addKeyListener([10,13], function(){\r
156                     if(dlg.isVisible() && opt && opt.buttons){\r
157                         if(opt.buttons.ok){\r
158                             handleButton("ok");\r
159                         }else if(opt.buttons.yes){\r
160                             handleButton("yes");\r
161                         }\r
162                     }\r
163                 });\r
164                 textareaEl = Ext.get(contentEl.childNodes[2].childNodes[1]);\r
165                 textareaEl.enableDisplayMode();\r
166                 progressBar = new Ext.ProgressBar({\r
167                     renderTo:bodyEl\r
168                 });\r
169                bodyEl.createChild({cls:'x-clear'});\r
170             }\r
171             return dlg;\r
172         },\r
173 \r
174         /**\r
175          * Updates the message box body text\r
176          * @param {String} text (optional) Replaces the message box element's innerHTML with the specified string (defaults to\r
177          * the XHTML-compliant non-breaking space character '&amp;#160;')\r
178          * @return {Ext.MessageBox} this\r
179          */\r
180         updateText : function(text){\r
181             if(!dlg.isVisible() && !opt.width){\r
182                 dlg.setSize(this.maxWidth, 100); // resize first so content is never clipped from previous shows\r
183             }\r
184             msgEl.update(text || '&#160;');\r
185 \r
186             var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;\r
187             var mw = msgEl.getWidth() + msgEl.getMargins('lr');\r
188             var fw = dlg.getFrameWidth('lr');\r
189             var bw = dlg.body.getFrameWidth('lr');\r
190             if (Ext.isIE && iw > 0){\r
191                 //3 pixels get subtracted in the icon CSS for an IE margin issue,\r
192                 //so we have to add it back here for the overall width to be consistent\r
193                 iw += 3;\r
194             }\r
195             var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),\r
196                         Math.max(opt.minWidth || this.minWidth, bwidth || 0));\r
197 \r
198             if(opt.prompt === true){\r
199                 activeTextEl.setWidth(w-iw-fw-bw);\r
200             }\r
201             if(opt.progress === true || opt.wait === true){\r
202                 progressBar.setSize(w-iw-fw-bw);\r
203             }\r
204             if(Ext.isIE && w == bwidth){\r
205                 w += 4; //Add offset when the content width is smaller than the buttons.    \r
206             }\r
207             dlg.setSize(w, 'auto').center();\r
208             return this;\r
209         },\r
210 \r
211         /**\r
212          * Updates a progress-style message box's text and progress bar. Only relevant on message boxes\r
213          * initiated via {@link Ext.MessageBox#progress} or {@link Ext.MessageBox#wait},\r
214          * or by calling {@link Ext.MessageBox#show} with progress: true.\r
215          * @param {Number} value Any number between 0 and 1 (e.g., .5, defaults to 0)\r
216          * @param {String} progressText The progress text to display inside the progress bar (defaults to '')\r
217          * @param {String} msg The message box's body text is replaced with the specified string (defaults to undefined\r
218          * so that any existing body text will not get overwritten by default unless a new value is passed in)\r
219          * @return {Ext.MessageBox} this\r
220          */\r
221         updateProgress : function(value, progressText, msg){\r
222             progressBar.updateProgress(value, progressText);\r
223             if(msg){\r
224                 this.updateText(msg);\r
225             }\r
226             return this;\r
227         },\r
228 \r
229         /**\r
230          * Returns true if the message box is currently displayed\r
231          * @return {Boolean} True if the message box is visible, else false\r
232          */\r
233         isVisible : function(){\r
234             return dlg && dlg.isVisible();\r
235         },\r
236 \r
237         /**\r
238          * Hides the message box if it is displayed\r
239          * @return {Ext.MessageBox} this\r
240          */\r
241         hide : function(){\r
242             var proxy = dlg ? dlg.activeGhost : null;\r
243             if(this.isVisible() || proxy){\r
244                 dlg.hide();\r
245                 handleHide();\r
246                 if (proxy){\r
247                     // unghost is a private function, but i saw no better solution\r
248                     // to fix the locking problem when dragging while it closes\r
249                     dlg.unghost(false, false);\r
250                 } \r
251             }\r
252             return this;\r
253         },\r
254 \r
255         /**\r
256          * Displays a new message box, or reinitializes an existing message box, based on the config options\r
257          * passed in. All display functions (e.g. prompt, alert, etc.) on MessageBox call this function internally,\r
258          * although those calls are basic shortcuts and do not support all of the config options allowed here.\r
259          * @param {Object} config The following config options are supported: <ul>\r
260          * <li><b>animEl</b> : String/Element<div class="sub-desc">An id or Element from which the message box should animate as it\r
261          * opens and closes (defaults to undefined)</div></li>\r
262          * <li><b>buttons</b> : Object/Boolean<div class="sub-desc">A button config object (e.g., Ext.MessageBox.OKCANCEL or {ok:'Foo',\r
263          * cancel:'Bar'}), or false to not show any buttons (defaults to false)</div></li>\r
264          * <li><b>closable</b> : Boolean<div class="sub-desc">False to hide the top-right close button (defaults to true). Note that\r
265          * progress and wait dialogs will ignore this property and always hide the close button as they can only\r
266          * be closed programmatically.</div></li>\r
267          * <li><b>cls</b> : String<div class="sub-desc">A custom CSS class to apply to the message box's container element</div></li>\r
268          * <li><b>defaultTextHeight</b> : Number<div class="sub-desc">The default height in pixels of the message box's multiline textarea\r
269          * if displayed (defaults to 75)</div></li>\r
270          * <li><b>fn</b> : Function<div class="sub-desc">A callback function which is called when the dialog is dismissed either\r
271          * by clicking on the configured buttons, or on the dialog close button, or by pressing\r
272          * the return button to enter input.\r
273          * <p>Progress and wait dialogs will ignore this option since they do not respond to user\r
274          * actions and can only be closed programmatically, so any required function should be called\r
275          * by the same code after it closes the dialog. Parameters passed:<ul>\r
276          * <li><b>buttonId</b> : String<div class="sub-desc">The ID of the button pressed, one of:<div class="sub-desc"><ul>\r
277          * <li><tt>ok</tt></li>\r
278          * <li><tt>yes</tt></li>\r
279          * <li><tt>no</tt></li>\r
280          * <li><tt>cancel</tt></li>\r
281          * </ul></div></div></li>\r
282          * <li><b>text</b> : String<div class="sub-desc">Value of the input field if either <tt><a href="#show-option-prompt" ext:member="show-option-prompt" ext:cls="Ext.MessageBox">prompt</a></tt>\r
283          * or <tt><a href="#show-option-multiline" ext:member="show-option-multiline" ext:cls="Ext.MessageBox">multiline</a></tt> is true</div></li>\r
284          * <li><b>opt</b> : Object<div class="sub-desc">The config object passed to show.</div></li>\r
285          * </ul></p></div></li>\r
286          * <li><b>scope</b> : Object<div class="sub-desc">The scope of the callback function</div></li>\r
287          * <li><b>icon</b> : String<div class="sub-desc">A CSS class that provides a background image to be used as the body icon for the\r
288          * dialog (e.g. Ext.MessageBox.WARNING or 'custom-class') (defaults to '')</div></li>\r
289          * <li><b>iconCls</b> : String<div class="sub-desc">The standard {@link Ext.Window#iconCls} to\r
290          * add an optional header icon (defaults to '')</div></li>\r
291          * <li><b>maxWidth</b> : Number<div class="sub-desc">The maximum width in pixels of the message box (defaults to 600)</div></li>\r
292          * <li><b>minWidth</b> : Number<div class="sub-desc">The minimum width in pixels of the message box (defaults to 100)</div></li>\r
293          * <li><b>modal</b> : Boolean<div class="sub-desc">False to allow user interaction with the page while the message box is\r
294          * displayed (defaults to true)</div></li>\r
295          * <li><b>msg</b> : String<div class="sub-desc">A string that will replace the existing message box body text (defaults to the\r
296          * XHTML-compliant non-breaking space character '&amp;#160;')</div></li>\r
297          * <li><a id="show-option-multiline"></a><b>multiline</b> : Boolean<div class="sub-desc">\r
298          * True to prompt the user to enter multi-line text (defaults to false)</div></li>\r
299          * <li><b>progress</b> : Boolean<div class="sub-desc">True to display a progress bar (defaults to false)</div></li>\r
300          * <li><b>progressText</b> : String<div class="sub-desc">The text to display inside the progress bar if progress = true (defaults to '')</div></li>\r
301          * <li><a id="show-option-prompt"></a><b>prompt</b> : Boolean<div class="sub-desc">True to prompt the user to enter single-line text (defaults to false)</div></li>\r
302          * <li><b>proxyDrag</b> : Boolean<div class="sub-desc">True to display a lightweight proxy while dragging (defaults to false)</div></li>\r
303          * <li><b>title</b> : String<div class="sub-desc">The title text</div></li>\r
304          * <li><b>value</b> : String<div class="sub-desc">The string value to set into the active textbox element if displayed</div></li>\r
305          * <li><b>wait</b> : Boolean<div class="sub-desc">True to display a progress bar (defaults to false)</div></li>\r
306          * <li><b>waitConfig</b> : Object<div class="sub-desc">A {@link Ext.ProgressBar#waitConfig} object (applies only if wait = true)</div></li>\r
307          * <li><b>width</b> : Number<div class="sub-desc">The width of the dialog in pixels</div></li>\r
308          * </ul>\r
309          * Example usage:\r
310          * <pre><code>\r
311 Ext.Msg.show({\r
312    title: 'Address',\r
313    msg: 'Please enter your address:',\r
314    width: 300,\r
315    buttons: Ext.MessageBox.OKCANCEL,\r
316    multiline: true,\r
317    fn: saveAddress,\r
318    animEl: 'addAddressBtn',\r
319    icon: Ext.MessageBox.INFO\r
320 });\r
321 </code></pre>\r
322          * @return {Ext.MessageBox} this\r
323          */\r
324         show : function(options){\r
325             if(this.isVisible()){\r
326                 this.hide();\r
327             }\r
328             opt = options;\r
329             var d = this.getDialog(opt.title || "&#160;");\r
330 \r
331             d.setTitle(opt.title || "&#160;");\r
332             var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);\r
333             d.tools.close.setDisplayed(allowClose);\r
334             activeTextEl = textboxEl;\r
335             opt.prompt = opt.prompt || (opt.multiline ? true : false);\r
336             if(opt.prompt){\r
337                 if(opt.multiline){\r
338                     textboxEl.hide();\r
339                     textareaEl.show();\r
340                     textareaEl.setHeight(Ext.isNumber(opt.multiline) ? opt.multiline : this.defaultTextHeight);\r
341                     activeTextEl = textareaEl;\r
342                 }else{\r
343                     textboxEl.show();\r
344                     textareaEl.hide();\r
345                 }\r
346             }else{\r
347                 textboxEl.hide();\r
348                 textareaEl.hide();\r
349             }\r
350             activeTextEl.dom.value = opt.value || "";\r
351             if(opt.prompt){\r
352                 d.focusEl = activeTextEl;\r
353             }else{\r
354                 var bs = opt.buttons;\r
355                 var db = null;\r
356                 if(bs && bs.ok){\r
357                     db = buttons["ok"];\r
358                 }else if(bs && bs.yes){\r
359                     db = buttons["yes"];\r
360                 }\r
361                 if (db){\r
362                     d.focusEl = db;\r
363                 }\r
364             }\r
365             if(opt.iconCls){\r
366               d.setIconClass(opt.iconCls);\r
367             }\r
368             this.setIcon(Ext.isDefined(opt.icon) ? opt.icon : bufferIcon);\r
369             bwidth = updateButtons(opt.buttons);\r
370             progressBar.setVisible(opt.progress === true || opt.wait === true);\r
371             this.updateProgress(0, opt.progressText);\r
372             this.updateText(opt.msg);\r
373             if(opt.cls){\r
374                 d.el.addClass(opt.cls);\r
375             }\r
376             d.proxyDrag = opt.proxyDrag === true;\r
377             d.modal = opt.modal !== false;\r
378             d.mask = opt.modal !== false ? mask : false;\r
379             if(!d.isVisible()){\r
380                 // force it to the end of the z-index stack so it gets a cursor in FF\r
381                 document.body.appendChild(dlg.el.dom);\r
382                 d.setAnimateTarget(opt.animEl);\r
383                 //workaround for window internally enabling keymap in afterShow\r
384                 d.on('show', function(){\r
385                     if(allowClose === true){\r
386                         d.keyMap.enable();\r
387                     }else{\r
388                         d.keyMap.disable();\r
389                     }\r
390                 }, this, {single:true});\r
391                 d.show(opt.animEl);\r
392             }\r
393             if(opt.wait === true){\r
394                 progressBar.wait(opt.waitConfig);\r
395             }\r
396             return this;\r
397         },\r
398 \r
399         /**\r
400          * Adds the specified icon to the dialog.  By default, the class 'ext-mb-icon' is applied for default\r
401          * styling, and the class passed in is expected to supply the background image url. Pass in empty string ('')\r
402          * to clear any existing icon. This method must be called before the MessageBox is shown.\r
403          * The following built-in icon classes are supported, but you can also pass in a custom class name:\r
404          * <pre>\r
405 Ext.MessageBox.INFO\r
406 Ext.MessageBox.WARNING\r
407 Ext.MessageBox.QUESTION\r
408 Ext.MessageBox.ERROR\r
409          *</pre>\r
410          * @param {String} icon A CSS classname specifying the icon's background image url, or empty string to clear the icon\r
411          * @return {Ext.MessageBox} this\r
412          */\r
413         setIcon : function(icon){\r
414             if(!dlg){\r
415                 bufferIcon = icon;\r
416                 return;\r
417             }\r
418             bufferIcon = undefined;\r
419             if(icon && icon != ''){\r
420                 iconEl.removeClass('x-hidden');\r
421                 iconEl.replaceClass(iconCls, icon);\r
422                 bodyEl.addClass('x-dlg-icon');\r
423                 iconCls = icon;\r
424             }else{\r
425                 iconEl.replaceClass(iconCls, 'x-hidden');\r
426                 bodyEl.removeClass('x-dlg-icon');\r
427                 iconCls = '';\r
428             }\r
429             return this;\r
430         },\r
431 \r
432         /**\r
433          * Displays a message box with a progress bar.  This message box has no buttons and is not closeable by\r
434          * the user.  You are responsible for updating the progress bar as needed via {@link Ext.MessageBox#updateProgress}\r
435          * and closing the message box when the process is complete.\r
436          * @param {String} title The title bar text\r
437          * @param {String} msg The message box body text\r
438          * @param {String} progressText (optional) The text to display inside the progress bar (defaults to '')\r
439          * @return {Ext.MessageBox} this\r
440          */\r
441         progress : function(title, msg, progressText){\r
442             this.show({\r
443                 title : title,\r
444                 msg : msg,\r
445                 buttons: false,\r
446                 progress:true,\r
447                 closable:false,\r
448                 minWidth: this.minProgressWidth,\r
449                 progressText: progressText\r
450             });\r
451             return this;\r
452         },\r
453 \r
454         /**\r
455          * Displays a message box with an infinitely auto-updating progress bar.  This can be used to block user\r
456          * interaction while waiting for a long-running process to complete that does not have defined intervals.\r
457          * You are responsible for closing the message box when the process is complete.\r
458          * @param {String} msg The message box body text\r
459          * @param {String} title (optional) The title bar text\r
460          * @param {Object} config (optional) A {@link Ext.ProgressBar#waitConfig} object\r
461          * @return {Ext.MessageBox} this\r
462          */\r
463         wait : function(msg, title, config){\r
464             this.show({\r
465                 title : title,\r
466                 msg : msg,\r
467                 buttons: false,\r
468                 closable:false,\r
469                 wait:true,\r
470                 modal:true,\r
471                 minWidth: this.minProgressWidth,\r
472                 waitConfig: config\r
473             });\r
474             return this;\r
475         },\r
476 \r
477         /**\r
478          * Displays a standard read-only message box with an OK button (comparable to the basic JavaScript alert prompt).\r
479          * If a callback function is passed it will be called after the user clicks the button, and the\r
480          * id of the button that was clicked will be passed as the only parameter to the callback\r
481          * (could also be the top-right close button).\r
482          * @param {String} title The title bar text\r
483          * @param {String} msg The message box body text\r
484          * @param {Function} fn (optional) The callback function invoked after the message box is closed\r
485          * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.\r
486          * @return {Ext.MessageBox} this\r
487          */\r
488         alert : function(title, msg, fn, scope){\r
489             this.show({\r
490                 title : title,\r
491                 msg : msg,\r
492                 buttons: this.OK,\r
493                 fn: fn,\r
494                 scope : scope\r
495             });\r
496             return this;\r
497         },\r
498 \r
499         /**\r
500          * Displays a confirmation message box with Yes and No buttons (comparable to JavaScript's confirm).\r
501          * If a callback function is passed it will be called after the user clicks either button,\r
502          * and the id of the button that was clicked will be passed as the only parameter to the callback\r
503          * (could also be the top-right close button).\r
504          * @param {String} title The title bar text\r
505          * @param {String} msg The message box body text\r
506          * @param {Function} fn (optional) The callback function invoked after the message box is closed\r
507          * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.\r
508          * @return {Ext.MessageBox} this\r
509          */\r
510         confirm : function(title, msg, fn, scope){\r
511             this.show({\r
512                 title : title,\r
513                 msg : msg,\r
514                 buttons: this.YESNO,\r
515                 fn: fn,\r
516                 scope : scope,\r
517                 icon: this.QUESTION\r
518             });\r
519             return this;\r
520         },\r
521 \r
522         /**\r
523          * Displays a message box with OK and Cancel buttons prompting the user to enter some text (comparable to JavaScript's prompt).\r
524          * The prompt can be a single-line or multi-line textbox.  If a callback function is passed it will be called after the user\r
525          * clicks either button, and the id of the button that was clicked (could also be the top-right\r
526          * close button) and the text that was entered will be passed as the two parameters to the callback.\r
527          * @param {String} title The title bar text\r
528          * @param {String} msg The message box body text\r
529          * @param {Function} fn (optional) The callback function invoked after the message box is closed\r
530          * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.\r
531          * @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight\r
532          * property, or the height in pixels to create the textbox (defaults to false / single-line)\r
533          * @param {String} value (optional) Default value of the text input element (defaults to '')\r
534          * @return {Ext.MessageBox} this\r
535          */\r
536         prompt : function(title, msg, fn, scope, multiline, value){\r
537             this.show({\r
538                 title : title,\r
539                 msg : msg,\r
540                 buttons: this.OKCANCEL,\r
541                 fn: fn,\r
542                 minWidth:250,\r
543                 scope : scope,\r
544                 prompt:true,\r
545                 multiline: multiline,\r
546                 value: value\r
547             });\r
548             return this;\r
549         },\r
550 \r
551         /**\r
552          * Button config that displays a single OK button\r
553          * @type Object\r
554          */\r
555         OK : {ok:true},\r
556         /**\r
557          * Button config that displays a single Cancel button\r
558          * @type Object\r
559          */\r
560         CANCEL : {cancel:true},\r
561         /**\r
562          * Button config that displays OK and Cancel buttons\r
563          * @type Object\r
564          */\r
565         OKCANCEL : {ok:true, cancel:true},\r
566         /**\r
567          * Button config that displays Yes and No buttons\r
568          * @type Object\r
569          */\r
570         YESNO : {yes:true, no:true},\r
571         /**\r
572          * Button config that displays Yes, No and Cancel buttons\r
573          * @type Object\r
574          */\r
575         YESNOCANCEL : {yes:true, no:true, cancel:true},\r
576         /**\r
577          * The CSS class that provides the INFO icon image\r
578          * @type String\r
579          */\r
580         INFO : 'ext-mb-info',\r
581         /**\r
582          * The CSS class that provides the WARNING icon image\r
583          * @type String\r
584          */\r
585         WARNING : 'ext-mb-warning',\r
586         /**\r
587          * The CSS class that provides the QUESTION icon image\r
588          * @type String\r
589          */\r
590         QUESTION : 'ext-mb-question',\r
591         /**\r
592          * The CSS class that provides the ERROR icon image\r
593          * @type String\r
594          */\r
595         ERROR : 'ext-mb-error',\r
596 \r
597         /**\r
598          * The default height in pixels of the message box's multiline textarea if displayed (defaults to 75)\r
599          * @type Number\r
600          */\r
601         defaultTextHeight : 75,\r
602         /**\r
603          * The maximum width in pixels of the message box (defaults to 600)\r
604          * @type Number\r
605          */\r
606         maxWidth : 600,\r
607         /**\r
608          * The minimum width in pixels of the message box (defaults to 100)\r
609          * @type Number\r
610          */\r
611         minWidth : 100,\r
612         /**\r
613          * The minimum width in pixels of the message box if it is a progress-style dialog.  This is useful\r
614          * for setting a different minimum width than text-only dialogs may need (defaults to 250)\r
615          * @type Number\r
616          */\r
617         minProgressWidth : 250,\r
618         /**\r
619          * An object containing the default button text strings that can be overriden for localized language support.\r
620          * Supported properties are: ok, cancel, yes and no.  Generally you should include a locale-specific\r
621          * resource file for handling language support across the framework.\r
622          * Customize the default text like so: Ext.MessageBox.buttonText.yes = "oui"; //french\r
623          * @type Object\r
624          */\r
625         buttonText : {\r
626             ok : "OK",\r
627             cancel : "Cancel",\r
628             yes : "Yes",\r
629             no : "No"\r
630         }\r
631     };\r
632 }();\r
633 \r
634 /**\r
635  * Shorthand for {@link Ext.MessageBox}\r
636  */\r
637 Ext.Msg = Ext.MessageBox;