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.

126 lines
4.1 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. Ext.onReady(function(){
  16. Ext.get('mb1').on('click', function(e){
  17. Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult);
  18. });
  19. Ext.get('mb2').on('click', function(e){
  20. Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText);
  21. });
  22. Ext.get('mb3').on('click', function(e){
  23. Ext.MessageBox.show({
  24. title: 'Address',
  25. msg: 'Please enter your address:',
  26. width:300,
  27. buttons: Ext.MessageBox.OKCANCEL,
  28. multiline: true,
  29. fn: showResultText,
  30. animEl: 'mb3'
  31. });
  32. });
  33. Ext.get('mb4').on('click', function(e){
  34. Ext.MessageBox.show({
  35. title:'Save Changes?',
  36. msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?',
  37. buttons: Ext.MessageBox.YESNOCANCEL,
  38. fn: showResult,
  39. animEl: 'mb4',
  40. icon: Ext.MessageBox.QUESTION
  41. });
  42. });
  43. Ext.get('mb6').on('click', function(){
  44. Ext.MessageBox.show({
  45. title: 'Please wait',
  46. msg: 'Loading items...',
  47. progressText: 'Initializing...',
  48. width:300,
  49. progress:true,
  50. closable:false,
  51. animEl: 'mb6'
  52. });
  53. // this hideous block creates the bogus progress
  54. var f = function(v){
  55. return function(){
  56. if(v == 12){
  57. Ext.MessageBox.hide();
  58. Ext.example.msg('Done', 'Your fake items were loaded!');
  59. }else{
  60. var i = v/11;
  61. Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
  62. }
  63. };
  64. };
  65. for(var i = 1; i < 13; i++){
  66. setTimeout(f(i), i*500);
  67. }
  68. });
  69. Ext.get('mb7').on('click', function(){
  70. Ext.MessageBox.show({
  71. msg: 'Saving your data, please wait...',
  72. progressText: 'Saving...',
  73. width:300,
  74. wait:true,
  75. waitConfig: {interval:200},
  76. icon:'ext-mb-download', //custom class in msg-box.html
  77. animEl: 'mb7'
  78. });
  79. setTimeout(function(){
  80. //This simulates a long-running operation like a database save or XHR call.
  81. //In real code, this would be in a callback function.
  82. Ext.MessageBox.hide();
  83. Ext.example.msg('Done', 'Your fake data was saved!');
  84. }, 8000);
  85. });
  86. Ext.get('mb8').on('click', function(){
  87. Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult);
  88. });
  89. //Add these values dynamically so they aren't hard-coded in the html
  90. Ext.fly('info').dom.value = Ext.MessageBox.INFO;
  91. Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;
  92. Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;
  93. Ext.fly('error').dom.value = Ext.MessageBox.ERROR;
  94. Ext.get('mb9').on('click', function(){
  95. Ext.MessageBox.show({
  96. title: 'Icon Support',
  97. msg: 'Here is a message with an icon!',
  98. buttons: Ext.MessageBox.OK,
  99. animEl: 'mb9',
  100. fn: showResult,
  101. icon: Ext.get('icons').dom.value
  102. });
  103. });
  104. function showResult(btn){
  105. Ext.example.msg('Button Click', 'You clicked the {0} button', btn);
  106. };
  107. function showResultText(btn, text){
  108. Ext.example.msg('Button Click', 'You clicked the {0} button and entered the text "{1}".', btn, text);
  109. };
  110. });