]> git.proxmox.com Git - extjs.git/blame - extjs/build/examples/kitchensink/classic/samples/view/form/FileUploadsController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / build / examples / kitchensink / classic / samples / view / form / FileUploadsController.js
CommitLineData
6527f429
DM
1Ext.define('KitchenSink.view.form.FileUploadsController', {\r
2 extend: 'Ext.app.ViewController',\r
3 alias: 'controller.form-fileuploads',\r
4 \r
5 getFilePath: function() {\r
6 var v = this.lookupReference('basicFile').getValue();\r
7 \r
8 Ext.Msg.alert('Selected File', v && v !== '' ? v : 'None');\r
9 },\r
10 \r
11 buttonOnlyChange: function(field, value) {\r
12 Ext.toast('<b>Selected:</b> ' + value);\r
13 },\r
14 \r
15 firstFormSave: function() {\r
16 var form = this.lookupReference('firstForm').getForm();\r
17 \r
18 if (form.isValid()) {\r
19 form.submit({\r
20 url: 'data/form/file-upload.php',\r
21 waitMsg: 'Uploading your photo...',\r
22 success: function(fp, o) {\r
23 var tpl = new Ext.XTemplate(\r
24 'File processed on the server.<br />',\r
25 'Name: {fileName}<br />',\r
26 'Size: {fileSize:fileSize}'\r
27 );\r
28 \r
29 Ext.Msg.alert('Success', tpl.apply(o.result));\r
30 }\r
31 });\r
32 }\r
33 },\r
34 \r
35 firstFormReset: function() {\r
36 this.lookupReference('firstForm').getForm().reset();\r
37 },\r
38 \r
39 secondFormSubmit: function() {\r
40 var form = this.lookupReference('secondForm').getForm();\r
41 \r
42 if (form.isValid()) {\r
43 form.submit({\r
44 url: 'data/form/file-upload.php',\r
45 waitMsg: 'Uploading your photo...',\r
46 success: this.secondFormUploadSuccess,\r
47 failure: this.secondFormUploadFailure\r
48 });\r
49 }\r
50 },\r
51 \r
52 secondFormReset: function() {\r
53 this.lookupReference('secondForm').getForm().reset();\r
54 },\r
55 \r
56 secondFormUploadSuccess: function(form, action) {\r
57 Ext.Msg.alert('Success', 'Processed file "' + action.result.file + '" on the server');\r
58 },\r
59 \r
60 secondFormUploadFailure: function(form, action) {\r
61 Ext.Msg.alert("Error", Ext.JSON.decode(this.response.responseText).message);\r
62 }\r
63});\r