/* * Ext JS Library 2.3.0 * Copyright(c) 2006-2009, Ext JS, LLC. * licensing@extjs.com * * http://extjs.com/license */ Ext.DataView=Ext.extend(Ext.BoxComponent,{selectedClass:"x-view-selected",emptyText:"",deferEmptyText:true,trackOver:false,last:false,initComponent:function(){Ext.DataView.superclass.initComponent.call(this);if(typeof this.tpl=="string"||Ext.isArray(this.tpl)){this.tpl=new Ext.XTemplate(this.tpl);} this.addEvents("beforeclick","click","mouseenter","mouseleave","containerclick","dblclick","contextmenu","selectionchange","beforeselect");this.all=new Ext.CompositeElementLite();this.selected=new Ext.CompositeElementLite();},onRender:function(){if(!this.el){this.el=document.createElement('div');this.el.id=this.id;} Ext.DataView.superclass.onRender.apply(this,arguments);},afterRender:function(){Ext.DataView.superclass.afterRender.call(this);this.el.on({"click":this.onClick,"dblclick":this.onDblClick,"contextmenu":this.onContextMenu,scope:this});if(this.overClass||this.trackOver){this.el.on({"mouseover":this.onMouseOver,"mouseout":this.onMouseOut,scope:this});} if(this.store){this.setStore(this.store,true);}},refresh:function(){this.clearSelections(false,true);this.el.update("");var records=this.store.getRange();if(records.length<1){if(!this.deferEmptyText||this.hasSkippedEmptyText){this.el.update(this.emptyText);} this.all.clear();}else{this.tpl.overwrite(this.el,this.collectData(records,0));this.all.fill(Ext.query(this.itemSelector,this.el.dom));this.updateIndexes(0);} this.hasSkippedEmptyText=true;},prepareData:function(data){return data;},collectData:function(records,startIndex){var r=[];for(var i=0,len=records.length;i0){if(!skipUpdate){this.selected.removeClass(this.selectedClass);} this.selected.clear();this.last=false;if(!suppressEvent){this.fireEvent("selectionchange",this,this.selected.elements);}}},isSelected:function(node){return this.selected.contains(this.getNode(node));},deselect:function(node){if(this.isSelected(node)){node=this.getNode(node);this.selected.removeElement(node);if(this.last==node.viewIndex){this.last=false;} Ext.fly(node).removeClass(this.selectedClass);this.fireEvent("selectionchange",this,this.selected.elements);}},select:function(nodeInfo,keepExisting,suppressEvent){if(Ext.isArray(nodeInfo)){if(!keepExisting){this.clearSelections(true);} for(var i=0,len=nodeInfo.length;i=end&&ns[i];i--){nodes.push(ns[i]);}} return nodes;},indexOf:function(node){node=this.getNode(node);if(typeof node.viewIndex=="number"){return node.viewIndex;} return this.all.indexOf(node);},onBeforeLoad:function(){if(this.loadingText){this.clearSelections(false,true);this.el.update('
'+this.loadingText+'
');this.all.clear();}},onDestroy:function(){Ext.DataView.superclass.onDestroy.call(this);this.setStore(null);}});Ext.reg('dataview',Ext.DataView);