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