]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('KitchenSink.view.form.ContactFormController', {\r |
2 | extend: 'Ext.app.ViewController',\r | |
3 | alias: 'controller.form-contact',\r | |
4 | \r | |
5 | showWindow: function() {\r | |
6 | var win = this.lookupReference('popupWindow');\r | |
7 | \r | |
8 | if (!win) {\r | |
9 | win = new KitchenSink.view.form.ContactFormWindow();\r | |
10 | \r | |
11 | // A Window is a floating component, so by default it is not connected\r | |
12 | // to our main View in any way. By adding it, we are creating this link\r | |
13 | // and allow the window to be controlled by the main ViewController,\r | |
14 | // as well as be destroyed automatically along with the main View.\r | |
15 | this.getView().add(win);\r | |
16 | }\r | |
17 | \r | |
18 | win.show();\r | |
19 | },\r | |
20 | \r | |
21 | onFormCancel: function() {\r | |
22 | this.lookupReference('windowForm').getForm().reset();\r | |
23 | this.lookupReference('popupWindow').hide();\r | |
24 | },\r | |
25 | \r | |
26 | onFormSubmit: function() {\r | |
27 | var formPanel = this.lookupReference('windowForm'),\r | |
28 | form = formPanel.getForm();\r | |
29 | \r | |
30 | if (form.isValid()) {\r | |
31 | // In a real application, this would submit the form to the configured url\r | |
32 | // form.submit();\r | |
33 | form.reset();\r | |
34 | this.lookupReference('popupWindow').hide();\r | |
35 | Ext.MessageBox.alert(\r | |
36 | 'Thank you!',\r | |
37 | 'Your inquiry has been sent. We will respond as soon as possible.'\r | |
38 | );\r | |
39 | }\r | |
40 | }\r | |
41 | });\r |