/*
	Copyright (c) 2004-2007, The TurboAjax Group, All Rights Reserved.
	http://turboajax.com/turbowidgets
*/

dojo.provide("turbo.lib.scroller");
dojo.require("dojo.event.*");
dojo.declare("turbo.scroller.base",null,function(){
this.pageHeights=[];
this.stack=[];
},{rowCount:0,defaultRowHeight:10,keepRows:100,contentNode:null,scrollboxNode:null,defaultPageHeight:0,keepPages:10,pageCount:0,windowHeight:0,firstVisibleRow:0,lastVisibleRow:0,page:0,pageTop:0,init:function(_1,_2,_3){
switch(arguments.length){
case 3:
this.rowsPerPage=_3;
case 2:
this.keepRows=_2;
case 1:
this.rowCount=_1;
}
this.defaultPageHeight=this.defaultRowHeight*this.rowsPerPage;
this.pageCount=Math.ceil(this.rowCount/this.rowsPerPage);
this.keepPages=Math.max(Math.ceil(this.keepRows/this.rowsPerPage),2);
this.invalidate();
if(this.scrollboxNode){
this.scrollboxNode.scrollTop=0;
this.scroll(0);
this.scrollboxNode.onscroll=turbo.bind(this,"onscroll");
}
},invalidate:function(){
this.invalidateNodes();
this.pageHeights=[];
this.height=(this.pageCount?(this.pageCount-1)*this.defaultPageHeight+this.calcLastPageHeight():0);
this.resize();
},updateRowCount:function(_4){
this.invalidateNodes();
this.rowCount=_4;
oldPageCount=this.pageCount;
this.pageCount=Math.ceil(this.rowCount/this.rowsPerPage);
if(this.pageCount<oldPageCount){
for(var i=oldPageCount-1;i>=this.pageCount;i--){
this.height-=this.getPageHeight(i);
delete this.pageHeights[i];
}
}else{
if(this.pageCount>oldPageCount){
this.height+=this.defaultPageHeight*(this.pageCount-oldPageCount-1)+this.calcLastPageHeight();
}
}
this.resize();
},pageExists:function(_6){
},measurePage:function(_7){
},positionPage:function(_8,_9){
},repositionPages:function(_a){
},installPage:function(_b){
},preparePage:function(_c,_d,_e){
},renderPage:function(_f){
},removePage:function(_10){
},pacify:function(_11){
},pacifying:false,pacifyTicks:200,setPacifying:function(_12){
if(this.pacifying!=_12){
this.pacifying=_12;
this.pacify(this.pacifying);
}
},startPacify:function(){
this.startPacifyTicks=new Date().getTime();
},doPacify:function(){
var _13=(new Date().getTime()-this.startPacifyTicks)>this.pacifyTicks;
this.setPacifying(true);
this.startPacify();
return _13;
},endPacify:function(){
this.setPacifying(false);
},resize:function(){
if(this.scrollboxNode){
this.windowHeight=this.scrollboxNode.clientHeight;
}
turbo.setStyleHeightPx(this.contentNode,this.height);
},calcLastPageHeight:function(){
if(!this.pageCount){
return 0;
}
var _14=this.pageCount-1;
var _15=((this.rowCount%this.rowsPerPage)||(this.rowsPerPage))*this.defaultRowHeight;
this.pageHeights[_14]=_15;
return _15;
},updateContentHeight:function(_16){
this.height+=_16;
this.resize();
},updatePageHeight:function(_17){
if(this.pageExists(_17)){
var oh=this.getPageHeight(_17);
var h=(this.measurePage(_17))||(oh);
this.pageHeights[_17]=h;
if((h)&&(oh!=h)){
this.updateContentHeight(h-oh);
this.repositionPages(_17);
}
}
},rowHeightChanged:function(_1a){
this.updatePageHeight(Math.floor(_1a/this.rowsPerPage));
},invalidateNodes:function(){
while(this.stack.length){
this.destroyPage(this.popPage());
}
},createPageNode:function(){
var p=document.createElement("div");
p.style.position="absolute";
p.style.left="0";
return p;
},getPageHeight:function(_1c){
var ph=this.pageHeights[_1c];
return (ph!==undefined?ph:this.defaultPageHeight);
},pushPage:function(_1e){
return this.stack.push(_1e);
},popPage:function(){
return this.stack.shift();
},findPage:function(_1f){
var i=0,h=0;
for(var ph=0;i<this.pageCount;i++,h+=ph){
ph=this.getPageHeight(i);
if(h+ph>=_1f){
break;
}
}
this.page=i;
this.pageTop=h;
},buildPage:function(_23,_24,_25){
this.preparePage(_23,_24);
this.positionPage(_23,_25);
this.installPage(_23);
this.renderPage(_23);
this.pushPage(_23);
},needPage:function(_26,_27){
var h=this.getPageHeight(_26),oh=h;
if(!this.pageExists(_26)){
this.buildPage(_26,(this.keepPages)&&(this.stack.length>=this.keepPages),_27);
h=this.measurePage(_26)||h;
this.pageHeights[_26]=h;
if(h&&(oh!=h)){
this.updateContentHeight(h-oh);
}
}else{
this.positionPage(_26,_27);
}
return h;
},onscroll:function(){
this.scroll(this.scrollboxNode.scrollTop);
},scroll:function(_2a){
this.startPacify();
this.findPage(_2a);
var h=this.height;
var b=this.getScrollBottom(_2a);
for(var p=this.page,y=this.pageTop;(p<this.pageCount)&&((b<0)||(y<b));p++){
y+=this.needPage(p,y);
}
this.firstVisibleRow=this.getFirstVisibleRow(this.page,this.pageTop,_2a);
this.lastVisibleRow=this.getLastVisibleRow(p-1,y,b);
if(h!=this.height){
this.repositionPages(p-1);
}
this.endPacify();
},getScrollBottom:function(_2f){
return (this.windowHeight>=0?_2f+this.windowHeight:-1);
},processNodeEvent:function(e,_31){
var t=e.target;
while(t&&(t!=_31)&&t.parentNode&&(t.parentNode.parentNode!=_31)){
t=t.parentNode;
}
if(!t||!t.parentNode||(t.parentNode.parentNode!=_31)){
return false;
}
var _33=t.parentNode;
e.topRowIndex=_33.pageIndex*this.rowsPerPage;
e.rowIndex=e.topRowIndex+turbo.indexInParent(t);
e.rowTarget=t;
return true;
},processEvent:function(e){
return this.processNodeEvent(e,this.contentNode);
},dummy:0});
dojo.declare("turbo.scroller",turbo.scroller.base,function(){
this.pageNodes=[];
},{renderRow:function(_35,_36){
},removeRow:function(_37){
},getDefaultNodes:function(){
return this.pageNodes;
},getDefaultPageNode:function(_38){
return this.getDefaultNodes()[_38];
},positionPageNode:function(_39,_3a){
_39.style.top=_3a+"px";
},getPageNodePosition:function(_3b){
return _3b.offsetTop;
},repositionPageNodes:function(_3c,_3d){
var _3e=0;
for(var i=0;i<this.stack.length;i++){
_3e=Math.max(this.stack[i],_3e);
}
var n=_3d[_3c];
var y=(n?this.getPageNodePosition(n)+this.getPageHeight(_3c):0);
for(var p=_3c+1;p<=_3e;p++){
n=_3d[p];
if(n){
if(this.getPageNodePosition(n)==y){
return;
}
this.positionPage(p,y);
}
y+=this.getPageHeight(p);
}
},invalidatePageNode:function(_43,_44){
var p=_44[_43];
if(p){
delete _44[_43];
this.removePage(_43,p);
turbo.clean(p);
p.innerHTML="";
}
return p;
},preparePageNode:function(_46,_47,_48){
var p=(_47===null?this.createPageNode():this.invalidatePageNode(_47,_48));
p.pageIndex=_46;
p.id="page-"+_46;
_48[_46]=p;
},pageExists:function(_4a){
return Boolean(this.getDefaultPageNode(_4a));
},measurePage:function(_4b){
return this.getDefaultPageNode(_4b).offsetHeight;
},positionPage:function(_4c,_4d){
this.positionPageNode(this.getDefaultPageNode(_4c),_4d);
},repositionPages:function(_4e){
this.repositionPageNodes(_4e,this.getDefaultNodes());
},preparePage:function(_4f,_50){
this.preparePageNode(_4f,(_50?this.popPage():null),this.getDefaultNodes());
},installPage:function(_51){
this.contentNode.appendChild(this.getDefaultPageNode(_51));
},destroyPage:function(_52){
var p=this.invalidatePageNode(_52,this.getDefaultNodes());
turbo.remove(p);
},renderPage:function(_54){
var _55=this.pageNodes[_54];
for(var i=0,j=_54*this.rowsPerPage;(i<this.rowsPerPage)&&(j<this.rowCount);i++,j++){
this.renderRow(j,_55);
}
},removePage:function(_58){
for(var i=0,j=_58*this.rowsPerPage;i<this.rowsPerPage;i++,j++){
this.removeRow(j);
}
},getPageRow:function(_5b){
return _5b*this.rowsPerPage;
},getLastPageRow:function(_5c){
return Math.min(this.rowCount,this.getPageRow(_5c+1))-1;
},getFirstVisibleRowNodes:function(_5d,_5e,_5f,_60){
var row=this.getPageRow(_5d);
var _62=turbo.divkids(_60[_5d]);
for(var i=0,l=_62.length;i<l&&_5e<_5f;i++,row++){
_5e+=_62[i].offsetHeight;
}
return (row?row-1:row);
},getFirstVisibleRow:function(_65,_66,_67){
if(!this.pageExists(_65)){
return 0;
}
return this.getFirstVisibleRowNodes(_65,_66,_67,this.getDefaultNodes());
},getLastVisibleRowNodes:function(_68,_69,_6a,_6b){
var row=this.getLastPageRow(_68);
var _6d=turbo.divkids(_6b[_68]);
for(var i=_6d.length-1;i>=0&&_69>_6a;i--,row--){
_69-=_6d[i].offsetHeight;
}
return row+1;
},getLastVisibleRow:function(_6f,_70,_71){
if(!this.pageExists(_6f)){
return 0;
}
return this.getLastVisibleRowNodes(_6f,_70,_71,this.getDefaultNodes());
},findTopRowForNodes:function(_72,_73){
var _74=turbo.divkids(_73[this.page]);
for(var i=0,l=_74.length,t=this.pageTop,h;i<l;i++){
h=_74[i].offsetHeight;
t+=h;
if(t>=_72){
this.offset=h-(t-_72);
return i+this.page*this.rowsPerPage;
}
}
return -1;
},findScrollTopForNodes:function(_79,_7a){
var _7b=Math.floor(_79/this.rowsPerPage);
var t=0;
for(var i=0;i<_7b;i++){
t+=this.getPageHeight(i);
}
this.pageTop=t;
this.needPage(_7b,this.pageTop);
var _7e=turbo.divkids(_7a[_7b]);
var r=_79-this.rowsPerPage*_7b;
for(var i=0,l=_7e.length;i<l&&i<r;i++){
t+=_7e[i].offsetHeight;
}
return t;
},findTopRow:function(_81){
return this.findTopRowForNodes(_81,this.getDefaultNodes());
},findScrollTop:function(_82){
return this.findScrollTopForNodes(_82,this.getDefaultNodes());
},dummy:0});
dojo.declare("turbo.scroller.columns",turbo.scroller,function(_83){
this.setContentNodes(_83);
},{setContentNodes:function(_84){
this.contentNodes=_84;
this.colCount=(this.contentNodes?this.contentNodes.length:0);
this.pageNodes=[];
for(var i=0;i<this.colCount;i++){
this.pageNodes[i]=[];
}
},getDefaultNodes:function(){
return this.pageNodes[0]||[];
},scroll:function(_86){
if(this.colCount){
turbo.scroller.prototype.scroll.call(this,_86);
}
},resize:function(){
if(this.scrollboxNode){
this.windowHeight=this.scrollboxNode.clientHeight;
}
for(var i=0;i<this.colCount;i++){
turbo.setStyleHeightPx(this.contentNodes[i],this.height);
}
},positionPage:function(_88,_89){
for(var i=0;i<this.colCount;i++){
this.positionPageNode(this.pageNodes[i][_88],_89);
}
},preparePage:function(_8b,_8c){
var p=(_8c?this.popPage():null);
for(var i=0;i<this.colCount;i++){
this.preparePageNode(_8b,p,this.pageNodes[i]);
}
},installPage:function(_8f){
for(var i=0;i<this.colCount;i++){
this.contentNodes[i].appendChild(this.pageNodes[i][_8f]);
}
},destroyPage:function(_91){
for(var i=0;i<this.colCount;i++){
turbo.remove(this.invalidatePageNode(_91,this.pageNodes[i]));
}
},renderPage:function(_93){
var _94=[];
for(var i=0;i<this.colCount;i++){
_94[i]=this.pageNodes[i][_93];
}
for(var i=0,j=_93*this.rowsPerPage;(i<this.rowsPerPage)&&(j<this.rowCount);i++,j++){
this.renderRow(j,_94);
}
}});
dojo.provide("turbo.data.fields");
turbo.data.mixer=function(){
this.defaultValue={};
this.values=[];
this.count=function(){
return this.values.length;
};
this.clear=function(){
this.values=[];
};
this.build=function(_97){
var _98=turbo.swiss(this.defaultValue,{owner:this});
_98.key=_97;
this.values[_97]=_98;
return _98;
};
this.getDefault=function(){
return this.defaultValue;
};
this.setDefault=function(_99){
for(var i=0,l=arguments.length;i<l;i++){
turbo.swiss(arguments[i]||{},this.defaultValue);
}
};
this.get=function(_9c){
return (this.values[_9c]||this.build(_9c));
};
this._set=function(_9d,_9e){
var v=this.get(_9d);
for(var i=1;i<arguments.length;i++){
turbo.swiss(arguments[i],v);
}
this.values[_9d]=v;
};
this.set=function(){
if(arguments.length<1){
return;
}
var a=arguments[0];
if(!dojo.lang.isArray(a)){
this._set.apply(this,arguments);
}else{
if(a.length&&a[0]["default"]){
this.setDefault(a.shift());
}
for(var i=0,l=a.length;i<l;i++){
this._set(i,a[i]);
}
}
};
this.insert=function(_a4,_a5){
if(_a4>=this.values.length){
this.values[_a4]=_a5;
}else{
this.values.splice(_a4,0,_a5);
}
};
this.remove=function(_a6){
this.values.splice(_a6,1);
};
this.swap=function(_a7,_a8){
turbo.arraySwap(this.values,_a7,_a8);
};
this.move=function(_a9,_aa){
turbo.arrayMove(this.values,_a9,_aa);
};
};
turbo.data.field=function(_ab){
this.name=_ab;
this.compare=turbo.data.compare;
this.na="...";
};
turbo.data.fields=function(_ac){
turbo.data.mixer.call(this);
var _ad=(_ac?_ac:turbo.data.field);
this.defaultValue=new _ad();
};
turbo.data.compare=function(a,b){
return (a>b?1:(a==b?0:-1));
};
turbo.data.generateComparator=function(_b0,_b1,_b2){
return function(a,b){
var c=Math.abs(_b1)-1;
var _b6=_b0(a[c],b[c]);
return (_b6?(_b1>0?_b6:-_b6):(_b2&&_b2(a,b)));
};
};
dojo.provide("turbo.data.model");
dojo.require("turbo.data.fields");
dojo.declare("turbo.data.model",null,function(_b7,_b8){
this.fields=new turbo.data.fields();
if(_b7){
this.fields.set(_b7);
}
this.set(_b8);
},{count:0,updating:0,observe:function(_b9,_ba,_bb,_bc){
dojo.event[_bc?"disconnect":"connect"](this,_b9,_ba,_bb);
},unobserve:function(_bd,_be,_bf){
this.observe(_bd,_be,_bf,true);
},clear:function(){
this.fields.clear();
this.clearData();
},beginUpdate:function(){
this.updating++;
},endUpdate:function(){
if(this.updating){
this.updating--;
if(!this.updating){
this.change();
}
}
},isUpdating:function(){
return Boolean(this.updating);
},clearData:function(){
this.set(null);
},change:function(){
},insertion:function(){
},removal:function(){
},_get:function(){
},_set:function(_c0){
},_setData:function(){
},_update:function(_c1,_c2){
return false;
},_insert:function(_c3){
return false;
},_remove:function(){
return false;
},get:function(){
return this._get.apply(this,arguments);
},set:function(_c4){
this._set.apply(this,arguments);
this.change.apply(this,turbo.cloneArguments(arguments,1));
return true;
},compare:function(_c5,_c6){
return turbo.arrayCompare(_c5,_c6);
},modify:function(_c7,_c8){
if(!this.compare(_c7,_c8)){
this.update.apply(this,arguments);
}
},update:function(_c9,_ca,_cb){
return this.defaultUpdate.apply(this,arguments);
},defaultUpdate:function(_cc,_cd){
if(!this._update.apply(this,arguments)){
return false;
}
this.change.apply(this,turbo.cloneArguments(arguments,2));
},insert:function(_ce){
return this.defaultInsert.apply(this,arguments);
},defaultInsert:function(_cf){
if(!this._insert.apply(this,arguments)){
return false;
}
this.insertion.apply(this,turbo.cloneArguments(arguments,1));
return true;
},remove:function(_d0){
return this.defaultRemove.apply(this,arguments);
},defaultRemove:function(){
if(!this._remove.apply(this,arguments)){
return false;
}
this.removal.apply(this,arguments);
return true;
},canSort:function(){
return this.sort!=null;
},sort:null,dummy:0});
dojo.declare("turbo.data.table",turbo.data.model,function(){
this.cache=[];
},{colCount:0,data:null,cache:null,measure:function(){
this.count=this.getRowCount();
this.colCount=this.getColCount();
},getRowCount:function(){
return (this.data?this.data.length:0);
},getColCount:function(){
return (this.data&&this.data.length?this.data[0].length:this.fields.count());
},badIndex:function(_d1,_d2){
turbo.debugf("%s.%s: bad index (%d, %d)",this.className,_d1,_d2[0],(_d2[1]||"n/a"));
},isGoodIndex:function(_d3,_d4){
return (_d3>=0&&_d3<this.count&&(arguments.length<2||(_d4>=0&&_d4<this.colCount)));
},_get:function(_d5,_d6){
var row=this.data[_d5];
return (_d6==undefined?row:row[_d6]);
},_setData:function(_d8){
this.data=(_d8||[]);
},_setRow:function(_d9,_da){
this.data[_da]=_d9;
},_setCell:function(_db,_dc,_dd){
this.data[_dc][_dd]=_db;
},setters:["_setData","_setData","_setRow","_setCell"],_set:function(_de,_df,_e0){
this[this.setters[arguments.length]].apply(this,arguments);
},setRows:function(_e1,_e2){
for(var i=0,l=_e1.length,r=_e2;i<l;i++,r++){
this.set(_e1[i],r);
}
},beginModifyRow:function(_e6){
if(!this.cache[_e6]){
this.cache[_e6]=turbo.arrayDup(this.get(_e6));
}
},endModifyRow:function(_e7){
var _e8=this.cache[_e7];
if(_e8){
var _e9=this.get(_e7);
if(!turbo.arrayCompare(_e8,_e9)){
this.modify(_e8,_e9,_e7);
}
}
},_update:function(_ea,_eb,_ec){
this._set(_eb,_ec);
delete this.cache[_ec];
return true;
},_insert:function(_ed,_ee){
turbo.arrayInsert(this.data,_ee,_ed);
this.count++;
return true;
},_remove:function(_ef){
for(var i=_ef.length-1;i>=0;i--){
turbo.arrayRemove(this.data,_ef[i]);
}
this.count-=_ef.length;
return true;
},makeComparator:function(_f1){
var _f2=null;
for(var i=_f1.length-1,col;i>=0;i--){
col=Math.abs(_f1[i])-1;
if(col>=0){
_f2=turbo.data.generateComparator(this.fields.get(col).compare,_f1[i],_f2);
}
}
return _f2;
},sort:function(){
this.data.sort(this.makeComparator(arguments));
},swap:function(_f5,_f6){
turbo.arraySwap(this.data,_f5,_f6);
this.change(_f5);
this.change(_f6);
},dummy:0});
dojo.declare("turbo.data.dynamic",turbo.data.table,function(){
this.page=[];
this.pages=[];
},{page:null,pages:null,rowsPerPage:100,requests:0,bop:-1,eop:-1,clearData:function(){
this.pages=[];
this.bop=this.eop=-1;
this.set([]);
},getRowCount:function(){
return this.count;
},getColCount:function(){
return this.fields.count();
},setRowCount:function(_f7){
this.count=_f7;
this.change();
},requestsPending:function(_f8){
},rowToPage:function(_f9){
return (this.rowsPerPage?Math.floor(_f9/this.rowsPerPage):_f9);
},pageToRow:function(_fa){
return (this.rowsPerPage?this.rowsPerPage*_fa:_fa);
},requestRows:function(_fb,_fc){
},rowsProvided:function(_fd,_fe){
this.requests--;
if(this.requests==0){
this.requestsPending(false);
}
},requestPage:function(_ff){
var row=this.pageToRow(_ff);
var _101=Math.min(this.rowsPerPage,this.count-row);
if(_101>0){
this.requests++;
this.requestsPending(true);
turbo.defer(this,"requestRows",row,_101,1);
}
},needPage:function(_102){
if(!this.pages[_102]){
this.pages[_102]=true;
this.requestPage(_102);
}
},preparePage:function(_103,_104){
if(_103<this.bop||_103>=this.eop){
var _105=this.rowToPage(_103);
this.needPage(_105);
this.bop=_105*this.rowsPerPage;
this.eop=this.bop+(this.rowsPerPage||this.count);
}
},isRowLoaded:function(_106){
return Boolean(this.data[_106]);
},getRow:function(_107){
var row=this.data[_107];
if(!row){
this.preparePage(_107);
}
return row;
},_get:function(_109,_10a){
var row=this.getRow(_109);
return (_10a==undefined?row:(row?row[_10a]:this.fields.get(_10a).na));
},_setCell:function(_10c,_10d,_10e){
var row=this.getRow(_10d);
if(!row){
turbo.debugf("[%s] turbo.data.dynamic.set: cannot set data on an unloaded row",this.declaredClass);
}
if(row){
row[_10e]=_10c;
}
},canSort:function(){
return false;
}});
dojo.provide("turbo.widgets.TurboGrid.builder");
dojo.declare("turbo.grid.builderBase",null,function(_110){
this.grid=_110;
},{isCellNode:function(_111){
return (_111)&&(_111.getAttribute)&&(Boolean(_111.getAttribute(turbo.grid.CELL_INDEX_TAG)));
},getCellNodeIndex:function(_112){
return (_112?Number(_112.getAttribute(turbo.grid.CELL_INDEX_TAG)):-1);
},getCellNode:function(_113,_114){
for(var i=0,row;row=turbo.getTableRow(_113.firstChild,i);i++){
for(var j=0,cell;cell=row.cells[j];j++){
if(this.getCellNodeIndex(cell)==_114){
return cell;
}
}
}
},findTarget:function(_119,_11a){
var n=_119;
while((n)&&(!this.isCellNode(n))&&(n!=_11a)){
n=n.parentNode;
}
return ((n!=_11a)?n:null);
},decorateEvent:function(e){
e.cellNode=this.findTarget(e.target,e.rowNode);
e.cellIndex=this.getCellNodeIndex(e.cellNode);
return true;
}});
dojo.declare("turbo.grid.builder",turbo.grid.builderBase,{});
turbo.grid.CELL_INDEX_TAG="idx";
dojo.provide("turbo.widgets.TurboGrid.header");
dojo.require("turbo.widgets.TurboGrid.builder");
dojo.require("turbo.lib.drag");
ascendDom=function(_11d,_11e){
var n=_11d;
while(n&&_11e(n)){
n=n.parentNode;
}
return n;
};
mkNotNode=function(_120){
return function(n){
return n!=isNode;
};
};
mkNotTagName=function(_122){
return function(n){
return turbo.getTagName(n)!=_122;
};
};
getProp=function(_124,_125){
return (_124)&&(_124[_125])||null;
};
dojo.declare("turbo.grid.header",turbo.grid.builderBase,function(){
},{bogusClickTime:0,overResizeWidth:4,getCellNode:function(_126,_127){
turbo.grid.header.superclass.getCellNode.apply(this,[_126.headerContentNode,_127]);
},getCellX:function(e){
var x=e.layerX;
if((dojo.render.html.moz)){
x-=getProp(ascendDom(e.target,mkNotTagName("td")),"offsetLeft")||0;
}
var n=ascendDom(e.target,function(){
if(!n||n==e.cellNode){
return false;
}
x+=(n.offsetLeft<0?0:n.offsetLeft);
return true;
});
return x;
},decorateEvent:function(e){
if(turbo.drag.dragging){
return true;
}
if((e.type=="click")&&(turbo.time()<this.bogusClickTime)){
return true;
}
if(!turbo.grid.header.superclass.decorateEvent.apply(this,arguments)){
return false;
}
e.cellX=this.getCellX(e);
e.cell=e.sourceView.layout.getCell(e.cellIndex);
return true;
},dispatchEvent:function(e){
if(e.dispatch in this){
return this[e.dispatch](e);
}
},prepareLeftResize:function(e){
var i=turbo.getCellIndex(e.cellNode);
e.cellNode=(i?e.cellNode.parentNode.cells[i-1]:null);
e.cellIndex=(e.cellNode?this.getCellNodeIndex(e.cellNode):-1);
return Boolean(e.cellNode);
},canResize:function(e){
if((!e.cellNode)||(e.cellNode.colSpan>1)){
return false;
}
var _130=e.sourceView.layout.getCell(e.cellIndex);
return (!_130.noresize)&&(!turbo.grid.layout.isFlexColumn(_130));
},overLeftResizeArea:function(e){
return (e.cellIndex>0)&&(e.cellX<this.overResizeWidth)&&(this.prepareLeftResize(e));
},overRightResizeArea:function(e){
return (e.cellNode)&&(e.cellX>=e.cellNode.offsetWidth-this.overResizeWidth);
},domousemove:function(e){
var c=(this.overRightResizeArea(e)?"e-resize":(this.overLeftResizeArea(e)?"w-resize":""));
if((c)&&(!this.canResize(e))){
c="not-allowed";
}
e.sourceView.headerNode.style.cursor=c||"";
},domousedown:function(e){
if(!turbo.drag.dragging){
if((this.overRightResizeArea(e)||this.overLeftResizeArea(e))&&this.canResize(e)){
this.beginColumnResize(e);
}
}
},beginColumnResize:function(e){
turbo.killEvent(e);
var _137=[],_138=e.sourceView.layout.tableMap.findOverlappingNodes(e.cellNode);
for(var i=0,cell;cell=_138[i];i++){
_137.push({node:cell,index:this.getCellNodeIndex(cell),width:cell.offsetWidth});
}
var drag={view:e.sourceView,node:e.cellNode,index:e.cellIndex,w:e.cellNode.clientWidth,spanners:_137};
turbo.drag.start(e.cellNode,turbo.bindArgs(this,"doResizeColumn",drag),turbo.bindArgs(this,"endResizeColumn",drag),e);
},minColWidth:1,doResizeColumn:function(_13c,_13d){
var w=_13c.w+_13d.deltaX;
if(w>=this.minColWidth){
for(var i=0,s,sw;(s=_13c.spanners[i]);i++){
sw=s.width+_13d.deltaX;
s.node.style.width=sw+"px";
_13c.view.setColWidth(s.index,sw);
}
_13c.node.style.width=w+"px";
_13c.view.setColWidth(_13c.index,w);
}
if(_13c.view.layout.flexColumns){
if(_13c.view.layout.testFlexColumns()==false){
var t=turbo.getTable(_13c.node);
(t)&&(t.style.width="");
}
}
},endResizeColumn:function(_143){
this.bogusClickTime=turbo.time()+30;
turbo.defer(_143.view,"update",50);
}});
dojo.provide("turbo.widgets.TurboGrid.layout");
dojo.declare("turbo.grid.layout",null,function(_144){
this.view=_144;
this.dataRow={index:-1};
},{defaultWidth:"6em",view:null,viewDef:null,cells:[],rows:null,tableMap:null,dataRow:null,flexColumns:false,setViewDef:function(_145,_146){
this.viewDef=_145;
this.contextNode=_146;
if((_145)&&(_145.cells)){
this._loadDef();
}
},_loadDef:function(){
this.prepareRows();
this.tableMap=new turbo.grid.tableMap(this.rows);
this.update();
},getCell:function(_147){
return this.cells[_147];
},update:function(){
if(!this.rows){
return;
}
this.testFlexColumns();
this.prepareHtml();
},prepareRows:function(){
this.cells=[];
this.rows=[];
var _148={view:this.view,grid:this.view.grid,getCellNode:this.cellGetCellNode,getContentNode:this.cellGetContentNode};
dojo.lang.mixin(_148,this.viewDef.defaultCell||{});
var _149=this.viewDef.subrows;
for(var j=0,k=0,row,_14d;(_14d=_149[j]);j++){
row=[];
row.def=_14d;
row.viewDef=this.viewDef;
row.index=j;
for(var i=0,cell,w,c;(cell=_14d[i]);i++,k++){
if(cell.colSpan>1){
w=0;
}else{
if(!isNaN(cell.width)){
w=cell.width+"em";
}else{
w=(cell.width)||(this.defaultWidth);
}
}
c=dojo.lang.mixin({},_148,cell,{subrow:row,layoutIndex:k,def:cell,unitWidth:w,styles:cell.styles||""});
this.cells.push(c);
row.push(c);
}
this.rows.push(row);
}
this.cellCount=this.cells.length;
},testFlexColumns:function(){
this.flexColumns=false;
for(var j=0,row;(row=this.rows[j]);j++){
for(var i=0,cell;(cell=row[i]);i++){
if(turbo.grid.layout.isFlexColumn(cell)){
this.flexColumns=true;
break;
}
}
}
return this.flexColumns;
},cellGetCellNode:function(_156){
return this.view.getCellNode(_156,this.layoutIndex);
},cellGetContentNode:function(_157){
return this.getCellNode(_157);
},generateCellMarkup:function(_158,_159,_15a){
var _15b=[];
var html=["<td"];
(_158.colSpan)&&(html.push(" colspan=\"",_158.colSpan,"\""));
(_158.rowSpan)&&(html.push(" rowspan=\"",_158.rowSpan,"\""));
html.push(" class=\"");
(_158.classes)&&(html.push(_158.classes," "));
(_15a)&&(html.push(_15a," "));
_15b.push(html.join(""));
_15b.push("");
html=["turbogrid-cell\" idx=\"",_158.layoutIndex,"\" style=\""];
html.push(_158.styles,_159||"");
(_158.unitWidth)&&(html.push("width:",_158.unitWidth,";"));
_15b.push(html.join(""));
_15b.push("");
html=["\""];
(_158.attrs)&&(html.push(" ",_158.attrs));
html.push(">");
_15b.push(html.join(""));
_15b.push("");
_15b.push("</td>");
return _15b;
},generateHeaderTable:function(_15d,_15e){
this.dataRow.index=-1;
(this.viewDef.onBeforeRow)&&(this.viewDef.onBeforeRow(-1,this.rows));
var html=["<table class=\"turbogrid-row-table\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"];
for(var j=0,row;(row=this.rows[j]);j++){
if(row.hidden){
continue;
}
html.push("<tr>");
for(var i=0,cell,_164;(cell=row[i]);i++){
cell.customClasses="";
cell.customStyles="";
_164=this.generateCellMarkup(cell,cell.headerStyles,cell.headerClasses);
_164[5]=(_15e!=undefined?_15e:_15d(this.dataRow,cell));
_164[3]=(cell.customStyles)||("");
_164[1]=(cell.customClasses?" "+cell.customClasses:"");
html.push(_164.join(""));
}
html.push("</tr>");
}
html.push("</table>");
return html.join("");
},prepareHtml:function(){
var _165=this.view.grid.get;
for(var j=0,row;(row=this.rows[j]);j++){
for(var i=0,cell;(cell=row[i]);i++){
cell.get=cell.get||_165;
cell.markup=this.generateCellMarkup(cell,cell.cellStyles,cell.cellClasses);
cell.customClasses=cell.customStyles="";
}
}
},generateDataTable:function(_16a,_16b){
this.dataRow.index=_16a;
(this.view.onBeforeRow)&&(this.view.onBeforeRow(_16a,this.rows));
var html=["<table class=\"turbogrid-row-table\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"];
for(var j=0,row;(row=this.rows[j]);j++){
if(row.hidden){
continue;
}
html.push("<tr>");
for(var i=0,cell;(cell=row[i]);i++){
with(cell){
customClasses="";
customStyles="";
markup[5]=(cell.get)&&(get(this.dataRow,cell))||(cell.value);
markup[1]=(customClasses?" "+customClasses:"");
markup[3]=customStyles;
html.push.apply(html,markup);
}
}
html.push("</tr>");
}
html.push("</table>");
return html.join("");
}});
turbo.grid.layout.isFlexColumn=function(_171){
return ((_171.unitWidth)&&((_171.unitWidth=="auto")||(_171.unitWidth.slice(-1)=="%")));
};
dojo.declare("turbo.grid.tableMap",null,function(_172){
this.mapRows(_172);
},{map:null,mapRows:function(_173){
var _174=_173.length;
var _175=0,row=_173[0];
for(var i=0,cell;(cell=row[i]);i++){
_175+=(cell.def.colSpan)||(1);
}
this.map=[];
for(var j=0,row;(row=_173[j]);j++){
this.map[j]=[];
}
for(var j=0,row;(row=_173[j]);j++){
for(var i=0,x=0,cell,_17b,_17c;(cell=row[i]);i++){
while(this.map[j][x]){
x++;
}
this.map[j][x]={c:i,r:j};
_17c=(cell.def.rowSpan)||(1);
_17b=(cell.def.colSpan)||(1);
for(var y=0;y<_17c;y++){
for(var s=0;s<_17b;s++){
this.map[j+y][x+s]=this.map[j][x];
}
}
x+=_17b;
}
}
if(0){
for(var j=0,row;(row=this.map[j]);j++){
var h="";
for(var i=0,cell;(cell=row[i]);i++){
h+=cell.r+","+cell.c+"   ";
}
console.log(h);
}
}
},getMapCoords:function(_180,_181){
for(var j=0,row;(row=this.map[j]);j++){
for(var i=0,cell;(cell=row[i]);i++){
if((cell.c==_181)&&(cell.r==_180)){
return {j:j,i:i};
}
}
}
return {j:-1,i:-1};
},getNode:function(_186,_187,_188){
var row=(_186)&&(_186.rows[_187]);
return (row)&&(row.cells[_188]);
},_findOverlappingNodes:function(_18a,_18b,_18c){
var _18d=[];
var m=this.getMapCoords(_18b,_18c);
var row=this.map[m.j];
for(var j=0,row;(row=this.map[j]);j++){
if(j==m.j){
continue;
}
with(row[m.i]){
var n=this.getNode(_18a,r,c);
if(n){
_18d.push(n);
}
}
}
return _18d;
},findOverlappingNodes:function(_192){
var r=turbo.getRowIndex(_192.parentNode);
var c=turbo.getCellIndex(_192);
return this._findOverlappingNodes(turbo.getTable(_192),r,c);
}});
dojo.provide("turbo.widgets.TurboGrid.view");
dojo.require("turbo.widgets.TurboGrid.builder");
dojo.require("turbo.widgets.TurboGrid.header");
dojo.require("turbo.widgets.TurboGrid.layout");
turbo.grid.rowIndexTag="gridRowIndex";
dojo.widget.defineWidget("dojo.widget.TurboGridView",dojo.widget.html.TurboWidget,function(){
this.rowNodes=[];
},{defaultWidth:"18em",viewWidth:"",templateString:"<div class=\"turbogrid-view\"><div class=\"turbogrid-header\" dojoAttachPoint=\"headerNode\"><div style=\"width: 9000em\"><div dojoAttachPoint=\"headerContentNode\"></div></div></div><div class=\"turbogrid-scrollbox\" dojoAttachPoint=\"scrollboxNode\"><div class=\"turbogrid-content\" dojoAttachPoint=\"contentNode\" hidefocus=\"hidefocus\"></div></div></div>",themeable:false,classTag:"turbogrid",colCount:0,cells:null,marginBottom:0,rowPad:2,viewDef:null,fillInTemplate:function(){
dojo.event.browser.addListener(this.scrollboxNode,"onscroll",turbo.bind(this,"doscroll"));
turbo.funnelEvents(this.contentNode,this,"doContentEvent",["mouseover","mouseout","click","dblclick","contextmenu"]);
turbo.funnelEvents(this.headerNode,this,"doHeaderEvent",["dblclick","mouseover","mouseout","mousemove","mousedown","click","contextmenu"]);
this.layout=new turbo.grid.layout(this);
dojo.html.disableSelection(this.contentNode);
},destroy:function(){
turbo.remove(this.headerNode);
this.inherited("destroy");
},setViewDef:function(_195){
_195.cells=_195.subrows=_195.subrows||_195.cells;
this.viewDef=_195;
if((_195.width)&&(dojo.lang.isNumber(_195.width))){
this.viewWidth=_195.width+"em";
}else{
this.viewWidth=_195.width||this.viewWidth;
}
this.colCount=0;
this.cells=_195.cells||_195.subrows;
if(this.cells){
for(var i=0,r;(r=this.cells[i]);i++){
for(var j=0,c;(c=r[j]);j++,this.colCount++){
}
}
}
this.onBeforeRow=_195.onBeforeRow;
this.layout.setViewDef(_195,this.contentNode);
this.noscroll=_195.noscroll;
if(this.noscroll){
this.scrollboxNode.style.overflow="hidden";
}
},getScrollbarWidth:function(){
return (this.noscroll?0:turbo.getScrollbarWidth());
},getColumnsWidth:function(){
return this.headerContentNode.firstChild.offsetWidth;
},getWidth:function(){
return (this.viewWidth)||((this.getColumnsWidth()+this.getScrollbarWidth())+"px");
},getContentWidth:function(){
return Math.max(0,dojo.html.getContentBox(this.domNode).width-this.getScrollbarWidth())+"px";
},render:function(){
this.scrollboxNode.style.height="";
this.renderHeader();
},renderHeader:function(){
this.headerContentNode.innerHTML=this.layout.generateHeaderTable(this._getHeaderContent);
},_getHeaderContent:function(_19a,_19b){
var h=_19b.name;
if(_19b.index!=_19b.grid.getSortIndex()){
return h;
}
h=["<div class=\"","","\">",h,"</div>"];
if(_19b.grid.sortInfo>0){
h[1]="turbogrid-sort-down";
}else{
h[1]="turbogrid-sort-up";
}
return h.join("");
},resize:function(){
this.resizeHeight();
this.resizeWidth();
},hasScrollbar:function(){
return (this.scrollboxNode.clientHeight!=this.scrollboxNode.offsetHeight);
},resizeHeight:function(){
if(!this.grid.autoHeight){
var h=this.domNode.clientHeight;
if(!this.hasScrollbar()){
h-=turbo.getScrollbarWidth();
}
turbo.setStyleHeightPx(this.scrollboxNode,h);
}
},resizeWidth:function(){
if(this.layout.flexColumns){
this.contentWidth=this.getContentWidth();
this.headerContentNode.firstChild.style.width=this.contentWidth;
}
var w=this.scrollboxNode.offsetWidth-this.getScrollbarWidth();
w=Math.max(w,this.getColumnsWidth())+"px";
with(this.contentNode){
style.width="";
offsetWidth;
style.width=w;
}
},setSize:function(w,h){
with(this.domNode.style){
width=w;
height=(h>=0?h+"px":"");
}
with(this.headerNode.style){
width=w;
}
},renderRow:function(_1a1,_1a2){
var _1a3=this.createRowNode(_1a1);
this.buildRow(_1a1,_1a3,_1a2);
return _1a3;
},createRowNode:function(_1a4){
var node=document.createElement("div");
node.className=this.classTag+"-row";
node[turbo.grid.rowIndexTag]=_1a4;
this.rowNodes[_1a4]=node;
return node;
},buildRow:function(_1a6,_1a7){
this.buildRowContent(_1a6,_1a7);
this.styleRow(_1a6,_1a7);
},buildRowContent:function(_1a8,_1a9){
_1a9.innerHTML=this.layout.generateDataTable(_1a8);
if(this.layout.flexColumns){
_1a9.firstChild.style.width=this.contentWidth;
}
},rowRemoved:function(_1aa){
delete this.rowNodes[_1aa];
},getRowNode:function(_1ab){
return this.rowNodes[_1ab];
},getCellNode:function(_1ac,_1ad){
var row=this.getRowNode(_1ac);
return (row?this.grid.builder.getCellNode(row,_1ad):null);
},styleRow:function(_1af,_1b0){
_1b0._style=turbo.getStyleText(_1b0);
this.styleRowNode(_1af,_1b0);
},styleRowNode:function(_1b1,_1b2){
(_1b2)&&(this.doStyleRowNode(_1b1,_1b2));
},doStyleRowNode:function(_1b3,_1b4){
this.grid.styleRowNode(_1b3,_1b4,this.cells);
},updateRow:function(_1b5,_1b6,_1b7){
var _1b8=this.getRowNode(_1b5);
if(_1b8){
_1b8.style.height="";
this.buildRow(_1b5,_1b8);
}
return _1b8;
},updateRowStyles:function(_1b9){
this.styleRowNode(_1b9,this.getRowNode(_1b9));
},lastTop:0,doscroll:function(_1ba){
this.headerNode.scrollLeft=this.scrollboxNode.scrollLeft;
var top=this.scrollboxNode.scrollTop;
if(top!=this.lastTop){
this.grid.scrollTo(top);
}
},setScrollTop:function(_1bc){
this.lastTop=_1bc;
this.scrollboxNode.scrollTop=_1bc;
return this.scrollboxNode.scrollTop;
},findTarget:function(_1bd,_1be){
var n=_1bd;
while((n)&&!(_1be in n)&&(n!=this.domNode)){
n=n.parentNode;
}
return (n!=this.domNode?n:null);
},findRowTarget:function(_1c0){
return this.findTarget(_1c0,turbo.grid.rowIndexTag);
},isIntraNodeEvent:function(e){
try{
return (e.cellNode&&e.relatedTarget&&dojo.dom.isDescendantOf(e.relatedTarget,e.cellNode));
}
catch(x){
return false;
}
},isIntraRowEvent:function(e){
try{
var row=(e.relatedTarget)&&(this.findRowTarget(e.relatedTarget));
return (!row)&&(e.rowIndex==-1)||(row)&&(e.rowIndex==row.gridRowIndex);
}
catch(x){
return false;
}
},doContentEvent:function(e){
if(this.decorateContentEvent(e)){
this.grid.onContentEvent(e);
}
},doHeaderEvent:function(e){
if(this.decorateHeaderEvent(e)){
this.grid.onHeaderEvent(e);
}
},decorateEvent:function(e){
e.sourceView=this;
e.dispatch="do"+e.type;
},decorateContentEvent:function(e){
this.decorateEvent(e);
e.rowNode=this.findRowTarget(e.target);
if(!e.rowNode){
return false;
}
e.rowIndex=e.rowNode[turbo.grid.rowIndexTag];
this.grid.builder.decorateEvent(e);
e.cell=this.layout.getCell(e.cellIndex);
return true;
},decorateHeaderEvent:function(e){
this.decorateEvent(e);
e.rowIndex=-1;
return this.grid.header.decorateEvent(e);
},dispatchEvent:function(m,e){
if(m in this){
return this[m](e);
}
},dispatchContentEvent:function(e){
this.dispatchEvent(e.dispatch,e);
},dispatchHeaderEvent:function(e){
this.dispatchEvent(e.dispatch,e);
},domouseover:function(e){
if((e.cellNode)&&(e.cellNode!=this.lastOverCellNode)){
this.lastOverCellNode=e.cellNode;
this.grid.onMouseOver(e);
}
this.grid.onMouseOverRow(e);
},domouseout:function(e){
if((e.cellNode)&&(e.cellNode==this.lastOverCellNode)&&(!this.isIntraNodeEvent(e,this.lastOverCellNode))){
this.lastOverCellNode=null;
this.grid.onMouseOut(e);
if(!this.isIntraRowEvent(e)){
this.grid.onMouseOutRow(e);
}
}
},setColWidth:function(_1cf,_1d0){
var cell=this.layout.getCell(_1cf);
cell.unitWidth=_1d0+"px";
},update:function(){
var left=this.scrollboxNode.scrollLeft;
this.layout.update();
this.grid.update();
this.scrollboxNode.scrollLeft=left;
},focusClass:"turbogrid-cell-focus",borkNode:function(_1d3,_1d4,_1d5){
turbo.addRemoveClass(this.getCellNode(_1d3,_1d4),this.focusClass,_1d5);
},blurCell:function(_1d6,_1d7){
this.borkNode(_1d6,_1d7,false);
},focusCell:function(_1d8,_1d9){
this.borkNode(_1d8,_1d9,true);
}});
dojo.provide("turbo.widgets.TurboGrid.views");
dojo.declare("turbo.grid.views",null,function(_1da){
this.grid=_1da;
},{defaultWidth:200,views:[],resize:function(){
this.onEach("resize");
},render:function(){
this.onEach("render");
this.normalizeHeaderNodeHeight();
},addView:function(_1db){
_1db.idx=this.views.length;
this.views.push(_1db);
},destroyViews:function(){
for(var i=0,v;v=this.views[i];i++){
v.destroy();
}
this.views=[];
},getContentNodes:function(){
var _1de=[];
for(var i=0,v;v=this.views[i];i++){
_1de.push(v.contentNode);
}
return _1de;
},forEach:function(_1e1){
for(var i=0,v;v=this.views[i];i++){
_1e1(v,i);
}
},onEach:function(_1e4,_1e5){
_1e5=_1e5||[];
for(var i=0,v;v=this.views[i];i++){
if(_1e4 in v){
v[_1e4].apply(v,_1e5);
}
}
},normalizeHeaderNodeHeight:function(){
var _1e8=[];
for(var i=0,v;(v=this.views[i]);i++){
(v.headerContentNode.firstChild)&&(_1e8.push(v.headerContentNode));
}
this.normalizeRowNodeHeights(_1e8);
},normalizeRowNodeHeights:function(_1eb){
var h=0;
for(var i=0,n,o;(n=_1eb[i]);i++){
h=Math.max(h,(n.firstChild.clientHeight)||(n.firstChild.offsetHeight));
}
h=(h>=0?h:0)+"px";
for(var i=0,n;(n=_1eb[i]);i++){
n.firstChild.style.height=h;
}
(_1eb[0])&&(_1eb[0].parentNode.offsetHeight);
},renormalizeRow:function(_1f0){
var _1f1=[];
for(var i=0,v,n;(v=this.views[i])&&(n=v.getRowNode(_1f0));i++){
n.firstChild.style.height="";
_1f1.push(n);
}
this.normalizeRowNodeHeights(_1f1);
},getViewWidth:function(_1f5){
return this.views[_1f5].getWidth()||this.defaultWidth;
},measureHeader:function(){
this.forEach(function(_1f6){
_1f6.headerContentNode.style.height="";
});
var h=0;
this.forEach(function(_1f8){
h=Math.max(_1f8.headerNode.offsetHeight,h);
});
return h;
},measureContent:function(){
var h=0;
this.forEach(function(_1fa){
h=Math.max(_1fa.domNode.offsetHeight,h);
});
return h;
},findClient:function(_1fb){
var c=this.grid.elasticView||-1;
if(c<0){
for(var i=1,v;(v=this.views[i]);i++){
if(v.viewWidth){
for(i=1;(v=this.views[i]);i++){
if(!v.viewWidth){
c=i;
break;
}
}
break;
}
}
}
if(c<0){
c=Math.floor(this.views.length/2);
}
return c;
},_arrange:function(l,t,w,h){
var i,v,vw,len=this.views.length;
var c=(w<=0?len:this.findClient());
var _208=function(v,l,t){
with(v.domNode.style){
left=l+"px";
top=t+"px";
}
with(v.headerNode.style){
left=l+"px";
top=0;
}
};
for(i=0;(v=this.views[i])&&(i<c);i++){
vw=this.getViewWidth(i);
v.setSize(vw,h);
_208(v,l,t);
vw=v.domNode.offsetWidth;
l+=vw;
}
i++;
var r=w;
for(var j=len-1;(v=this.views[j])&&(i<=j);j--){
vw=this.getViewWidth(j);
v.setSize(vw,h);
vw=v.domNode.offsetWidth;
r-=vw;
_208(v,r,t);
}
if(c<len){
v=this.views[c];
vw=Math.max(1,r-l);
v.setSize(vw+"px",h);
_208(v,l,t);
}
return l;
},arrange:function(l,t,w,h){
var w=this._arrange(l,t,w,h);
this.resize();
return w;
},renderRow:function(_212,_213){
var _214=[];
for(var i=0,v,n,_218;(v=this.views[i])&&(n=_213[i]);i++){
_218=v.renderRow(_212);
turbo.append(_218,n);
_214.push(_218);
}
this.normalizeRowNodeHeights(_214);
},rowRemoved:function(_219){
this.onEach("rowRemoved",[_219]);
},updateRow:function(_21a,_21b){
for(var i=0,v;v=this.views[i];i++){
v.updateRow(_21a,_21b);
}
this.renormalizeRow(_21a);
},updateRowStyles:function(_21e){
this.onEach("updateRowStyles",[_21e]);
},setScrollTop:function(_21f){
var top=_21f;
for(var i=0,v;v=this.views[i];i++){
top=v.setScrollTop(_21f);
}
return top;
},cellToColIndex:function(_223,_224){
var _225=_223;
for(var i=0,v;(v=this.views[i])&&(v!=_224);i++){
_225+=((v.cells)&&(v.colCount))||0;
}
return _225;
},colToCellIndex:function(_228){
for(var i=0,ci=_228,v;(v=this.views[i]);i++){
if(v.cells){
if(ci<v.colCount){
return {view:v,index:ci};
}
ci-=v.colCount;
}
}
return {};
},getFirstScrollingView:function(){
for(var i=0,v;(v=this.views[i]);i++){
if(v.hasScrollbar()){
return v;
}
}
}});
dojo.provide("turbo.widgets.TurboGrid.rows");
dojo.declare("turbo.grid.rows",null,function(_22e){
this.grid=_22e;
},{linesToEms:2,defaultRowHeight:1,overRow:-2,getHeight:function(_22f){
return "";
},getDefaultHeightPx:function(){
return 32;
},prepareStylingRow:function(_230,_231){
return {index:_230,node:_231,odd:Boolean(_230&1),selected:this.grid.selection.isSelected(_230),over:this.isOver(_230),customStyles:"",customClasses:"turbogrid-row"};
},styleRowNode:function(_232,_233){
var row=this.prepareStylingRow(_232,_233);
this.grid.onStyleRow(row);
this.applyStyles(row);
},applyStyles:function(_235){
with(_235){
node.className=customClasses;
var h=node.style.height;
turbo.setStyleText(node,customStyles+";"+(node._style||""));
node.style.height=h;
}
},updateStyles:function(_237){
this.grid.updateRowStyles(_237);
},setOverRow:function(_238){
var last=this.overRow;
this.overRow=_238;
if((last!=this.overRow)&&(last>=0)){
this.updateStyles(last);
}
this.updateStyles(this.overRow);
},isOver:function(_23a){
return (this.overRow==_23a);
}});
dojo.provide("turbo.widgets.TurboGrid.focus");
dojo.declare("turbo.grid.focus",null,function(_23b){
this.grid=_23b;
this.info={};
this.cell={row:0,col:-1};
this.canBlur={previous:false,next:false};
},{isLastFocusCell:function(){
return (this.cell.row==this.grid.rowCount-1&&this.cell.col==grid.colCount-1);
},isFirstFocusCell:function(){
return (this.cell.row==0&&this.cell.col==0);
},isNoFocusCell:function(){
return (this.cell.row<0||this.cell.col<0);
},resetBlur:function(){
this.canBlur.next=false;
this.canBlur.previous=false;
},doSetFocus:function(_23c){
if(this.info.view){
with(this.info){
view[_23c].call(view,this.cell.row,index);
}
}
},setFocusCell:function(_23d,_23e){
this.doSetFocus("blurCell");
this.cell={row:_23d,col:_23e};
this.info=this.grid.views.colToCellIndex(_23e);
this.doSetFocus("focusCell");
this.resetBlur();
this.grid.onCellFocus(_23d,_23e);
},next:function(){
var row=this.cell.row;
var col=this.cell.col+1;
if(col>=this.grid.colCount){
col=0;
row++;
}
if(row>this.grid.rowCount-1){
col=this.grid.colCount-1;
row=this.grid.rowCount-1;
}
this.setFocusCell(row,col);
},previous:function(){
var row=(this.cell.row||0);
var col=(this.cell.col||0)-1;
if(col<0){
col=this.grid.colCount-1;
row--;
}
if(row<0){
row=0;
col=0;
}
this.setFocusCell(row,col);
}});
dojo.provide("turbo.widgets.TurboGrid.selection");
dojo.declare("turbo.grid.selection",null,function(_243){
this.grid=_243;
this.selected=[];
},{multiSelect:true,selected:null,selectedIndex:-1,onCanSelect:function(_244){
return this.grid.canSelect(_244);
},onCanDeselect:function(_245){
return this.grid.canDeselect(_245);
},onSelected:function(_246){
return this.grid.selected(_246);
},onDeselected:function(_247){
return this.grid.deselected(_247);
},onChanged:function(){
},isSelected:function(_248){
return this.selected[_248];
},getFirstSelected:function(){
for(var i=0,l=this.selected.length;i<l;i++){
if(this.selected[i]){
return i;
}
}
return -1;
},getNextSelected:function(_24b){
for(var i=_24b+1,l=this.selected.length;i<l;i++){
if(this.selected[i]){
return i;
}
}
return -1;
},getSelected:function(){
var _24e=[];
for(var i=0,l=this.selected.length;i<l;i++){
if(this.selected[i]){
_24e.push(i);
}
}
return _24e;
},getSelectedCount:function(){
var c=0;
for(var i=0;i<this.selected.length;i++){
if(this.selected[i]){
c++;
}
}
return c;
},beginUpdate:function(){
if(this.updating==0){
this.onChanging();
}
this.updating++;
},endUpdate:function(){
this.updating--;
if(this.updating==0){
this.onChanged();
}
},select:function(_253){
this.unselectAll(_253);
this.addToSelection(_253);
},addToSelection:function(_254){
_254=Number(_254);
if(this.selected[_254]){
this.selectedIndex=_254;
}else{
if(this.onCanSelect(_254)!==false){
this.selectedIndex=_254;
this.beginUpdate();
this.selected[_254]=true;
this.grid.selected(_254);
this.endUpdate();
}
}
},deselect:function(_255){
_255=Number(_255);
if(this.selectedIndex==_255){
this.selectedIndex=-1;
}
if(this.selected[_255]){
if(this.onCanDeselect(_255)===false){
return;
}
this.beginUpdate();
delete this.selected[_255];
this.grid.deselected(_255);
this.endUpdate();
}
},setSelected:function(_256,_257){
this[(_257?"addToSelection":"deselect")](_256);
},toggleSelect:function(_258){
this.setSelected(_258,!this.selected[_258]);
},insert:function(_259){
this.selected.splice(_259,0,false);
if(this.selectedIndex>=_259){
this.selectedIndex++;
}
},remove:function(_25a){
this.selected.splice(_25a,1);
if(this.selectedIndex>=_25a){
this.selectedIndex--;
}
},unselectAll:function(_25b){
for(var i in this.selected){
if((i!=_25b)&&(this.selected[i]===true)){
this.deselect(i);
}
}
},shiftSelect:function(_25d,inTo){
var s=(_25d>=0?_25d:inTo);
var e=inTo;
if(s>e){
e=s;
s=inTo;
}
for(var i=s;i<=e;i++){
this.addToSelection(i);
}
},clickSelect:function(_262,_263,_264){
this.beginUpdate();
if(!this.multiSelect){
this.select(_262);
}else{
var _265=this.selectedIndex;
if(!_263){
this.unselectAll(_262);
}
if(_264){
this.shiftSelect(_265,_262);
}else{
this.toggleSelect(_262);
}
}
this.endUpdate();
},clickSelectEvent:function(e){
this.clickSelect(e.rowIndex,e.ctrlKey,e.shiftKey);
},clear:function(){
this.beginUpdate();
this.unselectAll();
this.endUpdate();
}});
dojo.provide("turbo.widgets.TurboGrid.edit");
dojo.declare("turbo.grid.edit",null,function(_267){
this.grid=_267;
},{shouldEdit:function(e){
return ((!e.ctrlKey)&&(!e.shiftKey));
},doclick:function(e){
if(!this.shouldEdit(e)){
return;
}
this.editCellNode(e.rowIndex,e.colIndex);
},editCellNode:function(_26a,_26b){
this.applyEdit();
this.editCell=this.grid.views.colToCellIndex(_26b);
this.editCell.col=_26b;
this.editCell.row=_26a;
this.editNode=(this.editCell.view)&&(this.editCell.view.getCellNode(this.editCell.row,this.editCell.index));
if(!this.editNode){
this.cancelEdit();
return;
}
this.editBak=this.editNode.innerHTML;
this.editNode.innerHTML="[EDITOR GOES HERE]";
},saveState:function(_26c){
if((this.editNode)&&(this.editCell.row==_26c)&&(this.edtiHtml)){
this.editHtml=this.editNode.innerHTML;
}
},restoreState:function(_26d){
if((this.editNode)&&(this.editCell.row==_26d)){
this.editNode.innerHTML=this.editHtml;
this.editHtml="";
}
},editDone:function(){
if(this.editNode){
this.editNode.innerHTML=this.editBak;
}
this.editNode=null;
},applyEdit:function(){
this.editDone();
},cancelEdit:function(){
this.editDone();
}});
dojo.provide("turbo.widgets.TurboGrid.rowbar");
dojo.require("turbo.widgets.TurboGrid.view");
dojo.widget.defineWidget("dojo.widget.TurboGridRowView",dojo.widget.TurboGridView,{defaultWidth:"3em",noscroll:true,padBorderWidth:2,fillInTemplate:function(){
this.inherited("fillInTemplate");
this.scrollboxNode.style.overflow="hidden";
dojo.html.setVisibility(this.headerNode,false);
},getWidth:function(){
return (this.viewWidth)||(this.defaultWidth);
},buildRowContent:function(_26e,_26f){
var w=this.contentNode.offsetWidth-this.padBorderWidth;
_26f.innerHTML="<div style=\"width:"+w+"px; height: 8px;\"><div class=\"turbogrid-rowbar-inner\"></div></div>";
},renderHeader:function(){
},resize:function(){
this.resizeHeight();
},doStyleRowNode:function(_271,_272){
var n=["turbogrid-rowbar"];
if(this.grid.rows.isOver(_271)){
n.push("turbogrid-rowbar-over");
}
if(this.grid.selection.isSelected(_271)){
n.push("turbogrid-rowbar-selected");
}
_272.className=n.join(" ");
},domouseover:function(e){
this.grid.onMouseOverRow(e);
},domouseout:function(e){
if(!this.isIntraRowEvent(e)){
this.grid.onMouseOutRow(e);
}
}});
dojo.require("turbo.lib.more");
dojo.require("turbo.lib.scroller");
dojo.require("turbo.widgets.TurboWidget");
dojo.require("turbo.widgets.TurboGrid.view");
dojo.require("turbo.widgets.TurboGrid.views");
dojo.require("turbo.widgets.TurboGrid.rows");
dojo.require("turbo.widgets.TurboGrid.focus");
dojo.require("turbo.widgets.TurboGrid.selection");
dojo.require("turbo.widgets.TurboGrid.edit");
dojo.require("turbo.widgets.TurboGrid.rowbar");
dojo.provide("turbo.widgets.TurboGrid.Grid");
dojo.widget.defineWidget("dojo.widget.TurboGrid",dojo.widget.html.TurboWidget,{templateString:"<div class=\"turbogrid\" hidefocus=\"hidefocus\"><div class=\"turbogrid-master-header\" dojoAttachPoint=\"headerNode\"></div><div class=\"turbogrid-master-view\" dojoAttachPoint=\"viewsNode\"></div><span dojoAttachPoint=\"lastFocusNode\" tabindex=\"0\"></span></div>",classTag:"turbogrid",styleRoot:"TurboGrid",get:turbo.nop,rowCount:5,keepRows:75,rowsPerPage:25,autoWidth:false,autoHeight:false,autoRender:true,defaultHeight:"15em",structure:"",elasticView:-1,focusView:null,sortInfo:0,themeable:true,fillInTemplate:function(){
if(!this.domNode.getAttribute("tabIndex")){
this.domNode.tabIndex="0";
}
this.domNode.onReveal=turbo.bind(this,"revealed");
this.createScroller();
this.createBuilder();
this.createHeader();
this.createViews();
this.createRowManager();
this.createFocusManager();
this.createSelectionManager();
this.createEditManager();
turbo.watchTextSizePoll(this,"textSizeChanged");
turbo.funnelEvents(this.domNode,this,"doKeyEvent",turbo.keyEvents);
turbo.connect(this.domNode,"onFocus",this,this.doFocus);
},postCreate:function(){
this.buildViews();
(this.autoRender)&&(this.render());
this.styleChanged=this.defaultStyleChanged;
},defaultStyleChanged:function(){
this.setStyledClass(this.domNode,"");
this.update();
},destroy:function(){
this.domNode.onReveal=null;
turbo.unwatchTextSizePoll(this,"textSizeChanged");
this.views.destroyViews();
this.inherited("destroy");
},revealed:function(){
this.render();
},textSizeChanged:function(){
var self=this;
turbo.defer(function(){
if(!self.domNode){
return;
}
var t=new Date().getTime();
self.views.forEach(function(v){
v.layout.update();
});
self.render();
},1);
},createRowManager:function(){
this.rows=new turbo.grid.rows(this);
},createFocusManager:function(){
this.focus=new turbo.grid.focus(this);
},createSelectionManager:function(){
this.selection=new turbo.grid.selection(this);
},createEditManager:function(){
this.edit=new turbo.grid.edit(this);
},createBuilder:function(){
this.builder=new turbo.grid.builder(this);
},createHeader:function(){
this.header=new turbo.grid.header(this);
},createScroller:function(){
this.scroller=new turbo.scroller.columns();
this.scroller.renderRow=turbo.bind(this,"renderRow");
this.scroller.removeRow=turbo.bind(this,"rowRemoved");
},createViews:function(){
this.views=new turbo.grid.views(this);
this.views.createView=turbo.bind(this,"createView");
},createView:function(_279){
var view=dojo.widget.createWidget(_279,{grid:this});
this.viewsNode.appendChild(view.domNode);
this.headerNode.appendChild(view.headerNode);
this.views.addView(view);
return view;
},buildViews:function(){
if(this.cells){
this.structure=this.cells;
this.cells=null;
}
if((this.structure)&&(dojo.lang.isString(this.structure))){
this.structure=window[this.structure];
}
if(!this.structure){
this.structure=window["layout"];
}
if(!this.structure){
return;
}
this.indexColumns();
this.views.destroyViews();
for(var i=0,v;(v=this.structure[i]);i++){
this.createView(v.type||"TurboGridView").setViewDef(v);
}
this.scroller.setContentNodes(this.views.getContentNodes());
},indexColumns:function(){
var idx=0;
for(var i=0,view;(view=this.structure[i]);i++){
for(var j=0,row;(view.cells)&&(row=view.cells[j]);j++){
for(var k=0,cell;(cell=row[k]);k++){
cell.index=idx++;
}
}
}
this.colCount=idx;
},setStructure:function(_284){
this.structure=_284;
this.buildViews();
this.render();
},resize:function(){
var _285=dojo.html.getPadBorder(this.domNode);
if(this.autoHeight){
this.domNode.style.height="auto";
this.viewsNode.style.height="";
}else{
if(this.domNode.clientHeight<=_285.height){
if(this.domNode.parentNode==document.body){
this.domNode.style.height=this.defaultHeight;
}else{
this.fitTo="parent";
}
}
}
if(this.fitTo=="parent"){
var h=dojo.html.getContentBox(this.domNode.parentNode).height;
dojo.html.setMarginBox(this.domNode,{height:Math.max(0,h)});
}
var t=this.views.measureHeader();
this.headerNode.style.height=t+"px";
var l=1,h=(this.autoHeight?-1:Math.max(this.domNode.clientHeight-t,0)||0);
if(this.autoWidth){
this.domNode.style.width=this.views.arrange(l,0,0,h)+"px";
}else{
var w=this.domNode.clientWidth||(this.domNode.offsetWidth-_285.width);
this.views.arrange(l,0,w,h);
}
this.scroller.windowHeight=h;
this.scroller.defaultRowHeight=this.rows.getDefaultHeightPx()+1;
},render:function(){
if(!this.domNode){
console.log("Grid.render: domNode is null",this);
return;
}
this.update=this.defaultUpdate;
this.scroller.init(this.rowCount,this.keepRows,this.rowsPerPage);
this.prerender();
this.setScrollTop(0);
this.postrender();
},prerender:function(){
this.views.render();
this.resize();
},postrender:function(){
if(this.autoHeight){
this.viewsNode.style.height=this.views.measureContent()+"px";
}
this.setFocusView();
},renderRow:function(_28a,_28b){
this.views.renderRow(_28a,_28b);
},rowRemoved:function(_28c){
this.views.rowRemoved(_28c);
},defaultUpdate:function(){
this.prerender();
this.scroller.invalidateNodes();
this.setScrollTop(this.scrollTop);
this.postrender();
},update:function(){
this.render();
},updateRow:function(_28d){
this.edit.saveState(_28d);
this.views.updateRow(_28d,this.rows.getHeight(_28d));
this.scroller.rowHeightChanged(_28d);
this.edit.restoreState(_28d);
},rowHeightChanged:function(_28e){
this.views.renormalizeRow(_28e);
this.scroller.rowHeightChanged(_28e);
},updateRowCount:function(_28f){
this.rowCount=_28f;
this.scroller.updateRowCount(_28f);
this.setScrollTop(this.scrollTop);
},updateRowStyles:function(_290){
this.views.updateRowStyles(_290);
},onStyleRow:function(_291){
with(_291){
customClasses+=(odd?" turbogrid-row-odd":"")+(selected?" turbogrid-row-selected":"")+(over?" turbogrid-row-over":"");
}
},fastScroll:true,delayScroll:false,scrollRedrawThreshold:(dojo.render.html.ie?100:50),scrollTo:function(_292){
if(!this.fastScroll){
this.setScrollTop(_292);
return;
}
var _293=Math.abs(this.lastScrollTop-_292);
this.lastScrollTop=_292;
if(_293>this.scrollRedrawThreshold||this.delayScroll){
this.delayScroll=true;
this.scrollTop=_292;
this.views.setScrollTop(_292);
turbo.job("turbogrid-scroll",200,turbo.bind(this,"finishScrollJob"));
}else{
this.setScrollTop(_292);
}
},finishScrollJob:function(){
this.delayScroll=false;
this.setScrollTop(this.scrollTop);
},setScrollTop:function(_294){
this.scrollTop=this.views.setScrollTop(_294);
this.scroller.scroll(this.scrollTop);
},scrollToRow:function(_295){
this.setScrollTop(this.scroller.findScrollTop(_295)+1);
},styleRowNode:function(_296,_297){
if(_297){
this.rows.styleRowNode(_296,_297);
}
},canSelect:function(_298){
return true;
},canDeselect:function(_299){
return true;
},selected:function(_29a){
this.updateRowStyles(_29a);
},deselected:function(_29b){
this.updateRowStyles(_29b);
},selectionChanged:function(){
},setSortInfo:function(_29c){
this.sortInfo=_29c;
this.update();
},getSortIndex:function(_29d){
return Math.abs(this.sortInfo)-1;
},setSortIndex:function(_29e){
if(this.getSortIndex()==_29e){
this.setSortInfo(-this.sortInfo);
}else{
this.setSortInfo(_29e+1);
}
},doKeyEvent:function(e){
e.dispatch="do"+e.type;
this.onKeyEvent(e);
},onKeyEvent:function(e){
this.dispatchKeyEvent(e);
},onContentEvent:function(e){
this.dispatchContentEvent(e);
},onHeaderEvent:function(e){
this.dispatchHeaderEvent(e);
},_dispatch:function(m,e){
if(m in this){
return this[m](e);
}
},dispatchContentEvent:function(e){
e.sourceView.dispatchContentEvent(e)||this._dispatch(e.dispatch,e);
},dispatchKeyEvent:function(e){
this._dispatch(e.dispatch,e);
},dispatchHeaderEvent:function(e){
e.sourceView.dispatchHeaderEvent(e)||this.header.dispatchEvent(e)||this._dispatch("doheader"+e.type,e);
},dokeydown:function(e){
this.onKeyDown(e);
},doclick:function(e){
if(e.cellNode){
this.onCellClick(e);
}else{
this.onRowClick(e);
}
},dodblclick:function(e){
if(e.cellNode){
this.onCellDblClick(e);
}else{
this.onRowDblClick(e);
}
},docontextmenu:function(e){
if(e.cellNode){
this.onCellContextMenu(e);
}else{
this.onRowContextMenu(e);
}
},doheaderclick:function(e){
if(e.cellNode){
this.onHeaderCellClick(e);
}else{
this.onHeaderClick(e);
}
},doheaderdblclick:function(e){
if(e.cellNode){
this.onHeaderCellDblClick(e);
}else{
this.onHeaderDblClick(e);
}
},doheadercontextmenu:function(e){
if(e.cellNode){
this.onHeaderCellContextMenu(e);
}else{
this.onHeaderContextMenu(e);
}
},onKeyDown:function(e){
if(e.altKey||e.ctrlKey||e.metaKey){
return;
}
switch(e.keyCode){
case e.KEY_ESCAPE:
break;
case e.KEY_ENTER:
break;
case e.KEY_TAB:
if(e.shiftKey){
if(!this.focus.isFirstFocusCell()){
this.focus.previous();
turbo.killEvent(e);
}else{
this.focus.canBlur.previous=true;
this.domNode.focus();
}
}else{
if(!this.focus.isLastFocusCell()){
this.focus.next();
turbo.killEvent(e);
}else{
this.focus.canBlur.next=true;
this.lastFocusNode.focus();
}
}
break;
}
},onMouseOver:function(e){
(e.rowIndex==-1?this.onHeaderCellMouseOver(e):this.onCellMouseOver(e));
},onMouseOut:function(e){
(e.rowIndex==-1?this.onHeaderCellMouseOut(e):this.onCellMouseOut(e));
},onMouseOverRow:function(e){
if(!this.rows.isOver(e.rowIndex)){
this.rows.setOverRow(e.rowIndex);
(e.rowIndex==-1?this.onHeaderMouseOver(e):this.onRowMouseOver(e));
}
},onMouseOutRow:function(e){
if(this.rows.isOver(-1)){
this.onHeaderMouseOut(e);
}else{
if(!this.rows.isOver(-2)){
this.rows.setOverRow(-2);
this.onRowMouseOut(e);
}
}
},onCellMouseOver:function(e){
dojo.html.addClass(e.cellNode,"turbogrid-cell-over");
},onCellMouseOut:function(e){
dojo.html.removeClass(e.cellNode,"turbogrid-cell-over");
},onRowMouseOver:function(e){
},onRowMouseOut:function(e){
},onCellClick:function(e){
turbo.killEvent(e);
this.focus.setFocusCell(e.rowIndex,e.cell.index);
this.onRowClick(e);
},onRowClick:function(e){
this.selection.clickSelectEvent(e);
},onCellDblClick:function(e){
this.onRowDblClick(e);
},onRowDblClick:function(e){
},onCellContextMenu:function(e){
this.onRowContextMenu(e);
},onRowContextMenu:function(e){
turbo.killEvent(e);
},onHeaderMouseOver:function(e){
},onHeaderMouseOut:function(e){
},onHeaderCellMouseOver:function(e){
dojo.html.addClass(e.cellNode,"turbogrid-cell-over");
},onHeaderCellMouseOut:function(e){
dojo.html.removeClass(e.cellNode,"turbogrid-cell-over");
},onHeaderClick:function(e){
},onHeaderCellClick:function(e){
this.setSortIndex(e.cell.index);
this.onHeaderClick(e);
},onHeaderDblClick:function(e){
},onHeaderCellDblClick:function(e){
this.onHeaderDblClick(e);
},onHeaderCellContextMenu:function(e){
this.onHeaderContextMenu(e);
},onHeaderContextMenu:function(e){
turbo.killEvent(e);
},onCellFocus:function(_2c8,_2c9){
var info=this.focus.info;
var n=info.view.getCellNode(_2c8,info.index);
if(n.firstChild&&n.firstChild.focus){
n.firstChild.focus();
}else{
this.focusView.scrollboxNode.focus();
}
},setFocusView:function(){
this.focusView=this.views.getFirstScrollingView();
},doFocus:function(e){
if(e&&e.target!=e.currentTarget){
return;
}
if(this.focus.canBlur.next||this.focus.canBlur.previous){
this.focus.resetBlur();
return;
}
this.focusView.scrollboxNode.focus();
if(this.focus.isNoFocusCell()){
this.focus.setFocusCell(0,0);
}
}});
dojo.provide("turbo.widgets.TurboGrid.DataGrid");
dojo.require("turbo.widgets.TurboGrid.Grid");
dojo.require("turbo.data.model");
dojo.widget.defineWidget("dojo.widget.TurboDGrid",dojo.widget.TurboGrid,{});
dojo.widget.defineWidget("dojo.widget.TurboDataGrid",dojo.widget.TurboGrid,{model:"turbo.data.table",postCreate:function(){
if(this.model){
if(typeof this.model=="string"){
var m=dojo.getObject(this.model);
this.model=(typeof m=="function"?new m():m);
}
this._setModel(this.model);
}
this.inherited("postCreate",arguments);
},_setModel:function(_2ce){
this.model=_2ce;
if(this.model){
this.model.observe("change",this,"modelChange");
this.model.observe("insertion",this,"modelInsertion");
this.model.observe("removal",this,"modelRemoval");
}
this.measureModel();
},setModel:function(_2cf){
if(this.model){
this.model.unobserve("change",this,"modelChange");
this.model.unobserve("insertion",this,"modelInsertion");
this.model.unobserve("removal",this,"modelRemoval");
}
this._setModel(_2cf);
this.modelChanged();
},measureModel:function(){
if(this.model){
this.model.measure();
}
this.rowCount=(this.model?this.model.count:0);
},getDataRowIndex:function(_2d0,_2d1){
return _2d0.index;
},defaultGet:function(_2d2,_2d3){
var _2d4=this.getDataRowIndex(_2d2,_2d3);
if(_2d3.def.keys){
for(var i=0,d=[],k;(k=_2d3.def.keys[i])||(k!==undefined);i++){
d.push(_2d3.grid.model.get(_2d4,k));
}
}else{
var d=_2d3.grid.model.get(_2d4,(_2d3.def.key!=undefined?_2d3.def.key:_2d3.index));
}
return (_2d3.def.formatter?_2d3.def.formatter.call(_2d3.grid,d,_2d2,_2d3):(dojo.lang.isArray(d)?d.join():d));
},get:function(_2d8,_2d9){
return _2d9.grid.defaultGet.apply(_2d9.grid,arguments);
},render:function(){
this.measureModel();
dojo.widget.TurboGrid.prototype.render.apply(this,arguments);
},modelChanged:function(){
this.measureModel();
this.updateRowCount(this.rowCount);
},modelRowChanged:function(_2da){
this.updateRow(_2da);
},modelColChanged:function(_2db,_2dc){
this.updateRow(_2db);
},modelUpdates:["modelChanged","modelRowChanged","modelColChanged"],defaultModelChange:function(_2dd,_2de){
this[this.modelUpdates[arguments.length]].apply(this,arguments);
},modelChange:function(_2df,_2e0){
this.defaultModelChange.apply(this,arguments);
},modelInsertion:function(_2e1){
this.updateRowCount(this.model.getRowCount());
},modelRemoval:function(_2e2){
this.updateRowCount(this.model.getRowCount());
},getCellDef:function(_2e3){
var i=this.views.colToCellIndex(_2e3);
return i.view.layout.cells[i.index].def;
},canSort:function(){
var d=this.getCellDef(this.getSortIndex());
return (d&&!d.get&&this.model.canSort());
},sortData:function(){
var k=this.getCellDef(this.getSortIndex()).key||this.getSortIndex();
var s=(k+1)*(this.sortInfo>0?1:-1);
this.model.sort(s);
},setSortInfo:function(_2e8){
this.sortInfo=_2e8;
if(this.canSort()){
this.sortData();
this.update();
}
},junk:0});


