-<html>
-<head>
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body onload="prettyPrint();">
- <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-<div id="cls-Ext.MessageBox"></div>/**\r
+<html>\r
+<head>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
+ <title>The source code</title>\r
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
+</head>\r
+<body onload="prettyPrint();">\r
+ <pre class="prettyprint lang-js"><div id="cls-Ext.MessageBox"></div>/**\r
* @class Ext.MessageBox\r
* <p>Utility class for generating different styles of message boxes. The alias Ext.Msg can also be used.<p/>\r
* <p>Note that the MessageBox is asynchronous. Unlike a regular JavaScript <code>alert</code> (which will halt\r
Ext.MessageBox = function(){\r
var dlg, opt, mask, waitTimer,\r
bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl,\r
- buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '';\r
+ buttons, activeTextEl, bwidth, bufferIcon = '', iconCls = '',\r
+ buttonNames = ['ok', 'yes', 'no', 'cancel'];\r
\r
// private\r
var handleButton = function(button){\r
+ buttons[button].blur();\r
if(dlg.isVisible()){\r
dlg.hide();\r
handleHide();\r
if(opt && opt.cls){\r
dlg.el.removeClass(opt.cls);\r
}\r
- progressBar.reset();\r
+ progressBar.reset(); \r
};\r
\r
// private\r
\r
// private\r
var updateButtons = function(b){\r
- var width = 0;\r
+ var width = 0,\r
+ cfg;\r
if(!b){\r
- buttons["ok"].hide();\r
- buttons["cancel"].hide();\r
- buttons["yes"].hide();\r
- buttons["no"].hide();\r
+ Ext.each(buttonNames, function(name){\r
+ buttons[name].hide();\r
+ });\r
return width;\r
}\r
dlg.footer.dom.style.display = '';\r
- for(var k in buttons){\r
- if(!Ext.isFunction(buttons[k])){\r
- if(b[k]){\r
- buttons[k].show();\r
- buttons[k].setText(Ext.isString(b[k]) ? b[k] : Ext.MessageBox.buttonText[k]);\r
- width += buttons[k].el.getWidth()+15;\r
- }else{\r
- buttons[k].hide();\r
- }\r
+ Ext.iterate(buttons, function(name, btn){\r
+ cfg = b[name];\r
+ if(cfg){\r
+ btn.show();\r
+ btn.setText(Ext.isString(cfg) ? cfg : Ext.MessageBox.buttonText[name]);\r
+ width += btn.getEl().getWidth() + 15;\r
+ }else{\r
+ btn.hide();\r
}\r
- }\r
+ });\r
return width;\r
};\r
\r
*/\r
getDialog : function(titleText){\r
if(!dlg){\r
+ var btns = [];\r
+ \r
+ buttons = {};\r
+ Ext.each(buttonNames, function(name){\r
+ btns.push(buttons[name] = new Ext.Button({\r
+ text: this.buttonText[name],\r
+ handler: handleButton.createCallback(name),\r
+ hideMode: 'offsets'\r
+ }));\r
+ }, this);\r
dlg = new Ext.Window({\r
autoCreate : true,\r
title:titleText,\r
}else{\r
handleButton("cancel");\r
}\r
- }\r
+ },\r
+ fbar: new Ext.Toolbar({\r
+ items: btns,\r
+ enableOverflow: false\r
+ })\r
});\r
- buttons = {};\r
- var bt = this.buttonText;\r
- //TODO: refactor this block into a buttons config to pass into the Window constructor\r
- buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));\r
- buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));\r
- buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));\r
- buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));\r
- buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets';\r
dlg.render(document.body);\r
dlg.getEl().addClass('x-window-dlg');\r
mask = dlg.mask;\r
}\r
msgEl.update(text || ' ');\r
\r
- var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;\r
- var mw = msgEl.getWidth() + msgEl.getMargins('lr');\r
- var fw = dlg.getFrameWidth('lr');\r
- var bw = dlg.body.getFrameWidth('lr');\r
+ var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0,\r
+ mw = msgEl.getWidth() + msgEl.getMargins('lr'),\r
+ fw = dlg.getFrameWidth('lr'),\r
+ bw = dlg.body.getFrameWidth('lr'),\r
+ w;\r
+ \r
if (Ext.isIE && iw > 0){\r
//3 pixels get subtracted in the icon CSS for an IE margin issue,\r
//so we have to add it back here for the overall width to be consistent\r
iw += 3;\r
}\r
- var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),\r
- Math.max(opt.minWidth || this.minWidth, bwidth || 0));\r
+ w = Math.max(Math.min(opt.width || iw+mw+fw+bw, opt.maxWidth || this.maxWidth),\r
+ Math.max(opt.minWidth || this.minWidth, bwidth || 0));\r
\r
if(opt.prompt === true){\r
activeTextEl.setWidth(w-iw-fw-bw);\r
// force it to the end of the z-index stack so it gets a cursor in FF\r
document.body.appendChild(dlg.el.dom);\r
d.setAnimateTarget(opt.animEl);\r
+ //workaround for window internally enabling keymap in afterShow\r
+ d.on('show', function(){\r
+ if(allowClose === true){\r
+ d.keyMap.enable();\r
+ }else{\r
+ d.keyMap.disable();\r
+ }\r
+ }, this, {single:true});\r
d.show(opt.animEl);\r
}\r
-\r
- //workaround for window internally enabling keymap in afterShow\r
- d.on('show', function(){\r
- if(allowClose === true){\r
- d.keyMap.enable();\r
- }else{\r
- d.keyMap.disable();\r
- }\r
- }, this, {single:true});\r
-\r
if(opt.wait === true){\r
progressBar.wait(opt.waitConfig);\r
}\r
* @param {String} title The title bar text\r
* @param {String} msg The message box body text\r
* @param {Function} fn (optional) The callback function invoked after the message box is closed\r
- * @param {Object} scope (optional) The scope of the callback function\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.\r
* @return {Ext.MessageBox} this\r
*/\r
alert : function(title, msg, fn, scope){\r
msg : msg,\r
buttons: this.OK,\r
fn: fn,\r
- scope : scope\r
+ scope : scope,\r
+ minWidth: this.minWidth\r
});\r
return this;\r
},\r
* @param {String} title The title bar text\r
* @param {String} msg The message box body text\r
* @param {Function} fn (optional) The callback function invoked after the message box is closed\r
- * @param {Object} scope (optional) The scope of the callback function\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.\r
* @return {Ext.MessageBox} this\r
*/\r
confirm : function(title, msg, fn, scope){\r
buttons: this.YESNO,\r
fn: fn,\r
scope : scope,\r
- icon: this.QUESTION\r
+ icon: this.QUESTION,\r
+ minWidth: this.minWidth\r
});\r
return this;\r
},\r
* @param {String} title The title bar text\r
* @param {String} msg The message box body text\r
* @param {Function} fn (optional) The callback function invoked after the message box is closed\r
- * @param {Object} scope (optional) The scope of the callback function\r
+ * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to the browser wnidow.\r
* @param {Boolean/Number} multiline (optional) True to create a multiline textbox using the defaultTextHeight\r
* property, or the height in pixels to create the textbox (defaults to false / single-line)\r
* @param {String} value (optional) Default value of the text input element (defaults to '')\r
msg : msg,\r
buttons: this.OKCANCEL,\r
fn: fn,\r
- minWidth:250,\r
+ minWidth: this.minPromptWidth,\r
scope : scope,\r
prompt:true,\r
multiline: multiline,\r
minWidth : 100,\r
<div id="prop-Ext.MessageBox-minProgressWidth"></div>/**\r
* The minimum width in pixels of the message box if it is a progress-style dialog. This is useful\r
- * for setting a different minimum width than text-only dialogs may need (defaults to 250)\r
+ * for setting a different minimum width than text-only dialogs may need (defaults to 250).\r
* @type Number\r
*/\r
minProgressWidth : 250,\r
+ <div id="prop-Ext.MessageBox-minPromptWidth"></div>/**\r
+ * The minimum width in pixels of the message box if it is a prompt dialog. This is useful\r
+ * for setting a different minimum width than text-only dialogs may need (defaults to 250).\r
+ * @type Number\r
+ */\r
+ minPromptWidth: 250,\r
<div id="prop-Ext.MessageBox-buttonText"></div>/**\r
* An object containing the default button text strings that can be overriden for localized language support.\r
* Supported properties are: ok, cancel, yes and no. Generally you should include a locale-specific\r
<div id="prop-Ext.MessageBox-Msg"></div>/**\r
* Shorthand for {@link Ext.MessageBox}\r
*/\r
-Ext.Msg = Ext.MessageBox;</pre>
-</body>
+Ext.Msg = Ext.MessageBox;</pre> \r
+</body>\r
</html>
\ No newline at end of file