123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- Ext.require([
- 'Ext.form.*',
- 'Ext.layout.container.Column',
- 'Ext.tab.*'
- ]);
- Ext.onReady(function() {
- Ext.QuickTips.init();
- var bd = Ext.getBody();
- /*
- * ================ Simple form =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 1 - Very Simple'});
- var simple = Ext.create('Ext.form.Panel', {
- url:'save-form.php',
- frame:true,
- title: 'Simple Form',
- bodyStyle:'padding:5px 5px 0',
- width: 350,
- fieldDefaults: {
- msgTarget: 'side',
- labelWidth: 75
- },
- defaultType: 'textfield',
- defaults: {
- anchor: '100%'
- },
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false
- },{
- fieldLabel: 'Last Name',
- name: 'last'
- },{
- fieldLabel: 'Company',
- name: 'company'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }, {
- fieldLabel: 'DOB',
- name: 'dob',
- xtype: 'datefield'
- }, {
- fieldLabel: 'Age',
- name: 'age',
- xtype: 'numberfield',
- minValue: 0,
- maxValue: 100
- }, {
- fieldLabel: 'Qualified',
- name: 'qualified',
- xtype: 'checkbox'
- }, {
- fieldLabel: 'Which',
- xtype: 'radiogroup',
- items: [{
- boxLabel: 'This',
- name: 'which'
- }, {
- boxLabel: 'That',
- name: 'which'
- }]
- }, {
- xtype: 'timefield',
- fieldLabel: 'Time',
- name: 'time',
- minValue: '8:00am',
- maxValue: '6:00pm'
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- simple.render(document.body);
- /*
- * ================ Form 2 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 2 - Adding fieldsets'});
- var fsf = Ext.create('Ext.form.Panel', {
- url:'save-form.php',
- frame:true,
- title: 'Simple Form with FieldSets',
- bodyStyle:'padding:5px 5px 0',
- width: 350,
- fieldDefaults: {
- msgTarget: 'side',
- labelWidth: 75
- },
- defaults: {
- anchor: '100%'
- },
- items: [{
- xtype:'fieldset',
- checkboxToggle:true,
- title: 'User Information',
- defaultType: 'textfield',
- collapsed: true,
- layout: 'anchor',
- defaults: {
- anchor: '100%'
- },
- items :[{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false
- },{
- fieldLabel: 'Last Name',
- name: 'last'
- },{
- fieldLabel: 'Company',
- name: 'company'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }]
- },{
- xtype:'fieldset',
- title: 'Phone Number',
- collapsible: true,
- defaultType: 'textfield',
- layout: 'anchor',
- defaults: {
- anchor: '100%'
- },
- items :[{
- fieldLabel: 'Home',
- name: 'home',
- value: '(888) 555-1212'
- },{
- fieldLabel: 'Business',
- name: 'business'
- },{
- fieldLabel: 'Mobile',
- name: 'mobile'
- },{
- fieldLabel: 'Fax',
- name: 'fax'
- }]
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- fsf.render(document.body);
- /*
- * ================ Form 3 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 3 - A little more complex'});
- var top = Ext.create('Ext.form.Panel', {
- frame:true,
- title: 'Multi Column, Nested Layouts and Anchoring',
- bodyStyle:'padding:5px 5px 0',
- width: 600,
- fieldDefaults: {
- labelAlign: 'top',
- msgTarget: 'side'
- },
- items: [{
- xtype: 'container',
- anchor: '100%',
- layout:'column',
- items:[{
- xtype: 'container',
- columnWidth:.5,
- layout: 'anchor',
- items: [{
- xtype:'textfield',
- fieldLabel: 'First Name',
- name: 'first',
- anchor:'96%'
- }, {
- xtype:'textfield',
- fieldLabel: 'Company',
- name: 'company',
- anchor:'96%'
- }]
- },{
- xtype: 'container',
- columnWidth:.5,
- layout: 'anchor',
- items: [{
- xtype:'textfield',
- fieldLabel: 'Last Name',
- name: 'last',
- anchor:'100%'
- },{
- xtype:'textfield',
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email',
- anchor:'100%'
- }]
- }]
- }, {
- xtype: 'htmleditor',
- name: 'bio',
- fieldLabel: 'Biography',
- height: 200,
- anchor: '100%'
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- top.render(document.body);
- /*
- * ================ Form 4 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 4 - Forms can be a TabPanel...'});
- var tabs = Ext.create('Ext.form.Panel', {
- width: 350,
- border: false,
- bodyBorder: false,
- fieldDefaults: {
- labelWidth: 75,
- msgTarget: 'side'
- },
- defaults: {
- anchor: '100%'
- },
- items: {
- xtype:'tabpanel',
- activeTab: 0,
- defaults:{
- bodyStyle:'padding:10px'
- },
- items:[{
- title:'Personal Details',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false,
- value: 'Ed'
- },{
- fieldLabel: 'Last Name',
- name: 'last',
- value: 'Spencer'
- },{
- fieldLabel: 'Company',
- name: 'company',
- value: 'Ext JS'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }]
- },{
- title:'Phone Numbers',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Home',
- name: 'home',
- value: '(888) 555-1212'
- },{
- fieldLabel: 'Business',
- name: 'business'
- },{
- fieldLabel: 'Mobile',
- name: 'mobile'
- },{
- fieldLabel: 'Fax',
- name: 'fax'
- }]
- }]
- },
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- tabs.render(document.body);
- /*
- * ================ Form 5 =======================
- */
- bd.createChild({tag: 'h2', html: 'Form 5 - ... and forms can contain TabPanel(s)'});
- var tab2 = Ext.create('Ext.form.Panel', {
- title: 'Inner Tabs',
- bodyStyle:'padding:5px',
- width: 600,
- fieldDefaults: {
- labelAlign: 'top',
- msgTarget: 'side'
- },
- defaults: {
- anchor: '100%'
- },
- items: [{
- layout:'column',
- border:false,
- items:[{
- columnWidth:.5,
- border:false,
- layout: 'anchor',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- anchor:'95%'
- }, {
- fieldLabel: 'Company',
- name: 'company',
- anchor:'95%'
- }]
- },{
- columnWidth:.5,
- border:false,
- layout: 'anchor',
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Last Name',
- name: 'last',
- anchor:'95%'
- },{
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email',
- anchor:'95%'
- }]
- }]
- },{
- xtype:'tabpanel',
- plain:true,
- activeTab: 0,
- height:235,
- defaults:{bodyStyle:'padding:10px'},
- items:[{
- title:'Personal Details',
- defaults: {width: 230},
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'First Name',
- name: 'first',
- allowBlank:false,
- value: 'Jamie'
- },{
- fieldLabel: 'Last Name',
- name: 'last',
- value: 'Avins'
- },{
- fieldLabel: 'Company',
- name: 'company',
- value: 'Ext JS'
- }, {
- fieldLabel: 'Email',
- name: 'email',
- vtype:'email'
- }]
- },{
- title:'Phone Numbers',
- defaults: {width: 230},
- defaultType: 'textfield',
- items: [{
- fieldLabel: 'Home',
- name: 'home',
- value: '(888) 555-1212'
- },{
- fieldLabel: 'Business',
- name: 'business'
- },{
- fieldLabel: 'Mobile',
- name: 'mobile'
- },{
- fieldLabel: 'Fax',
- name: 'fax'
- }]
- },{
- cls: 'x-plain',
- title: 'Biography',
- layout: 'fit',
- items: {
- xtype: 'htmleditor',
- name: 'bio2',
- fieldLabel: 'Biography'
- }
- }]
- }],
- buttons: [{
- text: 'Save'
- },{
- text: 'Cancel'
- }]
- });
- tab2.render(document.body);
- });
|