var Rico={Version:"1.1rc1",prototypeVersion:parseFloat(Prototype.Version.split(".")[0]+"."+Prototype.Version.split(".")[1])}; Rico.ArrayExtensions=new Array(); if(Object.prototype.extend){ Rico.ArrayExtensions[Rico.ArrayExtensions.length]=Object.prototype.extend; }else{ Object.prototype.extend=function(_1){ return Object.extend.apply(this,[this,_1]); }; Rico.ArrayExtensions[Rico.ArrayExtensions.length]=Object.prototype.extend; } if(Array.prototype.push){ Rico.ArrayExtensions[Rico.ArrayExtensions.length]=Array.prototype.push; } if(!Array.prototype.remove){ Array.prototype.remove=function(dx){ if(isNaN(dx)||dx>this.length){ return false; } for(var i=0,n=0;i=this.accordionTabs.length){ this.options.onLoadShowTab=0; } for(var i=0;i0.5; },isDark:function(){ return !this.isBright(); },asRGB:function(){ return "rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"; },asHex:function(){ return "#"+this.rgb.r.toColorPart()+this.rgb.g.toColorPart()+this.rgb.b.toColorPart(); },asHSB:function(){ return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b); },toString:function(){ return this.asHex(); }}; Rico.Color.createFromHex=function(_54){ if(_54.indexOf("#")==0){ _54=_54.substring(1); } var red=_54.substring(0,2); var _55=_54.substring(2,4); var _56=_54.substring(4,6); return new Rico.Color(parseInt(red,16),parseInt(_55,16),parseInt(_56,16)); }; Rico.Color.createColorFromBackground=function(_57){ var _58=RicoUtil.getElementsComputedStyle($(_57),"backgroundColor","background-color"); if(_58=="transparent"&&_57.parent){ return Rico.Color.createColorFromBackground(_57.parent); } if(_58==null){ return new Rico.Color(255,255,255); } if(_58.indexOf("rgb(")==0){ var _59=_58.substring(4,_58.length-1); var _60=_59.split(","); return new Rico.Color(parseInt(_60[0]),parseInt(_60[1]),parseInt(_60[2])); }else{ if(_58.indexOf("#")==0){ var _61=parseInt(_58.substring(1,3),16); var _62=parseInt(_58.substring(3,5),16); var _63=parseInt(_58.substring(5),16); return new Rico.Color(_61,_62,_63); }else{ return new Rico.Color(255,255,255); } } }; Rico.Color.HSBtoRGB=function(hue,_65,_66){ var red=0; var _67=0; var _68=0; if(_65==0){ red=parseInt(_66*255+0.5); _67=red; _68=red; }else{ var h=(hue-Math.floor(hue))*6; var f=h-Math.floor(h); var p=_66*(1-_65); var q=_66*(1-_65*f); var t=_66*(1-(_65*(1-f))); switch(parseInt(h)){ case 0: red=(_66*255+0.5); _67=(t*255+0.5); _68=(p*255+0.5); break; case 1: red=(q*255+0.5); _67=(_66*255+0.5); _68=(p*255+0.5); break; case 2: red=(p*255+0.5); _67=(_66*255+0.5); _68=(t*255+0.5); break; case 3: red=(p*255+0.5); _67=(q*255+0.5); _68=(_66*255+0.5); break; case 4: red=(t*255+0.5); _67=(p*255+0.5); _68=(_66*255+0.5); break; case 5: red=(_66*255+0.5); _67=(p*255+0.5); _68=(q*255+0.5); break; } } return {r:parseInt(red),g:parseInt(_67),b:parseInt(_68)}; }; Rico.Color.RGBtoHSB=function(r,g,b){ var hue; var _73; var _74; var _75=(r>g)?r:g; if(b>_75){ _75=b; } var _76=(r"+el.innerHTML+""; },_roundTopCorners:function(el,_91,_92){ var _93=this._createCorner(_92); for(var i=0;i=0;i--){ _96.appendChild(this._createCornerSlice(_94,_95,i,"bottom")); } el.style.paddingBottom=0; el.appendChild(_96); },_createCorner:function(_97){ var _98=document.createElement("div"); _98.style.backgroundColor=(this._isTransparent()?"transparent":_97); return _98; },_createCornerSlice:function(_99,_100,n,_102){ var _103=document.createElement("span"); var _104=_103.style; _104.backgroundColor=_99; _104.display="block"; _104.height="1px"; _104.overflow="hidden"; _104.fontSize="1px"; var _105=this._borderColor(_99,_100); if(this.options.border&&n==0){ _104.borderTopStyle="solid"; _104.borderTopWidth="1px"; _104.borderLeftWidth="0px"; _104.borderRightWidth="0px"; _104.borderBottomWidth="0px"; _104.height="0px"; _104.borderColor=_105; }else{ if(_105){ _104.borderColor=_105; _104.borderStyle="solid"; _104.borderWidth="0px 1px"; } } if(!this.options.compact&&(n==(this.options.numSlices-1))){ _104.height="2px"; } this._setMargin(_103,n,_102); this._setBorder(_103,n,_102); return _103; },_setOptions:function(_106){ this.options={corners:"all",color:"fromElement",bgColor:"fromParent",blend:true,border:false,compact:false}; Object.extend(this.options,_106||{}); this.options.numSlices=this.options.compact?2:4; if(this._isTransparent()){ this.options.blend=false; } },_whichSideTop:function(){ if(this._hasString(this.options.corners,"all","top")){ return ""; } if(this.options.corners.indexOf("tl")>=0&&this.options.corners.indexOf("tr")>=0){ return ""; } if(this.options.corners.indexOf("tl")>=0){ return "left"; }else{ if(this.options.corners.indexOf("tr")>=0){ return "right"; } } return ""; },_whichSideBottom:function(){ if(this._hasString(this.options.corners,"all","bottom")){ return ""; } if(this.options.corners.indexOf("bl")>=0&&this.options.corners.indexOf("br")>=0){ return ""; } if(this.options.corners.indexOf("bl")>=0){ return "left"; }else{ if(this.options.corners.indexOf("br")>=0){ return "right"; } } return ""; },_borderColor:function(_107,_108){ if(_107=="transparent"){ return _108; }else{ if(this.options.border){ return this.options.border; }else{ if(this.options.blend){ return this._blend(_108,_107); }else{ return ""; } } } },_setMargin:function(el,n,_109){ var _110=this._marginSize(n); var _111=_109=="top"?this._whichSideTop():this._whichSideBottom(); if(_111=="left"){ el.style.marginLeft=_110+"px"; el.style.marginRight="0px"; }else{ if(_111=="right"){ el.style.marginRight=_110+"px"; el.style.marginLeft="0px"; }else{ el.style.marginLeft=_110+"px"; el.style.marginRight=_110+"px"; } } },_setBorder:function(el,n,_112){ var _113=this._borderSize(n); var _114=_112=="top"?this._whichSideTop():this._whichSideBottom(); if(_114=="left"){ el.style.borderLeftWidth=_113+"px"; el.style.borderRightWidth="0px"; }else{ if(_114=="right"){ el.style.borderRightWidth=_113+"px"; el.style.borderLeftWidth="0px"; }else{ el.style.borderLeftWidth=_113+"px"; el.style.borderRightWidth=_113+"px"; } } if(this.options.border!=false){ el.style.borderLeftWidth=_113+"px"; } el.style.borderRightWidth=_113+"px"; },_marginSize:function(n){ if(this._isTransparent()){ return 0; } var _115=[5,3,2,1]; var _116=[3,2,1,0]; var _117=[2,1]; var _118=[1,0]; if(this.options.compact&&this.options.blend){ return _118[n]; }else{ if(this.options.compact){ return _117[n]; }else{ if(this.options.blend){ return _116[n]; }else{ return _115[n]; } } } },_borderSize:function(n){ var _119=[5,3,2,1]; var _120=[2,1,1,1]; var _121=[1,0]; var _122=[0,2,0,0]; if(this.options.compact&&(this.options.blend||this._isTransparent())){ return 1; }else{ if(this.options.compact){ return _121[n]; }else{ if(this.options.blend){ return _120[n]; }else{ if(this.options.border){ return _122[n]; }else{ if(this._isTransparent()){ return _119[n]; } } } } } return 0; },_hasString:function(str){ for(var i=1;i=0){ return true; } } return false; },_blend:function(c1,c2){ var cc1=Rico.Color.createFromHex(c1); cc1.blend(Rico.Color.createFromHex(c2)); return cc1; },_background:function(el){ try{ return Rico.Color.createColorFromBackground(el).asHex(); } catch(err){ return "#ffffff"; } },_isTransparent:function(){ return this.options.color=="transparent"; },_isTopRounded:function(){ return this._hasString(this.options.corners,"all","top","tl","tr"); },_isBottomRounded:function(){ return this._hasString(this.options.corners,"all","bottom","bl","br"); },_hasSingleTextChild:function(el){ return el.childNodes.length==1&&el.childNodes[0].nodeType==3; }}; if(window.Effect==undefined){ Effect={}; } Effect.SizeAndPosition=Class.create(); Effect.SizeAndPosition.prototype={initialize:function(_127,x,y,w,h,_131,_132,_133){ this.element=$(_127); this.x=x; this.y=y; this.w=w; this.h=h; this.duration=_131; this.steps=_132; this.options=arguments[7]||{}; this.sizeAndPosition(); },sizeAndPosition:function(){ if(this.isFinished()){ if(this.options.complete){ this.options.complete(this); } return; } if(this.timer){ clearTimeout(this.timer); } var _134=Math.round(this.duration/this.steps); var _135=this.element.offsetLeft; var _136=this.element.offsetTop; var _137=this.element.offsetWidth; var _138=this.element.offsetHeight; this.x=(this.x)?this.x:_135; this.y=(this.y)?this.y:_136; this.w=(this.w)?this.w:_137; this.h=(this.h)?this.h:_138; var difX=this.steps>0?(this.x-_135)/this.steps:0; var difY=this.steps>0?(this.y-_136)/this.steps:0; var difW=this.steps>0?(this.w-_137)/this.steps:0; var difH=this.steps>0?(this.h-_138)/this.steps:0; this.moveBy(difX,difY); this.resizeBy(difW,difH); this.duration-=_134; this.steps--; this.timer=setTimeout(this.sizeAndPosition.bind(this),_134); },isFinished:function(){ return this.steps<=0; },moveBy:function(difX,difY){ var _143=this.element.offsetLeft; var _144=this.element.offsetTop; var _145=parseInt(difX); var _146=parseInt(difY); var _147=this.element.style; if(_145!=0){ _147.left=(_143+_145)+"px"; } if(_146!=0){ _147.top=(_144+_146)+"px"; } },resizeBy:function(difW,difH){ var _148=this.element.offsetWidth; var _149=this.element.offsetHeight; var _150=parseInt(difW); var _151=parseInt(difH); var _152=this.element.style; if(_150!=0){ _152.width=(_148+_150)+"px"; } if(_151!=0){ _152.height=(_149+_151)+"px"; } }}; Effect.Size=Class.create(); Effect.Size.prototype={initialize:function(_153,w,h,_154,_155,_156){ new Effect.SizeAndPosition(_153,null,null,w,h,_154,_155,_156); }}; Effect.Position=Class.create(); Effect.Position.prototype={initialize:function(_157,x,y,_158,_159,_160){ new Effect.SizeAndPosition(_157,x,y,null,null,_158,_159,_160); }}; Effect.Round=Class.create(); Effect.Round.prototype={initialize:function(_161,_162,_163){ var _164=document.getElementsByTagAndClassName(_161,_162); for(var i=0;i<_164.length;i++){ Rico.Corner.round(_164[i],_163); } }}; Effect.FadeTo=Class.create(); Effect.FadeTo.prototype={initialize:function(_165,_166,_167,_168,_169){ this.element=$(_165); this.opacity=_166; this.duration=_167; this.steps=_168; this.options=arguments[4]||{}; this.fadeTo(); },fadeTo:function(){ if(this.isFinished()){ if(this.options.complete){ this.options.complete(this); } return; } if(this.timer){ clearTimeout(this.timer); } var _170=Math.round(this.duration/this.steps); var _171=this.getElementOpacity(); var _172=this.steps>0?(this.opacity-_171)/this.steps:0; this.changeOpacityBy(_172); this.duration-=_170; this.steps--; this.timer=setTimeout(this.fadeTo.bind(this),_170); },changeOpacityBy:function(v){ var _174=this.getElementOpacity(); var _175=Math.max(0,Math.min(_174+v,1)); this.element.ricoOpacity=_175; this.element.style.filter="alpha(opacity:"+Math.round(_175*100)+")"; this.element.style.opacity=_175; },isFinished:function(){ return this.steps<=0; },getElementOpacity:function(){ if(this.element.ricoOpacity==undefined){ var _176=RicoUtil.getElementsComputedStyle(this.element,"opacity"); this.element.ricoOpacity=_176!=undefined?_176:1; } return parseFloat(this.element.ricoOpacity); }}; Effect.AccordionSize=Class.create(); Effect.AccordionSize.prototype={initialize:function(e1,e2,_179,end,_181,_182,_183){ this.e1=$(e1); this.e2=$(e2); this.start=_179; this.end=end; this.duration=_181; this.steps=_182; this.options=arguments[6]||{}; this.accordionSize(); },accordionSize:function(){ if(this.isFinished()){ this.e1.style.height=this.start+"px"; this.e2.style.height=this.end+"px"; if(this.options.complete){ this.options.complete(this); } return; } if(this.timer){ clearTimeout(this.timer); } var _184=Math.round(this.duration/this.steps); var diff=this.steps>0?(parseInt(this.e1.offsetHeight)-this.start)/this.steps:0; this.resizeBy(diff); this.duration-=_184; this.steps--; this.timer=setTimeout(this.accordionSize.bind(this),_184); },isFinished:function(){ return this.steps<=0; },resizeBy:function(diff){ var _186=this.e1.offsetHeight; var _187=this.e2.offsetHeight; var _188=parseInt(diff); if(diff!=0){ this.e1.style.height=(_186-_188)+"px"; this.e2.style.height=(_187+_188)+"px"; } }}; if(window.Effect==undefined){ Effect={}; } Effect.SizeAndPosition=Class.create(); Effect.SizeAndPosition.prototype={initialize:function(_189,x,y,w,h,_190,_191,_192){ this.element=$(_189); this.x=x; this.y=y; this.w=w; this.h=h; this.duration=_190; this.steps=_191; this.options=arguments[7]||{}; this.sizeAndPosition(); },sizeAndPosition:function(){ if(this.isFinished()){ if(this.options.complete){ this.options.complete(this); } return; } if(this.timer){ clearTimeout(this.timer); } var _193=Math.round(this.duration/this.steps); var _194=this.element.offsetLeft; var _195=this.element.offsetTop; var _196=this.element.offsetWidth; var _197=this.element.offsetHeight; this.x=(this.x)?this.x:_194; this.y=(this.y)?this.y:_195; this.w=(this.w)?this.w:_196; this.h=(this.h)?this.h:_197; var difX=this.steps>0?(this.x-_194)/this.steps:0; var difY=this.steps>0?(this.y-_195)/this.steps:0; var difW=this.steps>0?(this.w-_196)/this.steps:0; var difH=this.steps>0?(this.h-_197)/this.steps:0; this.moveBy(difX,difY); this.resizeBy(difW,difH); this.duration-=_193; this.steps--; this.timer=setTimeout(this.sizeAndPosition.bind(this),_193); },isFinished:function(){ return this.steps<=0; },moveBy:function(difX,difY){ var _198=this.element.offsetLeft; var _199=this.element.offsetTop; var _200=parseInt(difX); var _201=parseInt(difY); var _202=this.element.style; if(_200!=0){ _202.left=(_198+_200)+"px"; } if(_201!=0){ _202.top=(_199+_201)+"px"; } },resizeBy:function(difW,difH){ var _203=this.element.offsetWidth; var _204=this.element.offsetHeight; var _205=parseInt(difW); var _206=parseInt(difH); var _207=this.element.style; if(_205!=0){ _207.width=(_203+_205)+"px"; } if(_206!=0){ _207.height=(_204+_206)+"px"; } }}; Effect.Size=Class.create(); Effect.Size.prototype={initialize:function(_208,w,h,_209,_210,_211){ new Effect.SizeAndPosition(_208,null,null,w,h,_209,_210,_211); }}; Effect.Position=Class.create(); Effect.Position.prototype={initialize:function(_212,x,y,_213,_214,_215){ new Effect.SizeAndPosition(_212,x,y,null,null,_213,_214,_215); }}; Effect.Round=Class.create(); Effect.Round.prototype={initialize:function(_216,_217,_218){ var _219=document.getElementsByTagAndClassName(_216,_217); for(var i=0;i<_219.length;i++){ Rico.Corner.round(_219[i],_218); } }}; Effect.FadeTo=Class.create(); Effect.FadeTo.prototype={initialize:function(_220,_221,_222,_223,_224){ this.element=$(_220); this.opacity=_221; this.duration=_222; this.steps=_223; this.options=arguments[4]||{}; this.fadeTo(); },fadeTo:function(){ if(this.isFinished()){ if(this.options.complete){ this.options.complete(this); } return; } if(this.timer){ clearTimeout(this.timer); } var _225=Math.round(this.duration/this.steps); var _226=this.getElementOpacity(); var _227=this.steps>0?(this.opacity-_226)/this.steps:0; this.changeOpacityBy(_227); this.duration-=_225; this.steps--; this.timer=setTimeout(this.fadeTo.bind(this),_225); },changeOpacityBy:function(v){ var _228=this.getElementOpacity(); var _229=Math.max(0,Math.min(_228+v,1)); this.element.ricoOpacity=_229; this.element.style.filter="alpha(opacity:"+Math.round(_229*100)+")"; this.element.style.opacity=_229; },isFinished:function(){ return this.steps<=0; },getElementOpacity:function(){ if(this.element.ricoOpacity==undefined){ var _230=RicoUtil.getElementsComputedStyle(this.element,"opacity"); this.element.ricoOpacity=_230!=undefined?_230:1; } return parseFloat(this.element.ricoOpacity); }}; Effect.AccordionSize=Class.create(); Effect.AccordionSize.prototype={initialize:function(e1,e2,_231,end,_232,_233,_234){ this.e1=$(e1); this.e2=$(e2); this.start=_231; this.end=end; this.duration=_232; this.steps=_233; this.options=arguments[6]||{}; this.accordionSize(); },accordionSize:function(){ if(this.isFinished()){ this.e1.style.height=this.start+"px"; this.e2.style.height=this.end+"px"; if(this.options.complete){ this.options.complete(this); } return; } if(this.timer){ clearTimeout(this.timer); } var _235=Math.round(this.duration/this.steps); var diff=this.steps>0?(parseInt(this.e1.offsetHeight)-this.start)/this.steps:0; this.resizeBy(diff); this.duration-=_235; this.steps--; this.timer=setTimeout(this.accordionSize.bind(this),_235); },isFinished:function(){ return this.steps<=0; },resizeBy:function(diff){ var _236=this.e1.offsetHeight; var _237=this.e2.offsetHeight; var _238=parseInt(diff); if(diff!=0){ this.e1.style.height=(_236-_238)+"px"; this.e2.style.height=(_237+_238)+"px"; } }}; Rico.LiveGridMetaData=Class.create(); Rico.LiveGridMetaData.prototype={initialize:function(_239,_240,_241,_242){ this.pageSize=_239; this.totalRows=_240; this.setOptions(_242); this.ArrowHeight=16; this.columnCount=_241; },setOptions:function(_243){ this.options={largeBufferSize:7,nearLimitFactor:0.2}; Object.extend(this.options,_243||{}); },getPageSize:function(){ return this.pageSize; },getTotalRows:function(){ return this.totalRows; },setTotalRows:function(n){ this.totalRows=n; },getLargeBufferSize:function(){ return parseInt(this.options.largeBufferSize*this.pageSize); },getLimitTolerance:function(){ return parseInt(this.getLargeBufferSize()*this.options.nearLimitFactor); }}; Rico.LiveGridScroller=Class.create(); Rico.LiveGridScroller.prototype={initialize:function(_244,_245){ this.isIE=navigator.userAgent.toLowerCase().indexOf("msie")>=0; this.liveGrid=_244; this.metaData=_244.metaData; this.createScrollBar(); this.scrollTimeout=null; this.lastScrollPos=0; this.viewPort=_245; this.rows=new Array(); },isUnPlugged:function(){ return this.scrollerDiv.onscroll==null; },plugin:function(){ this.scrollerDiv.onscroll=this.handleScroll.bindAsEventListener(this); },unplug:function(){ this.scrollerDiv.onscroll=null; },sizeIEHeaderHack:function(){ if(!this.isIE){ return; } var _246=$(this.liveGrid.tableId+"_header"); if(_246){ _246.rows[0].cells[0].style.width=(_246.rows[0].cells[0].offsetWidth+1)+"px"; } },createScrollBar:function(){ var _247=this.liveGrid.viewPort.visibleHeight(); this.scrollerDiv=document.createElement("div"); var _248=this.scrollerDiv.style; _248.borderRight=this.liveGrid.options.scrollerBorderRight; _248.position="relative"; _248.left=this.isIE?"-6px":"-3px"; _248.width="19px"; _248.height=_247+"px"; _248.overflow="auto"; this.heightDiv=document.createElement("div"); this.heightDiv.style.width="1px"; this.heightDiv.style.height=parseInt(_247*this.metaData.getTotalRows()/this.metaData.getPageSize())+"px"; this.scrollerDiv.appendChild(this.heightDiv); this.scrollerDiv.onscroll=this.handleScroll.bindAsEventListener(this); var _249=this.liveGrid.table; _249.parentNode.parentNode.insertBefore(this.scrollerDiv,_249.parentNode.nextSibling); var _250=this.isIE?"mousewheel":"DOMMouseScroll"; Event.observe(_249,_250,function(evt){ if(evt.wheelDelta>=0||evt.detail<0){ this.scrollerDiv.scrollTop-=(2*this.viewPort.rowHeight); }else{ this.scrollerDiv.scrollTop+=(2*this.viewPort.rowHeight); } this.handleScroll(false); }.bindAsEventListener(this),false); },updateSize:function(){ var _252=this.liveGrid.table; var _253=this.viewPort.visibleHeight(); this.heightDiv.style.height=parseInt(_253*this.metaData.getTotalRows()/this.metaData.getPageSize())+"px"; },rowToPixel:function(_254){ return (_254/this.metaData.getTotalRows())*this.heightDiv.offsetHeight; },moveScroll:function(_255){ this.scrollerDiv.scrollTop=this.rowToPixel(_255); if(this.metaData.options.onscroll){ this.metaData.options.onscroll(this.liveGrid,_255); } },handleScroll:function(){ if(this.scrollTimeout){ clearTimeout(this.scrollTimeout); } var _256=this.lastScrollPos-this.scrollerDiv.scrollTop; if(_256!=0){ var r=this.scrollerDiv.scrollTop%this.viewPort.rowHeight; if(r!=0){ this.unplug(); if(_256<0){ this.scrollerDiv.scrollTop+=(this.viewPort.rowHeight-r); }else{ this.scrollerDiv.scrollTop-=r; } this.plugin(); } } var _257=parseInt(this.scrollerDiv.scrollTop/this.viewPort.rowHeight); this.liveGrid.requestContentRefresh(_257); this.viewPort.scrollTo(this.scrollerDiv.scrollTop); if(this.metaData.options.onscroll){ this.metaData.options.onscroll(this.liveGrid,_257); } this.scrollTimeout=setTimeout(this.scrollIdle.bind(this),1200); this.lastScrollPos=this.scrollerDiv.scrollTop; },scrollIdle:function(){ if(this.metaData.options.onscrollidle){ this.metaData.options.onscrollidle(); } }}; Rico.LiveGridBuffer=Class.create(); Rico.LiveGridBuffer.prototype={initialize:function(_258,_259){ this.startPos=0; this.size=0; this.metaData=_258; this.rows=new Array(); this.updateInProgress=false; this.viewPort=_259; this.maxBufferSize=_258.getLargeBufferSize()*2; this.maxFetchSize=_258.getLargeBufferSize(); this.lastOffset=0; },getBlankRow:function(){ if(!this.blankRow){ this.blankRow=new Array(); for(var i=0;ithis.startPos){ if(this.startPos+this.rows.length<_270){ this.rows=_271; this.startPos=_270; }else{ this.rows=this.rows.concat(_271.slice(0,_271.length)); if(this.rows.length>this.maxBufferSize){ var _272=this.rows.length; this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length); this.startPos=this.startPos+(_272-this.rows.length); } } }else{ if(_270+_271.lengththis.maxBufferSize){ this.rows=this.rows.slice(0,this.maxBufferSize); } } this.startPos=_270; } this.size=this.rows.length; },clear:function(){ this.rows=new Array(); this.startPos=0; this.size=0; },isOverlapping:function(_273,size){ return ((_273=this.startPos)&&(_275+this.metaData.getPageSize()<=this.endPos()); },isNearingTopLimit:function(_276){ return _276-this.startPos=this.startPos){ var _282=this.maxFetchSize+_280; if(_282>this.metaData.totalRows){ _282=this.metaData.totalRows; } _281=_282-_280; if(_280==0&&_281this.maxFetchSize){ _281=this.maxFetchSize; } } return _281; },getFetchOffset:function(_283){ var _284=_283; if(_283>this.startPos){ _284=(_283>this.endPos())?_283:this.endPos(); }else{ if(_283+this.maxFetchSize>=this.startPos){ var _284=this.startPos-this.maxFetchSize; if(_284<0){ _284=0; } } } this.lastOffset=_284; return _284; },getRows:function(_285,_286){ var _287=_285-this.startPos; var _288=_287+_286; if(_288>this.size){ _288=this.size; } var _289=new Array(); var _290=0; for(var i=_287;i<_288;i++){ _289[_290++]=this.rows[i]; } return _289; },convertSpaces:function(s){ return s.split(" ").join(" "); }}; Rico.GridViewPort=Class.create(); Rico.GridViewPort.prototype={initialize:function(_291,_292,_293,_294,_295){ this.lastDisplayedStartPos=0; this.div=_291.parentNode; this.table=_291; this.rowHeight=_292; this.div.style.height=this.rowHeight*_293; this.div.style.overflow="hidden"; this.buffer=_294; this.liveGrid=_295; this.visibleRows=_293+1; this.lastPixelOffset=0; this.startPos=0; },populateRow:function(_296,row){ for(var j=0;j_297; var _299=_298?this.buffer.startPos:_297; var _300=(this.buffer.startPos+this.buffer.size<_297+this.visibleRows)?this.buffer.startPos+this.buffer.size:_297+this.visibleRows; var _301=_300-_299; var rows=this.buffer.getRows(_299,_301); var _303=this.visibleRows-_301; var _304=_298?0:_301; var _305=_298?_303:0; for(var i=0;i0; this.lastRowPos=_297; this.liveGrid.table.className=this.liveGrid.options.tableClass; var _306=this.liveGrid.options.onRefreshComplete; if(_306!=null){ _306(); } },scrollTo:function(_307){ if(this.lastPixelOffset==_307){ return; } this.refreshContents(parseInt(_307/this.rowHeight)); this.div.scrollTop=_307%this.rowHeight; this.lastPixelOffset=_307; },visibleHeight:function(){ return parseInt(RicoUtil.getElementsComputedStyle(this.div,"height")); }}; Rico.LiveGridRequest=Class.create(); Rico.LiveGridRequest.prototype={initialize:function(_308,_309){ this.requestOffset=_308; }}; Rico.LiveGrid=Class.create(); Rico.LiveGrid.prototype={initialize:function(_310,_311,_312,url,_314,_315){ this.options={tableClass:$(_310).className,loadingClass:$(_310).className,scrollerBorderRight:"1px solid #ababab",bufferTimeout:20000,sortAscendImg:"images/sort_asc.gif",sortDescendImg:"images/sort_desc.gif",sortImageWidth:9,sortImageHeight:5,ajaxSortURLParms:[],onRefreshComplete:null,requestParameters:null,inlineStyles:true}; Object.extend(this.options,_314||{}); this.ajaxOptions={parameters:null}; Object.extend(this.ajaxOptions,_315||{}); this.tableId=_310; this.table=$(_310); this.addLiveGridHtml(); var _316=this.table.rows[0].cells.length; this.metaData=new Rico.LiveGridMetaData(_311,_312,_316,_314); this.buffer=new Rico.LiveGridBuffer(this.metaData); var _317=this.table.rows.length; this.viewPort=new Rico.GridViewPort(this.table,this.table.offsetHeight/_317,_311,this.buffer,this); this.scroller=new Rico.LiveGridScroller(this,this.viewPort); this.options.sortHandler=this.sortHandler.bind(this); if($(_310+"_header")){ this.sort=new Rico.LiveGridSort(_310+"_header",this.options); } this.processingRequest=null; this.unprocessedRequest=null; this.initAjax(url); if(this.options.prefetchBuffer||this.options.prefetchOffset>0){ var _318=0; if(this.options.offset){ _318=this.options.offset; this.scroller.moveScroll(_318); this.viewPort.scrollTo(this.scroller.rowToPixel(_318)); } if(this.options.sortCol){ this.sortCol=_314.sortCol; this.sortDir=_314.sortDir; } this.requestContentRefresh(_318); } },addLiveGridHtml:function(){ if(this.table.getElementsByTagName("thead").length>0){ var _319=this.table.cloneNode(true); _319.setAttribute("id",this.tableId+"_header"); _319.setAttribute("class",this.table.className+"_header"); for(var i=0;i<_319.tBodies.length;i++){ _319.removeChild(_319.tBodies[i]); } this.table.deleteTHead(); this.table.parentNode.insertBefore(_319,this.table); } new Insertion.Before(this.table,"
"); this.table.previousSibling.appendChild(this.table); new Insertion.Before(this.table,"
"); this.table.previousSibling.appendChild(this.table); },resetContents:function(){ this.scroller.moveScroll(0); this.buffer.clear(); this.viewPort.clearContents(); },sortHandler:function(_320){ this.sortCol=_320.name; this.sortDir=_320.currentSort; this.resetContents(); this.requestContentRefresh(0); },setTotalRows:function(_321){ this.resetContents(); this.metaData.setTotalRows(_321); this.scroller.updateSize(); },initAjax:function(url){ ajaxEngine.registerRequest(this.tableId+"_request",url); ajaxEngine.registerAjaxObject(this.tableId+"_updater",this); },invokeAjax:function(){ },handleTimedOut:function(){ this.processingRequest=null; this.processQueuedRequest(); },fetchBuffer:function(_322){ if(this.buffer.isInRange(_322)&&!this.buffer.isNearingLimit(_322)){ return; } if(this.processingRequest){ this.unprocessedRequest=new Rico.LiveGridRequest(_322); return; } var _323=this.buffer.getFetchOffset(_322); this.processingRequest=new Rico.LiveGridRequest(_322); this.processingRequest.bufferOffset=_323; var _324=this.buffer.getFetchSize(_322); var _325=false; var _326; if(this.options.requestParameters){ _326=this._createQueryString(this.options.requestParameters,0); } _326=(_326==null)?"":_326+"&"; _326=_326+"id="+this.tableId+"&page_size="+_324+"&offset="+_323; if(this.sortCol){ _326=_326+"&sort_col="+escape(this.sortCol)+"&sort_dir="+this.sortDir; } this.ajaxOptions.parameters=_326; ajaxEngine.sendRequest(this.tableId+"_request",this.ajaxOptions); this.timeoutHandler=setTimeout(this.handleTimedOut.bind(this),this.options.bufferTimeout); },setRequestParams:function(){ this.options.requestParameters=[]; for(var i=0;i"+"   "; } },headerCellClicked:function(evt){ var _343=evt.target?evt.target:evt.srcElement; var _344=_343.id; var _345=parseInt(_344.substring(_344.lastIndexOf("_")+1)); var _346=this.getSortedColumnIndex(); if(_346!=-1){ if(_346!=_345){ this.removeColumnSort(_346); this.setColumnSort(_345,Rico.TableColumn.SORT_ASC); }else{ this.toggleColumnSort(_346); } }else{ this.setColumnSort(_345,Rico.TableColumn.SORT_ASC); } if(this.options.sortHandler){ this.options.sortHandler(this.options.columns[_345]); } },removeColumnSort:function(n){ this.options.columns[n].setUnsorted(); this.setSortImage(n); },setColumnSort:function(n,_347){ this.options.columns[n].setSorted(_347); this.setSortImage(n); },toggleColumnSort:function(n){ this.options.columns[n].toggleSort(); this.setSortImage(n); },setSortImage:function(n){ var _348=this.options.columns[n].getSortDirection(); var _349=$(this.headerTableId+"_img_"+n); if(_348==Rico.TableColumn.UNSORTED){ _349.innerHTML="  "; }else{ if(_348==Rico.TableColumn.SORT_ASC){ _349.innerHTML="  "; }else{ if(_348==Rico.TableColumn.SORT_DESC){ _349.innerHTML="  "; } } } },getSortedColumnIndex:function(){ var cols=this.options.columns; for(var i=0;ithis.length){ return false; } for(var i=0,n=0;i=0){ var _5=this.options.initialOffset; this.scroller.moveScroll(_5); this.viewPort.scrollTo(this.scroller.rowToPixel(_5)); if(this.options.sortCol){ this.sortCol=_2.sortCol; this.sortDir=_2.sortDir; } var _6=this; setTimeout(function(){ _6.requestContentRefresh(_5); },100); } },fetchBuffer:function(_7){ if(this.buffer.isInRange(_7)&&!this.buffer.isNearingLimit(_7)){ return; } if(this.processingRequest){ this.unprocessedRequest=new Rico.LiveGridRequest(_7); return; } var _8=this.buffer.getFetchOffset(_7); this.processingRequest=new Rico.LiveGridRequest(_7); this.processingRequest.bufferOffset=_8; var _9=this.buffer.getFetchSize(_7); var _10=false; var _11={"page_size":_9,"offset":_8}; if(this.sortCol){ Object.extend(_11,{"sort_col":this.sortCol,"sort_dir":this.sortDir}); } Prado.Callback(this.tableId,_11,this.ajaxUpdate.bind(this),this.options); this.timeoutHandler=setTimeout(this.handleTimedOut.bind(this),this.options.bufferTimeout); },ajaxUpdate:function(_12,_13){ try{ clearTimeout(this.timeoutHandler); this.buffer.update(_12,this.processingRequest.bufferOffset); this.viewPort.bufferChanged(); } catch(err){ } finally{ this.processingRequest=null; } this.processQueuedRequest(); }}); Object.extend(Rico.LiveGridBuffer.prototype,{update:function(_14,_15){ if(this.rows.length==0){ this.rows=_14; this.size=this.rows.length; this.startPos=_15; return; } if(_15>this.startPos){ if(this.startPos+this.rows.length<_15){ this.rows=_14; this.startPos=_15; }else{ this.rows=this.rows.concat(_14.slice(0,_14.length)); if(this.rows.length>this.maxBufferSize){ var _16=this.rows.length; this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length); this.startPos=this.startPos+(_16-this.rows.length); } } }else{ if(_15+_14.lengththis.maxBufferSize){ this.rows=this.rows.slice(0,this.maxBufferSize); } } this.startPos=_15; } this.size=this.rows.length; }}); Object.extend(Rico.GridViewPort.prototype,{populateRow:function(_17,row){ if(isdef(_17)){ for(var j=0;j