]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/kitchensink/classic/samples/view/window/MessageBoxController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / kitchensink / classic / samples / view / window / MessageBoxController.js
CommitLineData
6527f429
DM
1Ext.define('KitchenSink.view.window.MessageBoxController', {\r
2 extend: 'Ext.app.ViewController',\r
3 alias: 'controller.window-messagebox',\r
4\r
5 onConfirmClick: function() {\r
6 Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', this.showResult, this);\r
7 },\r
8\r
9 onPromptClick: function() {\r
10 Ext.MessageBox.prompt('Name', 'Please enter your name:', this.showResultText, this);\r
11 },\r
12\r
13 onMultiLinePromptClick: function(btn) {\r
14 Ext.MessageBox.show({\r
15 title: 'Address',\r
16 msg: 'Please enter your address:',\r
17 width:300,\r
18 buttons: Ext.MessageBox.OKCANCEL,\r
19 multiline: true,\r
20 scope: this,\r
21 fn: this.showResultText,\r
22 animateTarget: btn\r
23 });\r
24 },\r
25\r
26 onYesNoCancelClick: function(btn) {\r
27 Ext.MessageBox.show({\r
28 title:'Save Changes?',\r
29 msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?',\r
30 buttons: Ext.MessageBox.YESNOCANCEL,\r
31 scope: this,\r
32 fn: this.showResult,\r
33 animateTarget: btn,\r
34 icon: Ext.MessageBox.QUESTION\r
35 });\r
36 },\r
37\r
38 onProgressClick: function(btn) {\r
39 var me = this,\r
40 i = 0,\r
41 fn;\r
42\r
43 Ext.MessageBox.show({\r
44 title: 'Please wait',\r
45 msg: 'Loading items...',\r
46 progressText: 'Initializing...',\r
47 width:300,\r
48 progress:true,\r
49 closable:false,\r
50 animateTarget: btn\r
51 });\r
52\r
53 // Fake progress fn\r
54 fn = function() {\r
55 me.timer = null;\r
56 ++i;\r
57 if (i === 12) {\r
58 Ext.MessageBox.hide();\r
59 me.showToast('Your fake items were loaded', 'Done');\r
60 } else {\r
61 var val = i / 11;\r
62 Ext.MessageBox.updateProgress(val, Math.round(100 * val) + '% completed');\r
63 me.timer = Ext.defer(fn, 500);\r
64 }\r
65 };\r
66 me.timer = Ext.defer(fn, 500);\r
67\r
68 },\r
69\r
70 onWaitClick: function(btn) {\r
71 Ext.MessageBox.show({\r
72 msg: 'Saving your data, please wait...',\r
73 progressText: 'Saving...',\r
74 width: 300,\r
75 wait: {\r
76 interval: 200\r
77 },\r
78 animateTarget: btn\r
79 });\r
80\r
81 var me = this;\r
82 me.timer = Ext.defer(function(){\r
83 //This simulates a long-running operation like a database save or XHR call.\r
84 //In real code, this would be in a callback function.\r
85 me.timer = null;\r
86 Ext.MessageBox.hide();\r
87 me.showToast('Your fake data was saved!', 'Done');\r
88 }, 8000);\r
89 },\r
90\r
91 onAlertClick: function() {\r
92 Ext.MessageBox.alert('Status', 'Changes saved successfully.', this.showResult, this);\r
93 },\r
94\r
95 onIconClick: function(btn) {\r
96 var value = this.lookupReference('icon').getValue(),\r
97 icon = Ext.MessageBox[value.toUpperCase()];\r
98\r
99 Ext.MessageBox.show({\r
100 title: 'Icon Support',\r
101 msg: 'Here is a message with an icon!',\r
102 buttons: Ext.MessageBox.OK,\r
103 animateTarget: btn,\r
104 scope: this,\r
105 fn: this.showResult,\r
106 icon: icon\r
107 });\r
108 },\r
109\r
110 onCustomButtonText: function() {\r
111 Ext.MessageBox.show({\r
112 title: 'What, really?',\r
113 msg: 'Are you sure?',\r
114 buttons: Ext.MessageBox.YESNO,\r
115 buttonText:{ \r
116 yes: "Definitely!", \r
117 no: "No chance!" \r
118 },\r
119 scope: this,\r
120 fn: this.showResult\r
121 });\r
122 },\r
123\r
124 showResult: function(btn, text) {\r
125 this.showToast(Ext.String.format('You clicked the {0} button', btn));\r
126 },\r
127\r
128 showResultText: function(btn, text) {\r
129 this.showToast(Ext.String.format('You clicked the {0} button and entered the text "{1}".', btn, text));\r
130 },\r
131\r
132 showToast: function(s, title) {\r
133 Ext.toast({\r
134 html: s,\r
135 closable: false,\r
136 align: 't',\r
137 slideInDuration: 400,\r
138 minWidth: 400\r
139 });\r
140 },\r
141\r
142 destroy: function() {\r
143 if (this.timer) {\r
144 window.clearTimeout(this.timer);\r
145 }\r
146 Ext.Msg.hide();\r
147 this.callParent();\r
148 }\r
149});