sample.js
资源名称:a.rar [点击查看]
上传用户:aa118c
上传日期:2021-05-13
资源大小:4785k
文件大小:15k
源码类别:

WEB源码(ASP,PHP,...)

开发平台:

HTML/CSS

  1. /*
  2.  * Ext JS Library 2.2.1
  3.  * Copyright(c) 2006-2009, Ext JS, LLC.
  4.  * licensing@extjs.com
  5.  * 
  6.  * http://extjs.com/license
  7.  */
  8. // Sample desktop configuration
  9. MyDesktop = new Ext.app.App({
  10. init :function(){
  11. Ext.QuickTips.init();
  12. },
  13. getModules : function(){
  14. return [
  15. new MyDesktop.GridWindow(),
  16.             new MyDesktop.TabWindow(),
  17.             new MyDesktop.AccordionWindow(),
  18.             new MyDesktop.BogusMenuModule(),
  19.             new MyDesktop.BogusModule()
  20. ];
  21. },
  22.     // config for the start menu
  23.     getStartConfig : function(){
  24.         return {
  25.             title: 'Jack Slocum',
  26.             iconCls: 'user',
  27.             toolItems: [{
  28.                 text:'Settings',
  29.                 iconCls:'settings',
  30.                 scope:this
  31.             },'-',{
  32.                 text:'Logout',
  33.                 iconCls:'logout',
  34.                 scope:this
  35.             }]
  36.         };
  37.     }
  38. });
  39. /*
  40.  * Example windows
  41.  */
  42. MyDesktop.GridWindow = Ext.extend(Ext.app.Module, {
  43.     id:'grid-win',
  44.     init : function(){
  45.         this.launcher = {
  46.             text: 'Grid Window',
  47.             iconCls:'icon-grid',
  48.             handler : this.createWindow,
  49.             scope: this
  50.         }
  51.     },
  52.     createWindow : function(){
  53.         var desktop = this.app.getDesktop();
  54.         var win = desktop.getWindow('grid-win');
  55.         if(!win){
  56.             win = desktop.createWindow({
  57.                 id: 'grid-win',
  58.                 title:'Grid Window',
  59.                 width:740,
  60.                 height:480,
  61.                 iconCls: 'icon-grid',
  62.                 shim:false,
  63.                 animCollapse:false,
  64.                 constrainHeader:true,
  65.                 layout: 'fit',
  66.                 items:
  67.                     new Ext.grid.GridPanel({
  68.                         border:false,
  69.                         ds: new Ext.data.Store({
  70.                             reader: new Ext.data.ArrayReader({}, [
  71.                                {name: 'company'},
  72.                                {name: 'price', type: 'float'},
  73.                                {name: 'change', type: 'float'},
  74.                                {name: 'pctChange', type: 'float'}
  75.                             ]),
  76.                             data: Ext.grid.dummyData
  77.                         }),
  78.                         cm: new Ext.grid.ColumnModel([
  79.                             new Ext.grid.RowNumberer(),
  80.                             {header: "Company", width: 120, sortable: true, dataIndex: 'company'},
  81.                             {header: "Price", width: 70, sortable: true, renderer: Ext.util.Format.usMoney, dataIndex: 'price'},
  82.                             {header: "Change", width: 70, sortable: true, dataIndex: 'change'},
  83.                             {header: "% Change", width: 70, sortable: true, dataIndex: 'pctChange'}
  84.                         ]),
  85.                         viewConfig: {
  86.                             forceFit:true
  87.                         },
  88.                         //autoExpandColumn:'company',
  89.                         tbar:[{
  90.                             text:'Add Something',
  91.                             tooltip:'Add a new row',
  92.                             iconCls:'add'
  93.                         }, '-', {
  94.                             text:'Options',
  95.                             tooltip:'Blah blah blah blaht',
  96.                             iconCls:'option'
  97.                         },'-',{
  98.                             text:'Remove Something',
  99.                             tooltip:'Remove the selected item',
  100.                             iconCls:'remove'
  101.                         }]
  102.                     })
  103.             });
  104.         }
  105.         win.show();
  106.     }
  107. });
  108. MyDesktop.TabWindow = Ext.extend(Ext.app.Module, {
  109.     id:'tab-win',
  110.     init : function(){
  111.         this.launcher = {
  112.             text: 'Tab Window',
  113.             iconCls:'tabs',
  114.             handler : this.createWindow,
  115.             scope: this
  116.         }
  117.     },
  118.     createWindow : function(){
  119.         var desktop = this.app.getDesktop();
  120.         var win = desktop.getWindow('tab-win');
  121.         if(!win){
  122.             win = desktop.createWindow({
  123.                 id: 'tab-win',
  124.                 title:'Tab Window',
  125.                 width:740,
  126.                 height:480,
  127.                 iconCls: 'tabs',
  128.                 shim:false,
  129.                 animCollapse:false,
  130.                 border:false,
  131.                 constrainHeader:true,
  132.                 layout: 'fit',
  133.                 items:
  134.                     new Ext.TabPanel({
  135.                         activeTab:0,
  136.                         items: [{
  137.                             title: 'Tab Text 1',
  138.                             header:false,
  139.                             html : '<p>Something useful would be in here.</p>',
  140.                             border:false
  141.                         },{
  142.                             title: 'Tab Text 2',
  143.                             header:false,
  144.                             html : '<p>Something useful would be in here.</p>',
  145.                             border:false
  146.                         },{
  147.                             title: 'Tab Text 3',
  148.                             header:false,
  149.                             html : '<p>Something useful would be in here.</p>',
  150.                             border:false
  151.                         },{
  152.                             title: 'Tab Text 4',
  153.                             header:false,
  154.                             html : '<p>Something useful would be in here.</p>',
  155.                             border:false
  156.                         }]
  157.                     })
  158.             });
  159.         }
  160.         win.show();
  161.     }
  162. });
  163. MyDesktop.AccordionWindow = Ext.extend(Ext.app.Module, {
  164.     id:'acc-win',
  165.     init : function(){
  166.         this.launcher = {
  167.             text: 'Accordion Window',
  168.             iconCls:'accordion',
  169.             handler : this.createWindow,
  170.             scope: this
  171.         }
  172.     },
  173.     createWindow : function(){
  174.         var desktop = this.app.getDesktop();
  175.         var win = desktop.getWindow('acc-win');
  176.         if(!win){
  177.             win = desktop.createWindow({
  178.                 id: 'acc-win',
  179.                 title: 'Accordion Window',
  180.                 width:250,
  181.                 height:400,
  182.                 iconCls: 'accordion',
  183.                 shim:false,
  184.                 animCollapse:false,
  185.                 constrainHeader:true,
  186.                 tbar:[{
  187.                     tooltip:{title:'Rich Tooltips', text:'Let your users know what they can do!'},
  188.                     iconCls:'connect'
  189.                 },'-',{
  190.                     tooltip:'Add a new user',
  191.                     iconCls:'user-add'
  192.                 },' ',{
  193.                     tooltip:'Remove the selected user',
  194.                     iconCls:'user-delete'
  195.                 }],
  196.                 layout:'accordion',
  197.                 border:false,
  198.                 layoutConfig: {
  199.                     animate:false
  200.                 },
  201.                 items: [
  202.                     new Ext.tree.TreePanel({
  203.                         id:'im-tree',
  204.                         title: 'Online Users',
  205.                         loader: new Ext.tree.TreeLoader(),
  206.                         rootVisible:false,
  207.                         lines:false,
  208.                         autoScroll:true,
  209.                         tools:[{
  210.                             id:'refresh',
  211.                             on:{
  212.                                 click: function(){
  213.                                     var tree = Ext.getCmp('im-tree');
  214.                                     tree.body.mask('Loading', 'x-mask-loading');
  215.                                     tree.root.reload();
  216.                                     tree.root.collapse(true, false);
  217.                                     setTimeout(function(){ // mimic a server call
  218.                                         tree.body.unmask();
  219.                                         tree.root.expand(true, true);
  220.                                     }, 1000);
  221.                                 }
  222.                             }
  223.                         }],
  224.                         root: new Ext.tree.AsyncTreeNode({
  225.                             text:'Online',
  226.                             children:[{
  227.                                 text:'Friends',
  228.                                 expanded:true,
  229.                                 children:[{
  230.                                     text:'Jack',
  231.                                     iconCls:'user',
  232.                                     leaf:true
  233.                                 },{
  234.                                     text:'Brian',
  235.                                     iconCls:'user',
  236.                                     leaf:true
  237.                                 },{
  238.                                     text:'Jon',
  239.                                     iconCls:'user',
  240.                                     leaf:true
  241.                                 },{
  242.                                     text:'Tim',
  243.                                     iconCls:'user',
  244.                                     leaf:true
  245.                                 },{
  246.                                     text:'Nige',
  247.                                     iconCls:'user',
  248.                                     leaf:true
  249.                                 },{
  250.                                     text:'Fred',
  251.                                     iconCls:'user',
  252.                                     leaf:true
  253.                                 },{
  254.                                     text:'Bob',
  255.                                     iconCls:'user',
  256.                                     leaf:true
  257.                                 }]
  258.                             },{
  259.                                 text:'Family',
  260.                                 expanded:true,
  261.                                 children:[{
  262.                                     text:'Kelly',
  263.                                     iconCls:'user-girl',
  264.                                     leaf:true
  265.                                 },{
  266.                                     text:'Sara',
  267.                                     iconCls:'user-girl',
  268.                                     leaf:true
  269.                                 },{
  270.                                     text:'Zack',
  271.                                     iconCls:'user-kid',
  272.                                     leaf:true
  273.                                 },{
  274.                                     text:'John',
  275.                                     iconCls:'user-kid',
  276.                                     leaf:true
  277.                                 }]
  278.                             }]
  279.                         })
  280.                     }), {
  281.                         title: 'Settings',
  282.                         html:'<p>Something useful would be in here.</p>',
  283.                         autoScroll:true
  284.                     },{
  285.                         title: 'Even More Stuff',
  286.                         html : '<p>Something useful would be in here.</p>'
  287.                     },{
  288.                         title: 'My Stuff',
  289.                         html : '<p>Something useful would be in here.</p>'
  290.                     }
  291.                 ]
  292.             });
  293.         }
  294.         win.show();
  295.     }
  296. });
  297. // for example purposes
  298. var windowIndex = 0;
  299. MyDesktop.BogusModule = Ext.extend(Ext.app.Module, {
  300.     init : function(){
  301.         this.launcher = {
  302.             text: 'Window '+(++windowIndex),
  303.             iconCls:'bogus',
  304.             handler : this.createWindow,
  305.             scope: this,
  306.             windowId:windowIndex
  307.         }
  308.     },
  309.     createWindow : function(src){
  310.         var desktop = this.app.getDesktop();
  311.         var win = desktop.getWindow('bogus'+src.windowId);
  312.         if(!win){
  313.             win = desktop.createWindow({
  314.                 id: 'bogus'+src.windowId,
  315.                 title:src.text,
  316.                 width:640,
  317.                 height:480,
  318.                 html : '<p>Something useful would be in here.</p>',
  319.                 iconCls: 'bogus',
  320.                 shim:false,
  321.                 animCollapse:false,
  322.                 constrainHeader:true
  323.             });
  324.         }
  325.         win.show();
  326.     }
  327. });
  328. MyDesktop.BogusMenuModule = Ext.extend(MyDesktop.BogusModule, {
  329.     init : function(){
  330.         this.launcher = {
  331.             text: 'Bogus Submenu',
  332.             iconCls: 'bogus',
  333.             handler: function() {
  334. return false;
  335. },
  336.             menu: {
  337.                 items:[{
  338.                     text: 'Bogus Window '+(++windowIndex),
  339.                     iconCls:'bogus',
  340.                     handler : this.createWindow,
  341.                     scope: this,
  342.                     windowId: windowIndex
  343.                     },{
  344.                     text: 'Bogus Window '+(++windowIndex),
  345.                     iconCls:'bogus',
  346.                     handler : this.createWindow,
  347.                     scope: this,
  348.                     windowId: windowIndex
  349.                     },{
  350.                     text: 'Bogus Window '+(++windowIndex),
  351.                     iconCls:'bogus',
  352.                     handler : this.createWindow,
  353.                     scope: this,
  354.                     windowId: windowIndex
  355.                     },{
  356.                     text: 'Bogus Window '+(++windowIndex),
  357.                     iconCls:'bogus',
  358.                     handler : this.createWindow,
  359.                     scope: this,
  360.                     windowId: windowIndex
  361.                     },{
  362.                     text: 'Bogus Window '+(++windowIndex),
  363.                     iconCls:'bogus',
  364.                     handler : this.createWindow,
  365.                     scope: this,
  366.                     windowId: windowIndex
  367.                 }]
  368.             }
  369.         }
  370.     }
  371. });
  372. // Array data for the grid
  373. Ext.grid.dummyData = [
  374.     ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  375.     ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  376.     ['American Express Company',52.55,0.01,0.02,'9/1 12:00am'],
  377.     ['American International Group, Inc.',64.13,0.31,0.49,'9/1 12:00am'],
  378.     ['AT&T Inc.',31.61,-0.48,-1.54,'9/1 12:00am'],
  379.     ['Caterpillar Inc.',67.27,0.92,1.39,'9/1 12:00am'],
  380.     ['Citigroup, Inc.',49.37,0.02,0.04,'9/1 12:00am'],
  381.     ['Exxon Mobil Corp',68.1,-0.43,-0.64,'9/1 12:00am'],
  382.     ['General Electric Company',34.14,-0.08,-0.23,'9/1 12:00am'],
  383.     ['General Motors Corporation',30.27,1.09,3.74,'9/1 12:00am'],
  384.     ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  385.     ['Honeywell Intl Inc',38.77,0.05,0.13,'9/1 12:00am'],
  386.     ['Intel Corporation',19.88,0.31,1.58,'9/1 12:00am'],
  387.     ['Johnson & Johnson',64.72,0.06,0.09,'9/1 12:00am'],
  388.     ['Merck & Co., Inc.',40.96,0.41,1.01,'9/1 12:00am'],
  389.     ['Microsoft Corporation',25.84,0.14,0.54,'9/1 12:00am'],
  390.     ['The Coca-Cola Company',45.07,0.26,0.58,'9/1 12:00am'],
  391.     ['The Procter & Gamble Company',61.91,0.01,0.02,'9/1 12:00am'],
  392.     ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am'],
  393.     ['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'9/1 12:00am']
  394. ];