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.

404 lines
11 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.QuickTips.init();
  17. // turn on validation errors beside the field globally
  18. Ext.form.Field.prototype.msgTarget = 'side';
  19. var bd = Ext.getBody();
  20. /*
  21. * ================ Simple form =======================
  22. */
  23. bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'});
  24. var simple = new Ext.FormPanel({
  25. labelWidth: 75, // label settings here cascade unless overridden
  26. url:'save-form.php',
  27. frame:true,
  28. title: 'Simple Form',
  29. bodyStyle:'padding:5px 5px 0',
  30. width: 350,
  31. defaults: {width: 230},
  32. defaultType: 'textfield',
  33. items: [{
  34. fieldLabel: 'First Name',
  35. name: 'first',
  36. allowBlank:false
  37. },{
  38. fieldLabel: 'Last Name',
  39. name: 'last'
  40. },{
  41. fieldLabel: 'Company',
  42. name: 'company'
  43. }, {
  44. fieldLabel: 'Email',
  45. name: 'email',
  46. vtype:'email'
  47. }, new Ext.form.TimeField({
  48. fieldLabel: 'Time',
  49. name: 'time',
  50. minValue: '8:00am',
  51. maxValue: '6:00pm'
  52. })
  53. ],
  54. buttons: [{
  55. text: 'Save'
  56. },{
  57. text: 'Cancel'
  58. }]
  59. });
  60. simple.render(document.body);
  61. /*
  62. * ================ Form 2 =======================
  63. */
  64. bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'});
  65. var fsf = new Ext.FormPanel({
  66. labelWidth: 75, // label settings here cascade unless overridden
  67. url:'save-form.php',
  68. frame:true,
  69. title: 'Simple Form with FieldSets',
  70. bodyStyle:'padding:5px 5px 0',
  71. width: 350,
  72. items: [{
  73. xtype:'fieldset',
  74. checkboxToggle:true,
  75. title: 'User Information',
  76. autoHeight:true,
  77. defaults: {width: 210},
  78. defaultType: 'textfield',
  79. collapsed: true,
  80. items :[{
  81. fieldLabel: 'First Name',
  82. name: 'first',
  83. allowBlank:false
  84. },{
  85. fieldLabel: 'Last Name',
  86. name: 'last'
  87. },{
  88. fieldLabel: 'Company',
  89. name: 'company'
  90. }, {
  91. fieldLabel: 'Email',
  92. name: 'email',
  93. vtype:'email'
  94. }
  95. ]
  96. },{
  97. xtype:'fieldset',
  98. title: 'Phone Number',
  99. collapsible: true,
  100. autoHeight:true,
  101. defaults: {width: 210},
  102. defaultType: 'textfield',
  103. items :[{
  104. fieldLabel: 'Home',
  105. name: 'home',
  106. value: '(888) 555-1212'
  107. },{
  108. fieldLabel: 'Business',
  109. name: 'business'
  110. },{
  111. fieldLabel: 'Mobile',
  112. name: 'mobile'
  113. },{
  114. fieldLabel: 'Fax',
  115. name: 'fax'
  116. }
  117. ]
  118. }],
  119. buttons: [{
  120. text: 'Save'
  121. },{
  122. text: 'Cancel'
  123. }]
  124. });
  125. fsf.render(document.body);
  126. /*
  127. * ================ Form 3 =======================
  128. */
  129. bd.createChild({tag: 'h2', html: 'Form 3 - A little more complex'});
  130. var top = new Ext.FormPanel({
  131. labelAlign: 'top',
  132. frame:true,
  133. title: 'Multi Column, Nested Layouts and Anchoring',
  134. bodyStyle:'padding:5px 5px 0',
  135. width: 600,
  136. items: [{
  137. layout:'column',
  138. items:[{
  139. columnWidth:.5,
  140. layout: 'form',
  141. items: [{
  142. xtype:'textfield',
  143. fieldLabel: 'First Name',
  144. name: 'first',
  145. anchor:'95%'
  146. }, {
  147. xtype:'textfield',
  148. fieldLabel: 'Company',
  149. name: 'company',
  150. anchor:'95%'
  151. }]
  152. },{
  153. columnWidth:.5,
  154. layout: 'form',
  155. items: [{
  156. xtype:'textfield',
  157. fieldLabel: 'Last Name',
  158. name: 'last',
  159. anchor:'95%'
  160. },{
  161. xtype:'textfield',
  162. fieldLabel: 'Email',
  163. name: 'email',
  164. vtype:'email',
  165. anchor:'95%'
  166. }]
  167. }]
  168. },{
  169. xtype:'htmleditor',
  170. id:'bio',
  171. fieldLabel:'Biography',
  172. height:200,
  173. anchor:'98%'
  174. }],
  175. buttons: [{
  176. text: 'Save'
  177. },{
  178. text: 'Cancel'
  179. }]
  180. });
  181. top.render(document.body);
  182. /*
  183. * ================ Form 4 =======================
  184. */
  185. bd.createChild({tag: 'h2', html: 'Form 4 - Forms can be a TabPanel...'});
  186. var tabs = new Ext.FormPanel({
  187. labelWidth: 75,
  188. border:false,
  189. width: 350,
  190. items: {
  191. xtype:'tabpanel',
  192. activeTab: 0,
  193. defaults:{autoHeight:true, bodyStyle:'padding:10px'},
  194. items:[{
  195. title:'Personal Details',
  196. layout:'form',
  197. defaults: {width: 230},
  198. defaultType: 'textfield',
  199. items: [{
  200. fieldLabel: 'First Name',
  201. name: 'first',
  202. allowBlank:false,
  203. value: 'Jack'
  204. },{
  205. fieldLabel: 'Last Name',
  206. name: 'last',
  207. value: 'Slocum'
  208. },{
  209. fieldLabel: 'Company',
  210. name: 'company',
  211. value: 'Ext JS'
  212. }, {
  213. fieldLabel: 'Email',
  214. name: 'email',
  215. vtype:'email'
  216. }]
  217. },{
  218. title:'Phone Numbers',
  219. layout:'form',
  220. defaults: {width: 230},
  221. defaultType: 'textfield',
  222. items: [{
  223. fieldLabel: 'Home',
  224. name: 'home',
  225. value: '(888) 555-1212'
  226. },{
  227. fieldLabel: 'Business',
  228. name: 'business'
  229. },{
  230. fieldLabel: 'Mobile',
  231. name: 'mobile'
  232. },{
  233. fieldLabel: 'Fax',
  234. name: 'fax'
  235. }]
  236. }]
  237. },
  238. buttons: [{
  239. text: 'Save'
  240. },{
  241. text: 'Cancel'
  242. }]
  243. });
  244. tabs.render(document.body);
  245. /*
  246. * ================ Form 5 =======================
  247. */
  248. bd.createChild({tag: 'h2', html: 'Form 5 - ... and forms can contain TabPanel(s)'});
  249. var tab2 = new Ext.FormPanel({
  250. labelAlign: 'top',
  251. title: 'Inner Tabs',
  252. bodyStyle:'padding:5px',
  253. width: 600,
  254. items: [{
  255. layout:'column',
  256. border:false,
  257. items:[{
  258. columnWidth:.5,
  259. layout: 'form',
  260. border:false,
  261. items: [{
  262. xtype:'textfield',
  263. fieldLabel: 'First Name',
  264. name: 'first',
  265. anchor:'95%'
  266. }, {
  267. xtype:'textfield',
  268. fieldLabel: 'Company',
  269. name: 'company',
  270. anchor:'95%'
  271. }]
  272. },{
  273. columnWidth:.5,
  274. layout: 'form',
  275. border:false,
  276. items: [{
  277. xtype:'textfield',
  278. fieldLabel: 'Last Name',
  279. name: 'last',
  280. anchor:'95%'
  281. },{
  282. xtype:'textfield',
  283. fieldLabel: 'Email',
  284. name: 'email',
  285. vtype:'email',
  286. anchor:'95%'
  287. }]
  288. }]
  289. },{
  290. xtype:'tabpanel',
  291. plain:true,
  292. activeTab: 0,
  293. height:235,
  294. /*
  295. By turning off deferred rendering we are guaranteeing that the
  296. form fields within tabs that are not activated will still be rendered.
  297. This is often important when creating multi-tabbed forms.
  298. */
  299. deferredRender: false,
  300. defaults:{bodyStyle:'padding:10px'},
  301. items:[{
  302. title:'Personal Details',
  303. layout:'form',
  304. defaults: {width: 230},
  305. defaultType: 'textfield',
  306. items: [{
  307. fieldLabel: 'First Name',
  308. name: 'first',
  309. allowBlank:false,
  310. value: 'Jack'
  311. },{
  312. fieldLabel: 'Last Name',
  313. name: 'last',
  314. value: 'Slocum'
  315. },{
  316. fieldLabel: 'Company',
  317. name: 'company',
  318. value: 'Ext JS'
  319. }, {
  320. fieldLabel: 'Email',
  321. name: 'email',
  322. vtype:'email'
  323. }]
  324. },{
  325. title:'Phone Numbers',
  326. layout:'form',
  327. defaults: {width: 230},
  328. defaultType: 'textfield',
  329. items: [{
  330. fieldLabel: 'Home',
  331. name: 'home',
  332. value: '(888) 555-1212'
  333. },{
  334. fieldLabel: 'Business',
  335. name: 'business'
  336. },{
  337. fieldLabel: 'Mobile',
  338. name: 'mobile'
  339. },{
  340. fieldLabel: 'Fax',
  341. name: 'fax'
  342. }]
  343. },{
  344. cls:'x-plain',
  345. title:'Biography',
  346. layout:'fit',
  347. items: {
  348. xtype:'htmleditor',
  349. id:'bio2',
  350. fieldLabel:'Biography'
  351. }
  352. }]
  353. }],
  354. buttons: [{
  355. text: 'Save'
  356. },{
  357. text: 'Cancel'
  358. }]
  359. });
  360. tab2.render(document.body);
  361. });