dynamic.js
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:10k
源码类别:

中间件编程

开发平台:

JavaScript

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