samplescripts.js

来自「经典编程900例(C语言),主要是C基础知识」· JavaScript 代码 · 共 127 行 · 第 1/4 页

JS
127
字号
SampleScripts.grid.EditGridScript.main=function(args){ExtClass.onReady(Delegate.create(null,function(){new SampleScripts.grid.EditGridScript().init();}));}SampleScripts.grid.EditGridScript.prototype={init:function(){var $0=new SampleScripts.grid.CheckColumn(new Ext.grid.ColumnModelConfig().header('Indoor?').dataIndex('indoor').width(55).toDictionary());var $1=new Ext.grid.ColumnModel([new Ext.grid.ColumnModelConfig().id('common').header('Common Name').dataIndex('common').width(220).editor(new Ext.form.TextField(new Ext.form.TextFieldConfig().allowBlank(false).toDictionary())).toDictionary(),new Ext.grid.ColumnModelConfig().header('Light').dataIndex('light').width(130).editor(new Ext.form.ComboBox(new Ext.form.ComboBoxConfig().typeAhead(true).triggerAction('all').transform('light').lazyRender(true).listClass('x-combo-list-small').toDictionary())).toDictionary(),new Ext.grid.ColumnModelConfig().header('Price').dataIndex('price').width(70).align('right').renderer(Delegate.create(null,Ext.util.Format.usMoney)).editor(new Ext.form.NumberField(new Ext.form.NumberFieldConfig().allowBlank(false).allowNegative(false).maxValue(100000).toDictionary())).toDictionary(),new Ext.grid.ColumnModelConfig().header('Available').dataIndex('availDate').width(95).renderer(Delegate.create(this,this.formatDate)).editor(new Ext.form.DateField(new Ext.form.DateFieldConfig().format('m/d/y').minValue('01/01/06').disabledDays([0,6]).disabledDaysText('Plants are not available on the weekends').toDictionary())).toDictionary(),$0]);$1.defaultSortable=true;var $2=[{name:'common',type:'string'},{name:'botanical',type:'string'},{name:'light'},{name:'price',type:'float'},{name:'availDate',mapping:'availability',type:'date',dateFormat:'m/d/Y'},{name:'indoor',type:'bool'}];var $3=new Ext.data.Store(new Ext.data.StoreConfig().url('plants.xml').reader(new Ext.data.XmlReader(new Ext.data.XmlReaderConfig().record('plant').toDictionary(),$2)).sortInfo({field:'common',direction:'ASC'}).toDictionary());var $4=null;$4=new Ext.grid.EditorGridPanel(new Ext.grid.EditorGridPanelConfig().ds($3).cm($1).renderTo('editor-grid').width(600).height(300).autoExpandColumn('common').title('Edit Plants?').frame(true).plugins($0).clicksToEdit(1).tbar([{text:'Add Plant',handler:Delegate.create(this,function(){var $0=new Ext.data.Record($2);$4.stopEditing();$3.insert(0,[$0]);$0.set('common','New Plant 1');$0.set('light','Mostly Shade');$0.set('price',0);$0.set('availDate',new Date());$0.set('indoor',false);$4.startEditing(0,0);})}]).toDictionary());$3.load();},formatBoolean:function(value){return (value)?'Yes':'No';},formatDate:function(value){return (isNullOrUndefined(value))?'':value.dateFormat('M d, Y');}}SampleScripts.grid.CheckColumn=function(config){ExtClass.apply(this,config,null);if(isNullOrUndefined(this.id)){this.id=ExtClass.id();}}SampleScripts.grid.CheckColumn.prototype={id:null,dataIndex:null,grid:null,init:function(g){this.grid=g;this.grid.on('render',Delegate.create(this,function(){var $0=this.grid.getView();var $1=$0.mainBody;$1.on('mousedown',Delegate.create(this,this.onMouseDown),this);}),this);},onMouseDown:function(e,t){if(!isNullOrUndefined(t.className)&&t.className.indexOf('x-grid3-cc-'+this.id)!==-1){e.stopEvent();var $0=this.grid.getView().findRowIndex(t);var $1=this.grid.store.getAt($0);var $2=$1.get(this.dataIndex);$1.set(this.dataIndex,!$2);}},renderer:function(value,p,record){p['css']+=' x-grid3-check-col-td';return '<div class=\"x-grid3-check-col'+((value)?'-on':'')+' x-grid3-cc-'+this.id+'\">&#160;</div>';}}SampleScripts.grid.GroupingGridScript=function(){}SampleScripts.grid.GroupingGridScript.main=function(args){ExtClass.onReady(Delegate.create(null,function(){new SampleScripts.grid.GroupingGridScript().init();}));}SampleScripts.grid.GroupingGridScript.prototype={init:function(){var $0=new Ext.data.ArrayReader(new Ext.data.ArrayReaderConfig().toDictionary(),[{name:'company'},{name:'price',type:'float'},{name:'change',type:'float'},{name:'pctChange',type:'float'},{name:'lastChange',type:'date',dateFormat:'n/j h:ia'},{name:'industry'},{name:'desc'}]);var $1=new Ext.data.GroupingStore(new Ext.data.GroupingStoreConfig().reader($0).data(this.$0()).sortInfo({field:'company',direction:'ASC'}).groupField('industry').toDictionary());var $2=[{id:'company',header:'Company',width:60,sortable:true,dataIndex:'company'},{header:'Price',width:20,sortable:true,renderer:Delegate.create(null,Ext.util.Format.usMoney),dataIndex:'price'},{header:'Change',width:20,sortable:true,dataIndex:'change',renderer:Delegate.create(null,Ext.util.Format.usMoney)},{header:'Industry',width:20,sortable:true,dataIndex:'industry'},{header:'Last Updated',width:20,sortable:true,renderer:Ext.util.Format.dateRenderer('m/d/Y'),dataIndex:'lastChange'}];var $3=new Ext.grid.GroupingView(new Ext.grid.GroupingViewConfig().forceFit(true).groupTextTpl('{text} ({[values.rs.length]} {[values.rs.length > 1 ? \"Items\" : \"Item\"]})').toDictionary());var $4=new Ext.grid.GridPanel(new Ext.grid.GridPanelConfig().ds($1).columns($2).view($3).frame(true).width(700).height(400).collapsible(true).animCollapse(false).title('Grouping Example').iconCls('icon-grid').renderTo(document.body).toDictionary());},$0:function(){return [['3m Co',71.72,0.02,0.03,'4/2 12:00am','Manufacturing'],['Alcoa Inc',29.01,0.42,1.47,'4/1 12:00am','Manufacturing'],['Altria Group Inc',83.81,0.28,0.34,'4/3 12:00am','Manufacturing'],['American Express Company',52.55,0.01,0.02,'4/8 12:00am','Finance'],['American International Group, Inc.',64.13,0.31,0.49,'4/1 12:00am','Services'],['AT&T Inc.',31.61,-0.48,-1.54,'4/8 12:00am','Services'],['Boeing Co.',75.43,0.53,0.71,'4/8 12:00am','Manufacturing'],['Caterpillar Inc.',67.27,0.92,1.39,'4/1 12:00am','Services'],['Citigroup, Inc.',49.37,0.02,0.04,'4/4 12:00am','Finance'],['E.I. du Pont de Nemours and Company',40.48,0.51,1.28,'4/1 12:00am','Manufacturing'],['Exxon Mobil Corp',68.1,-0.43,-0.64,'4/3 12:00am','Manufacturing'],['General Electric Company',34.14,-0.08,-0.23,'4/3 12:00am','Manufacturing'],['General Motors Corporation',30.27,1.09,3.74,'4/3 12:00am','Automotive'],['Hewlett-Packard Co.',36.53,-0.03,-0.08,'4/3 12:00am','Computer'],['Honeywell Intl Inc',38.77,0.05,0.13,'4/3 12:00am','Manufacturing'],['Intel Corporation',19.88,0.31,1.58,'4/2 12:00am','Computer'],['International Business Machines',81.41,0.44,0.54,'4/1 12:00am','Computer'],['Johnson & Johnson',64.72,0.06,0.09,'4/2 12:00am','Medical'],['JP Morgan & Chase & Co',45.73,0.07,0.15,'4/2 12:00am','Finance'],['McDonald\"s Corporation',36.76,0.86,2.4,'4/2 12:00am','Food'],['Merck & Co., Inc.',40.96,0.41,1.01,'4/2 12:00am','Medical'],['Microsoft Corporation',25.84,0.14,0.54,'4/2 12:00am','Computer'],['Pfizer Inc',27.96,0.4,1.45,'4/8 12:00am','Services','Medical'],['The Coca-Cola Company',45.07,0.26,0.58,'4/1 12:00am','Food'],['The Home Depot, Inc.',34.64,0.35,1.02,'4/8 12:00am','Retail'],['The Procter & Gamble Company',61.91,0.01,0.02,'4/1 12:00am','Manufacturing'],['United Technologies Corporation',63.26,0.55,0.88,'4/1 12:00am','Computer'],['Verizon Communications',35.57,0.39,1.11,'4/3 12:00am','Services'],['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'4/3 12:00am','Retail'],['Walt Disney Company (The) (Holding Company)',29.89,0.24,0.81,'4/1 12:00am','Services']];}}SampleScripts.grid.PagingGridScript=function(){}SampleScripts.grid.PagingGridScript.main=function(args){ExtClass.onReady(Delegate.create(null,function(){new SampleScripts.grid.PagingGridScript().init();}));}SampleScripts.grid.PagingGridScript.prototype={$0:null,$1:null,init:function(){var $0=new Ext.data.Store(new Ext.data.StoreConfig().custom('proxy',new Ext.data.ScriptTagProxy(new Ext.data.ScriptTagProxyConfig().url('http://extjs.com/forum/topics-browse-remote.php').toDictionary())).reader(new Ext.data.JsonReader(new Ext.data.JsonReaderConfig().root('topics').totalProperty('totalCount').id('threadid').toDictionary(),['title','forumtitle','forumid','author',{name:'replycount',type:'int'},{name:'lastpost',mapping:'lastpost',type:'date',dateFormat:'timestamp'},'lastposter','excerpt'])).remoteSort(true).toDictionary());$0.setDefaultSort('lastpost','desc');this.$1=new Ext.grid.ColumnModel([new Ext.grid.ColumnModelConfig().id('topic').header('Topic').dataIndex('title').width(420).renderer(Delegate.create(this,this.$4)).toDictionary(),new Ext.grid.ColumnModelConfig().header('Author').dataIndex('author').width(100).hidden(true).toDictionary(),new Ext.grid.ColumnModelConfig().header('Replies').dataIndex('replycount').width(70).align('right').toDictionary(),new Ext.grid.ColumnModelConfig().id('last').header('Last Post').dataIndex('lastpost').width(150).renderer(Delegate.create(this,this.$5)).toDictionary()]);this.$1.defaultSortable=true;var $1=new Ext.PagingToolbar(new Ext.PagingToolbarConfig().pageSize(25).store($0).displayInfo(true).displayMsg('Displaying topics {0} - {1} of {2}').emptyMsg('No topics to display').items(['-',new Ext.ButtonConfig().pressed(true).enableToggle(true).text('Show Preview').cls('x-btn-text-icon details').toggleHandler(Delegate.create(this,this.$2)).toDictionary()]).toDictionary());var $2=new Ext.grid.GridViewConfig().forceFit(true).enableRowBody(true).custom('showPreview',true).getRowClass(Delegate.create(this,this.$3));this.$0=new Ext.grid.GridPanel(new Ext.grid.GridPanelConfig().el('topic-grid').width(700).height(500).title('ExtJS.com - Browse Forums').store($0).cm(this.$1).trackMouseOver(false).sm(new Ext.grid.RowSelectionModel({selectRow:Delegate.create(null,ExtClass.emptyFn)})).loadMask(true).viewConfig($2.toDictionary()).bbar($1).toDictionary());this.$0.render();$0.load({params:{start:0,limit:25,forumId:4}});},$2:function($p0,$p1){var $0=this.$0.getView();$0.showPreview = $p1;$0.refresh();},$3:function($p0,$p1,$p2,$p3){if(this.$0.getView().showPreview){$p2['body']='<p>'+$p0.get('excerpt')+'</p>';return 'x-grid3-row-expanded';}return 'x-grid3-row-collapsed';},$4:function($p0,$p1,$p2){return String.format('<b><a href=\"http://extjs.com/forum/showthread.php?t={2}\" target=\"_blank\">{0}</a></b>'+'<a href=\"http://extjs.com/forum/forumdisplay.php?f={3}\" target=\"_blank\">{1} Forum</a>',$p0,$p2.get('forumtitle'),$p2.get('id'),$p2.get('forumid'));},$5:function($p0,$p1,$p2){return String.format('{0}<br/>by {1}',$p0.dateFormat('M j, Y, g:i a'),$p2.get('author'));}}SampleScripts.grid.TotalsGridScript=function(){}SampleScripts.grid.TotalsGridScript.main=function(args){ExtClass.onReady(Delegate.create(null,function(){new SampleScripts.grid.TotalsGridScript().init();}));}SampleScripts.grid.TotalsGridScript.prototype={init:function(){var $0=new Ext.data.JsonReader(new Ext.data.JsonReaderConfig().custom('idProperty','taskId').custom('fields',[{name:'projectId',type:'int'},{name:'project',type:'string'},{name:'taskId',type:'int'},{name:'description',type:'string'},{name:'estimate',type:'float'},{name:'rate',type:'float'},{name:'cost',type:'float'},{name:'due',type:'date',dateFormat:'m/d/Y'}]).toDictionary());},$0:function(){return [{projectId:100,project:'Ext Forms: Field Anchoring'},{projectId:101,project:'Ext Grid: Single-level Grouping'},{projectId:102,project:'Ext Grid: Summary Rows'}];},$1:function(){return [{projectId:100,project:'Ext Forms: Field Anchoring',taskId:112,description:'Integrate 2.0 Forms with 2.0 Layouts',estimate:6,rate:150,due:'06/24/2007'},{projectId:100,project:'Ext Forms: Field Anchoring',taskId:113,description:'Implement AnchorLayout',estimate:4,rate:150,due:'06/25/2007'},{projectId:100,project:'Ext Forms: Field Anchoring',taskId:114,description:'Add support for multiple types of anchors',estimate:4,rate:150,due:'06/27/2007'},{projectId:100,project:'Ext Forms: Field Anchoring',taskId:115,description:'Testing and debugging',estimate:8,rate:0,due:'06/29/2007'},{projectId:101,project:'Ext Grid: Single-level Grouping',taskId:101,description:'Add required rendering \"hooks\" to GridView',estimate:6,rate:100,due:'07/01/2007'},{projectId:101,project:'Ext Grid: Single-level Grouping',taskId:102,description:'Extend GridView and override rendering functions',estimate:6,rate:100,due:'07/03/2007'},{projectId:101,project:'Ext Grid: Single-level Grouping',taskId:103,description:'Extend Store with grouping functionality',estimate:4,rate:100,due:'07/04/2007'},{projectId:101,project:'Ext Grid: Single-level Grouping',taskId:121,description:'Default CSS Styling',estimate:2,rate:100,due:'07/05/2007'},{projectId:101,project:'Ext Grid: Single-level Grouping',taskId:104,description:'Testing and debugging',estimate:6,rate:100,due:'07/06/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:105,description:'Ext Grid plugin integration',estimate:4,rate:125,due:'07/01/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:106,description:'Summary creation during rendering phase',estimate:4,rate:125,due:'07/02/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:107,description:'Dynamic summary updates in editor grids',estimate:6,rate:125,due:'07/05/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:108,description:'Remote summary integration',estimate:4,rate:125,due:'07/05/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:109,description:'Summary renderers and calculators',estimate:4,rate:125,due:'07/06/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:110,description:'Integrate summaries with GroupingView',estimate:10,rate:125,due:'07/11/2007'},{projectId:102,project:'Ext Grid: Summary Rows',taskId:111,description:'Testing and debugging',estimate:8,rate:125,due:'07/15/2007'}];}}SampleScripts.grid.XmlGridScript=function(){}SampleScripts.grid.XmlGridScript.main=function(args){ExtClass.onReady(Delegate.create(null,function(){new SampleScripts.grid.XmlGridScript().init();}));}SampleScripts.grid.XmlGridScript.prototype={init:function(){var $0=new Ext.data.Store(new Ext.data.StoreConfig().url('sheldon.xml').reader(new Ext.data.XmlReader(new Ext.data.XmlReaderConfig().record('Item').id('ASIN').totalRecords('@total').toDictionary(),[{name:'Author',mapping:'ItemAttributes > Author'},'Title','Manufacturer','ProductGroup'])).toDictionary());var $1=new Ext.grid.ColumnModel([new Ext.grid.ColumnModelConfig().header('Author').width(120).dataIndex('Author').toDictionary(),new Ext.grid.ColumnModelConfig().header('Title').width(180).dataIndex('Title').toDictionary(),new Ext.grid.ColumnModelConfig().header('Manufacturer').width(115).dataIndex('Manufacturer').toDictionary(),new Ext.grid.ColumnModelConfig().header('Product Group').width(100).dataIndex('ProductGroup').toDictionary()]);$1.defaultSortable=true;var $2=new Ext.grid.GridPanel(new Ext.grid.GridPanelConfig().ds($0).cm($1).renderTo('example-grid').width(540).height(200).toDictionary());$0.load();}}Type.createNamespace('SampleScripts.messagebox');SampleScripts.messagebox.MessageBoxScript=function(){}SampleScripts.messagebox.MessageBoxScript.main=function(args){ExtClass.onReady(Delegate.create(null,function(){new SampleScripts.messagebox.MessageBoxScript().init();}));}SampleScripts.messagebox.MessageBoxScript.$0=function($p0,$p1){Ext.MessageBox.alert('Button Click',String.format('You clicked the {0} button',$p0));}SampleScripts.messagebox.MessageBoxScript.$1=function($p0,$p1){Ext.MessageBox.alert('Button Click',String.format('You clicked the {0} button and entered the text \"{1}\".',$p0,$p1));}SampleScripts.messagebox.MessageBoxScript.$2=function($p0){return Delegate.create(null,function(){if($p0===12){Ext.MessageBox.hide();Ext.MessageBox.alert('Done','Your fake items were loaded!');}else{var $0=$p0/11;Ext.MessageBox.updateProgress($0,Math.round(100*$0)+'% completed');}});}SampleScripts.messagebox.MessageBoxScript.prototype={init:function(){ExtClass.get('mb1').on('click',Delegate.create(this,function(){Ext.MessageBox.confirm('Confirm','Are you sure you want to do that?',Delegate.create(null,SampleScripts.messagebox.MessageBoxScript.$0));}));ExtClass.get('mb2').on('click',Delegate.create(this,function(){

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?