aria-form.js 11 KB

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