Web UI for ARGUS server
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.

653 lines
30 KiB

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