-<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
// 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
* @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
* @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
<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