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

中间件编程

开发平台:

JavaScript

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