You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

657 lines
32 KiB

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