1 Rico.applyShadow=function(b,a){if(typeof a=="undefined"){a=true
2 }if(a){Rico.addClass(b,"ricoShadow")
5 Rico._OpenPopupList=[];
6 Rico._RemoveOpenPopup=function(a){if(a.openIndex>=0&&a.openIndex<Rico._OpenPopupList.length){Rico._OpenPopupList.splice(a.openIndex,1)
9 Rico._AddOpenPopup=function(a){a.openIndex=Rico._OpenPopupList.push(a)-1
11 Rico._checkEscKey=function(b){if(Rico.eventKey(b)!=27){return true
12 }while(Rico._OpenPopupList.length>0){var a=Rico._OpenPopupList.pop();
13 if(a&&a.visible()){a.openIndex=-1;
19 Rico.eventBind(document,"keyup",Rico.eventHandle(Rico,"_checkEscKey"));
20 Rico.Popup=function(b,a){this.initialize(b,a)
22 Rico.Popup.prototype={initialize:function(b,a){this.options={hideOnClick:false,ignoreClicks:false,position:"absolute",shadow:true,zIndex:2,canDrag:false,dragElement:false,closeFunc:false};
24 if(b){this.setDiv(b,a)
25 }},createContainer:function(a){this.setDiv(document.createElement("div"),a);
26 if(a&&a.parent){a.parent.appendChild(this.container)
27 }else{document.getElementsByTagName("body")[0].appendChild(this.container)
28 }},setDiv:function(c,b){Rico.extend(this.options,b||{});
29 this.container=Rico.$(c);
30 if(this.options.position=="auto"){this.position=Rico.getStyle(this.container,"position").toLowerCase()
31 }else{this.position=this.container.style.position=this.options.position
32 }if(this.position!="absolute"){this.content=this.container;
34 }if(this.options.zIndex>=0){this.container.style.zIndex=this.options.zIndex
35 }if(this.options.closeFunc){this.closeFunc=this.options.closeFunc
37 this.closeFunc=function(){a.closePopup()
39 }this.container.style.top="0px";
40 this.container.style.left="0px";
41 this.container.style.display="none";
42 this.content=document.createElement("div");
43 while(this.container.firstChild){this.content.appendChild(this.container.firstChild)
44 }this.container.appendChild(this.content);
45 this.content.className="RicoPopupContent";
46 this.content.style.position="relative";
47 if(Rico.isIE&&Rico.ieVersion<7){this.ifr=document.createElement("iframe");
48 this.ifr.style.position="absolute";
49 this.ifr.style.top="0px";
50 this.ifr.style.left="0px";
51 this.ifr.style.width="2000px";
52 this.ifr.style.height="2000px";
53 this.ifr.style.zIndex=-1;
54 this.ifr.frameBorder=0;
55 this.ifr.src="javascript:false;";
56 this.content.appendChild(this.ifr)
57 }Rico.applyShadow(this.container,this.options.shadow);
58 if(this.options.hideOnClick){Rico.eventBind(document,"click",Rico.eventHandle(this,"_docClick"))
59 }this.dragEnabled=false;
60 this.mousedownHandler=Rico.eventHandle(this,"_startDrag");
61 this.dragHandler=Rico.eventHandle(this,"_drag");
62 this.dropHandler=Rico.eventHandle(this,"_endDrag");
63 if(this.options.canDrag){this.enableDragging()
64 }if(this.options.ignoreClicks||this.options.canDrag){this.ignoreClicks()
65 }},clearContent:function(){this.content.innerHTML=""
66 },setContent:function(a){this.content.innerHTML=a
67 },enableDragging:function(){if(!this.dragEnabled&&this.options.dragElement){Rico.eventBind(this.options.dragElement,"mousedown",this.mousedownHandler);
69 }return this.dragEnabled
70 },disableDragging:function(){if(!this.dragEnabled){return
71 }Rico.eventUnbind(this.options.dragElement,"mousedown",this.mousedownHandler);
72 this.dragEnabled=false
73 },setZ:function(a){this.container.style.zIndex=a
74 },ignoreClicks:function(){Rico.eventBind(this.container,"click",Rico.eventHandle(this,"_ignoreClick"))
75 },_ignoreClick:function(a){if(a.stopPropagation){a.stopPropagation()
76 }else{a.cancelBubble=true
78 },_docClick:function(a){this.closeFunc();
80 },move:function(b,a){if(typeof b=="number"){this.container.style.left=b+"px"
81 }if(typeof a=="number"){this.container.style.top=a+"px"
82 }},_startDrag:function(b){var a=Rico.eventElement(b);
83 this.container.style.cursor="move";
84 this.lastMouse=Rico.eventClient(b);
85 Rico.eventBind(document,"mousemove",this.dragHandler);
86 Rico.eventBind(document,"mouseup",this.dropHandler);
88 },_drag:function(d){var b=Rico.eventClient(d);
89 var c=parseInt(this.container.style.left,10)+b.x-this.lastMouse.x;
90 var a=parseInt(this.container.style.top,10)+b.y-this.lastMouse.y;
94 },_endDrag:function(){this.container.style.cursor="";
95 Rico.eventUnbind(document,"mousemove",this.dragHandler);
96 Rico.eventUnbind(document,"mouseup",this.dropHandler)
97 },openPopup:function(b,a){this.container.style.display=this.position=="absolute"?"block":Rico.isIE&&Rico.ieVersion<8?"inline":"inline-block";
98 if(typeof b=="number"){this.container.style.left=b+"px"
99 }if(typeof a=="number"){this.container.style.top=a+"px"
100 }if(this.container.id){Rico.log("openPopup "+this.container.id+" at "+b+","+a)
101 }Rico._AddOpenPopup(this)
102 },centerPopup:function(){this.openPopup();
103 var d=this.container.offsetWidth;
104 var c=this.container.offsetHeight;
105 var a=this.container.parentNode.offsetWidth;
106 var b=this.container.parentNode.offsetHeight;
107 this.move(parseInt(Math.max((a-d)/2,0),10),parseInt(Math.max((b-c)/2,0),10))
108 },visible:function(){return Rico.visible(this.container)
109 },closePopup:function(){Rico._RemoveOpenPopup(this);
110 if(!Rico.visible(this.container)){return
111 }if(this.container.id){Rico.log("closePopup "+this.container.id)
112 }if(this.dragEnabled){this._endDrag()
113 }this.container.style.display="none";
114 if(this.options.onClose){this.options.onClose()
116 Rico.closeButton=function(d){var b=document.createElement("a");
117 b.className="RicoCloseAnchor";
118 if(Rico.theme.closeAnchor){Rico.addClass(b,Rico.theme.closeAnchor)
119 }var c=b.appendChild(document.createElement("span"));
120 c.title=Rico.getPhraseById("close");
121 new Rico.HoverSet([b]);
122 Rico.addClass(c,Rico.theme.close||"rico-icon RicoClose");
123 Rico.eventBind(b,"click",d);
126 Rico.floatButton=function(b,e,f){var c=document.createElement("a");
127 c.className="RicoButtonAnchor";
128 Rico.addClass(c,Rico.theme.buttonAnchor||"RicoButtonAnchorNative");
129 var d=c.appendChild(document.createElement("span"));
131 }d.className=Rico.theme[b.toLowerCase()]||"rico-icon Rico"+b;
132 Rico.eventBind(c,"click",e,false);
133 new Rico.HoverSet([c]);
136 Rico.clearButton=function(b){var a=document.createElement("span");
137 a.title=Rico.getPhraseById("clear");
138 a.className="ricoClear";
139 Rico.addClass(a,Rico.theme.clear||"rico-icon ricoClearNative");
140 Rico.eventBind(a,"click",b);
143 Rico.Window=function(c,a,b){this.initialize(c,a,b)
145 Rico.Window.prototype={initialize:function(c,a,b){a=a||{overflow:"auto"};
146 Rico.extend(this,new Rico.Popup());
147 this.titleDiv=document.createElement("div");
148 this.options.canDrag=true;
149 this.options.dragElement=this.titleDiv;
150 this.createContainer(a);
151 this.content.appendChild(this.titleDiv);
153 this.contentDiv=b||document.createElement("div");
154 this.content.appendChild(this.contentDiv);
155 this.titleDiv.className="ricoTitle";
156 if(Rico.theme.dialogTitle){Rico.addClass(this.titleDiv,Rico.theme.dialogTitle)
157 }this.titleDiv.style.position="relative";
158 this.titleContent=document.createElement("span");
159 this.titleContent.className="ricoTitleSpan";
160 this.titleDiv.appendChild(this.titleContent);
161 this.titleDiv.appendChild(Rico.closeButton(Rico.eventHandle(this,"closePopup")));
164 }this.setTitle(c||" ");
165 this.contentDiv.className="ricoContent";
166 if(Rico.theme.dialogContent){Rico.addClass(this.contentDiv,Rico.theme.dialogContent)
167 }this.contentDiv.style.position="relative";
168 if(a.height){this.contentDiv.style.height=a.height
169 }if(a.width){this.contentDiv.style.width=a.width
170 }if(a.overflow){this.contentDiv.style.overflow=a.overflow
171 }Rico.addClass(this.content,"ricoWindow");
172 if(Rico.theme.dialog){Rico.addClass(this.content,Rico.theme.dialog)
173 }if(Rico.isIE){this.titleDiv.style.zoom=1;
174 this.contentDiv.style.zoom=1
175 }this.content=this.contentDiv
176 },setTitle:function(a){this.titleContent.innerHTML=a
178 Rico.Menu=function(a){this.initialize(a)
180 Rico.Menu.prototype={initialize:function(a){Rico.extend(this,new Rico.Popup());
181 Rico.extend(this.options,{width:"15em",arrowColor:"b",showDisabled:false,hideOnClick:true});
182 if(typeof a=="string"){this.options.width=a
183 }else{Rico.extend(this.options,a||{})
185 this.highlightElem=null
186 },createDiv:function(a){if(this.container){return
188 var c={closeFunc:function(){b.cancelmenu()
191 }this.createContainer(c);
192 this.content.className=Rico.isWebKit?"ricoMenuSafari":"ricoMenu";
193 this.content.style.width=this.options.width;
194 this.direction=Rico.getStyle(this.container,"direction")||"ltr";
195 this.direction=this.direction.toLowerCase();
198 },showmenu:function(b,c){Rico.eventStop(b);
200 if(this.content.childNodes.length==0){this.cancelmenu();
202 }var a=Rico.eventClient(b);
203 this.openmenu(a.x,a.y,0,0)
204 },openmenu:function(g,f,j,e,a){var h=g+(a?0:Rico.docScrollLeft());
205 this.container.style.visibility="hidden";
206 this.container.style.display="block";
207 var i=this.container.offsetWidth;
208 var b=this.content.offsetWidth;
209 if(this.direction=="rtl"){if(h>i+j){h-=b+j
210 }}else{if(g+i>Rico.windowWidth()){h-=b+j-2
211 }}var d=Rico.docScrollTop();
213 if(f+this.container.offsetHeight-d>Rico.windowHeight()){c=Math.max(c-this.content.offsetHeight+e,0)
214 }this.openPopup(h,c);
215 this.container.style.visibility="visible";
217 },clearMenu:function(){this.clearContent();
218 this.defaultAction=null;
220 },addMenuHeading:function(b){var a=document.createElement("div");
222 a.className="ricoMenuHeading";
223 this.content.appendChild(a)
224 },addMenuBreak:function(){var a=document.createElement("div");
225 a.className="ricoMenuBreak";
226 this.content.appendChild(a)
227 },addSubMenuItem:function(b,e,g){var d=this.direction=="rtl"?"left":"right";
228 var c=this.addMenuItem(b,null,true,null,g);
229 c.className="ricoSubMenu";
230 var f=c.appendChild(document.createElement("div"));
231 f.className="rico-icon rico-"+d+"-"+this.options.arrowColor;
232 Rico.setStyle(f,{position:"absolute",top:"2px"});
235 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"showSubMenu"));
236 Rico.eventBind(c,"mouseout",Rico.eventHandle(this,"subMenuOut"))
237 },showSubMenu:function(c){if(this.openSubMenu){this.hideSubMenu()
238 }var b=Rico.eventElement(c);
239 if(!b.RicoSubmenu){b=b.parentNode
240 }if(!b.RicoSubmenu){return
241 }this.openSubMenu=b.RicoSubmenu;
242 this.openMenuAnchor=b;
243 if(Rico.hasClass(b,"ricoSubMenu")){Rico.removeClass(b,"ricoSubMenu");
244 Rico.addClass(b,"ricoSubMenuOpen")
245 }b.RicoSubmenu.openmenu(parseInt(this.container.style.left)+b.offsetWidth,parseInt(this.container.style.top)+b.offsetTop,b.offsetWidth-2,b.offsetHeight+2,true)
246 },subMenuOut:function(d){if(!this.openSubMenu){return
248 var c=Rico.eventElement(d);
249 var a=Rico.eventRelatedTarget(d)||d.toElement;
250 try{while(a!=null&&a!=this.openSubMenu.div){a=a.parentNode
251 }}catch(b){}if(a==this.openSubMenu.div){return
253 },hideSubMenu:function(){if(this.openMenuAnchor){Rico.removeClass(this.openMenuAnchor,"ricoSubMenuOpen");
254 Rico.addClass(this.openMenuAnchor,"ricoSubMenu");
255 this.openMenuAnchor=null
256 }if(this.openSubMenu){this.openSubMenu.hidemenu();
257 this.openSubMenu=null
258 }},addMenuItemId:function(c,b,a,e,d){if(arguments.length<3){a=true
259 }this.addMenuItem(Rico.getPhraseById(c),b,a,e,d)
260 },addMenuItem:function(b,e,d,g,f){if(arguments.length>=3&&!d&&!this.options.showDisabled){return null
262 var c=document.createElement(typeof e=="string"?"a":"div");
263 if(arguments.length<3||d){if(typeof e=="string"){c.href=e;
265 }}else{if(f=="event"){Rico.eventBind(c,"click",e)
267 }}c.className="enabled";
268 if(this.defaultAction==null){this.defaultAction=e
269 }}else{c.disabled=true;
270 c.className="disabled"
272 if(typeof g=="string"){c.title=g
273 }c=this.content.appendChild(c);
274 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"mouseOver"));
275 Rico.eventBind(c,"mouseout",Rico.eventHandle(this,"mouseOut"));
277 },mouseOver:function(b){if(this.highlightElem&&this.highlightElem.className=="enabled-hover"){this.highlightElem.className="enabled";
278 this.highlightElem=null
279 }var a=Rico.eventElement(b);
280 if(this.openMenuAnchor&&this.openMenuAnchor!=a){this.hideSubMenu()
281 }if(a.className=="enabled"){a.className="enabled-hover";
283 }},mouseOut:function(b){var a=Rico.eventElement(b);
284 if(a.className=="enabled-hover"){a.className="enabled"
285 }if(this.highlightElem==a){this.highlightElem=null
286 }},cancelmenu:function(){if(!this.visible()){return
287 }if(this.hideFunc){this.hideFunc()
290 },hidemenu:function(){if(this.openSubMenu){this.openSubMenu.hidemenu()
293 Rico.SelectionSet=function(b,a){this.initialize(b,a)
295 Rico.SelectionSet.prototype={initialize:function(e,b){Rico.log("SelectionSet#initialize");
297 if(typeof e=="string"){e=Rico.select(e)
298 }this.previouslySelected=[];
299 this.selectionSet=[];
300 this.selectedClassName=this.options.selectedClass||Rico.theme.selected||"selected";
301 this.selectNode=this.options.selectNode||function(f){return f
303 this.onSelect=this.options.onSelect;
304 this.onFirstSelect=this.options.onFirstSelect;
306 this.clickHandler=function(f){a.selectIndex(f)
308 this.selectedIndex=-1;
312 }if(!this.options.noDefault){var d=this.options.cookieName?this.getCookie():0;
313 this.selectIndex(d||this.options.selectedIndex||0)
314 }},getCookie:function(){var b=Rico.getCookie(this.options.cookieName);
317 return a<this.selectionSet.length?a:0
318 },reset:function(){this.previouslySelected=[];
319 this._notifySelected(this.selectedIndex)
320 },clearSelected:function(){if(this.selected){Rico.removeClass(this.selectNode(this.selected),this.selectedClassName)
321 }},getIndex:function(b){for(var a=0;
322 a<this.selectionSet.length;
323 a++){if(b==this.selectionSet[a]){return a
325 },select:function(b){if(this.selected==b){return
326 }var a=this.getIndex(b);
327 if(a>=0){this.selectIndex(a)
328 }},_notifySelected:function(a){if(a<0){return
329 }var b=this.selectionSet[a];
330 if(this.options.cookieName){Rico.setCookie(this.options.cookieName,a,this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
331 }if(this.onFirstSelect&&!this.previouslySelected[a]){this.onFirstSelect(b,a);
332 this.previouslySelected[a]=true
333 }if(this.onSelect){try{this.onSelect(a)
334 }catch(c){}}},selectIndex:function(a){if(this.selectedIndex==a||a>=this.selectionSet.length){return
335 }this.clearSelected();
336 this._notifySelected(a);
337 this.selectedIndex=a;
338 this.selected=this.selectionSet[a].element;
339 Rico.addClass(this.selectNode(this.selected),this.selectedClassName)
340 },nextSelectIndex:function(){return(this.selectedIndex+1)%this.selectionSet.length
341 },nextSelectItem:function(){return this.selectionSet[this.nextSelectIndex()]
342 },selectNext:function(){this.selectIndex(this.nextSelectIndex())
343 },add:function(b){var a=this.selectionSet.length;
344 this.selectionSet[a]=new Rico._SelectionItem(b,a,this.clickHandler)
345 },remove:function(b){if(b==this.selected){this.clearSelected()
346 }var a=this.getIndex(b);
348 }this.selectionSet[a].remove();
349 this.selectionSet.splice(a,1)
350 },removeAll:function(){this.clearSelected();
351 while(this.selectionSet.length>0){this.selectionSet.pop().remove()
353 Rico._SelectionItem=function(b,a,c){this.add(b,a,c)
355 Rico._SelectionItem.prototype={add:function(b,a,c){this.element=b;
358 this.handle=Rico.eventHandle(this,"click");
359 Rico.eventBind(b,"click",this.handle)
360 },click:function(a){this.callback(this.index)
361 },remove:function(){Rico.eventUnbind(this.element,"click",this.handle)
363 Rico.HoverSet=function(b,a){this.initialize(b,a)
365 Rico.HoverSet.prototype={initialize:function(c,a){Rico.log("HoverSet#initialize");
367 this.hoverClass=a.hoverClass||Rico.theme.hover||"hover";
368 this.hoverFunc=a.hoverNodes||function(d){return[d]
375 }},add:function(a){this.hoverSet.push(new Rico._HoverItem(a,this.hoverFunc,this.hoverClass))
376 },removeAll:function(){while(this.hoverSet.length>0){this.hoverSet.pop().remove()
378 Rico._HoverItem=function(b,a,c){this.add(b,a,c)
380 Rico._HoverItem.prototype={add:function(b,a,c){this.element=b;
383 this.movehandle=Rico.eventHandle(this,"move");
384 this.outhandle=Rico.eventHandle(this,"mouseout");
385 Rico.eventBind(b,"mousemove",this.movehandle);
386 Rico.eventBind(b,"mouseout",this.outhandle)
387 },move:function(c){var a=this.selectFunc(this.element);
390 b++){Rico.addClass(a[b],this.hoverClass)
391 }},mouseout:function(c){var a=this.selectFunc(this.element);
394 b++){Rico.removeClass(a[b],this.hoverClass)
395 }},remove:function(){Rico.eventUnbind(element,"mousemove",this.movehandle);
396 Rico.eventUnbind(element,"mouseout",this.outhandle)
399 Rico.Effect.easeIn=function(a){return Math.sqrt(a)
401 Rico.Effect.easeOut=function(a){return a*a
403 Rico.ContentTransitionBase=function(){};
404 Rico.ContentTransitionBase.prototype={initBase:function(e,d,b){Rico.log("ContentTransitionBase#initBase");
405 if(typeof e=="string"){e=Rico.select(e)
406 }if(typeof d=="string"){d=Rico.select(d)
410 this.hoverSet=new Rico.HoverSet(e,b);
413 c++){if(d[c]){Rico.hide(d[c])
415 this.selectionSet=new Rico.SelectionSet(e,Rico.extend(b,{onSelect:function(f){a._finishSelect(f)
417 },reset:function(){this.selectionSet.reset()
418 },select:function(a){this.selectionSet.selectIndex(a)
419 },_finishSelect:function(b){Rico.log("ContentTransitionBase#_finishSelect");
420 var a=this.contents[b];
421 if(!a){alert("Internal error: no panel @index="+b);
423 }if(this.selected==a){return
424 }if(this.transition){if(this.selected){this.transition(a)
425 }else{a.style.display="block"
426 }}else{if(this.selected){Rico.hide(this.selected)
427 }a.style.display="block"
429 },addBase:function(b,a){this.titles.push(b);
430 this.contents.push(a);
431 this.hoverSet.add(b);
432 this.selectionSet.add(b);
434 },removeBase:function(a){},removeAll:function(){this.hoverSet.removeAll();
435 this.selectionSet.removeAll()
437 Rico.Accordion=function(b,a){this.initialize(b,a)
439 Rico.Accordion.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(g,e){g=Rico.$(g);
440 g.style.overflow="hidden";
441 g.className=e.accClass||Rico.theme.accordion||"Rico_accordion";
442 if(typeof e.panelWidth=="number"){e.panelWidth+="px"
443 }if(e.panelWidth){g.style.width=e.panelWidth
444 }var d=Rico.getDirectChildrenByTag(g,"div");
448 f++){c=Rico.getDirectChildrenByTag(d[f],"div");
449 if(c.length>=2){c[0].className=e.titleClass||Rico.theme.accTitle||"Rico_accTitle";
450 c[1].className=e.contentClass||Rico.theme.accContent||"Rico_accContent";
453 var b=Rico.wrapChildren(c[0],"","","a");
454 b.href="javascript:void(0)"
455 }}Rico.log("creating Rico.Accordion for "+g.id+" with "+j.length+" panels");
456 this.initBase(j,h,e);
457 this.selected.style.height=this.options.panelHeight+"px";
458 this.totSteps=(typeof e.duration=="number"?e.duration:200)/25
459 },transition:function(b){if(!this.options.noAnimate){this.closing=this.selected;
463 this.timer=setInterval(function(){a.step()
465 }else{b.style.height=this.options.panelHeight+"px";
466 if(this.selected){Rico.hide(this.selected)
467 }b.style.display="block"
468 }},step:function(){this.curStep++;
469 var a=Math.round(this.curStep/this.totSteps*this.options.panelHeight);
470 this.opening.style.height=a+"px";
471 this.closing.style.height=(this.options.panelHeight-a)+"px";
472 if(this.curStep==1){this.opening.style.paddingTop=this.opening.style.paddingBottom="0px";
473 this.opening.style.display="block"
474 }if(this.curStep==this.totSteps){clearInterval(this.timer);
475 this.opening.style.paddingTop=this.opening.style.paddingBottom="";
476 Rico.hide(this.closing)
477 }},setPanelHeight:function(a){this.options.panelHeight=a;
478 this.selected.style.height=this.options.panelHeight+"px"
480 Rico.TabbedPanel=function(b,a){this.initialize(b,a)
482 Rico.TabbedPanel.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(d,k){d=Rico.$(d);
484 if(typeof k.panelWidth=="number"){k.panelWidth+="px"
485 }if(typeof k.panelHeight=="number"){k.panelHeight+="px"
486 }d.className=k.tabClass||Rico.theme.tabPanel||"Rico_tabPanel";
487 if(k.panelWidth){d.style.width=k.panelWidth
492 e++){if(j[e]&&j[e].tagName&&j[e].tagName.match(/^div|ul$/i)){g.push(j[e])
493 }}if(g.length<2){return
494 }var c=g[0].tagName.toLowerCase()=="ul"?"li":"div";
495 g[0].className=k.navContainerClass||Rico.theme.tabNavContainer||"Rico_tabNavContainer";
496 g[0].style.listStyle="none";
497 g[1].className=k.contentContainerClass||Rico.theme.tabContentContainer||"Rico_tabContentContainer";
498 var f=Rico.getDirectChildrenByTag(g[0],c);
499 var b=Rico.getDirectChildrenByTag(g[1],"div");
500 if(!k.corners){k.corners="top"
503 e++){f[e].className=k.titleClass||Rico.theme.tabTitle||"Rico_tabTitle";
504 var h=Rico.wrapChildren(f[e],"","","a");
505 h.href="javascript:void(0)";
506 b[e].className=k.contentClass||Rico.theme.tabContent||"Rico_tabContent";
507 if(k.panelHeight){b[e].style.overflow="auto"
508 }if(k.corners!="none"){if(k.panelHdrWidth){f[e].style.width=k.panelHdrWidth
509 }Rico.Corner.round(f[e],Rico.theme.tabCornerOptions||k)
510 }}k.selectedClass=Rico.theme.tabSelected||"selected";
511 this.initBase(f,b,k);
512 if(this.selected){this.transition(this.selected)
513 }},transition:function(a){Rico.log("TabbedPanel#transition "+typeof(a));
514 if(this.selected){Rico.hide(this.selected)
516 if(this.options.panelHeight){a.style.height=this.options.panelHeight
518 Rico.Corner={round:function(b,a){b=Rico.$(b);
519 this.options={corners:"all",bgColor:"fromParent",compact:false,nativeCorners:false};
520 Rico.extend(this.options,a||{});
521 if(typeof(Rico.getStyle(b,"border-radius"))=="string"){this._roundCornersStdCss(b)
522 }else{if(typeof(Rico.getStyle(b,"-webkit-border-radius"))=="string"){this._roundCornersWebKit(b)
523 }else{if(typeof(Rico.getStyle(b,"-moz-border-radius"))=="string"){this._roundCornersMoz(b)
524 }else{if(!this.options.nativeCorners){this._roundCornersImpl(b)
525 }}}}},_roundCornersStdCss:function(b){var a=this.options.compact?"4px":"8px";
526 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{borderRadius:a})
527 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{borderTopLeftRadius:a})
528 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{borderTopRightRadius:a})
529 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{borderBottomLeftRadius:a})
530 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{borderBottomRightRadius:a})
531 }}},_roundCornersWebKit:function(b){var a=this.options.compact?"4px":"8px";
532 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{WebkitBorderRadius:a})
533 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{WebkitBorderTopLeftRadius:a})
534 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{WebkitBorderTopRightRadius:a})
535 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{WebkitBorderBottomLeftRadius:a})
536 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{WebkitBorderBottomRightRadius:a})
537 }}},_roundCornersMoz:function(b){var a=this.options.compact?"4px":"8px";
538 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{MozBorderRadius:a})
539 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{MozBorderRadiusTopleft:a})
540 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{MozBorderRadiusTopright:a})
541 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{MozBorderRadiusBottomleft:a})
542 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{MozBorderRadiusBottomright:a})
543 }}},_roundCornersImpl:function(b){var a=this.options.bgColor=="fromParent"?this._background(b.parentNode):this.options.bgColor;
544 b.style.position="relative";
545 if(this._hasString(this.options.corners,"all","top","tl")){this._createCorner(b,"top","left",a)
546 }if(this._hasString(this.options.corners,"all","top","tr")){this._createCorner(b,"top","right",a)
547 }if(this._hasString(this.options.corners,"all","bottom","bl")){this._createCorner(b,"bottom","left",a)
548 }if(this._hasString(this.options.corners,"all","bottom","br")){this._createCorner(b,"bottom","right",a)
549 }},_createCorner:function(b,c,f,k){var n=document.createElement("div");
550 n.className="ricoCorner";
551 Rico.setStyle(n,{width:"6px",height:"5px"});
552 var o=Rico.getStyle(b,"border-"+c+"-style");
553 var a=o=="none"?k:Rico.getStyle(b,"border-"+c+"-color");
554 var j=o=="none"?"0px":"-1px";
556 n.style[f]=Rico.isIE&&Rico.ieVersion<7&&f=="right"&&o!="none"?"-2px":"-1px";
559 if(c=="bottom"){h.reverse()
560 }var m=o=="none"?"0px none":"1px solid "+a;
561 var g=f=="left"?"Right":"Left";
564 e++){var l=document.createElement("div");
565 Rico.setStyle(l,{backgroundColor:k,height:"1px"});
566 l.style["margin"+g]=h[e]+"px";
567 l.style["border"+g]=m;
569 }},_background:function(c){try{var a=Rico.getStyle(c,"backgroundColor");
570 if(a.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&c.parentNode){return this._background(c.parentNode)
571 }return a==null?"#ffffff":a
572 }catch(b){return"#ffffff"
573 }},_hasString:function(b){for(var a=1;
575 a++){if(b.indexOf(arguments[a])>=0){return true
578 Rico.toColorPart=function(a){return Rico.zFill(a,2,16)
580 Rico.Color=function(c,b,a){this.initialize(c,b,a)
582 Rico.Color.prototype={initialize:function(c,b,a){this.rgb={r:c,g:b,b:a}
583 },setRed:function(a){this.rgb.r=a
584 },setGreen:function(a){this.rgb.g=a
585 },setBlue:function(a){this.rgb.b=a
586 },setHue:function(b){var a=this.asHSB();
588 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
589 },setSaturation:function(b){var a=this.asHSB();
591 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
592 },setBrightness:function(a){var c=this.asHSB();
594 this.rgb=Rico.Color.HSBtoRGB(c.h,c.s,c.b)
595 },darken:function(b){var a=this.asHSB();
596 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))
597 },brighten:function(b){var a=this.asHSB();
598 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))
599 },blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);
600 this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);
601 this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)
602 },isBright:function(){var a=this.asHSB();
603 return this.asHSB().b>0.5
604 },isDark:function(){return !this.isBright()
605 },asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"
606 },asHex:function(){return"#"+Rico.toColorPart(this.rgb.r)+Rico.toColorPart(this.rgb.g)+Rico.toColorPart(this.rgb.b)
607 },asHSB:function(){return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)
608 },toString:function(){return this.asHex()
610 Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;
614 c++){d+=(b.charAt(c)+b.charAt(c))
615 }}if(d.indexOf("#")==0){d=d.substring(1)
616 }if(!d.match(/^[0-9A-Fa-f]{6}$/)){return null
617 }var f=d.substring(0,2);
618 var e=d.substring(2,4);
619 var a=d.substring(4,6);
620 return new Rico.Color(parseInt(f,16),parseInt(e,16),parseInt(a,16))
622 Rico.Color.createColorFromBackground=function(d){if(!d.style){return new Rico.Color(255,255,255)
623 }var b=Rico.getStyle(d,"background-color");
624 if(b.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&d.parentNode){return Rico.Color.createColorFromBackground(d.parentNode)
625 }if(b==null){return new Rico.Color(255,255,255)
626 }if(b.indexOf("rgb(")==0){var a=b.substring(4,b.length-1);
628 return new Rico.Color(parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10))
629 }else{if(b.indexOf("#")==0){return Rico.Color.createFromHex(b)
630 }else{return new Rico.Color(255,255,255)
632 Rico.Color.HSBtoRGB=function(i,e,k){var c=0;
635 if(e==0){c=parseInt(k*255+0.5,10);
638 }else{var g=(i-Math.floor(i))*6;
639 var j=g-Math.floor(g);
642 var m=k*(1-(e*(1-j)));
643 switch(parseInt(g,10)){case 0:c=(k*255+0.5);
647 case 1:c=(a*255+0.5);
651 case 2:c=(b*255+0.5);
655 case 3:c=(b*255+0.5);
659 case 4:c=(m*255+0.5);
663 case 5:c=(k*255+0.5);
667 }}return{r:parseInt(c,10),g:parseInt(d,10),b:parseInt(l,10)}
669 Rico.Color.RGBtoHSB=function(a,f,l){var h;
680 }else{var c=(m-a)/(m-i);
684 }else{if(f==m){h=2+c-d
688 }}return{h:h,s:e,b:k}
690 Rico.createXmlDocument=function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);
691 if(a.readyState==null){a.readyState=1;
692 a.addEventListener("load",function(){a.readyState=4;
693 if(typeof a.onreadystatechange=="function"){a.onreadystatechange()
696 }if(window.ActiveXObject){return Rico.tryFunctions(function(){return new ActiveXObject("MSXML2.DomDocument")
697 },function(){return new ActiveXObject("Microsoft.DomDocument")
698 },function(){return new ActiveXObject("MSXML.DomDocument")
699 },function(){return new ActiveXObject("MSXML3.DomDocument")
703 Rico.CalendarControl=function(b,a){this.initialize(b,a)
705 Rico.CalendarControl.prototype={initialize:function(c,b){this.id=c;
707 Rico.extend(this,new Rico.Popup());
708 Rico.extend(this.options,{ignoreClicks:true,startAt:0,showWeekNumber:0,showToday:1,dateFmt:"ISO8601",minDate:new Date(a.getFullYear()-50,0,1),maxDate:new Date(a.getFullYear()+50,11,31)});
709 Rico.extend(this.options,b||{});
710 this.close=this.closePopup;
711 this.bPageLoaded=false;
714 this.weekString=Rico.getPhraseById("calWeekHdg");
715 this.re=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
716 this.setDateFmt(this.options.dateFmt)
717 },setDateFmt:function(a){this.dateFmt=(a=="rico")?Rico.dateFmt:a;
718 Rico.log(this.id+" date format set to "+this.dateFmt);
720 if(this.re.exec(this.dateFmt)){this.dateParts[RegExp.$1]=0;
721 this.dateParts[RegExp.$3]=1;
722 this.dateParts[RegExp.$5]=2
723 }},addHoliday:function(f,a,g,e,c,b){this.Holidays[this.holidayKey(g,a-1,f)]={desc:e,txtColor:b,bgColor:c||"#DDF"}
724 },holidayKey:function(c,a,b){return"h"+Rico.zFill(c,4)+Rico.zFill(a,2)+Rico.zFill(b,2)
725 },atLoad:function(){Rico.log("Calendar#atLoad: "+this.id);
726 this.createContainer();
727 this.container.id=this.id;
728 Rico.addClass(this.container,Rico.theme.calendar||"ricoCalContainer");
729 this.maintab=document.createElement("table");
730 this.maintab.cellSpacing=2;
731 this.maintab.cellPadding=0;
732 this.maintab.border=0;
733 this.maintab.style.borderCollapse="separate";
734 this.maintab.className="ricoCalTab";
735 if(Rico.theme.calendarTable){Rico.addClass(this.maintab,Rico.theme.calendarTable)
736 }this.tbody=Rico.getTBody(this.maintab);
737 var b,n,m,k,h,l,p,o,q,f;
738 this.colStart=this.options.showWeekNumber?1:0;
741 k++){b=this.tbody.insertRow(-1);
745 n++){b.insertCell(-1)
746 }}b=this.tbody.rows[0];
747 b.className="ricoCalDayNames";
748 if(this.options.showWeekNumber){b.cells[0].innerHTML=this.weekString;
751 k++){this.tbody.rows[k].cells[0].className="ricoCalWeekNum"
755 k++){p=(k+this.options.startAt)%7;
756 b.cells[k+this.colStart].innerHTML=Rico.dayAbbr(p);
757 this.styles[k]="ricoCal"+p
758 }this.thead=this.maintab.createTHead();
759 b=this.thead.insertRow(-1);
760 n=b.appendChild(document.createElement("th"));
761 n.colSpan=7+this.colStart;
762 m=n.appendChild(document.createElement("div"));
763 m.className=Rico.theme.calendarHeading||"RicoCalHeading";
764 m.appendChild(this._createTitleSection("Month"));
765 m.appendChild(this._createTitleSection("Year"));
766 new Rico.HoverSet(m.getElementsByTagName("a"));
767 new Rico.HoverSet(this.tbody.getElementsByTagName("td"),{hoverNodes:function(a){return a.innerHTML.match(/^\d+$/)?[a]:[]
769 m.appendChild(Rico.closeButton(Rico.eventHandle(this,"close")));
770 if(this.options.showToday){this.tfoot=this.maintab.createTFoot();
771 b=this.tfoot.insertRow(-1);
772 this.todayCell=b.insertCell(-1);
773 this.todayCell.colSpan=7+this.colStart;
774 if(Rico.theme.calendarFooter){Rico.addClass(this.todayCell,Rico.theme.calendarFooter)
775 }Rico.eventBind(this.todayCell,"click",Rico.eventHandle(this,"selectNow"),false)
776 }this.content.appendChild(this.maintab);
777 var g=Rico.isIE&&Rico.ieVersion<7;
779 this.monthPopup=new Rico.Popup(document.createElement("div"),e);
780 this.monthPopup.closePopup();
781 f=document.createElement("table");
782 f.className="ricoCalMenu";
783 if(Rico.theme.calendarPopdown){Rico.addClass(f,Rico.theme.calendarPopdown)
787 f.style.borderCollapse="separate";
788 f.style.margin="0px";
791 k++){b=f.insertRow(-1);
794 h++){n=b.insertCell(-1);
795 o=document.createElement("a");
796 o.innerHTML=Rico.monthAbbr(k*3+h);
798 if(Rico.theme.calendarDay){Rico.addClass(o,Rico.theme.calendarDay)
800 Rico.eventBind(o,"click",Rico.eventHandle(this,"selectMonth"),false)
801 }}new Rico.HoverSet(f.getElementsByTagName("a"));
802 this.monthPopup.content.appendChild(f);
803 this.content.appendChild(this.monthPopup.container);
804 this.yearPopup=new Rico.Popup(document.createElement("div"),e);
805 this.yearPopup.closePopup();
806 this.yearPopup.content.className="ricoCalYearPrompt";
807 if(Rico.theme.calendarPopdown){Rico.addClass(this.yearPopup.content,Rico.theme.calendarPopdown)
808 }var f=document.createElement("table");
812 f.style.borderCollapse="separate";
813 f.style.margin="0px";
815 this.yearLabel=b.insertCell(-1);
816 this.yearLabel.colSpan=3;
819 this.yearInput=n.appendChild(document.createElement("input"));
820 this.yearInput.maxlength=4;
821 this.yearInput.size=4;
822 Rico.eventBind(this.yearInput,"keypress",Rico.eventHandle(this,"yearKey"),false);
824 var o=Rico.floatButton("Checkmark",Rico.eventHandle(this,"processPopUpYear"));
825 Rico.setStyle(o.firstChild,{margin:"0px",padding:"0px",border:"none"});
828 o=Rico.floatButton("Cancel",Rico.eventHandle(this,"popDownYear"));
829 Rico.setStyle(o.firstChild,{margin:"0px",padding:"0px",border:"none"});
831 this.yearPopup.content.appendChild(f);
832 this.content.appendChild(this.yearPopup.container);
833 o=this.content.getElementsByTagName("a");
836 k++){o[k].href="javascript:void(0)"
837 }Rico.eventBind(this.tbody,"click",Rico.eventHandle(this,"saveAndClose"));
839 this.bPageLoaded=true
840 },_createTitleSection:function(d){var c=document.createElement("span");
841 c.className="RicoCal"+d+"Heading";
842 var b=c.appendChild(document.createElement("a"));
843 b.className="Rico_leftArrow";
844 if(Rico.theme.leftArrowAnchor){Rico.addClass(b,Rico.theme.leftArrowAnchor)
845 }b.appendChild(this.createNavArrow("dec"+d,"left"));
846 b=c.appendChild(document.createElement("a"));
847 b.style.display="inline";
848 Rico.eventBind(b,"click",Rico.eventHandle(this,"popUp"+d),false);
850 b=c.appendChild(document.createElement("a"));
851 b.className="Rico_rightArrow";
852 if(Rico.theme.rightArrowAnchor){Rico.addClass(b,Rico.theme.rightArrowAnchor)
853 }b.appendChild(this.createNavArrow("inc"+d,"right"));
855 },selectNow:function(){var a=new Date();
856 this.dateNow=a.getDate();
857 this.monthNow=a.getMonth();
858 this.yearNow=a.getFullYear();
859 this.monthSelected=this.monthNow;
860 this.yearSelected=this.yearNow;
861 this.constructCalendar()
862 },createNavArrow:function(a,c){var b=document.createElement("span");
863 b.className=Rico.theme[c+"Arrow"]||"rico-icon Rico_"+c+"Arrow";
864 Rico.eventBind(b,"click",Rico.eventHandle(this,a),false);
866 },isValidMonth:function(a,b){if(a<this.options.minDate.getFullYear()){return false
867 }if(a==this.options.minDate.getFullYear()&&b<this.options.minDate.getMonth()){return false
868 }if(a>this.options.maxDate.getFullYear()){return false
869 }if(a==this.options.maxDate.getFullYear()&&b>this.options.maxDate.getMonth()){return false
871 },incMonth:function(){var b=this.monthSelected+1;
872 var a=this.yearSelected;
875 }if(!this.isValidMonth(a,b)){return
876 }this.monthSelected=b;
878 this.constructCalendar()
879 },decMonth:function(){var b=this.monthSelected-1;
880 var a=this.yearSelected;
883 }if(!this.isValidMonth(a,b)){return
884 }this.monthSelected=b;
886 this.constructCalendar()
887 },selectMonth:function(b){var a=Rico.eventElement(b);
888 this.monthSelected=parseInt(a.name,10);
889 this.constructCalendar();
891 },popUpMonth:function(a){if(this.monthPopup.visible()){this.popDownMonth();
894 this.monthPopup.openPopup(this.titleMonth.parentNode.offsetLeft,this.thead.offsetHeight+2);
897 },popDownMonth:function(){this.monthPopup.closePopup()
898 },popDownYear:function(){this.yearPopup.closePopup();
899 this.yearInput.disabled=true
900 },popUpYear:function(a){if(this.yearPopup.visible()){this.popDownYear();
902 }this.popDownMonth();
903 this.yearPopup.openPopup(90,this.thead.offsetHeight+2);
904 this.yearLabel.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
905 this.yearInput.disabled=false;
906 this.yearInput.value="";
907 this.yearInput.focus();
910 },yearKey:function(a){switch(Rico.eventKey(a)){case 27:this.popDownYear();
913 case 13:this.processPopUpYear();
917 },processPopUpYear:function(){var a=this.yearInput.value;
919 if(isNaN(a)||a<this.options.minDate.getFullYear()||a>this.options.maxDate.getFullYear()){alert(Rico.getPhraseById("calInvalidYear"))
920 }else{this.yearSelected=a;
922 this.constructCalendar()
923 }},incYear:function(){if(this.yearSelected>=this.options.maxDate.getFullYear()){return
924 }this.yearSelected++;
925 this.constructCalendar()
926 },decYear:function(){if(this.yearSelected<=this.options.minDate.getFullYear()){return
927 }this.yearSelected--;
928 this.constructCalendar()
929 },WeekNbr:function(h,f,j){var g=new Date(h,f,j);
930 var c=new Date(h,0,1);
931 var e=7+1-c.getDay();
933 }var b=((Date.UTC(h,g.getMonth(),g.getDate(),0,0,0)-Date.UTC(h,0,1,0,0,0))/1000/60/60/24)+1;
934 var d=Math.floor((b-e+7)/7);
936 var a=new Date(h,0,1);
937 var i=7+1-a.getDay();
940 },constructCalendar:function(){var l=[31,0,31,30,31,30,31,31,30,31,30,31];
941 var d=new Date(this.yearSelected,this.monthSelected,1);
943 if(typeof this.monthSelected!="number"||this.monthSelected>=12||this.monthSelected<0){alert("ERROR in calendar: monthSelected="+this.monthSelected);
945 }if(this.monthSelected==1){j=new Date(this.yearSelected,this.monthSelected+1,1);
946 j=new Date(j-(24*60*60*1000));
948 }else{e=l[this.monthSelected]
949 }var n=d.getDay()-this.options.startAt;
951 }this.popDownMonth();
953 if(this.options.showWeekNumber){for(f=1;
955 f++){this.tbody.rows[f].cells[0].innerHTML=" "
958 f++){this.resetCell(this.tbody.rows[1].cells[f+this.colStart])
962 if(this.options.showWeekNumber&&b==0){this.tbody.rows[a].cells[0].innerHTML=this.WeekNbr(this.yearSelected,this.monthSelected,k)
963 }var m=this.tbody.rows[a].cells[b+this.colStart];
965 m.className=this.styles[b];
966 if((k==this.dateNow)&&(this.monthSelected==this.monthNow)&&(this.yearSelected==this.yearNow)){Rico.addClass(m,Rico.theme.calendarToday||"ricoCalToday")
967 }if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
968 }if((k==this.odateSelected)&&(this.monthSelected==this.omonthSelected)&&(this.yearSelected==this.oyearSelected)){Rico.addClass(m,Rico.theme.calendarSelectedDay||"ricoSelectedDay")
969 }var g=this.Holidays[this.holidayKey(this.yearSelected,this.monthSelected,k)];
970 if(!g){g=this.Holidays[this.holidayKey(0,this.monthSelected,k)]
971 }m.style.color=g?g.txtColor:"";
972 m.style.backgroundColor=g?g.bgColor:"";
976 this.resetCell(this.tbody.rows[a].cells[b+this.colStart]);
979 }}this.titleMonth.innerHTML=Rico.monthAbbr(this.monthSelected);
980 this.titleYear.innerHTML=this.yearSelected;
981 if(this.todayCell){this.todayCell.innerHTML=Rico.getPhraseById("calToday",this.dateNow,Rico.monthAbbr(this.monthNow),this.yearNow,this.monthNow+1)
982 }},resetCell:function(a){a.innerHTML=" ";
983 a.className="ricoCalEmpty";
985 a.style.backgroundColor="";
987 },saveAndClose:function(g){Rico.eventStop(g);
988 var f=Rico.eventElement(g);
989 var c=f.innerHTML.replace(/ /g,"");
990 if(c==""||f.className=="ricoCalWeekNum"){return
991 }var b=parseInt(c,10);
993 }var h=new Date(this.yearSelected,this.monthSelected,b);
994 var a=Rico.formatDate(h,this.dateFmt=="ISO8601"?"yyyy-mm-dd":this.dateFmt);
995 if(this.returnValue){this.returnValue(a);
997 }},open:function(b){if(!this.bPageLoaded){return
999 this.dateNow=a.getDate();
1000 this.monthNow=a.getMonth();
1001 this.yearNow=a.getFullYear();
1002 this.oyearSelected=-1;
1003 if(typeof b=="object"){this.odateSelected=b.getDate();
1004 this.omonthSelected=b.getMonth();
1005 this.oyearSelected=b.getFullYear()
1006 }else{if(this.dateFmt=="ISO8601"){var c=Rico.setISO8601(b);
1007 if(c){this.odateSelected=c.getDate();
1008 this.omonthSelected=c.getMonth();
1009 this.oyearSelected=c.getFullYear()
1010 }}else{if(this.re.exec(b)){var f=[RegExp.$1,RegExp.$3,RegExp.$5];
1011 this.odateSelected=parseInt(f[this.dateParts.dd],10);
1012 this.omonthSelected=parseInt(f[this.dateParts.mm],10)-1;
1013 this.oyearSelected=parseInt(f[this.dateParts.yyyy],10);
1014 if(this.oyearSelected<100){this.oyearSelected+=this.yearNow-(this.yearNow%100);
1015 var e=this.options.maxDate.getFullYear();
1016 while(this.oyearSelected>e){this.oyearSelected-=100
1017 }}}else{if(b){alert("ERROR: invalid date passed to calendar ("+b+")")
1018 }}}}if(this.oyearSelected>0){this.dateSelected=this.odateSelected;
1019 this.monthSelected=this.omonthSelected;
1020 this.yearSelected=this.oyearSelected
1021 }else{this.dateSelected=this.dateNow;
1022 this.monthSelected=this.monthNow;
1023 this.yearSelected=this.yearNow
1024 }this.constructCalendar();
1027 Rico.ColorPicker=function(b,a){this.initialize(b,a)
1029 Rico.ColorPicker.prototype={initialize:function(h,c){this.id=h;
1030 this.currentValue="#FFFFFF";
1031 Rico.extend(this,new Rico.Popup());
1032 Rico.extend(this.options,{showColorCode:false,cellsPerRow:18,palette:[]});
1033 var f=["00","33","66","99","CC","FF"];
1040 a++){this.options.palette.push(f[d]+f[e]+f[a])
1041 }}}Rico.extend(this.options,c||{})
1042 },atLoad:function(){this.createContainer();
1043 this.content.className="ricoColorPicker";
1044 var c=this.options.cellsPerRow;
1045 var d="<TABLE BORDER='1' CELLSPACING='1' CELLPADDING='0'>";
1047 b<this.options.palette.length;
1048 b++){if((b%c)==0){d+="<TR>"
1049 }d+='<TD BGCOLOR="#'+this.options.palette[b]+'"> </TD>';
1050 if(((b+1)>=this.options.palette.length)||(((b+1)%c)==0)){d+="</TR>"
1051 }}var a=Math.floor(c/2);
1052 if(this.options.showColorCode){d+="<TR><TD COLSPAN='"+a+"' ID='colorPickerSelectedColor'> </TD><TD COLSPAN='"+(c-a)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>"
1053 }else{d+="<TR><TD COLSPAN='"+c+"' ID='colorPickerSelectedColor'> </TD></TR>"
1055 this.content.innerHTML=d;
1056 this.open=this.openPopup;
1057 this.close=this.closePopup;
1058 Rico.eventBind(this.container,"mouseover",Rico.eventHandle(this,"highlightColor"),false);
1059 Rico.eventBind(this.container,"click",Rico.eventHandle(this,"selectColor"),false);
1061 },selectColor:function(a){Rico.eventStop(a);
1062 if(this.returnValue){this.returnValue(this.currentValue)
1064 },highlightColor:function(b){var a=Rico.eventElement(b);
1065 if(!a.tagName||a.tagName.toLowerCase()!="td"){return
1066 }var g=Rico.Color.createColorFromBackground(a).toString();
1067 this.currentValue=g;
1068 Rico.setStyle("colorPickerSelectedColor",{backgroundColor:g});
1069 var f=Rico.$("colorPickerSelectedColorValue");
1073 Rico.registerDraggable=function(b,a){if(typeof a!="number"){a=0
1074 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1075 }Rico.dndMgrList[a].registerDraggable(b)
1077 Rico.registerDropZone=function(b,a){if(typeof a!="number"){a=0
1078 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1079 }Rico.dndMgrList[a].registerDropZone(b)
1081 Rico.dndMgr=function(){this.initialize()
1083 Rico.dndMgr.prototype={initialize:function(){this.dropZones=[];
1085 this.currentDragObjects=[];
1086 this.dragElement=null;
1087 this.lastSelectedDraggable=null;
1088 this.currentDragObjectVisible=false;
1089 this.interestedInMotionEvents=false;
1090 this._mouseDown=Rico.eventHandle(this,"_mouseDownHandler");
1091 this._mouseMove=Rico.eventHandle(this,"_mouseMoveHandler");
1092 this._mouseUp=Rico.eventHandle(this,"_mouseUpHandler")
1093 },registerDropZone:function(a){this.dropZones[this.dropZones.length]=a
1094 },deregisterDropZone:function(a){var d=new Array();
1097 c<this.dropZones.length;
1098 c++){if(this.dropZones[c]!=a){d[b++]=this.dropZones[c]
1100 },clearDropZones:function(){this.dropZones=new Array()
1101 },registerDraggable:function(a){this.draggables[this.draggables.length]=a;
1102 var b=a.getMouseDownHTMLElement();
1103 if(b!=null){b.ricoDraggable=a;
1104 Rico.eventBind(b,"mousedown",Rico.eventHandle(this,"_attachEvents"));
1105 Rico.eventBind(b,"mousedown",this._mouseDown)
1106 }},clearSelection:function(){for(var a=0;
1107 a<this.currentDragObjects.length;
1108 a++){this.currentDragObjects[a].deselect()
1109 }this.currentDragObjects=new Array();
1110 this.lastSelectedDraggable=null
1111 },hasSelection:function(){return this.currentDragObjects.length>0
1112 },setStartDragFromElement:function(a,c){this.origPos=Rico.cumulativeOffset(c);
1113 var b=Rico.eventClient(a);
1114 this.startx=b.x-this.origPos.left;
1115 this.starty=b.y-this.origPos.top;
1116 this.interestedInMotionEvents=this.hasSelection();
1118 },updateSelection:function(a,b){if(!b){this.clearSelection()
1119 }if(a.isSelected()){this.currentDragObjects=this.currentDragObjects.without(a);
1121 if(a==this.lastSelectedDraggable){this.lastSelectedDraggable=null
1123 if(a.isSelected()){this.currentDragObjects.push(a);
1124 this.lastSelectedDraggable=a
1125 }}},_mouseDownHandler:function(f){if(!Rico.eventLeftClick(f)){return
1126 }var d=Rico.eventElement(f);
1127 var a=d.ricoDraggable;
1129 while(a==null&&c.parentNode){c=c.parentNode;
1132 }this.updateSelection(a,f.ctrlKey);
1133 if(this.hasSelection()){for(var b=0;
1134 b<this.dropZones.length;
1135 b++){this.dropZones[b].clearPositionCache()
1136 }}this.setStartDragFromElement(f,a.getMouseDownHTMLElement())
1137 },_mouseMoveHandler:function(a){if(!this.interestedInMotionEvents){return
1138 }if(!this.hasSelection()){return
1139 }if(!this.currentDragObjectVisible){this._startDrag(a)
1140 }if(!this.activatedDropZones){this._activateRegisteredDropZones()
1141 }this._updateDraggableLocation(a);
1142 this._updateDropZonesHover(a);
1144 },_makeDraggableObjectVisible:function(b){if(!this.hasSelection()){return
1146 if(this.currentDragObjects.length>1){a=this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects)
1147 }else{a=this.currentDragObjects[0].getSingleObjectDragGUI()
1148 }this.dragElemPosition=Rico.getStyle(a,"position");
1149 if(this.dragElemPosition!="absolute"){a.style.position="absolute"
1150 }if(a.parentNode==null||a.parentNode.nodeType==11){document.body.appendChild(a)
1151 }this.dragElement=a;
1152 this._updateDraggableLocation(b);
1153 this.currentDragObjectVisible=true
1154 },_leftOffset:function(a){return a.offsetX?document.body.scrollLeft:0
1155 },_topOffset:function(a){return a.offsetY?document.body.scrollTop:0
1156 },_updateDraggableLocation:function(b){var a=this.dragElement.style;
1157 var c=Rico.eventClient(b);
1158 a.left=(c.x+this._leftOffset(b)-this.startx)+"px";
1159 a.top=(c.y+this._topOffset(b)-this.starty)+"px"
1160 },_updateDropZonesHover:function(b){var a,c=this.dropZones.length;
1163 a++){if(!this._mousePointInDropZone(b,this.dropZones[a])){this.dropZones[a].hideHover()
1166 a++){if(this._mousePointInDropZone(b,this.dropZones[a])){if(this.dropZones[a].canAccept(this.currentDragObjects)){this.dropZones[a].showHover()
1167 }}}},_startDrag:function(b){for(var a=0;
1168 a<this.currentDragObjects.length;
1169 a++){this.currentDragObjects[a].startDrag()
1170 }this._makeDraggableObjectVisible(b)
1171 },_mouseUpHandler:function(b){if(!this.hasSelection()){return
1172 }if(!Rico.eventLeftClick(b)){return
1173 }this.interestedInMotionEvents=false;
1174 if(this._placeDraggableInDropZone(b)){this._completeDropOperation(b)
1175 }else{if(this.dragElement!=null){Rico.eventStop(b);
1177 Rico.animate(this.dragElement,{duration:300,onEnd:function(){a._doCancelDragProcessing()
1178 }},{left:this.origPos.left,top:this.origPos.top})
1179 }}Rico.eventUnbind(document.body,"mousemove",this._mouseMove);
1180 Rico.eventUnbind(document.body,"mouseup",this._mouseUp)
1181 },_retTrue:function(){return true
1182 },_completeDropOperation:function(a){if(this.dragElement!=this.currentDragObjects[0].getMouseDownHTMLElement()){if(this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1183 }}this._deactivateRegisteredDropZones();
1185 this.clearSelection();
1186 this.dragElement=null;
1187 this.currentDragObjectVisible=false;
1189 },_doCancelDragProcessing:function(){this._cancelDrag();
1190 if(this.dragElement==this.currentDragObjects[0].getMouseDownHTMLElement()){this.dragElement.style.position=this.dragElemPosition
1191 }else{if(this.dragElement&&this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1192 }}this._deactivateRegisteredDropZones();
1193 this.dragElement=null;
1194 this.currentDragObjectVisible=false
1195 },_placeDraggableInDropZone:function(c){var a=false;
1196 var d=this.dropZones.length;
1199 b++){if(this._mousePointInDropZone(c,this.dropZones[b])){if(this.dropZones[b].canAccept(this.currentDragObjects)){this.dropZones[b].hideHover();
1200 this.dropZones[b].accept(this.currentDragObjects);
1204 },_cancelDrag:function(){for(var a=0;
1205 a<this.currentDragObjects.length;
1206 a++){this.currentDragObjects[a].cancelDrag()
1207 }},_endDrag:function(){for(var a=0;
1208 a<this.currentDragObjects.length;
1209 a++){this.currentDragObjects[a].endDrag()
1210 }},_mousePointInDropZone:function(b,c){var a=c.getAbsoluteRect();
1211 var d=Rico.eventClient(b);
1212 return d.x>a.left+this._leftOffset(b)&&d.x<a.right+this._leftOffset(b)&&d.y>a.top+this._topOffset(b)&&d.y<a.bottom+this._topOffset(b)
1213 },_activateRegisteredDropZones:function(){var c=this.dropZones.length;
1216 a++){var b=this.dropZones[a];
1217 if(b.canAccept(this.currentDragObjects)){b.activate()
1218 }}this.activatedDropZones=true
1219 },_deactivateRegisteredDropZones:function(){var b=this.dropZones.length;
1222 a++){this.dropZones[a].deactivate()
1223 }this.activatedDropZones=false
1224 },_attachEvents:function(){Rico.eventBind(document.body,"mousemove",this._mouseMove);
1225 Rico.eventBind(document.body,"mouseup",this._mouseUp)
1227 Rico.Draggable=function(a,b){this.initialize(a,b)
1229 Rico.Draggable.prototype={initialize:function(a,b){this.type=a;
1230 this.htmlElement=Rico.$(b);
1232 },getMouseDownHTMLElement:function(){return this.htmlElement
1233 },select:function(){this._select()
1234 },_select:function(){this.selected=true;
1235 if(this.showingSelected){return
1236 }this.showingSelected=true;
1237 var b=this.getMouseDownHTMLElement();
1238 var a=Rico.Color.createColorFromBackground(b);
1239 a.isBright()?a.darken(0.033):a.brighten(0.033);
1240 this.saveBackground=Rico.getStyle(b,"backgroundColor","background-color");
1241 b.style.backgroundColor=a.asHex()
1242 },deselect:function(){this.selected=false;
1243 if(!this.showingSelected){return
1244 }var a=this.getMouseDownHTMLElement();
1245 a.style.backgroundColor=this.saveBackground;
1246 this.showingSelected=false
1247 },isSelected:function(){return this.selected
1248 },startDrag:function(){},cancelDrag:function(){},endDrag:function(){},getSingleObjectDragGUI:function(){return this.htmlElement
1249 },getMultiObjectDragGUI:function(a){return this.htmlElement
1250 },getDroppedGUI:function(){return this.htmlElement
1251 },toString:function(){return this.type+":"+this.htmlElement+":"
1253 Rico.LiveGridDraggable=function(b,a,c){this.initialize(b,a,c)
1255 Rico.LiveGridDraggable.prototype=Rico.extend(new Rico.Draggable(),{initialize:function(b,a,c){this.type="RicoCell";
1256 this.htmlElement=b.cell(a,c);
1260 },select:function(){if(this.dragRow>=this.liveGrid.buffer.totalRows){return
1261 }this.selected=true;
1262 this.showingSelected=true
1263 },deselect:function(){this.selected=false;
1264 this.showingSelected=false
1265 },getSingleObjectDragGUI:function(){var a=document.createElement("div");
1266 a.className="LiveGridDraggable";
1267 a.style.width=(this.htmlElement.offsetWidth-10)+"px";
1268 a.innerHTML=this.htmlElement.innerHTML;
1271 Rico.Dropzone=function(a){this.initialize(a)
1273 Rico.Dropzone.prototype={initialize:function(a){this.htmlElement=Rico.$(a);
1274 this.absoluteRect=null
1275 },getHTMLElement:function(){return this.htmlElement
1276 },clearPositionCache:function(){this.absoluteRect=null
1277 },getAbsoluteRect:function(){if(this.absoluteRect==null){var a=this.getHTMLElement();
1278 var b=Rico.viewportOffset(a);
1279 this.absoluteRect={top:b.top,left:b.left,bottom:b.top+a.offsetHeight,right:b.left+a.offsetWidth}
1280 }return this.absoluteRect
1281 },activate:function(){var c=this.getHTMLElement();
1282 if(c==null||this.showingActive){return
1283 }this.showingActive=true;
1284 this.saveBackgroundColor=c.style.backgroundColor;
1286 var a=Rico.Color.createColorFromBackground(c);
1287 if(a==null){c.style.backgroundColor=b
1288 }else{a.isBright()?a.darken(0.2):a.brighten(0.2);
1289 c.style.backgroundColor=a.asHex()
1290 }},deactivate:function(){var a=this.getHTMLElement();
1291 if(a==null||!this.showingActive){return
1292 }a.style.backgroundColor=this.saveBackgroundColor;
1293 this.showingActive=false;
1294 this.saveBackgroundColor=null
1295 },showHover:function(){var a=this.getHTMLElement();
1296 if(a==null||this.showingHover){return
1297 }this.saveBorderWidth=a.style.borderWidth;
1298 this.saveBorderStyle=a.style.borderStyle;
1299 this.saveBorderColor=a.style.borderColor;
1300 this.showingHover=true;
1301 a.style.borderWidth="1px";
1302 a.style.borderStyle="solid";
1303 a.style.borderColor="#ffff00"
1304 },hideHover:function(){var a=this.getHTMLElement();
1305 if(a==null||!this.showingHover){return
1306 }a.style.borderWidth=this.saveBorderWidth;
1307 a.style.borderStyle=this.saveBorderStyle;
1308 a.style.borderColor=this.saveBorderColor;
1309 this.showingHover=false
1310 },canAccept:function(a){return true
1311 },accept:function(b){var d=this.getHTMLElement();
1316 a++){var c=b[a].getDroppedGUI();
1317 if(Rico.getStyle(c,"position")=="absolute"){c.style.position="static";
1322 Rico.KeywordSearch=function(b,a){this.initialize(b,a)
1324 Rico.KeywordSearch.prototype={initialize:function(b,a){this.id=b;
1325 Rico.extend(this,new Rico.Window(Rico.getPhraseById("keywordTitle"),a));
1326 Rico.addClass(this.content,"ricoKeywordSearch");
1327 Rico.extend(this.options,{listLength:10,maxSuggest:20,width:"12em"})
1328 },atLoad:function(){this.searchField=Rico.createFormField(this.contentDiv,"input","text",this.id+"_search");
1329 this.searchField.style.display="block";
1330 this.searchField.style.width=this.options.width;
1331 Rico.eventBind(this.searchField,"keyup",Rico.eventHandle(this,"filterKeypress"),false);
1332 this.selectList=Rico.createFormField(this.contentDiv,"select",null,this.id+"_list");
1333 this.selectList.size=this.options.listLength;
1334 this.selectList.style.display="block";
1335 this.selectList.style.width=this.options.width;
1336 Rico.eventBind(this.selectList,"change",Rico.eventHandle(this,"listClick"),false);
1337 this.close=this.closePopup;
1339 },open:function(a,b){this.column=b;
1340 this.grid=this.column.liveGrid;
1341 this.searchField.value="";
1342 this.selectList.options.length=0;
1344 this.searchField.focus();
1345 this.selectValuesRequest("")
1346 },selectValuesRequest:function(c){var d=this.column.index;
1348 Rico.extend(b,this.grid.buffer.ajaxOptions);
1349 b.parameters={id:this.grid.tableId,offset:"0",page_size:this.options.maxSuggest,edit:d};
1350 b.parameters[this.grid.actionId]="query";
1351 if(c!=""&&c!="*"){if(c.indexOf("*")==-1){c="*"+c+"*"
1352 }b.parameters["f[1][op]"]="LIKE";
1353 b.parameters["f[1][len]"]=1;
1354 b.parameters["f[1][0]"]=c
1356 b.onComplete=function(e){a.selectValuesUpdate(e)
1358 new Rico.ajaxRequest(this.grid.buffer.dataSource,b)
1359 },selectValuesUpdate:function(b){var a=b.responseXML.getElementsByTagName("ajax-response");
1360 Rico.log("selectValuesUpdate: "+b.status);
1361 if(a==null||a.length!=1){return
1363 var h=a.getElementsByTagName("error");
1364 if(h.length>0){var f=Rico.getContentAsString(h[0],this.grid.buffer.isEncoded);
1365 Rico.log("Data provider returned an error:\n"+f);
1366 alert(Rico.getPhraseById("requestError",f));
1368 }this.selectList.options.length=0;
1369 a=a.getElementsByTagName("response")[0];
1370 var g=a.getElementsByTagName("rows")[0];
1371 var j=this.grid.buffer.dom2jstable(g);
1372 Rico.log("selectValuesUpdate: id="+this.selectList.id+" rows="+j.length);
1375 d++){if(j[d].length>0){var e=j[d][0];
1376 var c=(j[d].length>1)?j[d][1]:e;
1377 Rico.addSelectOption(this.selectList,e,c)
1378 }}},filterKeypress:function(c){var a=Rico.eventElement(c);
1379 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
1380 }if(this.lastKeyFilter==a.value){return
1382 Rico.log("filterKeypress: "+this.index+" "+b);
1383 this.lastKeyFilter=b;
1384 this.selectValuesRequest(b)
1385 },listClick:function(c){var b=Rico.eventElement(c);
1386 if(b.tagName.toLowerCase()!="select"){return
1387 }if(this.returnValue){var a=b.options[b.selectedIndex];
1388 this.returnValue(a.value,a.innerHTML)
1391 Rico.TreeControl=function(c,b,a){this.initialize(c,b,a)
1393 Rico.TreeControl.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Popup());
1394 Rico.extend(this.options,{ignoreClicks:true,nodeIdDisplay:"none",showCheckBox:false,showFolders:false,showPlusMinus:true,showLines:true,defaultAction:Rico.eventHandle(this,"nodeClick"),height:"300px",width:"300px",leafIcon:"rico-icon rico-doc"});
1395 Rico.extend(this.options,a||{});
1398 this.close=this.closePopup;
1399 this.hoverSet=new Rico.HoverSet([])
1400 },atLoad:function(){this.treeDiv=document.createElement("div");
1401 this.treeDiv.id=this.id;
1402 this.treeDiv.className="ricoTree";
1403 if(Rico.theme.treeContent){Rico.addClass(this.treeDiv,Rico.theme.treeContent)
1404 }this.treeDiv.style.height=this.options.height;
1405 this.treeDiv.style.width=this.options.width;
1406 this.createContainer();
1407 this.content.className=Rico.theme.tree||"ricoTreeContainer";
1408 this.content.appendChild(this.treeDiv);
1409 if(this.options.showCheckBox){this.buttonDiv=document.createElement("div");
1410 this.buttonDiv.style.width=this.options.width;
1411 this.buttonDiv.className="ricoTreeButtons";
1412 if(Rico.getStyle(this.container,"position")=="absolute"){var a=document.createElement("span");
1413 a.innerHTML=RicoTranslate.getPhraseById("treeSave");
1414 Rico.setStyle(a,{"float":"left",cursor:"pointer"});
1415 this.buttonDiv.appendChild(a);
1416 Rico.eventBind(a,"click",Rico.eventHandle(this,"saveSelection"))
1417 }var a=document.createElement("span");
1418 a.innerHTML=RicoTranslate.getPhraseById("treeClear");
1419 Rico.setStyle(a,{"float":"right",cursor:"pointer"});
1420 this.buttonDiv.appendChild(a);
1421 this.content.appendChild(this.buttonDiv);
1422 Rico.eventBind(a,"click",Rico.eventHandle(this,"clrCheckBoxEvent"))
1424 },setTreeDiv:function(a){this.treeDiv=Rico.$(a);
1425 this.openPopup=function(){}
1426 },open:function(){this.openPopup();
1427 if(this.treeDiv.childNodes.length==0&&this.dataSource){this.loadXMLDoc()
1428 }},loadXMLDoc:function(c){var b={id:this.id};
1430 }Rico.log("Tree loadXMLDoc: "+this.id);
1432 new Rico.ajaxRequest(this.dataSource,{parameters:b,method:"get",onComplete:function(d){a.processResponse(d)
1434 },domID:function(b,a){return"RicoTree_"+a+"_"+this.id+"_"+b
1435 },processResponse:function(d){var b=d.responseXML.getElementsByTagName("ajax-response");
1436 if(b==null||b.length!=1){return
1437 }var f=b[0].getElementsByTagName("rows")[0];
1438 var g=f.getElementsByTagName("tr");
1442 e++){var l=g[e].getElementsByTagName("td");
1443 if(l.length<5){continue
1445 h[5]=this.options.leafIcon;
1448 c++){h[c]=Rico.getContentAsString(l[c],true)
1449 }h[3]=h[3].match(/^0|L$/i)?0:1;
1450 h[4]=parseInt(h[4]);
1454 e++){var a=(e<k.length-1)&&(k[e][0]==k[e+1][0]);
1455 this.addNode(k[e][0],k[e][1],k[e][2],k[e][3],k[e][4],k[e][5],!a)
1456 }},addNode:function(q,l,t,f,u,s,k){var h=Rico.$(this.domID(q,"Parent"));
1457 var v=Rico.$(this.domID(q,"Children"));
1458 var a=h?h.TreeLevel+1:0;
1459 var b=document.createElement("table");
1460 var m=document.createElement("div");
1461 m.id=this.domID(l,"Children");
1462 m.className="ricoTreeBranch";
1463 m.style.display=h?"none":"";
1467 b.id=this.domID(l,"Parent");
1470 b.TreeFetchedChildren=this.dataSource?false:true;
1471 var d=b.insertRow(0);
1475 r++){g[r]=d.insertCell(-1)
1476 }if(a>1){var e=h.getElementsByTagName("td");
1479 r++){g[r].innerHTML=e[r].innerHTML
1480 }var w=document.createElement("div");
1481 w.className="rico-icon rico-tree-"+(v.nextSibling&&this.options.showLines?"nodeline":"nodeblank");
1482 g[a-2].appendChild(w)
1483 }if(a>0){var c=k&&this.options.showLines?"last":"";
1484 var o=this.options.showLines?"node":"";
1485 if(this.options.showPlusMinus&&f){var w=document.createElement("div");
1487 w.style.cursor="pointer";
1488 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1489 w.className="rico-icon rico-tree-"+o+"p"+c;
1490 d.insertCell(-1).appendChild(w)
1491 }else{if(this.options.showLines){var w=document.createElement("div");
1492 w.className="rico-icon rico-tree-node"+c;
1493 d.insertCell(-1).appendChild(w)
1494 }}if(this.options.showFolders&&(f||(s&&s!="none"))){var w=document.createElement("div");
1495 if(!f){w.className=s
1497 w.style.cursor="pointer";
1498 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1499 w.className="rico-icon rico-folderclosed"
1500 }d.insertCell(-1).appendChild(w)
1501 }}if(u&&this.options.showCheckBox){var n=document.createElement("input");
1504 d.insertCell(-1).appendChild(n)
1505 }if(u&&!this.options.showCheckBox){var p=document.createElement("a");
1506 if(typeof u=="string"){p.href=u
1507 }else{p.href="javascript:void(0)";
1508 Rico.eventBind(p,"click",this.options.defaultAction)
1509 }this.hoverSet.add(p)
1510 }else{var p=document.createElement("p")
1511 }p.id=this.domID(l,"Desc");
1512 p.className="ricoTreeLevel"+a;
1513 switch(this.options.nodeIdDisplay){case"last":t+=" ("+l+")";
1515 case"first":t=l+" - "+t;
1517 case"tooltip":p.title=l;
1519 }p.appendChild(document.createTextNode(t));
1520 d.insertCell(-1).appendChild(p);
1521 var j=v||this.treeDiv;
1524 },nodeClick:function(c){var b=Rico.eventElement(c);
1525 if(this.returnValue){var a=this.domID("","Desc");
1526 this.returnValue(b.id.substr(a.length),b.innerHTML)
1528 },saveSelection:function(a){if(this.returnValue){this.returnValue(this.getCheckedItems())
1530 },getCheckedItems:function(){var b=this.treeDiv.getElementsByTagName("input");
1534 a++){if(b[a].type=="checkbox"&&b[a].checked){c.push(b[a].value)
1536 },setCheckBoxes:function(c){var b=this.treeDiv.getElementsByTagName("input");
1539 a++){if(b[a].type=="checkbox"){b[a].checked=c
1540 }}},clrCheckBoxEvent:function(a){Rico.eventStop(a);
1541 this.setCheckBoxes(false)
1542 },clickBranch:function(h){var g=Rico.eventElement(h);
1543 var f=Rico.getParentByTagName(g,"table");
1544 if(!f||!f.TreeContainer){return
1545 }var c=f.id.split("_");
1547 var b=Rico.$(c.join("_"));
1549 if(g.tagName=="DIV"){var d=Rico.visible(b);
1550 if(g.className.match(/node(p|m)(last)?$/)){g.className=g.className.replace(/nodep|nodem/,"node"+(d?"m":"p"))
1551 }else{if(g.className.match(/folder(open|closed)$/)){g.className=g.className.replace(/folder(open|closed)/,"folder"+(d?"open":"closed"))
1552 }else{if(g.className.match(/\b(m|p)$/)){g.className=g.className.replace(/(p|m)$/,d?"m":"p")
1553 }}}}if(!f.TreeFetchedChildren){f.TreeFetchedChildren=1;
1554 this.loadXMLDoc(g.name)
1556 if(typeof Rico=="undefined"){throw ("GridCommon requires the Rico JavaScript framework")
1557 }Rico.GridCommon={baseInit:function(){this.options={saveColumnInfo:{width:true,filter:false,sort:false},cookiePrefix:"RicoGrid.",allowColResize:true,windowResize:true,click:null,dblclick:null,contextmenu:null,menuEvent:"dblclick",defaultWidth:-1,scrollBarWidth:19,minScrollWidth:100,frozenColumns:0,exportWindow:"height=400,width=500,scrollbars=1,menubar=1,resizable=1",exportStyleList:["background-color","color","text-align","font-weight","font-size","font-family"],exportImgTags:false,exportFormFields:true,FilterLocation:null,FilterAllToken:"___ALL___",columnSpecs:[]};
1560 this.headerColCnt=0;
1561 this.headerRowIdx=0;
1562 this.tabs=new Array(2);
1563 this.thead=new Array(2);
1564 this.tbody=new Array(2)
1565 },attachMenuEvents:function(){var a;
1566 if(!this.options.menuEvent||this.options.menuEvent=="none"){return
1567 }this.hideScroll=navigator.userAgent.match(/Macintosh\b.*\b(Firefox|Camino)\b/i)||(Rico.isOpera&&parseFloat(window.opera.version())<9.5);
1568 this.options[this.options.menuEvent]=Rico.eventHandle(this,"handleMenuClick");
1569 if(this.highlightDiv){switch(this.options.highlightElem){case"cursorRow":this.attachMenu(this.highlightDiv[0]);
1571 case"cursorCell":for(a=0;
1573 a++){this.attachMenu(this.highlightDiv[a])
1577 a++){this.attachMenu(this.tbody[a])
1578 }},attachMenu:function(a){if(this.options.click){Rico.eventBind(a,"click",this.options.click,false)
1579 }if(this.options.dblclick){if(Rico.isWebKit||Rico.isOpera){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleDblClick"),false)
1580 }else{Rico.eventBind(a,"dblclick",this.options.dblclick,false)
1581 }}if(this.options.contextmenu){if(Rico.isOpera||Rico.isKonqueror){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleContextMenu"),false)
1582 }else{Rico.eventBind(a,"contextmenu",this.options.contextmenu,false)
1583 }}},handleDblClick:function(b){var a=Rico.eventElement(b);
1584 if(this.dblClickElem==a){this.options.dblclick(b)
1585 }else{this.dblClickElem=a;
1586 this.safariTimer=Rico.runLater(300,this,"clearDblClick")
1587 }},clearDblClick:function(){this.dblClickElem=null
1588 },handleContextMenu:function(c){var a;
1589 if(typeof(c.which)=="number"){a=c.which
1590 }else{if(typeof(c.button)=="number"){a=c.button
1592 }}if(a==1&&c.ctrlKey){this.options.contextmenu(c)
1593 }},cancelMenu:function(){if(this.menu){this.menu.cancelmenu()
1594 }},getColumnInfo:function(f){Rico.log("getColumnInfo: len="+f.length);
1595 if(f.length==0){return 0
1596 }this.headerRowCnt=f.length;
1599 d<this.headerRowCnt;
1602 if(d>=this.hdrCells.length){this.hdrCells[d]=[]
1607 g.colSpan=a[h].colSpan||1;
1608 if(this.options.defaultWidth<0){g.initWidth=a[h].offsetWidth
1609 }this.hdrCells[d].push(g)
1610 }if(b.id.slice(-5)=="_main"){e=this.hdrCells[d].length;
1612 }}if(!e){this.headerRowIdx=this.headerRowCnt-1;
1613 e=this.hdrCells[this.headerRowIdx].length
1614 }Rico.log("getColumnInfo: colcnt="+e);
1616 },addHeadingRow:function(g){var a=this.headerRowCnt++;
1617 this.hdrCells[a]=[];
1620 e++){var k=this.thead[e].insertRow(-1);
1621 var f="ricoLG_hdg "+this.tableId+"_hdg"+a;
1624 var b=e==0?this.options.frozenColumns:this.headerColCnt-this.options.frozenColumns;
1627 j++){var d=k.insertCell(-1);
1628 var i=Rico.wrapChildren(d,"ricoLG_col");
1629 Rico.wrapChildren(i,"ricoLG_cell");
1630 this.hdrCells[a].push({cell:d,colSpan:1})
1632 },createColumnArray:function(b){this.direction=Rico.getStyle(this.outerDiv,"direction").toLowerCase();
1633 this.align=this.direction=="rtl"?["right","left"]:["left","right"];
1634 Rico.log("createColumnArray: dir="+this.direction);
1637 e<this.headerColCnt;
1638 e++){Rico.log("createColumnArray: c="+e);
1639 var d=e<this.options.frozenColumns?0:1;
1640 var a=new Rico[b](this,e,this.hdrCells[this.headerRowIdx][e],d);
1641 this.columns.push(a);
1642 if(e>0){this.columns[e-1].next=a
1644 Rico.runLater(100,this,"insertResizers")
1645 },insertResizers:function(){if(!this.options.allowColResize){return
1647 a<this.columns.length;
1648 a++){this.columns[a].insertResizer()
1649 }},createDivs:function(){Rico.log("createDivs start");
1650 this.outerDiv=this.createDiv("outer");
1651 if(Rico.theme.widget){Rico.addClass(this.outerDiv,Rico.theme.widget)
1652 }if(this.outerDiv.firstChild&&this.outerDiv.firstChild.tagName&&this.outerDiv.firstChild.tagName.toUpperCase()=="TABLE"){this.structTab=this.outerDiv.firstChild;
1653 this.structTabLeft=this.structTab.rows[0].cells[0];
1654 this.structTabUR=this.structTab.rows[0].cells[1];
1655 this.structTabLR=this.structTab.rows[1].cells[0]
1656 }else{this.structTab=document.createElement("table");
1657 this.structTab.border=0;
1658 this.structTab.cellPadding=0;
1659 this.structTab.cellSpacing=0;
1660 var b=this.structTab.insertRow(-1);
1662 this.structTabLeft=b.insertCell(-1);
1663 this.structTabLeft.rowSpan=2;
1664 var d=this.structTab.insertRow(-1);
1666 this.structTabUR=b.insertCell(-1);
1667 this.structTabLR=d.insertCell(-1);
1668 this.outerDiv.appendChild(this.structTab)
1669 }this.frozenTabs=this.createDiv("frozenTabs",this.structTabLeft);
1670 this.innerDiv=this.createDiv("inner",this.structTabUR);
1671 this.scrollDiv=this.createDiv("scroll",this.structTabLR);
1672 this.resizeDiv=this.createDiv("resize",this.outerDiv,true);
1673 this.exportDiv=this.createDiv("export",this.outerDiv,true);
1674 this.messagePopup=new Rico.Popup();
1675 this.messagePopup.createContainer({hideOnEscape:false,hideOnClick:false,parent:this.outerDiv});
1676 this.messagePopup.content.className="ricoLG_messageDiv";
1677 if(Rico.theme.gridMessage){Rico.addClass(this.messagePopup.content,Rico.theme.gridMessage)
1678 }this.keywordPopup=new Rico.Window("",{zIndex:-1,parent:this.outerDiv});
1679 Rico.addClass(this.keywordPopup.container,"ricoLG_keywordDiv");
1680 var a=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
1681 a.innerHTML=Rico.getPhraseById("keywordPrompt");
1682 this.keywordBox=this.keywordPopup.contentDiv.appendChild(document.createElement("input"));
1683 this.keywordBox.size=20;
1684 Rico.eventBind(this.keywordBox,"keypress",Rico.eventHandle(this,"keywordKey"),false);
1685 this.keywordPopup.contentDiv.appendChild(Rico.floatButton("Checkmark",Rico.eventHandle(this,"processKeyword")));
1686 var c=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
1687 Rico.setStyle(c,{clear:"both"});
1688 Rico.log("createDivs end")
1689 },keywordKey:function(a){switch(Rico.eventKey(a)){case 27:this.closeKeyword();
1692 case 13:this.processKeyword();
1696 },openKeyword:function(a){this.keywordCol=a;
1697 this.keywordBox.value="";
1698 this.keywordPopup.setTitle(this.columns[a].displayName);
1699 this.keywordPopup.centerPopup();
1700 this.keywordBox.focus()
1701 },closeKeyword:function(){this.keywordPopup.closePopup();
1703 },processKeyword:function(){var a=this.keywordBox.value;
1704 this.closeKeyword();
1705 this.columns[this.keywordCol].setFilterKW(a)
1706 },createDiv:function(c,a,b){var e=this.tableId+"_"+c+"Div";
1707 var d=document.getElementById(e);
1708 if(!d){d=document.createElement("div");
1710 if(a){a.appendChild(d)
1711 }}d.className="ricoLG_"+c+"Div";
1714 },baseSizeDivs:function(){this.setOtherHdrCellWidths();
1715 if(this.options.frozenColumns){Rico.show(this.tabs[0]);
1716 Rico.show(this.frozenTabs);
1717 this.hdrHt=Math.max(Rico.nan2zero(this.thead[0].offsetHeight),this.thead[1].offsetHeight);
1718 this.dataHt=Math.max(Rico.nan2zero(this.tbody[0].offsetHeight),this.tbody[1].offsetHeight);
1719 this.frzWi=this.borderWidth(this.tabs[0])
1720 }else{Rico.hide(this.tabs[0]);
1721 Rico.hide(this.frozenTabs);
1723 this.hdrHt=this.thead[1].offsetHeight;
1724 this.dataHt=this.tbody[1].offsetHeight
1726 var c=this.borderWidth(this.columns[0].dataCell);
1727 Rico.log("baseSizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
1728 Rico.log(this.tableId+" frzWi="+this.frzWi+" borderWi="+c);
1730 b<this.options.frozenColumns;
1731 b++){if(this.columns[b].visible){this.frzWi+=parseInt(this.columns[b].colWidth,10)+c
1732 }}this.scrTabWi=this.borderWidth(this.tabs[1]);
1733 this.scrTabWi0=this.scrTabWi;
1734 Rico.log("scrTabWi: "+this.scrTabWi);
1735 for(b=this.options.frozenColumns;
1736 b<this.columns.length;
1737 b++){if(this.columns[b].visible){this.scrTabWi+=parseInt(this.columns[b].colWidth,10)+c
1738 }}this.scrWi=this.scrTabWi+this.options.scrollBarWidth;
1739 if(this.sizeTo=="parent"){if(Rico.isIE){Rico.hide(this.outerDiv)
1740 }d=this.outerDiv.parentNode.offsetWidth;
1741 if(Rico.isIE){Rico.show(this.outerDiv)
1742 }}else{d=Rico.windowWidth()-this.options.scrollBarWidth-8
1743 }if(this.outerDiv.parentNode.clientWidth>0){d=Math.min(this.outerDiv.parentNode.clientWidth,d)
1744 }var a=this.frzWi+this.scrWi-d;
1745 Rico.log("baseSizeDivs "+this.tableId+": scrWi="+this.scrWi+" wiLimit="+d+" overage="+a+" clientWidth="+this.outerDiv.parentNode.clientWidth);
1746 if(a>0&&this.options.frozenColumns<this.columns.length){this.scrWi=Math.max(this.scrWi-a,this.options.minScrollWidth)
1747 }this.scrollDiv.style.width=this.scrWi+"px";
1748 this.frozenTabs.style.width=this.frzWi+"px";
1749 this.outerDiv.style.width=(this.frzWi+this.scrWi)+"px"
1750 },borderWidth:function(c){var a=Rico.nan2zero(Rico.getStyle(c,"borderLeftWidth"));
1751 var b=Rico.nan2zero(Rico.getStyle(c,"borderRightWidth"));
1752 Rico.log((c.id||c.tagName)+" borderWidth: L="+a+", R="+b);
1754 },setOtherHdrCellWidths:function(){var k,g,f,a,l,b,m,d,e,h;
1756 a<this.hdrCells.length;
1757 a++){if(a==this.headerRowIdx){continue
1758 }Rico.log("setOtherHdrCellWidths: r="+a);
1760 while(g<this.headerColCnt&&k<this.hdrCells[a].length){b=this.hdrCells[a][k];
1765 f++,g++){if(this.columns[g].hdrCell.style.display=="none"){e--
1766 }else{if(this.columns[g].hdrColDiv.style.display!="none"){l+=parseInt(this.columns[g].colWidth,10)
1767 }}}if(!b.hdrColDiv||!b.hdrCellDiv){h=m.getElementsByTagName("div");
1768 b.hdrColDiv=(h.length<1)?Rico.wrapChildren(m,"ricoLG_col"):h[0];
1769 b.hdrCellDiv=(h.length<2)?Rico.wrapChildren(b.hdrColDiv,"ricoLG_cell"):h[1]
1770 }if(e==0){m.style.display="none"
1771 }else{if(l==0){b.hdrColDiv.style.display="none";
1773 }else{m.style.display="";
1774 b.hdrColDiv.style.display="";
1776 b.hdrColDiv.style.width=l+"px"
1778 }}},initFilterImage:function(a){this.filterAnchor=document.getElementById(this.tableId+"_filterLink");
1779 if(!this.filterAnchor){return
1780 }this.filterRows=Rico.select("tr."+this.tableId+"_hdg"+a);
1781 if(this.filterRows.length!=2){return
1784 c++){d[c]=Rico.select(".ricoLG_cell",this.filterRows[c])
1785 }this.filterElements=d[0].concat(d[1]);
1786 this.saveHeight=this.filterElements[0].offsetHeight;
1787 var e=Rico.getStyle(this.filterElements[0],"paddingTop");
1788 var b=Rico.getStyle(this.filterElements[0],"paddingBottom");
1789 if(e){this.saveHeight-=parseInt(e,10)
1790 }if(b){this.saveHeight-=parseInt(b,10)
1792 this.setFilterImage(false)
1793 },toggleFilterRow:function(){if(Rico.visible(this.filterRows[0])){this.slideFilterUp()
1794 }else{this.slideFilterDown()
1795 }},setFilterImage:function(b){var a=Rico.getPhraseById((b?"show":"hide")+"FilterRow");
1796 this.filterAnchor.innerHTML='<img src="'+Rico.imgDir+"tableFilter"+(b?"Expand":"Collapse")+'.gif" alt="'+a+'" border="0">'
1797 },cell:function(a,b){return(0<=b&&b<this.columns.length&&a>=0)?this.columns[b].cell(a):null
1798 },availHt:function(){var a=Rico.cumulativeOffset(this.outerDiv);
1799 return Rico.windowHeight()-a.top-2*this.options.scrollBarWidth-15
1800 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
1801 this.hdrTabs[1].style.marginLeft=a
1802 },pluginScroll:function(){if(this.scrollPluggedIn){return
1803 }Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
1804 this.scrollPluggedIn=true
1805 },unplugScroll:function(){Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
1806 this.scrollPluggedIn=false
1807 },hideMsg:function(){this.messagePopup.closePopup()
1808 },showMsg:function(a){this.messagePopup.setContent(a);
1809 this.messagePopup.centerPopup();
1810 Rico.log("showMsg: "+a)
1811 },listInvisible:function(b){var c=[];
1813 a<this.columns.length;
1814 a++){if(!this.columns[a].visible){c.push(b?this.columns[a][b]:this.columns[a])
1816 },firstVisible:function(){for(var a=0;
1817 a<this.columns.length;
1818 a++){if(this.columns[a].visible){return a
1820 },showAll:function(){var b=this.listInvisible();
1823 a++){b[a].showColumn()
1824 }},chooseColumns:function(){this.menu.cancelmenu();
1826 if(!this.columnChooser){Rico.log("creating columnChooser");
1827 f=Rico.getStyle(this.outerDiv.offsetParent,"zIndex");
1828 if(typeof f!="number"){f=0
1829 }this.columnChooser=new Rico.Window(Rico.getPhraseById("gridChooseCols"),{zIndex:f+2,parent:this.outerDiv});
1830 Rico.addClass(this.columnChooser.container,"ricoLG_chooserDiv");
1831 c=this.columnChooser.contentDiv;
1833 a<this.columns.length;
1834 a++){b=this.columns[a];
1835 e=c.appendChild(document.createElement("div"));
1836 b.ChooserBox=Rico.createFormField(e,"input","checkbox");
1837 d=e.appendChild(document.createElement("span"));
1838 d.innerHTML=b.displayName;
1839 Rico.eventBind(b.ChooserBox,"click",Rico.eventHandle(b,"chooseColumn"),false)
1840 }}Rico.log("opening columnChooser");
1841 this.columnChooser.openPopup(1,this.hdrHt);
1843 a<this.columns.length;
1844 a++){this.columns[a].ChooserBox.checked=this.columns[a].visible;
1845 this.columns[a].ChooserBox.disabled=!this.columns[a].canHideShow()
1846 }},blankRow:function(a){for(var b=0;
1847 b<this.columns.length;
1848 b++){this.columns[b].clearCell(a)
1849 }},getExportStyles:function(a){var e=this.options.exportStyleList;
1850 var b=Rico.getStyle(a,"backgroundImage");
1851 if(!b||b=="none"){return e
1854 c++){if(e[c]!="background-color"&&e[c]!="color"){d.push(e[c])
1856 },exportStart:function(){var a,h,f,d,b,e,k,l;
1857 var g=this.getExportStyles(this.thead[0]);
1859 this.exportText="<table border='1' cellspacing='0'>";
1861 h<this.columns.length;
1862 h++){if(this.columns[h].visible){this.exportText+="<col width='"+parseInt(this.columns[h].colWidth,10)+"'>"
1863 }}this.exportText+="<thead style='display: table-header-group;'>";
1864 if(this.exportHeader){this.exportText+=this.exportHeader
1866 a<this.hdrCells.length;
1867 a++){if(this.hdrCells[a].length==0||!Rico.visible(this.hdrCells[a][0].cell.parentNode)){continue
1868 }this.exportText+="<tr>";
1870 h<this.hdrCells[a].length;
1871 h++){b=this.hdrCells[a][h];
1875 d++,f++){if(!this.columns[f].visible){e--
1876 }}if(e>0){k=Rico.select(".ricoLG_cell",b.cell);
1877 l=k&&k.length>0?k[0]:b.cell;
1878 this.exportText+="<td style='"+this.exportStyle(l,g)+"'";
1879 if(b.colSpan>1){this.exportText+=" colspan='"+e+"'"
1880 }this.exportText+=">"+Rico.getInnerText(l,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport")+"</td>"
1881 }}this.exportText+="</tr>"
1882 }this.exportText+="</thead><tbody>"
1883 },exportFinish:function(b){if(this.hideMsg){this.hideMsg()
1884 }window.status=Rico.getPhraseById("exportComplete");
1885 if(this.exportRows.length>0){this.exportText+="<tr>"+this.exportRows.join("</tr><tr>")+"</tr>"
1886 }if(this.exportFooter){this.exportText+=this.exportFooter
1887 }this.exportText+="</tbody></table>";
1888 this.exportDiv.innerHTML=this.exportText;
1889 this.exportText=undefined;
1890 this.exportRows=undefined;
1891 if(this.cancelMenu){this.cancelMenu()
1892 }var a=window.open(Rico.htmDir+"export_"+(b||"plain")+".html?"+this.exportDiv.id,"",this.options.exportWindow);
1893 if(a==null){alert(Rico.getPhraseById("disableBlocker"))
1894 }},exportStyle:function(d,g){for(var b=0,c="";
1896 b++){try{var a=Rico.getStyle(d,g[b]);
1897 if(a){c+=g[b]+":"+a+";"
1898 }}catch(f){}}return c
1899 },getCookie:function(){var k=Rico.getCookie(this.options.cookiePrefix+this.tableId);
1901 }var f=k.split(",");
1904 g++){var a=f[g].split(":");
1905 if(a.length!=2){continue
1906 }var h=parseInt(a[0].slice(1),10);
1907 if(h<0||h>=this.columns.length){continue
1908 }var e=this.columns[h];
1909 switch(a[0].charAt(0)){case"w":e.setColWidth(a[1]);
1912 case"h":if(a[1].toLowerCase()=="true"){e.hideshow(true,true)
1913 }else{e.hideshow(false,true)
1915 case"s":if(!this.options.saveColumnInfo.sort||!e.sortable){break
1918 case"f":if(!this.options.saveColumnInfo.filter||!e.filterable){break
1919 }var d=a[1].split("~");
1920 e.filterOp=d.shift();
1922 e.filterType=Rico.ColumnConst.USERFILTER;
1925 b++){e.filterValues.push(unescape(d[b]))
1927 }}},setCookie:function(){var d=[];
1929 e<this.columns.length;
1930 e++){var c=this.columns[e];
1931 if(this.options.saveColumnInfo.width){if(c.customWidth){d.push("w"+e+":"+c.colWidth)
1932 }if(c.customVisible){d.push("h"+e+":"+c.visible)
1933 }}if(this.options.saveColumnInfo.sort){if(c.currentSort!=Rico.ColumnConst.UNSORTED){d.push("s"+e+":"+c.currentSort)
1934 }}if(this.options.saveColumnInfo.filter&&c.filterType==Rico.ColumnConst.USERFILTER){var b=[c.filterOp];
1936 a<c.filterValues.length;
1937 a++){b.push(escape(c.filterValues[a]))
1938 }d.push("f"+e+":"+b.join("~"))
1939 }}Rico.setCookie(this.options.cookiePrefix+this.tableId,d.join(","),this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
1941 Rico.ColumnConst={UNFILTERED:0,SYSTEMFILTER:1,USERFILTER:2,UNSORTED:0,SORT_ASC:"ASC",SORT_DESC:"DESC",MINWIDTH:10,DOLLAR:{type:"number",prefix:"$",decPlaces:2,ClassName:"alignright"},EURO:{type:"number",prefix:"€",decPlaces:2,ClassName:"alignright"},PERCENT:{type:"number",suffix:"%",decPlaces:2,multiplier:100,ClassName:"alignright"},QTY:{type:"number",decPlaces:0,ClassName:"alignright"},DEFAULT:{type:"showTags"}};
1942 Rico.TableColumnBase=function(){};
1943 Rico.TableColumnBase.prototype={baseInit:function(h,g,e,d){Rico.log("TableColumnBase.init index="+g+" tabIdx="+d);
1946 this.hideWidth=Rico.isKonqueror||Rico.isWebKit||h.headerRowCnt>1?5:2;
1947 this.options=h.options;
1949 this.hdrCell=e.cell;
1950 this.body=document.getElementsByTagName("body")[0];
1951 this.displayName=this.getDisplayName(this.hdrCell);
1952 var c=this.hdrCell.getElementsByTagName("div");
1953 this.hdrColDiv=(c.length<1)?Rico.wrapChildren(this.hdrCell,"ricoLG_col"):c[0];
1954 this.hdrCellDiv=(c.length<2)?Rico.wrapChildren(this.hdrColDiv,"ricoLG_cell"):c[1];
1955 var f=d==0?g:g-h.options.frozenColumns;
1956 this.dataCell=h.tbody[d].rows[0].cells[f];
1957 c=this.dataCell.getElementsByTagName("div");
1958 this.dataColDiv=(c.length<1)?Rico.wrapChildren(this.dataCell,"ricoLG_col"):c[0];
1959 this.mouseDownHandler=Rico.eventHandle(this,"handleMouseDown");
1960 this.mouseMoveHandler=Rico.eventHandle(this,"handleMouseMove");
1961 this.mouseUpHandler=Rico.eventHandle(this,"handleMouseUp");
1962 this.mouseOutHandler=Rico.eventHandle(this,"handleMouseOut");
1963 this.fieldName="col"+this.index;
1964 var b=h.options.columnSpecs[g];
1965 this.format=Rico.extend({},Rico.ColumnConst.DEFAULT);
1966 switch(typeof b){case"object":if(typeof b.format=="string"){Rico.extend(this.format,Rico.ColumnConst[b.format.toUpperCase()])
1967 }Rico.extend(this.format,b);
1969 case"string":if(b.slice(0,4)=="spec"){b=b.slice(4).toUpperCase()
1970 }if(typeof Rico.ColumnConst[b]=="object"){Rico.extend(this.format,Rico.ColumnConst[b])
1972 }Rico.addClass(this.dataColDiv,this.colClassName());
1974 if(typeof this.format.visible=="boolean"){this.visible=this.format.visible
1975 }Rico.log("TableColumn.init index="+g+" fieldName="+this.fieldName);
1976 this.sortable=typeof this.format.canSort=="boolean"?this.format.canSort:h.options.canSortDefault;
1977 this.currentSort=Rico.ColumnConst.UNSORTED;
1978 this.filterable=typeof this.format.canFilter=="boolean"?this.format.canFilter:h.options.canFilterDefault;
1979 this.filterType=Rico.ColumnConst.UNFILTERED;
1980 this.hideable=typeof this.format.canHide=="boolean"?this.format.canHide:h.options.canHideDefault;
1981 var a=(typeof(this.format.width)=="number")?this.format.width:e.initWidth;
1982 a=(typeof(a)=="number")?Math.max(a,Rico.ColumnConst.MINWIDTH):h.options.defaultWidth;
1983 this.setColWidth(a);
1984 if(!this.visible){this.setDisplay("none")
1985 }},colClassName:function(){return this.format.ClassName?this.format.ClassName:this.liveGrid.tableId+"_col"+this.index
1986 },insertResizer:function(){if(this.format.noResize){return
1987 }var a=document.createElement("div");
1988 a.className="ricoLG_Resize";
1989 a.style[this.liveGrid.align[1]]="0px";
1990 this.hdrCellDiv.appendChild(a);
1991 Rico.eventBind(a,"mousedown",this.mouseDownHandler,false)
1992 },getDisplayName:function(a){var b=a.getElementsByTagName("A");
1993 if(b.length>0){return b[0].innerHTML
1994 }else{return Rico.stripTags(a.innerHTML)
1995 }},_clear:function(a){a.innerHTML=" "
1996 },clearCell:function(d){var c=this.cell(d);
1998 if(!this.liveGrid.buffer){return
1999 }var b=this.liveGrid.buffer.options.acceptAttr;
2002 a++){switch(b[a]){case"style":c.style.cssText="";
2004 case"class":c.className="";
2006 default:c["_"+b[a]]="";
2008 }}},dataTable:function(){return this.liveGrid.tabs[this.tabIdx]
2009 },numRows:function(){return this.dataColDiv.childNodes.length
2010 },clearColumn:function(){var b=this.numRows();
2013 a++){this.clearCell(a)
2014 }},cell:function(a){return this.dataColDiv.childNodes[a]
2015 },getFormattedValue:function(c,a,d,b){return Rico.getInnerText(this.cell(c),a,d,b)
2016 },setColWidth:function(a){if(typeof a=="number"){a=parseInt(a,10);
2017 if(a<Rico.ColumnConst.MINWIDTH){return
2019 }Rico.log("setColWidth "+this.index+": "+a);
2021 this.hdrColDiv.style.width=a;
2022 this.dataColDiv.style.width=a
2023 },pluginMouseEvents:function(){if(this.mousePluggedIn==true){return
2024 }Rico.eventBind(this.body,"mousemove",this.mouseMoveHandler,false);
2025 Rico.eventBind(this.body,"mouseup",this.mouseUpHandler,false);
2026 Rico.eventBind(this.body,"mouseout",this.mouseOutHandler,false);
2027 this.mousePluggedIn=true
2028 },unplugMouseEvents:function(){Rico.eventUnbind(this.body,"mousemove",this.mouseMoveHandler,false);
2029 Rico.eventUnbind(this.body,"mouseup",this.mouseUpHandler,false);
2030 Rico.eventUnbind(this.body,"mouseout",this.mouseOutHandler,false);
2031 this.mousePluggedIn=false
2032 },handleMouseDown:function(b){this.resizeStart=Rico.eventClient(b).x;
2033 this.origWidth=parseInt(this.colWidth,10);
2034 var a=Rico.positionedOffset(this.hdrCell);
2035 if(this.liveGrid.direction=="rtl"){this.edge=a.left+this.liveGrid.options.scrollBarWidth;
2036 switch(this.tabIdx){case 0:this.edge+=this.liveGrid.innerDiv.offsetWidth;
2038 case 1:this.edge-=this.liveGrid.scrollDiv.scrollLeft;
2040 }}else{this.edge=a.left+this.hdrCell.offsetWidth;
2041 if(this.tabIdx>0){this.edge+=Rico.nan2zero(this.liveGrid.tabs[0].offsetWidth)
2042 }}this.liveGrid.resizeDiv.style.left=this.edge+"px";
2043 this.liveGrid.resizeDiv.style.display="";
2044 this.liveGrid.outerDiv.style.cursor="e-resize";
2045 this.tmpHighlight=this.liveGrid.highlightEnabled;
2046 this.liveGrid.highlightEnabled=false;
2047 this.pluginMouseEvents();
2049 },handleMouseMove:function(b){var c=Rico.eventClient(b).x-this.resizeStart;
2050 var a=(this.liveGrid.direction=="rtl")?this.origWidth-c:this.origWidth+c;
2051 if(a<Rico.ColumnConst.MINWIDTH){return
2052 }this.liveGrid.resizeDiv.style.left=(this.edge+c)+"px";
2055 },handleMouseUp:function(a){this.unplugMouseEvents();
2056 Rico.log("handleMouseUp "+this.liveGrid.tableId);
2057 this.liveGrid.outerDiv.style.cursor="";
2058 this.liveGrid.resizeDiv.style.display="none";
2059 this.setColWidth(this.colWidth);
2060 this.customWidth=true;
2061 this.liveGrid.setCookie();
2062 this.liveGrid.highlightEnabled=this.tmpHighlight;
2063 this.liveGrid.sizeDivs();
2065 },handleMouseOut:function(b){var a=Rico.eventRelatedTarget(b)||b.toElement;
2066 while(a!=null&&a.nodeName.toLowerCase()!="body"){a=a.parentNode
2067 }if(a!=null&&a.nodeName.toLowerCase()=="body"){return true
2068 }this.handleMouseUp(b);
2070 },setDisplay:function(a){this.hdrCell.style.display=a;
2071 this.hdrColDiv.style.display=a;
2072 this.dataCell.style.display=a;
2073 this.dataColDiv.style.display=a
2074 },hideshow:function(b,a){this.setDisplay(b?"":"none");
2075 this.liveGrid.cancelMenu();
2077 this.customVisible=true;
2079 }this.liveGrid.setCookie();
2080 this.liveGrid.sizeDivs()
2081 },hideColumn:function(){Rico.log("hideColumn "+this.liveGrid.tableId);
2082 this.hideshow(false,false)
2083 },showColumn:function(){Rico.log("showColumn "+this.liveGrid.tableId);
2084 this.hideshow(true,false)
2085 },chooseColumn:function(b){var a=Rico.eventElement(b);
2086 this.hideshow(a.checked,false)
2087 },setImage:function(){if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.imgSort.style.display="inline-block";
2088 this.imgSort.className=Rico.theme.sortAsc||"rico-icon ricoLG_sortAsc"
2089 }else{if(this.currentSort==Rico.ColumnConst.SORT_DESC){this.imgSort.style.display="inline-block";
2090 this.imgSort.className=Rico.theme.sortDesc||"rico-icon ricoLG_sortDesc"
2091 }else{this.imgSort.style.display="none"
2092 }}if(this.filterType==Rico.ColumnConst.USERFILTER){this.imgFilter.style.display="inline-block";
2093 this.imgFilter.title=this.getFilterText()
2094 }else{this.imgFilter.style.display="none"
2095 }},canHideShow:function(){return this.hideable
2097 if(typeof Rico=="undefined"){throw ("SimpleGrid requires the Rico JavaScript framework")
2098 }Rico.SimpleGrid=function(b,a){this.initialize(b,a)
2100 Rico.SimpleGrid.prototype={initialize:function(b,a){Rico.extend(this,Rico.GridCommon);
2102 Rico.setDebugArea(b+"_debugmsgs");
2103 Rico.extend(this.options,a||{});
2105 Rico.log("SimpleGrid initialize start: "+b);
2107 this.hdrTabs=new Array(2);
2108 this.simpleGridInit();
2109 Rico.log("SimpleGrid initialize end: "+b)
2110 },simpleGridInit:function(){var a;
2113 a++){Rico.log("simpleGridInit "+a);
2114 this.tabs[a]=document.getElementById(this.tableId+"_tab"+a);
2115 if(!this.tabs[a]){return
2116 }this.hdrTabs[a]=document.getElementById(this.tableId+"_tab"+a+"h");
2117 if(!this.hdrTabs[a]){return
2118 }this.thead[a]=this.hdrTabs[a];
2119 this.tbody[a]=this.tabs[a];
2120 this.headerColCnt=this.getColumnInfo(this.hdrTabs[a].rows);
2121 if(a==0){this.options.frozenColumns=this.headerColCnt
2122 }if(Rico.theme.gridheader){Rico.addClass(this.thead[a],Rico.theme.gridheader)
2123 }if(Rico.theme.gridcontent){Rico.addClass(this.tbody[a],Rico.theme.gridcontent)
2124 }}if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2126 }this.createColumnArray("SimpleGridColumn");
2127 this.pageSize=this.columns[0].dataColDiv.childNodes.length;
2129 if(typeof(this.options.FilterLocation)=="number"){this.createFilters(this.options.FilterLocation)
2130 }this.attachMenuEvents();
2131 this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2132 this.pluginScroll();
2133 if(this.options.windowResize){Rico.eventBind(window,"resize",Rico.eventHandle(this,"sizeDivs"),false)
2134 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2135 },createFilters:function(a){if(a<0){a=this.addHeadingRow();
2138 g<this.headerColCnt;
2139 g++){var d=this.columns[g];
2141 if(typeof e.filterUI!="string"){continue
2142 }var k=this.hdrCells[a][g].cell;
2143 var j,b=this.filterId(g);
2144 var h=k.getElementsByTagName("div");
2145 switch(e.filterUI.charAt(0)){case"t":j=Rico.createFormField(h[1],"input","text",b,b);
2146 var m=e.filterUI.match(/\d+/);
2147 j.maxLength=e.Length||50;
2148 j.size=m?parseInt(m,10):10;
2149 Rico.eventBind(j,"keyup",Rico.eventHandle(d,"filterKeypress"),false);
2151 case"s":j=Rico.createFormField(h[1],"select",null,b);
2152 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2153 this.getFilterValues(d);
2154 var l=Rico.keys(d.filterHash);
2158 f++){Rico.addSelectOption(j,l[f],l[f]||Rico.getPhraseById("filterBlank"))
2159 }Rico.eventBind(j,"change",Rico.eventHandle(d,"filterChange"),false);
2161 }}this.initFilterImage(a)
2162 },getFilterValues:function(b){var e={};
2166 c++){var a=Rico.getInnerText(b.cell(c));
2171 },applyFilters:function(){var b=[];
2173 f<this.columns.length;
2174 f++){if(this.columns[f].filterRows){b.push(this.columns[f].filterRows)
2175 }}if(b.length==0){this.showAllRows();
2182 a++){if(b[a].indexOf(d)==-1){e=false;
2184 }}if(e){this.showRow(d)
2185 }else{this.hideRow(d)
2187 },handleScroll:function(b){var a=(-this.scrollDiv.scrollTop)+"px";
2188 this.tabs[0].style.marginTop=a;
2189 this.setHorizontalScroll()
2190 },registerScrollMenu:function(a){if(!this.menu){this.menu=a
2192 a.showmenu=a.showSimpleMenu;
2193 a.showSubMenu=a.showSimpleSubMenu;
2194 a.createDiv(this.outerDiv)
2195 },handleMenuClick:function(a){if(!this.menu){return
2197 this.menuCell=Rico.getParentByTagName(Rico.eventElement(a),"div");
2198 this.highlightEnabled=false;
2199 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
2200 }if(this.menu.buildGridMenu){this.menu.buildGridMenu(this.menuCell)
2201 }this.menu.showmenu(a,this.closeMenu.bind(this))
2202 },closeMenu:function(){if(this.hideScroll){this.scrollDiv.style.overflow=""
2203 }this.highlightEnabled=true
2204 },sizeDivs:function(){if(this.outerDiv.offsetParent.style.display=="none"){return
2205 }this.baseSizeDivs();
2206 var c=Math.max(this.options.maxHt||this.availHt(),50);
2207 var b=Math.min(this.hdrHt+this.dataHt,c);
2208 Rico.log("sizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2209 this.dataHt=b-this.hdrHt;
2210 if(this.scrWi>0){this.dataHt+=this.options.scrollBarWidth
2211 }this.scrollDiv.style.height=this.dataHt+"px";
2212 this.frozenTabs.style.height=this.scrollDiv.clientHeight+"px";
2214 this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+a)+"px";
2216 this.resizeDiv.style.height=b+"px";
2218 },printVisible:function(a){this.showMsg(Rico.getPhraseById("exportInProgress"));
2219 Rico.runLater(10,this,"_printVisible",a)
2220 },_printVisible:function(a){this.exportStart();
2221 var g=this.getExportStyles(this.tbody[0]);
2224 f++){if(this.columns[0].cell(f).style.display=="none"){continue
2227 h<this.columns.length;
2228 h++){var d=this.columns[h];
2229 if(d.visible){var b=d.getFormattedValue(f,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport");
2230 if(d.format.exportPrefix){b=d.format.exportPrefix+b
2231 }if(b==""){b=" "
2232 }e+="<td style='"+this.exportStyle(d.cell(f),g)+"'>"+b+"</td>"
2233 }}this.exportRows.push(e)
2234 }this.exportFinish(a)
2235 },hideRow:function(a){if(this.columns[0].cell(a).style.display=="none"){return
2237 b<this.columns.length;
2238 b++){this.columns[b].cell(a).style.display="none"
2239 }},showRow:function(a){if(this.columns[0].cell(a).style.display==""){return
2241 b<this.columns.length;
2242 b++){this.columns[b].cell(a).style.display=""
2243 }},searchRows:function(h,e,c){if(!e){return
2244 }var f=new RegExp(e);
2245 var d=this.columns[h].numRows();
2248 g++){var b=this.cell(g,h).innerHTML;
2249 var a=(b.match(f)!=null);
2250 if(a!=c){this.hideRow(g)
2253 },showAllRows:function(){for(var a=0;
2255 a++){this.showRow(a)
2257 },openPopup:function(d,e){while(d&&!Rico.hasClass(d,"ricoLG_cell")){d=d.parentNode
2258 }if(!d){return false
2259 }var f=Rico.getParentByTagName(d,"td");
2260 var c=Math.floor(f.offsetLeft-this.scrollDiv.scrollLeft+f.offsetWidth/2);
2261 if(this.direction=="rtl"){if(c>this.width){c-=this.width
2262 }}else{if(c+this.width+this.options.margin>this.scrollDiv.clientWidth){c-=this.width
2263 }}e.divPopup.style.visibility="hidden";
2264 e.divPopup.style.display="block";
2265 var b=e.divPopup.offsetHeight;
2266 var a=Math.floor(d.offsetTop-this.scrollDiv.scrollTop+d.offsetHeight/2);
2267 if(a+b+e.options.margin>this.scrollDiv.clientHeight){a=Math.max(a-b,0)
2268 }e.openPopup(this.frzWi+c,this.hdrHt+a);
2269 e.divPopup.style.visibility="visible";
2272 if(Rico.Menu){Rico.extend(Rico.Menu.prototype,{showSimpleMenu:function(b,c){Rico.eventStop(b);
2274 if(this.div.childNodes.length==0){this.cancelmenu();
2276 }var a=Rico.eventElement(b);
2277 this.grid.openPopup(a,this);
2279 },showSimpleSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()
2280 }this.openSubMenu=c;
2281 this.openMenuAnchor=b;
2282 if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"
2283 }var e=parseInt(this.div.style.top,10);
2284 var d=parseInt(this.div.style.left,10);
2285 c.openPopup(d+b.offsetWidth,e+b.offsetTop);
2286 c.div.style.visibility="visible"
2288 }Rico.SimpleGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
2290 Rico.SimpleGridColumn.prototype={initialize:function(a,d,c,b){Rico.extend(this,new Rico.TableColumnBase());
2291 this.baseInit(a,d,c,b)
2292 },setUnfiltered:function(){this.filterRows=null
2293 },filterChange:function(a){var b=Rico.eventElement(a);
2294 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
2295 }else{this.filterRows=this.filterHash[b.value]
2296 }this.liveGrid.applyFilters()
2297 },filterKeypress:function(f){var a=Rico.eventElement(f);
2298 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
2299 }if(this.lastKeyFilter==a.value){return
2301 Rico.log("filterKeypress: "+this.index+" "+b);
2302 this.lastKeyFilter=b;
2303 if(b){b=b.replace("\\","\\\\");
2304 b=b.replace("(","\\(").replace(")","\\)");
2305 b=b.replace(".","\\.");
2306 if(this.format.filterUI.indexOf("^")>0){b="^"+b
2307 }var d=new RegExp(b,"i");
2309 var h=this.numRows();
2312 c++){var g=Rico.getInnerText(this.cell(c));
2313 if(g.match(d)){this.filterRows.push(c)
2314 }}}else{this.setUnfiltered()
2315 }this.liveGrid.applyFilters()
2317 if(typeof Rico=="undefined"){throw ("LiveGrid requires the Rico JavaScript framework")
2318 }if(!Rico.Buffer){Rico.Buffer={}
2319 }Rico.Buffer.Base=function(b,a){this.initialize(b,a)
2321 Rico.Buffer.Base.prototype={initialize:function(b,a){this.clear();
2322 this.updateInProgress=false;
2324 this.rcvdRowCount=false;
2325 this.foundRowCount=false;
2327 this.rowcntContent="";
2329 this.options={fixedHdrRows:0,canFilter:true,isEncoded:true,acceptAttr:[]};
2330 Rico.extend(this.options,a||{});
2331 if(b){this.loadRowsFromTable(b,this.options.fixedHdrRows)
2333 }},registerGrid:function(a){this.liveGrid=a
2334 },setTotalRows:function(a){if(typeof(a)!="number"){a=this.size
2335 }if(this.totalRows==a){return
2337 if(!this.liveGrid){return
2338 }Rico.log("setTotalRows, newTotalRows="+a);
2339 switch(this.liveGrid.sizeTo){case"data":this.liveGrid.resizeWindow();
2341 case"datamax":this.liveGrid.setPageSize(a);
2343 default:this.liveGrid.updateHeightDiv();
2345 }},loadRowsFromTable:function(h,g){var e=new Array();
2346 var a=h.getElementsByTagName("tr");
2349 d++){var f=new Array();
2350 var c=a[d].getElementsByTagName("td");
2353 b++){f[b]=c[b].innerHTML
2356 },loadRowsFromArray:function(b){for(var c=0;
2360 a++){b[c][a]=b[c][a].toString()
2362 },loadRows:function(a){this.baseRows=a;
2364 this.size=this.baseRows.length
2365 },dom2jstable:function(f){Rico.log("dom2jstable: encoded="+this.options.isEncoded);
2367 var a=f.getElementsByTagName("tr");
2370 d++){var g=new Array();
2371 var c=a[d].getElementsByTagName("td");
2374 b++){g[b]=Rico.getContentAsString(c[b],this.options.isEncoded)
2377 },dom2jstableAttr:function(e,b){var h=this.options.acceptAttr;
2378 Rico.log("dom2jstableAttr start, # attr="+h.length);
2380 var g=e.getElementsByTagName("tr");
2383 d++){var m=new Array();
2384 var l=g[d].getElementsByTagName("td");
2390 a++){m[c]["_"+h[a]]=l[c].getAttribute(h[a])
2391 }if(Rico.isIE){m[c]._class=l[c].getAttribute("className")
2393 }Rico.log("dom2jstableAttr end");
2395 },_blankRow:function(){var a=[];
2397 b<this.liveGrid.columns.length;
2400 },deleteRows:function(b,a){this.baseRows.splice(b,typeof(a)=="number"?a:1);
2401 this.liveGrid.isPartialBlank=true;
2402 this.size=this.baseRows.length
2403 },insertRow:function(a){var b=this._blankRow();
2404 this.baseRows.splice(a,0,b);
2405 this.size=this.baseRows.length;
2406 this.liveGrid.isPartialBlank=true;
2407 if(this.startPos<0){this.startPos=0
2409 },appendRows:function(b){var c=[];
2412 a++){var d=this._blankRow();
2413 this.baseRows.push(d);
2415 }this.size=this.baseRows.length;
2416 this.liveGrid.isPartialBlank=true;
2417 if(this.startPos<0){this.startPos=0
2419 },sortFunc:function(b){var a=this;
2420 switch(b){case"number":return function(d,c){return a._sortNumeric(d,c)
2422 case"control":return function(d,c){return a._sortControl(d,c)
2424 default:return function(d,c){return a._sortAlpha(d,c)
2426 }},sortBuffer:function(b){if(!this.baseRows){this.delayedSortCol=b;
2428 }this.liveGrid.showMsg(Rico.getPhraseById("sorting"));
2430 var a=this.liveGrid.columns[b];
2431 this.getValFunc=a._sortfunc;
2432 this.baseRows.sort(this.sortFunc(a.format.type));
2433 if(a.getSortDirection()=="DESC"){this.baseRows.reverse()
2434 }},_sortAlpha:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2435 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2439 },_sortNumeric:function(d,c){var e=this.sortColumn<d.length?this.nan2zero(Rico.getInnerText(d[this.sortColumn])):0;
2440 var f=this.sortColumn<c.length?this.nan2zero(Rico.getInnerText(c[this.sortColumn])):0;
2442 },nan2zero:function(a){if(typeof(a)=="string"){a=parseFloat(a)
2443 }return isNaN(a)||typeof(a)=="undefined"?0:a
2444 },_sortControl:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2445 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2446 if(this.getValFunc){e=this.getValFunc(e);
2447 f=this.getValFunc(f)
2451 },clear:function(){this.baseRows=[];
2456 },isInRange:function(a){var b=Math.min(this.totalRows,a+this.liveGrid.pageSize);
2457 return(a>=this.startPos)&&(b<=this.endPos())
2458 },endPos:function(){return this.startPos+this.rows.length
2459 },fetch:function(a){Rico.log("fetch "+this.liveGrid.tableId+": offset="+a);
2460 this.applyFilters();
2461 this.setTotalRows();
2462 this.rcvdRowCount=true;
2463 this.foundRowCount=true;
2465 }this.liveGrid.refreshContents(a);
2467 },visibleRows:function(){return this.rows.slice(this.windowStart,this.windowEnd)
2468 },setWindow:function(b,a){this.windowStart=b-this.startPos;
2469 Rico.log("setWindow "+this.liveGrid.tableId+": "+b+", "+a+", newstart="+this.windowStart);
2470 this.windowEnd=Math.min(a,this.size);
2472 },isVisible:function(a){return a<this.rows.length&&a>=this.windowStart&&a<this.windowEnd
2473 },bufferRow:function(a){return this.windowStart+a
2474 },getWindowCell:function(c,b){var a=this.bufferRow(c);
2475 return this.isVisible(a)&&b<this.rows[a].length?this.rows[a][b]:null
2476 },getWindowAttr:function(c,b){var a=this.bufferRow(c);
2477 return this.attr&&this.isVisible(a)&&b<this.attr[a].length?this.attr[a][b]:null
2478 },getWindowValue:function(b,a){return this.getWindowCell(b,a)
2479 },setWindowValue:function(d,b,c){var a=this.bufferRow(d);
2480 if(a>=this.windowEnd){return false
2481 }return this.setValue(a,b,c)
2482 },getCell:function(b,a){return b<this.size?this.rows[b][a]:null
2483 },getValue:function(b,a){return this.getCell(b,a)
2484 },setValue:function(d,b,c,a){if(d>=this.size){return false
2485 }if(!this.rows[d][b]){this.rows[d][b]={}
2487 if(typeof a=="string"){this.rows[d][b]._style=a
2488 }this.rows[d][b].modified=true;
2490 },getRows:function(f,d){var e=f-this.startPos;
2491 var a=Math.min(e+d,this.size);
2495 b++){c.push(this.rows[b])
2497 },applyFilters:function(){var g=[],k=[];
2499 var j=this.liveGrid.columns;
2503 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2505 if(h.filterOp=="LIKE"){k[d]=new RegExp(h.filterValues[0],"i")
2506 }}Rico.log("applyFilters: # of filters="+b);
2507 if(b==0){this.rows=this.baseRows
2509 a<this.baseRows.length;
2514 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2515 }switch(h.filterOp){case"LIKE":f=k[d].test(this.baseRows[a][d]);
2517 case"EQ":f=this.baseRows[a][d]==h.filterValues[0];
2520 e<h.filterValues.length&&f;
2521 e++){f=this.baseRows[a][d]!=h.filterValues[e]
2523 case"LE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])<=this.nan2zero(h.filterValues[0])
2524 }else{f=this.baseRows[a][d]<=h.filterValues[0]
2526 case"GE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])>=this.nan2zero(h.filterValues[0])
2527 }else{f=this.baseRows[a][d]>=h.filterValues[0]
2529 case"NULL":f=this.baseRows[a][d]=="";
2531 case"NOTNULL":f=this.baseRows[a][d]!="";
2533 }}if(f){g.push(this.baseRows[a])
2535 }this.rowcntContent=this.size=this.rows.length
2536 },printAll:function(a){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2537 Rico.runLater(10,this,"_printAll",a)
2538 },_printAll:function(a){this.liveGrid.exportStart();
2539 this.exportBuffer(this.getRows(0,this.totalRows));
2540 this.liveGrid.exportFinish(a)
2541 },printVisible:function(a){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2542 Rico.runLater(10,this,"_printVisible",a)
2543 },_printVisible:function(a){this.liveGrid.exportStart();
2544 this.exportBuffer(this.visibleRows());
2545 this.liveGrid.exportFinish(a)
2546 },exportBuffer:function(l,f){var a,g,k,b,j;
2547 Rico.log("exportBuffer: "+l.length+" rows");
2548 var e=this.liveGrid.getExportStyles(this.liveGrid.tbody[0]);
2551 var h=this.liveGrid.columns;
2554 g++){if(h[g].visible){i[g]=this.liveGrid.exportStyle(h[g].cell(0),e)
2560 g++){if(!h[g].visible){continue
2563 k=b._export(l[a][g],l[a]);
2564 if(k==""){k=" "
2565 }j+="<td style='"+b.expStyle+"'>"+k+"</td>"
2566 }this.liveGrid.exportRows.push(j);
2568 if(d%10==0){window.status=Rico.getPhraseById("exportStatus",d)
2570 Rico.LiveGrid=function(c,a,b){this.initialize(c,a,b)
2572 Rico.LiveGrid.prototype={initialize:function(e,b,d){Rico.extend(this,Rico.GridCommon);
2573 Rico.extend(this,Rico.LiveGridMethods);
2577 this.actionId="_action_"+e;
2578 Rico.setDebugArea(e+"_debugmsgs");
2579 Rico.extend(this.options,{visibleRows:-3,frozenColumns:0,offset:0,prefetchBuffer:true,minPageRows:2,maxPageRows:50,canSortDefault:true,canFilterDefault:b.options.canFilter,canHideDefault:true,highlightElem:"none",highlightSection:3,highlightMethod:"class",highlightClass:Rico.theme.gridHighlightClass||"ricoLG_selection",maxPrint:5000,headingSort:"link",hdrIconsFirst:true});
2581 this.options.sortHandler=function(){c.sortHandler()
2583 this.options.filterHandler=function(){c.filterHandler()
2585 this.options.onRefreshComplete=function(f,g){c.bookmarkHandler(f,g)
2587 this.options.rowOverHandler=Rico.eventHandle(this,"rowMouseOver");
2588 this.options.mouseDownHandler=Rico.eventHandle(this,"selectMouseDown");
2589 this.options.mouseOverHandler=Rico.eventHandle(this,"selectMouseOver");
2590 this.options.mouseUpHandler=Rico.eventHandle(this,"selectMouseUp");
2591 Rico.extend(this.options,d||{});
2592 switch(typeof this.options.visibleRows){case"string":this.sizeTo=this.options.visibleRows;
2593 switch(this.options.visibleRows){case"data":this.options.visibleRows=-2;
2595 case"body":this.options.visibleRows=-3;
2597 case"parent":this.options.visibleRows=-4;
2599 case"datamax":this.options.visibleRows=-5;
2601 default:this.options.visibleRows=-1;
2604 case"number":switch(this.options.visibleRows){case -1:this.sizeTo="window";
2606 case -2:this.sizeTo="data";
2608 case -3:this.sizeTo="body";
2610 case -4:this.sizeTo="parent";
2612 case -5:this.sizeTo="datamax";
2614 default:this.sizeTo="fixed";
2617 default:this.sizeTo="body";
2618 this.options.visibleRows=-3;
2620 }this.highlightEnabled=this.options.highlightSection>0;
2622 this.createTables();
2623 if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2625 }this.createColumnArray("LiveGridColumn");
2626 if(this.options.headingSort=="hover"){this.createHoverSet()
2627 }this.bookmark=document.getElementById(this.tableId+"_bookmark");
2629 var a=this.buffer.options.canFilter?this.options.FilterLocation:false;
2630 if(typeof(a)=="number"&&a<0){a=this.addHeadingRow("ricoLG_FilterRow")
2631 }this.createDataCells(this.options.visibleRows);
2632 if(this.pageSize==0){return
2633 }this.buffer.registerGrid(this);
2634 if(this.buffer.setBufferSize){this.buffer.setBufferSize(this.pageSize)
2635 }this.scrollTimeout=null;
2636 this.lastScrollPos=0;
2637 this.attachMenuEvents();
2638 this.setSortUI(this.options.sortCol,this.options.sortDir);
2640 if(this.listInvisible().length==this.columns.length){this.columns[0].showColumn()
2642 this.scrollDiv.style.display="";
2643 if(this.buffer.totalRows>0){this.updateHeightDiv()
2644 }if(this.options.prefetchBuffer){if(this.bookmark){this.bookmark.innerHTML=Rico.getPhraseById("bookmarkLoading")
2645 }if(this.options.canFilterDefault&&this.options.getQueryParms){this.checkForFilterParms()
2646 }this.scrollToRow(this.options.offset);
2647 this.buffer.fetch(this.options.offset)
2648 }if(typeof(a)=="number"){this.createFilters(a)
2649 }this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2650 this.wheelEventFunc=Rico.eventHandle(this,"handleWheel");
2651 this.wheelEvent=(Rico.isIE||Rico.isOpera||Rico.isWebKit)?"mousewheel":"DOMMouseScroll";
2652 if(this.options.offset&&this.options.offset<this.buffer.totalRows){Rico.runLater(50,this,"scrollToRow",this.options.offset)
2653 }this.pluginScroll();
2654 this.setHorizontalScroll();
2655 Rico.log("setHorizontalScroll done");
2656 if(this.options.windowResize){Rico.runLater(100,this,"pluginWindowResize")
2657 }Rico.log("initialize complete for "+this.tableId)
2659 Rico.LiveGridMethods={createHoverSet:function(){var a=[];
2661 b<this.headerColCnt;
2662 b++){if(this.columns[b].sortable){a.push(this.columns[b].hdrCellDiv)
2663 }}this.hoverSet=new Rico.HoverSet(a)
2664 },checkForFilterParms:function(){var b=window.location.search;
2665 if(b.charAt(0)=="?"){b=b.substring(1)
2666 }var c=b.split("&");
2669 a++){if(c[a].match(/^f\[\d+\]/)){this.buffer.options.requestParameters.push(c[a])
2670 }}},drillDown:function(g,f,h){var b=Rico.eventElement(g||window.event);
2671 b=Rico.getParentByTagName(b,"div","ricoLG_cell");
2673 }var a=this.winCellIndex(b);
2674 if(a.row>=this.buffer.totalRows){return -1
2675 }this.unhighlight();
2678 var c=this.buffer.getWindowCell(a.row,f);
2681 d++){arguments[d].setDetailFilter(h,c)
2683 },setDetailFilter:function(a,d){var b=this.columns[a];
2685 b.setSystemFilter("EQ",d)
2686 },createTables:function(){var f,g,b;
2687 var e=document.getElementById(this.tableId)||document.getElementById(this.tableId+"_outerDiv");
2689 }if(e.tagName.toLowerCase()=="table"){var a=e.getElementsByTagName("thead");
2690 if(a.length==1){Rico.log("createTables: using thead section, id="+this.tableId);
2691 if(this.options.PanelNamesOnTabHdr&&this.options.panels){var d=a[0].insertRow(0);
2692 this.insertPanelNames(d,0,this.options.frozenColumns,"ricoFrozen");
2693 this.insertPanelNames(d,this.options.frozenColumns,this.options.columnSpecs.length)
2695 }else{Rico.log("createTables: using tbody section, id="+this.tableId);
2696 g=new Array(e.rows[0])
2698 }else{if(this.options.columnSpecs.length>0){if(!e.id.match(/_outerDiv$/)){f=e
2699 }Rico.log("createTables: inserting at "+e.tagName+", id="+this.tableId)
2700 }else{alert("ERROR!\n\nUnable to initialize '"+this.tableId+"'\n\nLiveGrid terminated");
2702 }}this.createDivs();
2703 this.scrollContainer=this.createDiv("scrollContainer",this.structTabLR);
2704 this.scrollContainer.appendChild(this.scrollDiv);
2705 this.scrollTab=this.createDiv("scrollTab",this.scrollContainer);
2706 this.shadowDiv=this.createDiv("shadow",this.scrollDiv);
2707 this.shadowDiv.style.direction="ltr";
2708 this.scrollDiv.style.display="none";
2709 this.scrollDiv.scrollTop=0;
2710 if(this.options.highlightMethod!="class"){this.highlightDiv=[];
2711 switch(this.options.highlightElem){case"menuRow":case"cursorRow":this.highlightDiv[0]=this.createDiv("highlight",this.outerDiv);
2712 this.highlightDiv[0].style.display="none";
2714 case"menuCell":case"cursorCell":for(b=0;
2716 b++){this.highlightDiv[b]=this.createDiv("highlight",b==0?this.frozenTabs:this.scrollTab);
2717 this.highlightDiv[b].style.display="none";
2718 this.highlightDiv[b].id+=b
2720 case"selection":var h=this.options.highlightSection==1?this.frozenTabs:this.scrollTab;
2723 b++){this.highlightDiv[b]=this.createDiv("highlight",h);
2724 this.highlightDiv[b].style.display="none";
2725 this.highlightDiv[b].style.overflow="hidden";
2726 this.highlightDiv[b].id+=b;
2727 this.highlightDiv[b].style[b%2==0?"height":"width"]="0px"
2731 b++){this.tabs[b]=document.createElement("table");
2732 this.tabs[b].className="ricoLG_table";
2733 this.tabs[b].border=0;
2734 this.tabs[b].cellPadding=0;
2735 this.tabs[b].cellSpacing=0;
2736 this.tabs[b].id=this.tableId+"_tab"+b
2739 b++){this.thead[b]=this.tabs[b].createTHead();
2740 Rico.addClass(this.tabs[b],"ricoLG_top");
2741 if(Rico.theme.gridheader){Rico.addClass(this.thead[b],Rico.theme.gridheader)
2744 b++){this.tbody[b]=Rico.getTBody(this.tabs[b==0?0:2]);
2745 this.tbody[b].className="ricoLG_bottom";
2746 if(Rico.theme.gridcontent){Rico.addClass(this.tbody[b],Rico.theme.gridcontent)
2747 }this.tbody[b].insertRow(-1)
2748 }this.frozenTabs.appendChild(this.tabs[0]);
2749 this.innerDiv.appendChild(this.tabs[1]);
2750 this.scrollTab.appendChild(this.tabs[2]);
2751 if(f){f.parentNode.insertBefore(this.outerDiv,f)
2752 }if(g){this.headerColCnt=this.getColumnInfo(g);
2754 }else{this.createHdr(0,0,this.options.frozenColumns);
2755 this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);
2756 if(this.options.PanelNamesOnTabHdr&&this.options.panels){this.insertPanelNames(this.thead[0].insertRow(0),0,this.options.frozenColumns);
2757 this.insertPanelNames(this.thead[1].insertRow(0),this.options.frozenColumns,this.options.columnSpecs.length)
2760 b++){this.headerColCnt=this.getColumnInfo(this.thead[b].rows)
2762 j<this.headerColCnt;
2763 j++){this.tbody[j<this.options.frozenColumns?0:1].rows[0].insertCell(-1)
2764 }if(f){e.parentNode.removeChild(e)
2765 }Rico.log("createTables end");
2767 },createDataCells:function(d){if(d<0){for(var a=0;
2768 a<this.options.minPageRows;
2769 a++){this.appendBlankRow()
2771 this.autoAppendRows(this.remainingHt())
2774 c++){this.appendBlankRow()
2775 }}var b=this.options.highlightSection;
2776 if(b&1){this.attachHighlightEvents(this.tbody[0])
2777 }if(b&2){this.attachHighlightEvents(this.tbody[1])
2778 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2779 },createFilters:function(b){for(var h=0;
2780 h<this.headerColCnt;
2781 h++){var e=this.columns[h];
2783 if(typeof f.filterUI!="string"){continue
2784 }var l=this.hdrCells[b][h].cell;
2785 var j,d=this.filterId(h);
2786 var i=l.getElementsByTagName("div");
2787 var g=Rico.getStyle(this.cell(0,h),"textAlign");
2788 i[1].style.textAlign=g;
2789 switch(f.filterUI.charAt(0)){case"t":j=Rico.createFormField(i[1],"input","text",d,d);
2790 var n=f.filterUI.match(/\d+/);
2791 j.maxLength=f.Length||50;
2792 j.size=n?parseInt(n,10):10;
2793 i[1].appendChild(Rico.clearButton(Rico.eventHandle(e,"filterClear")));
2794 if(e.filterType==Rico.ColumnConst.USERFILTER&&e.filterOp=="LIKE"){var k=e.filterValues[0];
2795 if(k.charAt(0)=="*"){k=k.substr(1)
2796 }if(k.slice(-1)=="*"){k=k.slice(0,-1)
2799 }Rico.eventBind(j,"keyup",Rico.eventHandle(e,"filterKeypress"),false);
2802 case"m":case"s":j=Rico.createFormField(i[1],"select",null,d);
2803 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2806 Rico.extend(m,this.buffer.ajaxOptions);
2807 var a=typeof(f.filterCol)=="number"?f.filterCol:h;
2808 m.parameters={id:this.tableId,distinct:a};
2809 m.parameters[this.actionId]="query";
2810 m.onComplete=this.filterValuesUpdateFunc(h);
2811 new Rico.ajaxRequest(this.buffer.dataSource,m);
2813 case"c":if(typeof e._createFilters=="function"){e._createFilters(i[1],d)
2815 }}this.initFilterImage(b)
2816 },filterValuesUpdateFunc:function(b){var a=this;
2817 return function(c){a.filterValuesUpdate(b,c)
2819 },filterValuesUpdate:function(a,g){var f=g.responseXML.getElementsByTagName("ajax-response");
2820 Rico.log("filterValuesUpdate: "+g.status);
2821 if(f==null||f.length!=1){return false
2823 var n=f.getElementsByTagName("error");
2824 if(n.length>0){Rico.log("Data provider returned an error:\n"+Rico.getContentAsString(n[0],this.buffer.isEncoded));
2825 alert(Rico.getPhraseById("requestError",Rico.getContentAsString(n[0],this.buffer.isEncoded)));
2827 }f=f.getElementsByTagName("response")[0];
2828 var l=f.getElementsByTagName("rows")[0];
2829 var d=this.columns[parseInt(a,10)];
2830 var r=this.buffer.dom2jstable(l);
2832 if(d.filterType==Rico.ColumnConst.USERFILTER&&d.filterOp=="EQ"){q=d.filterValues[0]
2833 }Rico.log("filterValuesUpdate: col="+a+" rows="+r.length);
2834 switch(d.format.filterUI.charAt(0)){case"m":d.mFilter=document.body.appendChild(document.createElement("div"));
2835 d.mFilter.className="ricoLG_mFilter";
2836 Rico.hide(d.mFilter);
2837 var e=d.mFilter.appendChild(document.createElement("div"));
2838 e.className="ricoLG_mFilter_content";
2839 var o=d.mFilter.appendChild(document.createElement("div"));
2840 o.className="ricoLG_mFilter_button";
2841 d.mFilterButton=o.appendChild(document.createElement("button"));
2842 d.mFilterButton.innerHTML=Rico.getPhraseById("ok");
2843 var j=Rico.isWebKit?"mousedown":"click";
2844 Rico.eventBind(d.filterField,j,Rico.eventHandle(d,"mFilterSelectClick"));
2845 Rico.eventBind(d.mFilterButton,"click",Rico.eventHandle(d,"mFilterFinish"));
2846 tab=e.appendChild(document.createElement("table"));
2850 var p=this.filterId(a)+"_";
2851 this.createMFilterItem(tab,this.options.FilterAllToken,Rico.getPhraseById("filterAll"),p+"all",Rico.eventHandle(d,"mFilterAllClick"));
2852 var k=Rico.eventHandle(d,"mFilterOtherClick");
2855 h++){if(r[h].length>0){m=r[h][0];
2856 this.createMFilterItem(tab,m,m||Rico.getPhraseById("filterBlank"),p+h,k)
2857 }}d.mFilterInputs=e.getElementsByTagName("input");
2858 d.mFilterLabels=e.getElementsByTagName("label");
2859 d.mFilterFocus=d.mFilterInputs.length?d.mFilterInputs[0]:d.mFilterButton;
2861 case"s":for(var h=0;
2863 h++){if(r[h].length>0){m=r[h][0];
2864 b=Rico.addSelectOption(d.filterField,m,m||Rico.getPhraseById("filterBlank"));
2865 if(d.filterType==Rico.ColumnConst.USERFILTER&&m==q){b.selected=true
2866 }}}Rico.eventBind(d.filterField,"change",Rico.eventHandle(d,"filterChange"));
2869 },createMFilterItem:function(j,b,i,a,e){var f=j.insertRow(-1);
2871 if(f.rowIndex%2==1){f.className="ricoLG_mFilter_oddrow"
2872 }var d=f.insertCell(-1);
2873 var c=f.insertCell(-1);
2874 var h=Rico.createFormField(d,"input","checkbox",a);
2877 var g=c.appendChild(document.createElement("label"));
2880 Rico.eventBind(h,"click",e)
2881 },unplugHighlightEvents:function(){var a=this.options.highlightSection;
2882 if(a&1){this.detachHighlightEvents(this.tbody[0])
2883 }if(a&2){this.detachHighlightEvents(this.tbody[1])
2884 }},insertPanelNames:function(a,b,d,f){Rico.log("insertPanelNames: start="+b+" limit="+d);
2885 a.className="ricoLG_hdg";
2886 var i=-1,j,e=null,g=0;
2889 h++){if(i==this.options.columnSpecs[h].panelIdx){j++
2890 }else{if(e){e.colSpan=j
2891 }e=a.insertCell(-1);
2894 i=this.options.columnSpecs[h].panelIdx;
2895 e.innerHTML=this.options.panels[i]
2897 }},createHdr:function(d,g,b){Rico.log("createHdr: i="+d+" start="+g+" limit="+b);
2898 var a=this.thead[d].insertRow(-1);
2899 a.id=this.tableId+"_tab"+d+"h_main";
2900 a.className="ricoLG_hdg";
2903 f++){var e=a.insertCell(-1);
2904 e.innerHTML=this.options.columnSpecs[f].Hdg
2905 }},loadHdrSrc:function(g){var b,d,j,e,f,a;
2906 Rico.log("loadHdrSrc start");
2911 e++){f=this.thead[b].insertRow(-1);
2912 f.className="ricoLG_hdg "+this.tableId+"_hdg"+e
2913 }}if(g.length==1){a=g[0].cells;
2916 j++){this.thead[j<this.options.frozenColumns?0:1].rows[0].appendChild(a[0])
2922 j++){if(a[0].className=="ricoFrozen"){if(e==this.headerRowIdx){this.options.frozenColumns=j+1
2924 }this.thead[d].rows[e].appendChild(a[0])
2925 }}}Rico.log("loadHdrSrc end")
2926 },sizeDivs:function(){Rico.log("sizeDivs: "+this.tableId);
2928 this.baseSizeDivs();
2929 var d=this.firstVisible();
2930 if(this.pageSize==0||d<0){return
2931 }var c=this.columns[d].dataColDiv.offsetHeight;
2932 this.rowHeight=Math.round(c/this.pageSize);
2934 if(this.scrTabWi0==this.scrTabWi){this.innerDiv.style.height=(this.hdrHt+1)+"px";
2935 this.scrollDiv.style.overflowX="hidden"
2936 }else{this.scrollDiv.style.overflowX="scroll";
2937 b+=this.options.scrollBarWidth
2938 }this.scrollDiv.style.height=b+"px";
2939 this.innerDiv.style.width=(this.scrWi)+"px";
2940 this.scrollTab.style.width=(this.scrWi-this.options.scrollBarWidth)+"px";
2941 this.resizeDiv.style.height=(this.hdrHt+this.dataHt+1)+"px";
2942 Rico.log("sizeDivs scrHt="+b+" innerHt="+this.innerDiv.style.height+" rowHt="+this.rowHeight+" pageSize="+this.pageSize);
2943 var a=(this.scrWi-this.scrTabWi<this.options.scrollBarWidth)?2:0;
2944 this.shadowDiv.style.width=(this.scrTabWi+a)+"px";
2945 this.outerDiv.style.height=(this.hdrHt+b)+"px";
2946 this.setHorizontalScroll()
2947 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
2948 this.tabs[1].style.marginLeft=a;
2949 this.tabs[2].style.marginLeft=a
2950 },remainingHt:function(){var f;
2951 var g=Rico.windowHeight();
2952 var e=Rico.isIE?15:10;
2953 if(!Rico.isIE&&window.frameElement&&window.frameElement.scrolling=="yes"&&this.sizeTo!="parent"){e+=this.options.scrollBarWidth
2954 }switch(this.sizeTo){case"window":var d=Rico.cumulativeOffset(this.outerDiv).top;
2955 f=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);
2956 Rico.log("remainingHt, winHt="+g+" tabHt="+f+" gridY="+d);
2957 return g-d-f-this.options.scrollBarWidth-e;
2958 case"parent":var h=this.offsetFromParent(this.outerDiv);
2959 f=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);
2960 if(Rico.isIE){Rico.hide(this.outerDiv)
2961 }var b=this.outerDiv.parentNode.offsetHeight;
2962 if(Rico.isIE){Rico.show(this.outerDiv)
2963 }Rico.log("remainingHt, parentHt="+b+" gridY="+h+" winHt="+g+" tabHt="+f);
2964 return b-f-h-this.options.scrollBarWidth;
2965 case"data":case"body":var a=Rico.isIE?document.body.scrollHeight:document.body.offsetHeight;
2967 if(!Rico.isWebKit){c-=this.options.scrollBarWidth
2968 }Rico.log("remainingHt, winHt="+g+" pageHt="+a+" remHt="+c);
2970 default:f=Math.max(this.tabs[0].offsetHeight,this.tabs[1].offsetHeight);
2971 Rico.log("remainingHt, winHt="+g+" tabHt="+f);
2972 if(this.sizeTo.slice(-1)=="%"){g*=parseFloat(this.sizeTo)/100
2973 }else{if(this.sizeTo.slice(-2)=="px"){g=parseInt(this.sizeTo,10)
2974 }}return g-f-this.options.scrollBarWidth-e
2975 }},offsetFromParent:function(b){var a=0;
2977 do{a+=b.offsetTop||0;
2979 if(!b||b==null){break
2980 }var d=Rico.getStyle(b,"position");
2981 if(b.tagName=="BODY"||b.tagName=="HTML"||d=="absolute"){return a-c.offsetTop
2984 },adjustPageSize:function(){var a=this.remainingHt();
2985 Rico.log("adjustPageSize remHt="+a+" lastRow="+this.lastRowPos);
2986 if(a>this.rowHeight){this.autoAppendRows(a)
2987 }else{if(a<0||this.sizeTo=="data"){this.autoRemoveRows(-a)
2988 }}},setPageSize:function(b){b=Math.min(b,this.options.maxPageRows);
2989 b=Math.max(b,this.options.minPageRows);
2990 this.sizeTo="fixed";
2991 var a=this.pageSize;
2992 while(this.pageSize>b){this.removeRow()
2993 }while(this.pageSize<b){this.appendBlankRow()
2994 }this.finishResize(a)
2995 },pluginWindowResize:function(){Rico.log("pluginWindowResize");
2996 this.resizeWindowHandler=Rico.eventHandle(this,"resizeWindow");
2997 Rico.eventBind(window,"resize",this.resizeWindowHandler,false)
2998 },unplugWindowResize:function(){if(!this.resizeWindowHandler){return
2999 }Rico.eventUnbind(window,"resize",this.resizeWindowHandler,false);
3000 this.resizeWindowHandler=null
3001 },resizeWindow:function(){Rico.log("resizeWindow "+this.tableId+" lastRow="+this.lastRowPos);
3002 if(this.resizeState=="finish"){Rico.log("resizeWindow postponed");
3003 this.resizeState="resize";
3005 }if(!this.sizeTo||this.sizeTo=="fixed"){this.sizeDivs();
3007 }if(this.sizeTo=="parent"&&Rico.getStyle(this.outerDiv.parentNode,"display")=="none"){return
3008 }var a=this.pageSize;
3009 this.adjustPageSize();
3010 this.finishResize(a)
3011 },finishResize:function(b){if(this.pageSize>b&&this.buffer.totalRows>0){this.isPartialBlank=true;
3012 var a=this.adjustRow(this.lastRowPos);
3013 this.buffer.fetch(a)
3014 }else{if(this.pageSize<b){if(this.options.onRefreshComplete){this.options.onRefreshComplete(this.contentStartPos,this.contentStartPos+this.pageSize-1)
3015 }}}this.resizeState="finish";
3016 Rico.runLater(20,this,"finishResize2");
3017 Rico.log("Resize "+this.tableId+" complete. old size="+b+" new size="+this.pageSize)
3018 },finishResize2:function(){this.sizeDivs();
3019 this.updateHeightDiv();
3020 if(this.resizeState=="resize"){this.resizeWindow()
3021 }else{this.resizeState=""
3022 }},topOfLastPage:function(){return Math.max(this.buffer.totalRows-this.pageSize,0)
3023 },updateHeightDiv:function(){var b=this.topOfLastPage();
3024 var a=b?this.scrollDiv.clientHeight+Math.floor(this.rowHeight*(b+0.4)):1;
3025 Rico.log("updateHeightDiv, ht="+a+" scrollDiv.clientHeight="+this.scrollDiv.clientHeight+" rowsNotDisplayed="+b);
3026 this.shadowDiv.style.height=a+"px"
3027 },autoRemoveRows:function(a){if(!this.rowHeight){return
3028 }var c=Math.ceil(a/this.rowHeight);
3029 if(this.sizeTo=="data"){c=Math.max(c,this.pageSize-this.buffer.totalRows)
3030 }Rico.log("autoRemoveRows overage="+a+" removeCnt="+c);
3033 b++){this.removeRow()
3034 }},removeRow:function(){if(this.pageSize<=this.options.minPageRows){return
3037 b<this.headerColCnt;
3038 b++){var a=this.columns[b].cell(this.pageSize);
3039 this.columns[b].dataColDiv.removeChild(a)
3040 }},autoAppendRows:function(a){if(!this.rowHeight){return
3041 }var c=Math.floor(a/this.rowHeight);
3042 Rico.log("autoAppendRows overage="+a+" cnt="+c+" rowHt="+this.rowHeight);
3045 b++){if(this.sizeTo=="data"&&this.pageSize>=this.buffer.totalRows){break
3046 }this.appendBlankRow()
3047 }},appendBlankRow:function(){if(this.pageSize>=this.options.maxPageRows){return
3048 }Rico.log("appendBlankRow #"+this.pageSize);
3049 var a=this.defaultRowClass(this.pageSize);
3051 d<this.headerColCnt;
3052 d++){var b=document.createElement("div");
3053 b.className="ricoLG_cell "+a;
3054 b.id=this.tableId+"_"+this.pageSize+"_"+d;
3055 this.columns[d].dataColDiv.appendChild(b);
3056 if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
3057 }b.innerHTML=" ";
3058 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
3060 },defaultRowClass:function(b){var a;
3061 if(b%2==0){a="ricoLG_evenRow"
3062 }else{a="ricoLG_oddRow"
3064 },handleMenuClick:function(f){if(!this.menu){return
3068 var a=Rico.eventElement(f);
3069 if(a.className=="ricoLG_highlightDiv"){b=this.highlightIdx
3070 }else{a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3072 }b=this.winCellIndex(a);
3073 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3074 }}this.highlight(b);
3075 this.highlightEnabled=false;
3076 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
3078 if(!this.menu.div){this.menu.createDiv()
3079 }this.menu.liveGrid=this;
3080 if(this.menu.buildGridMenu){var d=this.menu.buildGridMenu(b.row,b.column,b.tabIdx);
3082 }}if(this.options.highlightElem=="selection"&&!this.isSelected(b.cell)){this.selectCell(b.cell)
3084 this.menu.showmenu(f,function(){c.closeMenu()
3086 },closeMenu:function(){if(!this.menuIdx){return
3087 }if(this.hideScroll){this.scrollDiv.style.overflow=""
3088 }this.highlightEnabled=true;
3090 },winCellIndex:function(b){var d=b.id.lastIndexOf("_",b.id.length);
3091 var a=b.id.lastIndexOf("_",d-1)+1;
3092 var f=parseInt(b.id.substr(d+1));
3093 var e=parseInt(b.id.substr(a,d));
3094 return{row:e,column:f,tabIdx:this.columns[f].tabIdx,cell:b}
3095 },datasetIndex:function(b){var a=this.winCellIndex(b);
3096 a.row+=this.buffer.windowPos;
3097 a.onBlankRow=(a.row>=this.buffer.endPos());
3099 },attachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventBind(a,"mousedown",this.options.mouseDownHandler,false);
3100 a.ondrag=function(){return false
3102 a.onselectstart=function(){return false
3105 case"cursorRow":case"cursorCell":Rico.eventBind(a,"mouseover",this.options.rowOverHandler,false);
3107 }},detachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventUnbind(a,"mousedown",this.options.mouseDownHandler,false);
3109 a.onselectstart=null;
3111 case"cursorRow":case"cursorCell":Rico.eventUnbind(a,"mouseover",this.options.rowOverHandler,false);
3113 }},getVisibleSelection:function(){var d=[];
3114 if(this.SelectIdxStart&&this.SelectIdxEnd){var b=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowStart);
3115 var a=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowEnd-1);
3116 var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3117 var f=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3122 j++){d.push({row:h-this.buffer.windowStart,column:j})
3123 }}}if(this.SelectCtrl){for(var e=0;
3124 e<this.SelectCtrl.length;
3125 e++){if(this.SelectCtrl[e].row>=this.buffer.windowStart&&this.SelectCtrl[e].row<this.buffer.windowEnd){d.push({row:this.SelectCtrl[e].row-this.buffer.windowStart,column:this.SelectCtrl[e].column})
3127 },updateSelectOutline:function(){if(!this.SelectIdxStart||!this.SelectIdxEnd){return
3128 }var d=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3129 var c=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3130 if(d>c){this.HideSelection();
3132 }var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3133 var e=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3134 var h=this.columns[g].cell(d-this.buffer.windowStart).offsetTop;
3135 var j=this.columns[g].cell(c-this.buffer.windowStart);
3136 var b=j.offsetTop+j.offsetHeight;
3137 var l=this.columns[g].dataCell.offsetLeft;
3138 var k=this.columns[e].dataCell.offsetLeft;
3139 var a=k+this.columns[e].dataCell.offsetWidth;
3140 this.highlightDiv[0].style.top=this.highlightDiv[3].style.top=this.highlightDiv[1].style.top=(this.hdrHt+h-1)+"px";
3141 this.highlightDiv[2].style.top=(this.hdrHt+b-1)+"px";
3142 this.highlightDiv[3].style.left=(l-2)+"px";
3143 this.highlightDiv[0].style.left=this.highlightDiv[2].style.left=(l-1)+"px";
3144 this.highlightDiv[1].style.left=(a-1)+"px";
3145 this.highlightDiv[0].style.width=this.highlightDiv[2].style.width=(a-l-1)+"px";
3146 this.highlightDiv[1].style.height=this.highlightDiv[3].style.height=(b-h)+"px";
3149 f++){this.highlightDiv[f].style.display=""
3150 }},HideSelection:function(){var b;
3151 if(this.options.highlightMethod!="class"){for(b=0;
3152 b<this.highlightDiv.length;
3153 b++){this.highlightDiv[b].style.display="none"
3154 }}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3155 Rico.log("HideSelection "+a.length);
3158 b++){this.unhighlightCell(this.columns[a[b].column].cell(a[b].row))
3159 }}},ShowSelection:function(){if(this.options.highlightMethod!="class"){this.updateSelectOutline()
3160 }if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3163 b++){this.highlightCell(this.columns[a[b].column].cell(a[b].row))
3164 }}},ClearSelection:function(){Rico.log("ClearSelection");
3165 this.HideSelection();
3166 this.SelectIdxStart=null;
3167 this.SelectIdxEnd=null;
3169 },selectCell:function(a){this.ClearSelection();
3170 this.SelectIdxStart=this.SelectIdxEnd=this.datasetIndex(a);
3171 this.ShowSelection()
3172 },AdjustSelection:function(a){var b=this.datasetIndex(a);
3173 if(this.SelectIdxStart.tabIdx!=b.tabIdx){return
3174 }this.HideSelection();
3175 this.SelectIdxEnd=b;
3176 this.ShowSelection()
3177 },RefreshSelection:function(){var a=this.getVisibleSelection();
3180 b++){this.columns[a[b].column].displayValue(a[b].row)
3181 }},FillSelection:function(b,f){if(this.SelectIdxStart&&this.SelectIdxEnd){var e=Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3182 var d=Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3183 var j=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3184 var g=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3189 k++){this.buffer.setValue(a,k,b,f)
3190 }}}if(this.SelectCtrl){for(var h=0;
3191 h<this.SelectCtrl.length;
3192 h++){this.buffer.setValue(this.SelectCtrl[h].row,this.SelectCtrl[h].column,b,f)
3193 }}this.RefreshSelection()
3194 },selectMouseDown:function(d){if(this.highlightEnabled==false){return true
3196 var a=Rico.eventElement(d);
3197 if(!Rico.eventLeftClick(d)){return true
3198 }a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3201 var c=this.datasetIndex(a);
3202 if(c.onBlankRow){return true
3203 }Rico.log("selectMouseDown @"+c.row+","+c.column);
3204 if(d.ctrlKey){if(!this.SelectIdxStart||this.options.highlightMethod!="class"){return true
3205 }if(!this.isSelected(a)){this.highlightCell(a);
3206 this.SelectCtrl.push(this.datasetIndex(a))
3208 b<this.SelectCtrl.length;
3209 b++){if(this.SelectCtrl[b].row==c.row&&this.SelectCtrl[b].column==c.column){this.unhighlightCell(a);
3210 this.SelectCtrl.splice(b,1);
3212 }}}}else{if(d.shiftKey){if(!this.SelectIdxStart){return true
3213 }this.AdjustSelection(a)
3214 }else{this.selectCell(a);
3217 },pluginSelect:function(){if(this.selectPluggedIn){return
3218 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3219 Rico.eventBind(a,"mouseover",this.options.mouseOverHandler,false);
3220 Rico.eventBind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3221 this.selectPluggedIn=true
3222 },unplugSelect:function(){if(!this.selectPluggedIn){return
3223 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3224 Rico.eventUnbind(a,"mouseover",this.options.mouseOverHandler,false);
3225 Rico.eventUnbind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3226 this.selectPluggedIn=false
3227 },selectMouseUp:function(b){this.unplugSelect();
3228 var a=Rico.eventElement(b);
3229 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3231 }if(this.SelectIdxStart&&this.SelectIdxEnd){this.AdjustSelection(a)
3232 }else{this.ClearSelection()
3233 }},selectMouseOver:function(b){var a=Rico.eventElement(b);
3234 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3236 }this.AdjustSelection(a);
3238 },isSelected:function(a){if(this.options.highlightMethod!="outline"){return Rico.hasClass(a,this.options.highlightClass)
3239 }if(!this.SelectIdxStart||!this.SelectIdxEnd){return false
3240 }var c=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3241 var b=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3242 if(c>b){return false
3243 }var e=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3244 var d=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3245 var f=this.datasetIndex(a);
3246 return(c<=f.row&&f.row<=b&&e<=f.column&&f.column<=d)
3247 },highlightCell:function(a){Rico.addClass(a,this.options.highlightClass)
3248 },unhighlightCell:function(a){if(a==null){return
3249 }Rico.removeClass(a,this.options.highlightClass)
3250 },selectRow:function(a){for(var b=0;
3251 b<this.columns.length;
3252 b++){this.highlightCell(this.columns[b].cell(a))
3253 }},unselectRow:function(a){for(var b=0;
3254 b<this.columns.length;
3255 b++){this.unhighlightCell(this.columns[b].cell(a))
3256 }},rowMouseOver:function(c){if(!this.highlightEnabled){return
3257 }var a=Rico.eventElement(c);
3258 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3260 }var b=this.winCellIndex(a);
3261 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3263 },highlight:function(a){if(this.options.highlightMethod!="outline"){this.cursorSetClass(a)
3264 }if(this.options.highlightMethod!="class"){this.cursorOutline(a)
3265 }this.highlightIdx=a
3266 },cursorSetClass:function(e){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3267 }this.highlightCell(e.cell);
3269 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3270 }var b=this.options.highlightSection&1;
3271 var a=this.options.highlightSection&2;
3272 var f=b?0:this.options.frozenColumns;
3273 var d=a?this.columns.length:this.options.frozenColumns;
3276 g++){this.highlightCell(this.columns[g].cell(e.row))
3279 }},cursorOutline:function(c){var d;
3280 switch(this.options.highlightElem){case"menuCell":case"cursorCell":d=this.highlightDiv[c.tabIdx];
3281 d.style.left=(this.columns[c.column].dataCell.offsetLeft-1)+"px";
3282 d.style.width=this.columns[c.column].colWidth;
3283 this.highlightDiv[1-c.tabIdx].style.display="none";
3285 case"menuRow":case"cursorRow":d=this.highlightDiv[0];
3286 var b=this.options.highlightSection&1;
3287 var a=this.options.highlightSection&2;
3288 d.style.left=b?"0px":this.frozenTabs.style.width;
3289 d.style.width=((b?this.frozenTabs.offsetWidth:0)+(a?this.innerDiv.offsetWidth:0)-4)+"px";
3292 }d.style.top=(this.hdrHt+c.row*this.rowHeight-1)+"px";
3293 d.style.height=(this.rowHeight-1)+"px";
3295 },unhighlight:function(){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3296 }if(!this.highlightDiv){return
3299 a++){this.highlightDiv[a].style.display="none"
3301 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3302 }if(this.highlightDiv){this.highlightDiv[0].style.display="none"
3304 }},resetContents:function(){Rico.log("resetContents");
3305 this.ClearSelection();
3306 this.buffer.clear();
3308 this.clearBookmark()
3309 },setImages:function(){for(var a=0;
3310 a<this.columns.length;
3311 a++){this.columns[a].setImage()
3312 }},findSortedColumn:function(){for(var a=0;
3313 a<this.columns.length;
3314 a++){if(this.columns[a].isSorted()){return a
3316 },findColumnName:function(a){for(var b=0;
3317 b<this.columns.length;
3318 b++){if(this.columns[b].fieldName==a){return b
3320 },findColumnsBySpec:function(b,c){var a=[];
3322 d<this.options.columnSpecs.length;
3323 d++){if(this.options.columnSpecs[d][b]==c){a.push(d)
3325 },setSortUI:function(b,c){Rico.log("setSortUI: "+b+" "+c);
3326 var a=this.findSortedColumn();
3327 if(a>=0){c=this.columns[a].getSortDirection()
3328 }else{if(typeof c!="string"){c=Rico.ColumnConst.SORT_ASC
3329 }else{c=c.toUpperCase();
3330 if(c!=Rico.ColumnConst.SORT_DESC){c=Rico.ColumnConst.SORT_ASC
3331 }}switch(typeof b){case"string":a=this.findColumnName(b);
3335 }}if(typeof(a)!="number"||a<0){return
3337 this.columns[a].setSorted(c);
3338 this.buffer.sortBuffer(a)
3339 },clearSort:function(){for(var a=0;
3340 a<this.columns.length;
3341 a++){this.columns[a].setUnsorted()
3342 }},clearFilters:function(){for(var a=0;
3343 a<this.columns.length;
3344 a++){this.columns[a].setUnfiltered(true)
3345 }if(this.options.filterHandler){this.options.filterHandler()
3346 }},filterCount:function(){for(var a=0,b=0;
3347 a<this.columns.length;
3348 a++){if(this.columns[a].isFiltered()){b++
3350 },sortHandler:function(){this.cancelMenu();
3351 this.ClearSelection();
3353 var a=this.findSortedColumn();
3355 }Rico.log("sortHandler: sorting column "+a);
3356 this.buffer.sortBuffer(a);
3358 this.scrollDiv.scrollTop=0;
3359 this.buffer.fetch(0)
3360 },filterHandler:function(){Rico.log("filterHandler");
3362 if(this.buffer.processingRequest){this.queueFilter=true;
3364 }this.unplugScroll();
3365 this.ClearSelection();
3367 this.clearBookmark();
3369 this.buffer.fetch(-1);
3370 Rico.runLater(10,this,"pluginScroll")
3371 },clearBookmark:function(){if(this.bookmark){this.bookmark.innerHTML=" "
3372 }},bookmarkHandler:function(a,d){var b;
3373 if(isNaN(a)||!this.bookmark){return
3374 }var c=this.buffer.totalRows;
3376 }if(c<=0){b=Rico.getPhraseById("bookmarkNoMatch")
3377 }else{if(d<0){b=Rico.getPhraseById("bookmarkNoRec")
3378 }else{if(this.buffer.foundRowCount){b=Rico.getPhraseById("bookmarkExact",a,d,c)
3379 }else{b=Rico.getPhraseById("bookmarkAbout",a,d,c)
3380 }}}this.bookmark.innerHTML=b
3381 },clearRows:function(){if(this.isBlank==true){return
3383 a<this.columns.length;
3384 a++){this.columns[a].clearColumn()
3386 },refreshContents:function(j){Rico.log("refreshContents1 "+this.tableId+": startPos="+j+" lastRow="+this.lastRowPos+" PartBlank="+this.isPartialBlank+" pageSize="+this.pageSize);
3390 if(this.queueFilter){Rico.log("refreshContents: cancelling refresh because filter has changed");
3391 this.queueFilter=false;
3392 this.filterHandler();
3394 }this.highlightEnabled=this.options.highlightSection!="none";
3395 var h=this.buffer.startPos>j;
3396 var d=h?this.buffer.startPos:j;
3397 this.contentStartPos=d+1;
3398 var b=Math.min(this.buffer.startPos+this.buffer.size,j+this.pageSize);
3399 this.buffer.setWindow(d,b);
3400 Rico.log("refreshContents2 "+this.tableId+": cStartPos="+d+" cEndPos="+b+" vPrecedesBuf="+h+" b.startPos="+this.buffer.startPos);
3401 if(j==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3402 }this.isBlank=false;
3403 var m=this.options.onRefreshComplete;
3404 if((j+this.pageSize<this.buffer.startPos)||(this.buffer.startPos+this.buffer.size<j)||(this.buffer.size==0)){this.clearRows();
3405 if(m){m(this.contentStartPos,b)
3407 }Rico.log("refreshContents: contentStartPos="+d+" contentEndPos="+b+" viewPrecedesBuffer="+h);
3409 var f=this.pageSize-n;
3415 l<this.columns.length;
3416 l++){this.columns[l].displayValue(a+e)
3419 g++){this.blankRow(g+k)
3420 }if(this.options.highlightElem=="selection"){this.ShowSelection()
3421 }this.isPartialBlank=f>0;
3423 Rico.log("refreshContents complete, startPos="+j);
3424 if(m){m(this.contentStartPos,b)
3425 }},scrollToRow:function(a){var b=this.rowToPixel(a);
3426 Rico.log("scrollToRow, rowOffset="+a+" pixel="+b);
3427 this.scrollDiv.scrollTop=b;
3428 if(this.options.onscroll){this.options.onscroll(this,a)
3429 }},scrollUp:function(){this.moveRelative(-1)
3430 },scrollDown:function(){this.moveRelative(1)
3431 },pageUp:function(){this.moveRelative(-this.pageSize)
3432 },pageDown:function(){this.moveRelative(this.pageSize)
3433 },adjustRow:function(a){var b=this.topOfLastPage();
3434 if(b==0||!a){return 0
3435 }return Math.min(b,a)
3436 },rowToPixel:function(a){return this.adjustRow(a)*this.rowHeight
3437 },pixeltorow:function(c){var b=this.topOfLastPage();
3439 }var a=parseInt(c/this.rowHeight,10);
3440 return Math.min(b,a)
3441 },moveRelative:function(b){var a=Math.max(this.scrollDiv.scrollTop+b*this.rowHeight,0);
3442 a=Math.min(a,this.scrollDiv.scrollHeight);
3443 this.scrollDiv.scrollTop=a
3444 },pluginScroll:function(){if(this.scrollPluggedIn){return
3445 }Rico.log("pluginScroll: wheelEvent="+this.wheelEvent);
3446 Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3449 a++){Rico.eventBind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3450 }this.scrollPluggedIn=true
3451 },unplugScroll:function(){if(!this.scrollPluggedIn){return
3452 }Rico.log("unplugScroll");
3453 Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3456 a++){Rico.eventUnbind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3457 }this.scrollPluggedIn=false
3458 },handleWheel:function(a){var b=0;
3459 if(a.wheelDelta){if(Rico.isOpera){b=a.wheelDelta/120
3460 }else{if(Rico.isWebKit){b=-a.wheelDelta/12
3461 }else{b=-a.wheelDelta/120
3462 }}}else{if(a.detail){b=a.detail/3
3463 }}if(b){this.moveRelative(b)
3466 },handleScroll:function(g){if(this.scrollTimeout){clearTimeout(this.scrollTimeout)
3467 }this.setHorizontalScroll();
3468 var a=this.scrollDiv.scrollTop;
3469 var b=this.lastScrollPos-a;
3471 }var d=this.pixeltorow(a);
3472 if(d==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3474 Rico.log("handleScroll, newrow="+d+" scrtop="+a);
3475 if(this.options.highlightElem=="selection"){this.HideSelection()
3476 }this.buffer.fetch(d);
3477 if(this.options.onscroll){this.options.onscroll(this,d)
3478 }this.scrollTimeout=Rico.runLater(1200,this,"scrollIdle");
3479 this.lastScrollPos=this.scrollDiv.scrollTop;
3481 },scrollIdle:function(){if(this.options.onscrollidle){this.options.onscrollidle()
3483 Rico.LiveGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
3485 Rico.LiveGridColumn.prototype={initialize:function(liveGrid,colIdx,hdrInfo,tabIdx){Rico.extend(this,new Rico.TableColumnBase());
3486 this.baseInit(liveGrid,colIdx,hdrInfo,tabIdx);
3487 this.buffer=liveGrid.buffer;
3488 if(typeof(this.format.type)!="string"||this.format.EntryType=="tinyMCE"){this.format.type="raw"
3489 }if(typeof this.isNullable!="boolean"){this.isNullable=/number|date/.test(this.format.type)
3490 }this.isText=/raw|text|showTags/.test(this.format.type);
3491 Rico.log(" sortable="+this.sortable+" filterable="+this.filterable+" hideable="+this.hideable+" isNullable="+this.isNullable+" isText="+this.isText);
3492 this.fixHeaders(this.liveGrid.tableId,this.options.hdrIconsFirst);
3493 if(this["format_"+this.format.type]){this._format=this["format_"+this.format.type]
3494 }if(this.format.control){if(typeof this.format.control=="string"){this.format.control=eval(this.format.control)
3495 }for(var property in this.format.control){if(property.charAt(0)=="_"){Rico.log("Copying control property "+property+" to "+this);
3496 this[property]=this.format.control[property]
3497 }}}},sortAsc:function(){this.setColumnSort(Rico.ColumnConst.SORT_ASC)
3498 },sortDesc:function(){this.setColumnSort(Rico.ColumnConst.SORT_DESC)
3499 },setColumnSort:function(a){this.liveGrid.clearSort();
3501 if(this.liveGrid.options.saveColumnInfo.sort){this.liveGrid.setCookie()
3502 }if(this.options.sortHandler){this.options.sortHandler()
3503 }},isSortable:function(){return this.sortable
3504 },isSorted:function(){return this.currentSort!=Rico.ColumnConst.UNSORTED
3505 },getSortDirection:function(){return this.currentSort
3506 },toggleSort:function(){if(this.buffer&&this.buffer.totalRows==0){return
3507 }if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.sortDesc()
3508 }else{this.sortAsc()
3509 }},setUnsorted:function(){this.setSorted(Rico.ColumnConst.UNSORTED)
3510 },setSorted:function(a){this.currentSort=a
3511 },canFilter:function(){return this.filterable
3512 },getFilterText:function(){var c=[];
3514 b<this.filterValues.length;
3515 b++){var a=this.filterValues[b];
3516 c.push(a==""?Rico.getPhraseById("filterBlank"):a)
3517 }switch(this.filterOp){case"EQ":return"= "+c.join(", ");
3518 case"NE":return Rico.getPhraseById("filterNot",c.join(", "));
3519 case"LE":return"<= "+c[0];
3520 case"GE":return">= "+c[0];
3521 case"LIKE":return Rico.getPhraseById("filterLike",c[0]);
3522 case"NULL":return Rico.getPhraseById("filterEmpty");
3523 case"NOTNULL":return Rico.getPhraseById("filterNotEmpty")
3525 },getFilterQueryParm:function(){if(this.filterType==Rico.ColumnConst.UNFILTERED){return""
3526 }var a="&f["+this.index+"][op]="+this.filterOp;
3527 a+="&f["+this.index+"][len]="+this.filterValues.length;
3529 b<this.filterValues.length;
3530 b++){a+="&f["+this.index+"]["+b+"]="+escape(this.filterValues[b])
3532 },setUnfiltered:function(a){this.filterType=Rico.ColumnConst.UNFILTERED;
3533 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3534 }if(this.removeFilterFunc){this.removeFilterFunc()
3535 }if(this.options.filterHandler&&!a){this.options.filterHandler()
3536 }},setFilterEQ:function(){this.setUserFilter("EQ")
3537 },setFilterNE:function(){this.setUserFilter("NE")
3538 },addFilterNE:function(){this.filterValues.push(this.userFilter);
3539 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3540 }if(this.options.filterHandler){this.options.filterHandler()
3541 }},setFilterGE:function(){this.setUserFilter("GE")
3542 },setFilterLE:function(){this.setUserFilter("LE")
3543 },setFilterKW:function(a){if(a!=""&&a!=null){this.setFilter("LIKE",a,Rico.ColumnConst.USERFILTER)
3544 }else{this.setUnfiltered(false)
3545 }},setUserFilter:function(a){this.setFilter(a,this.userFilter,Rico.ColumnConst.USERFILTER)
3546 },setSystemFilter:function(a,b){this.setFilter(a,b,Rico.ColumnConst.SYSTEMFILTER)
3547 },setFilter:function(a,c,b,d){this.filterValues=typeof(c)=="object"?c:[c];
3550 if(b==Rico.ColumnConst.USERFILTER&&this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3551 }this.removeFilterFunc=d;
3552 if(this.options.filterHandler){this.options.filterHandler()
3553 }},isFiltered:function(){return this.filterType==Rico.ColumnConst.USERFILTER
3554 },filterChange:function(a){var b=Rico.eventElement(a);
3555 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
3556 }else{this.setFilter("EQ",b.value,Rico.ColumnConst.USERFILTER,function(){b.selectedIndex=0
3558 }},filterClear:function(a){this.filterField.value="";
3559 this.setUnfiltered()
3560 },filterKeypress:function(c){var a=Rico.eventElement(c);
3561 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
3562 }if(this.lastKeyFilter==a.value){return
3564 Rico.log("filterKeypress: "+this.index+" "+b);
3565 this.lastKeyFilter=b;
3566 if(b==""||b=="*"){this.setUnfiltered()
3567 }else{this.setFilter("LIKE",b,Rico.ColumnConst.USERFILTER,function(){a.value=""
3569 }},mFilterSelectClick:function(a){Rico.eventStop(a);
3570 if(this.mFilter.style.display!="none"){this.mFilterFinish(a);
3571 if(Rico.isIE&&Rico.ieVersion<=6){this.filterField.focus()
3572 }else{this.filterField.blur()
3573 }}else{var b=Rico.cumulativeOffset(this.filterField);
3574 this.mFilter.style.top=(b.top+this.filterField.offsetHeight)+"px";
3575 this.mFilter.style.left=b.left+"px";
3576 this.mFilter.style.width=Math.min(this.filterField.offsetWidth,parseInt(this.colWidth,10))+"px";
3577 Rico.show(this.mFilter);
3578 this.mFilterFocus.focus()
3579 }},mFilterFinish:function(g){if(!this.mFilterChange){Rico.hide(this.mFilter);
3581 }if(this.mFilterInputs[0].checked){this.mFilterReset();
3582 Rico.hide(this.mFilter);
3583 this.setUnfiltered();
3588 d<this.mFilterInputs.length;
3589 d++){if(this.mFilterInputs[d].checked){c.push(this.mFilterInputs[d].value);
3590 a.push(this.mFilterLabels[d].innerHTML)
3591 }}if(c.length>0){var f=a.join(", ");
3592 this.filterField.options[0].text=f;
3593 this.filterField.title=f;
3594 Rico.hide(this.mFilter);
3595 this.mFilterChange=false;
3597 this.setFilter("EQ",c,Rico.ColumnConst.USERFILTER,function(){b.mFilterReset()
3599 }else{alert("Please select at least one value")
3600 }},mFilterReset:function(){var a=this.mFilterLabels[0].innerHTML;
3601 this.filterField.options[0].text=a;
3602 this.filterField.title=a
3603 },mFilterAllClick:function(c){var a=this.mFilterInputs[0].checked;
3605 b<this.mFilterInputs.length;
3606 b++){this.mFilterInputs[b].checked=a
3607 }this.mFilterChange=true
3608 },mFilterOtherClick:function(a){this.mFilterInputs[0].checked=false;
3609 this.mFilterChange=true
3610 },format_text:function(a){if(typeof a!="string"){return" "
3611 }else{return Rico.stripTags(a)
3612 }},format_showTags:function(a){if(typeof a!="string"){return" "
3613 }else{return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")
3614 }},format_number:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3615 }else{return Rico.formatNumber(a,this.format)
3616 }},format_datetime:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3617 }else{var b=Rico.setISO8601(a);
3619 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3620 }},format_UTCasLocalTime:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3621 }else{var c=new Date();
3622 var b=Rico.setISO8601(a,-c.getTimezoneOffset());
3624 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3625 }},format_date:function(a){if(typeof a=="undefined"||a==null||a==""){return" "
3626 }else{var b=Rico.setISO8601(a);
3628 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDate")+(this.format.suffix||"")
3629 }},fixHeaders:function(d,e){if(this.sortable){var c=Rico.eventHandle(this,"toggleSort");
3630 switch(this.options.headingSort){case"link":var b=Rico.wrapChildren(this.hdrCellDiv,"ricoSort",undefined,"a");
3631 b.href="javascript:void(0)";
3632 Rico.eventBind(b,"click",c);
3634 case"hover":Rico.eventBind(this.hdrCellDiv,"click",c);
3636 }}this.imgFilter=document.createElement("span");
3637 this.imgFilter.style.display="none";
3638 this.imgFilter.className="rico-icon ricoLG_filterCol";
3639 this.imgSort=document.createElement("span");
3640 this.imgSort.style.display="none";
3641 this.imgSort.style.verticalAlign="top";
3642 if(e){this.hdrCellDiv.insertBefore(this.imgSort,this.hdrCellDiv.firstChild);
3643 this.hdrCellDiv.insertBefore(this.imgFilter,this.hdrCellDiv.firstChild)
3644 }else{this.hdrCellDiv.appendChild(this.imgFilter);
3645 this.hdrCellDiv.appendChild(this.imgSort)
3646 }if(!this.format.filterUI){Rico.eventBind(this.imgFilter,"click",Rico.eventHandle(this,"filterClick"),false)
3647 }},filterClick:function(a){if(this.filterType==Rico.ColumnConst.USERFILTER&&this.filterOp=="LIKE"){this.liveGrid.openKeyword(this.index)
3648 }},getValue:function(a){return this.buffer.getWindowCell(a,this.index)
3649 },getBufferAttr:function(a){return this.buffer.getWindowAttr(a,this.index)
3650 },setValue:function(b,a){this.buffer.setWindowValue(b,this.index,a)
3651 },_format:function(a){return a
3652 },_display:function(a,b){b.innerHTML=this._format(a)
3653 },_export:function(a){return this._format(a)
3654 },exportBuffer:function(a){return this._export(this.buffer.getValue(a,this.index))
3655 },displayValue:function(f){var a=this.getValue(f);
3656 if(a==null){this.clearCell(f);
3658 }var e=this.cell(f);
3659 this._display(a,e,f);
3660 var d=this.buffer.options.acceptAttr;
3661 if(d.length==0){return
3662 }var c=this.getBufferAttr(f);
3666 b++){c=c["_"+d[b]]||"";
3667 switch(d[b]){case"style":e.style.cssText=c;
3669 case"class":e.className=c;
3671 default:e["_"+d[b]]=c;
3674 Rico.TableColumn={};
3675 Rico.TableColumn.checkboxKey=function(a){this.initialize(a)
3677 Rico.TableColumn.checkboxKey.prototype={initialize:function(a){this._checkboxes=[];
3681 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
3682 this._spans[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
3684 Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
3685 },_onclick:function(c){var b=Event.element(c);
3686 var d=parseInt(b.id.substr((b.id.lastIndexOf("_",b.id.length)+1)));
3687 var a=this.getValue(d);
3688 if(b.checked){this._addChecked(a)
3689 }else{this._remChecked(a)
3690 }},_clear:function(b,c){var a=this._checkboxes[c];
3692 a.style.display="none";
3693 this._spans[c].innerHTML=""
3694 },_display:function(a,c,d){var b=this._checkboxes[d];
3696 b.checked=this._KeyHash[a];
3697 if(this._showKey){this._spans[d].innerHTML=a
3698 }},_SelectedKeys:function(){return Rico.keys(this._KeyHash)
3699 },_addChecked:function(a){this._KeyHash[a]=1
3700 },_remChecked:function(a){delete this._KeyHash[a]
3702 Rico.TableColumn.checkbox=function(b,c,a,d){this.initialize(b,c,a,d)
3704 Rico.TableColumn.checkbox.prototype={initialize:function(b,c,a,d){this._checkedValue=b;
3705 this._uncheckedValue=c;
3706 this._defaultValue=a||false;
3707 this._readOnly=d||false;
3709 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
3711 if(this._readOnly){this._checkboxes[b].disabled=true
3712 }else{Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
3713 }},_onclick:function(c){var a=Event.element(c);
3714 var d=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
3715 var b=a.checked?this._checkedValue:this._uncheckedValue;
3717 },_clear:function(b,c){var a=this._checkboxes[c];
3718 a.checked=this._defaultValue;
3719 a.style.display="none"
3720 },_display:function(a,c,d){var b=this._checkboxes[d];
3722 b.checked=(a==this._checkedValue)
3724 Rico.TableColumn.textbox=function(c,b,a){this.initialize(c,b,a)
3726 Rico.TableColumn.textbox.prototype={initialize:function(c,b,a){this._boxSize=c;
3728 this._readOnly=a||false;
3730 },_create:function(b,c){var a=Rico.createFormField(b,"input","text",this.liveGrid.tableId+"_txtbox_"+this.index+"_"+c);
3731 a.size=this._boxSize;
3732 a.maxLength=this._boxMaxLen;
3733 this._textboxes[c]=a;
3735 if(this._readOnly){a.disabled=true
3736 }else{Rico.eventBind(a,"change",Rico.eventHandle(this,"_onchange"))
3737 }},_onchange:function(b){var a=Event.element(b);
3738 var c=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
3739 this.setValue(c,a.value)
3740 },_clear:function(b,c){var a=this._textboxes[c];
3742 a.style.display="none"
3743 },_display:function(a,c,d){var b=this._textboxes[d];
3747 Rico.TableColumn.HighlightCell=function(a,c,e,b,d){this.initialize(a,c,e,b,d)
3749 Rico.TableColumn.HighlightCell.prototype={initialize:function(a,c,e,b,d){this._chkcol=a;
3752 this._highlightColor=e;
3753 this._highlightBackground=b
3754 },_clear:function(a,b){a.style.color="";
3755 a.style.backgroundColor="";
3756 a.innerHTML=" "
3757 },_display:function(b,d,e){var a=this.liveGrid.buffer.getWindowValue(e,this._chkcol);
3759 switch(this._chkop){case"!=":c=(a!=this._chkval);
3761 case">":c=(a>this._chkval);
3763 case"<":c=(a<this._chkval);
3765 case">=":c=(a>=this._chkval);
3767 case"<=":c=(a<=this._chkval);
3769 case"abs>":c=(Math.abs(a)>this._chkval);
3771 case"abs<":c=(Math.abs(a)<this._chkval);
3773 case"abs>=":c=(Math.abs(a)>=this._chkval);
3775 case"abs<=":c=(Math.abs(a)<=this._chkval);
3777 default:c=(a==this._chkval);
3779 }d.style.color=c?this._highlightColor:"";
3780 d.style.backgroundColor=c?this._highlightBackground:"";
3781 d.innerHTML=this._format(b)
3783 Rico.TableColumn.bgColor=function(){};
3784 Rico.TableColumn.bgColor.prototype={_clear:function(a,b){a.style.backgroundColor=""
3785 },_display:function(a,b,c){b.style.backgroundColor=a
3787 Rico.TableColumn.link=function(a,c,b){this.initialize(a,c,b)
3789 Rico.TableColumn.link.prototype={initialize:function(a,c,b){this._href=a;
3793 },_create:function(a,b){this._anchors[b]=Rico.createFormField(a,"a",null,this.liveGrid.tableId+"_a_"+this.index+"_"+b);
3794 if(this._target){this._anchors[b].target=this._target
3796 },_clear:function(a,b){this._anchors[b].href="";
3797 this._anchors[b].innerHTML=""
3798 },_display:function(b,d,f){var c=this.liveGrid.buffer;
3799 var a=this._href=="self"?b:this._href.replace(/\{\d+\}/g,function(g){var h=parseInt(g.substr(1),10);
3800 return encodeURIComponent(c.getWindowValue(f,h))
3802 var e=this._linktext||b;
3803 if(a&&e){this._anchors[f].href=a;
3804 this._anchors[f].innerHTML=e
3805 }else{this._clear(d,f)
3807 Rico.TableColumn.image=function(a,b){this.initialize(a,b)
3809 Rico.TableColumn.image.prototype={initialize:function(a,b){this._img=[];
3812 },_create:function(a,b){this._img[b]=Rico.createFormField(a,"img",null,this.liveGrid.tableId+"_img_"+this.index+"_"+b);
3814 },_clear:function(b,c){var a=this._img[c];
3815 a.style.display="none";
3817 },_display:function(b,c,d){var a=this._img[d];
3818 this._img[d].src=this._prefix+b+this._suffix;
3821 Rico.TableColumn.lookup=function(c,a,b){this.initialize(c,a,b)
3823 Rico.TableColumn.lookup.prototype={initialize:function(d,a,c){this._map=d;
3824 this._defaultCode=a||"";
3825 this._defaultDesc=c||" ";
3827 this._sortfunc=function(e){return b._sortvalue(e)
3830 this._descriptions=[]
3831 },_create:function(a,b){this._descriptions[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
3832 this._codes[b]=Rico.createFormField(a,"input","hidden",this.liveGrid.tableId+"_code_"+this.index+"_"+b);
3834 },_clear:function(a,b){this._codes[b].value=this._defaultCode;
3835 this._descriptions[b].innerHTML=this._defaultDesc
3836 },_sortvalue:function(a){return this._getdesc(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")
3837 },_getdesc:function(a){var b=this._map[a];
3838 return(typeof b=="string")?b:this._defaultDesc
3839 },_export:function(a){return this._getdesc(a)
3840 },_display:function(a,b,c){this._codes[c].value=a;
3841 this._descriptions[c].innerHTML=this._getdesc(a)
3843 Rico.TableColumn.MultiLine=function(){};
3844 Rico.TableColumn.MultiLine.prototype={_display:function(a,c,d){var b=document.createElement("div");
3845 b.innerHTML=this._format(a);
3846 b.style.height="100%";
3847 if(c.firstChild){c.replaceChild(b,c.firstChild)
3848 }else{c.appendChild(b)
3850 if(typeof Rico=="undefined"){throw ("GridMenu requires the Rico JavaScript framework")
3851 }Rico.GridMenu=function(a){this.initialize(a)
3853 Rico.GridMenu.prototype={initialize:function(a){this.options={width:"18em",dataMenuHandler:null};
3854 Rico.extend(this.options,a||{});
3855 Rico.extend(this,new Rico.Menu(this.options));
3856 this.sortmenu=new Rico.Menu({width:"15em"});
3857 this.filtermenu=new Rico.Menu({width:"22em"});
3858 this.exportmenu=new Rico.Menu({width:"24em"});
3859 this.hideshowmenu=new Rico.Menu({width:"22em"});
3861 this.sortmenu.createDiv();
3862 this.filtermenu.createDiv();
3863 this.exportmenu.createDiv();
3864 this.hideshowmenu.createDiv()
3865 },buildGridMenu:function(a,i){this.clearMenu();
3866 var o=this.liveGrid;
3869 var n=o.options.maxPrint;
3872 if(this.options.dataMenuHandler){var l=this.options.dataMenuHandler(o,a,i,b);
3873 if(!l){return(this.itemCount>0)
3874 }}if(d.sortable&&m>0){this.sortmenu.clearMenu();
3875 this.addSubMenuItem(Rico.getPhraseById("gridmenuSortBy",d.displayName),this.sortmenu,false);
3876 this.sortmenu.addMenuItemId("gridmenuSortAsc",function(){d.sortAsc()
3878 this.sortmenu.addMenuItemId("gridmenuSortDesc",function(){d.sortDesc()
3880 }this.filtermenu.clearMenu();
3881 if(d.canFilter()&&!d.format.filterUI&&(!b||d.filterType==Rico.ColumnConst.USERFILTER)){this.addSubMenuItem(Rico.getPhraseById("gridmenuFilterBy",d.displayName),this.filtermenu,false);
3882 d.userFilter=d.getValue(a);
3883 if(d.filterType==Rico.ColumnConst.USERFILTER){this.filtermenu.addMenuItemId("gridmenuRemoveFilter",function(){d.setUnfiltered(false)
3885 if(d.filterOp=="LIKE"){this.filtermenu.addMenuItemId("gridmenuChgKeyword",function(){o.openKeyword(i)
3887 }if(d.filterOp=="NE"&&!b){this.filtermenu.addMenuItemId("gridmenuExcludeAlso",function(){d.addFilterNE()
3889 }}else{if(!b){this.filtermenu.addMenuItemId("gridmenuInclude",function(){d.setFilterEQ()
3891 this.filtermenu.addMenuItemId("gridmenuGreaterThan",function(){d.setFilterGE()
3892 },d.userFilter!="");
3893 this.filtermenu.addMenuItemId("gridmenuLessThan",function(){d.setFilterLE()
3894 },d.userFilter!="");
3895 if(d.isText){this.filtermenu.addMenuItemId("gridmenuContains",function(){o.openKeyword(i)
3897 }this.filtermenu.addMenuItemId("gridmenuExclude",function(){d.setFilterNE()
3899 }}if(o.filterCount()>0){this.filtermenu.addMenuItemId("gridmenuRefresh",function(){o.filterHandler()
3901 this.filtermenu.addMenuItemId("gridmenuRemoveAll",function(){o.clearFilters()
3903 }}else{if(o.filterCount()>0){this.addSubMenuItem(Rico.getPhraseById("gridmenuFilterBy",d.displayName),this.filtermenu,false);
3904 this.filtermenu.addMenuItemId("gridmenuRemoveAll",function(){o.clearFilters()
3906 }}this.exportmenu.clearMenu();
3907 if(f.printVisibleSQL&&typeof(f.dataSource)=="string"){this.addSubMenuItem(Rico.getPhraseById("gridmenuExport"),this.exportmenu,false);
3908 this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisibleSQL("html")
3910 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAllSQL("html")
3912 this.exportmenu.addMenuBreak();
3913 this.exportmenu.addMenuItemId("gridmenuExportVis2SS",function(){f.printVisibleSQL("xl")
3915 this.exportmenu.addMenuItemId("gridmenuExportAll2SS",function(){f.printAllSQL("xl")
3917 }else{if(n>0&&m>0){this.addSubMenuItem(Rico.getPhraseById("gridmenuExport"),this.exportmenu,false);
3918 this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisible("plain")
3920 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAll("plain")
3922 if(Rico.isIE){this.exportmenu.addMenuBreak();
3923 this.exportmenu.addMenuItemId("gridmenuExportVis2SS",function(){f.printVisible("owc")
3925 this.exportmenu.addMenuItemId("gridmenuExportAll2SS",function(){f.printAll("owc")
3927 }}}var k=o.listInvisible();
3930 j++){if(k[j].canHideShow()){e++
3931 }}if(e>0||d.canHideShow()){this.hideshowmenu.clearMenu();
3932 this.addSubMenuItem(Rico.getPhraseById("gridmenuHideShow"),this.hideshowmenu,false);
3933 this.hideshowmenu.addMenuItemId("gridmenuChooseCols",function(){o.chooseColumns()
3935 var h=o.columns.length-k.length;
3936 var g=(h>1&&d.visible&&d.canHideShow());
3937 this.hideshowmenu.addMenuItem(Rico.getPhraseById("gridmenuHide",d.displayName),function(){d.hideColumn()
3939 if(k.length>1){this.hideshowmenu.addMenuItemId("gridmenuShowAll",function(){o.showAll()
3943 if(typeof Rico=="undefined"){throw ("LiveGridAjax requires the Rico JavaScript framework")
3944 }if(!Rico.Buffer){Rico.Buffer={}
3945 }Rico.Buffer.AjaxXML=function(c,b,a){this.initialize(c,b,a)
3947 Rico.Buffer.AjaxXML.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.Base());
3948 Rico.extend(this,Rico.Buffer.AjaxXMLMethods);
3950 this.options.bufferTimeout=20000;
3951 this.options.requestParameters=[];
3952 this.options.waitMsg=Rico.getPhraseById("waitForData");
3953 this.options.canFilter=true;
3954 this.options.fmt="xml";
3955 Rico.extend(this.options,b||{});
3956 this.ajaxOptions={parameters:null,method:"get"};
3957 Rico.extend(this.ajaxOptions,a||{});
3958 this.requestCount=0;
3959 this.processingRequest=false;
3960 this.pendingRequest=-2;
3961 this.fetchData=true;
3964 Rico.Buffer.AjaxXMLMethods={fetch:function(b){if(this.fetchData){this.foundRowCount=true;
3965 this.fetchData=false;
3966 this.processingRequest=true;
3967 this.liveGrid.showMsg(this.options.waitMsg);
3968 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
3969 this.ajaxOptions.parameters=this.formQueryHashXML(0,-1);
3970 Rico.log("sending request");
3972 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(c){a.ajaxUpdate(b,c)
3974 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
3975 }else{this.ajaxOptions.onComplete=function(d,f,c,e){a.jsUpdate(b,d,f,c,e)
3977 this.dataSource(this.ajaxOptions)
3978 }}else{if(b<0){this.applyFilters();
3979 this.setTotalRows(this.size);
3981 }this.liveGrid.refreshContents(b)
3982 }},handleTimedOut:function(){Rico.log("Request Timed Out");
3983 this.liveGrid.showMsg(Rico.getPhraseById("requestTimedOut"))
3984 },formQueryHashXML:function(e,c){var d={id:this.liveGrid.tableId,page_size:(typeof c=="number")?c:this.totalRows,offset:e.toString()};
3985 if(!this.foundRowCount){d.get_total="true"
3986 }if(this.options.requestParameters){for(var f=0;
3987 f<this.options.requestParameters.length;
3988 f++){var g=this.options.requestParameters[f];
3989 if(g.name!=undefined&&g.value!=undefined){d[g.name]=g.value
3990 }else{var b=g.indexOf("=");
3991 var h=g.substring(0,b);
3992 var a=g.substring(b+1);
3995 },clearTimer:function(){if(typeof this.timeoutHandler!="number"){return
3996 }window.clearTimeout(this.timeoutHandler);
3997 delete this.timeoutHandler
3998 },jsUpdate:function(a,c,f,b,d){this.clearTimer();
3999 this.processingRequest=false;
4000 Rico.log("jsUpdate: "+arguments.length);
4001 if(d){Rico.log("jsUpdate: received error="+d);
4002 this.liveGrid.showMsg(Rico.getPhraseById("requestError",d));
4004 }this.rcvdRows=c.length;
4005 if(typeof b=="number"){this.rowcntContent=b.toString();
4006 this.rcvdRowCount=true;
4007 this.foundRowCount=true;
4008 Rico.log("jsUpdate: found RowCount="+this.rowcntContent)
4009 }this.updateBuffer(a,c,f);
4010 if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
4011 }this.updateGrid(a);
4012 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
4013 }if(this.pendingRequest>=-1){var e=this.pendingRequest;
4014 Rico.log("jsUpdate: found pending request for offset="+e);
4015 this.pendingRequest=-2;
4017 }},ajaxUpdate:function(a,c){this.clearTimer();
4018 this.processingRequest=false;
4019 if(c.status!=200){Rico.log("ajaxUpdate: received http error="+c.status);
4020 this.liveGrid.showMsg(Rico.getPhraseById("httpError",c.status));
4022 }this._responseHandler=this["processResponse"+this.options.fmt.toUpperCase()];
4023 if(!this._responseHandler(a,c)){return
4024 }if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
4025 }this.updateGrid(a);
4026 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
4027 }if(this.pendingRequest>=-1){var b=this.pendingRequest;
4028 Rico.log("ajaxUpdate: found pending request for offset="+b);
4029 this.pendingRequest=-2;
4031 }},processResponseXML:function(k,f){var o=f.responseXML;
4032 if(f.responseText.substring(0,4)=="<!--"){var m=f.responseText.indexOf("-->");
4033 if(m==-1){this.liveGrid.showMsg("Web server error - client side debugging may be enabled");
4035 }o=Rico.createXmlDocument();
4036 o.loadXML(f.responseText.substring(m+3))
4037 }if(!o){alert("Data provider returned an invalid XML response");
4038 Rico.log("Data provider returned an invalid XML response");
4040 }var e=o.getElementsByTagName("ajax-response");
4041 if(e==null||e.length!=1){return false
4043 this.rcvdRowCount=false;
4045 var a=c.getElementsByTagName("debug");
4048 g++){Rico.log("ajaxUpdate: debug msg "+g+": "+Rico.getContentAsString(a[g],this.options.isEncoded))
4049 }var l=c.getElementsByTagName("error");
4050 if(l.length>0){var d=Rico.getContentAsString(l[0],this.options.isEncoded);
4051 alert("Data provider returned an error:\n"+d);
4052 Rico.log("Data provider returned an error:\n"+d);
4054 }var j=c.getElementsByTagName("rows")[0];
4055 if(!j){Rico.log("ajaxUpdate: invalid response");
4056 this.liveGrid.showMsg(Rico.getPhraseById("invalidResponse"));
4058 }var n=c.getElementsByTagName("rowcount");
4059 if(n&&n.length==1){this.rowcntContent=Rico.getContentAsString(n[0],this.options.isEncoded);
4060 this.rcvdRowCount=true;
4061 this.foundRowCount=true;
4062 Rico.log("ajaxUpdate: found RowCount="+this.rowcntContent)
4063 }this.updateUI=j.getAttribute("update_ui")=="true";
4064 this.rcvdOffset=j.getAttribute("offset");
4065 Rico.log("ajaxUpdate: rcvdOffset="+this.rcvdOffset);
4066 var h=this.dom2jstable(j);
4067 var b=(this.options.acceptAttr.length>0)?this.dom2jstableAttr(j):false;
4068 this.rcvdRows=h.length;
4069 this.updateBuffer(k,h,b);
4071 },processResponseJSON:function(a,d){var c=Rico.getJSON(d);
4072 if(!c||c==null){alert("Data provider returned an invalid JSON response");
4073 Rico.log("Data provider returned an invalid JSON response");
4075 }if(c.debug){for(var b=0;
4077 b++){Rico.writeDebugMsg("debug msg "+b+": "+c.debug[b])
4078 }}if(c.error){alert("Data provider returned an error:\n"+c.error);
4079 Rico.writeDebugMsg("Data provider returned an error:\n"+c.error);
4081 }if(c.rowcount){this.rowcntContent=c.rowcount;
4082 this.rcvdRowCount=true;
4083 this.foundRowCount=true;
4084 Rico.writeDebugMsg("loadRows, found RowCount="+c.rowcount)
4085 }this.rcvdRows=c.rows.length;
4086 this.updateBuffer(a,c.rows);
4088 },updateBuffer:function(c,a,b){this.baseRows=a;
4090 Rico.log("updateBuffer: # of rows="+this.rcvdRows);
4091 this.rcvdRowCount=true;
4092 this.rowcntContent=this.rcvdRows;
4093 if(typeof this.delayedSortCol=="number"){this.sortBuffer(this.delayedSortCol)
4094 }this.applyFilters();
4096 },updateGrid:function(f){Rico.log("updateGrid, size="+this.size+" rcv cnt type="+typeof(this.rowcntContent));
4098 if(this.rcvdRowCount==true){Rico.log("found row cnt: "+this.rowcntContent);
4099 var d=parseInt(this.rowcntContent,10);
4100 var b=this.totalRows;
4101 if(!isNaN(d)&&d!=b){this.setTotalRows(d);
4102 e=Math.min(this.liveGrid.topOfLastPage(),f);
4103 Rico.log("updateGrid: new rowcnt="+d+" newpos="+e);
4104 if(b==0&&this.liveGrid.sizeTo=="data"){Rico.runLater(100,this.liveGrid,"adjustPageSize")
4105 }this.liveGrid.scrollToRow(e);
4106 if(this.isInRange(e)){this.liveGrid.refreshContents(e)
4109 }}else{var a=f+this.rcvdRows;
4110 if(a>this.totalRows){var c=a;
4111 Rico.log("extending totrows to "+c);
4112 this.setTotalRows(c)
4113 }}e=this.liveGrid.pixeltorow(this.liveGrid.scrollDiv.scrollTop);
4114 Rico.log("updateGrid: newpos="+e);
4115 this.liveGrid.refreshContents(e)
4117 Rico.Buffer.AjaxSQL=function(c,b,a){this.initialize(c,b,a)
4119 Rico.Buffer.AjaxSQL.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.AjaxXML());
4120 Rico.extend(this,Rico.Buffer.AjaxSQLMethods);
4122 this.options.canFilter=true;
4123 this.options.largeBufferSize=7;
4124 this.options.nearLimitFactor=1;
4125 Rico.extend(this.options,b||{});
4126 Rico.extend(this.ajaxOptions,a||{})
4128 Rico.Buffer.AjaxSQLMethods={registerGrid:function(a){this.liveGrid=a;
4129 this.sessionExpired=false;
4130 this.timerMsg=document.getElementById(a.tableId+"_timer");
4131 if(this.options.TimeOut&&this.timerMsg){if(!this.timerMsg.title){this.timerMsg.title=Rico.getPhraseById("sessionExpireMinutes")
4132 }this.restartSessionTimer()
4133 }},setBufferSize:function(a){this.maxFetchSize=Math.max(50,parseInt(this.options.largeBufferSize*a,10));
4134 this.nearLimit=parseInt(this.options.nearLimitFactor*a,10);
4135 this.maxBufferSize=this.maxFetchSize*3
4136 },restartSessionTimer:function(){if(this.sessionExpired==true){return
4137 }this.sessionEndTime=(new Date()).getTime()+this.options.TimeOut*60000;
4138 if(this.sessionTimer){clearTimeout(this.sessionTimer)
4139 }this.updateSessionTimer()
4140 },updateSessionTimer:function(){var b=(new Date()).getTime();
4141 if(b>this.sessionEndTime){this.displaySessionTimer(Rico.getPhraseById("sessionExpired"));
4142 this.timerMsg.style.backgroundColor="red";
4143 this.sessionExpired=true
4144 }else{var a=Math.ceil((this.sessionEndTime-b)/60000);
4145 this.displaySessionTimer(a);
4146 this.sessionTimer=Rico.runLater(10000,this,"updateSessionTimer")
4147 }},displaySessionTimer:function(a){this.timerMsg.innerHTML=" "+a+" "
4148 },refresh:function(b){var a=this.liveGrid.lastRowPos;
4150 if(b){this.setTotalRows(0);
4151 this.foundRowCount=false
4152 }this.liveGrid.clearBookmark();
4153 this.liveGrid.clearRows();
4155 },fetch:function(e){Rico.log("AjaxSQL fetch: offset="+e+", lastOffset="+this.lastOffset);
4156 if(this.processingRequest){Rico.log("AjaxSQL fetch: queue request");
4157 this.pendingRequest=e;
4159 }if(e<0){this.clear();
4160 this.setTotalRows(0);
4161 this.foundRowCount=false;
4163 }var d=this.lastOffset;
4165 if(this.isInRange(e)){Rico.log("AjaxSQL fetch: in buffer");
4166 this.liveGrid.refreshContents(e);
4167 if(e>d){if(e+this.liveGrid.pageSize<this.endPos()-this.nearLimit){return
4168 }if(this.endPos()==this.totalRows&&this.foundRowCount){return
4169 }}else{if(e<d){if(e>this.startPos+this.nearLimit){return
4170 }if(this.startPos==0){return
4172 }}}if(e>=this.totalRows&&this.foundRowCount){return
4173 }this.processingRequest=true;
4174 Rico.log("AjaxSQL fetch: processing offset="+e);
4175 var c=this.getFetchOffset(e);
4176 var a=this.getFetchSize(c);
4178 this.liveGrid.showMsg(this.options.waitMsg);
4179 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
4180 this.ajaxOptions.parameters=this.formQueryHashSQL(c,a,this.options.fmt);
4181 this.requestCount++;
4182 Rico.log("sending req #"+this.requestCount);
4184 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(g){b.ajaxUpdate(c,g)
4186 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
4187 }else{this.ajaxOptions.onComplete=function(h,j,g,i){b.jsUpdate(c,h,j,g,i)
4189 this.dataSource(this.ajaxOptions)
4190 }},formQueryHashSQL:function(g,h,d){var k=this.formQueryHashXML(g,h);
4191 k[this.liveGrid.actionId]="query";
4193 }Rico.extend(k,this.sortParm);
4195 b<this.liveGrid.columns.length;
4196 b++){var j=this.liveGrid.columns[b];
4197 if(j.filterType==Rico.ColumnConst.UNFILTERED){continue
4198 }var a=typeof(j.format.filterCol)=="number"?j.format.filterCol:j.index;
4199 k["f["+a+"][op]"]=j.filterOp;
4200 k["f["+a+"][len]"]=j.filterValues.length;
4202 e<j.filterValues.length;
4203 e++){var f=j.filterValues[e];
4204 if(j.filterOp=="LIKE"&&f.indexOf("*")==-1){f="*"+f+"*"
4205 }k["f["+a+"]["+e+"]"]=f
4207 },getFetchSize:function(a){var b=0;
4208 if(a>=this.startPos){var c=this.maxFetchSize+a;
4210 if(a==0&&b<this.maxFetchSize){b=this.maxFetchSize
4211 }Rico.log("getFetchSize/append, adjustedSize="+b+" adjustedOffset="+a+" endFetchOffset="+c)
4212 }else{b=Math.min(this.startPos-a,this.maxFetchSize)
4214 },getFetchOffset:function(b){var a=b;
4215 if(b>this.startPos){a=Math.max(b,this.endPos())
4216 }else{if(b+this.maxFetchSize>=this.startPos){a=Math.max(this.startPos-this.maxFetchSize,0)
4218 },updateBuffer:function(d,a,b){Rico.log("updateBuffer: start="+d+", # of rows="+this.rcvdRows);
4219 if(this.rows.length==0){this.rows=a;
4222 }else{if(d>this.startPos){if(this.startPos+this.rows.length<d){this.rows=a;
4225 }else{this.rows=this.rows.concat(a.slice(0,a.length));
4226 if(this.attr){this.attr=this.attr.concat(b.slice(0,b.length))
4227 }if(this.rows.length>this.maxBufferSize){var c=this.rows.length;
4228 this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length);
4229 if(this.attr){this.attr=this.attr.slice(this.attr.length-this.maxBufferSize,this.attr.length)
4230 }this.startPos=this.startPos+(c-this.rows.length)
4231 }}}else{if(d+a.length<this.startPos){this.rows=a
4232 }else{this.rows=a.slice(0,this.startPos).concat(this.rows);
4233 if(this.maxBufferSize&&this.rows.length>this.maxBufferSize){this.rows=this.rows.slice(0,this.maxBufferSize)
4235 }}this.size=this.rows.length
4236 },sortBuffer:function(b){this.sortParm={};
4237 var a=this.liveGrid.columns[b];
4238 if(this.options.sortParmFmt){this.sortParm.sort_col=a[this.options.sortParmFmt];
4239 this.sortParm.sort_dir=a.getSortDirection()
4240 }else{this.sortParm["s"+b]=a.getSortDirection()
4242 },printAllSQL:function(a){var c=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint,a);
4243 c.hidden=this.liveGrid.listInvisible("index").join(",");
4244 var b=this.dataSource+"?"+Rico.toQueryString(c);
4245 window.open(b,"",this.liveGrid.options.exportWindow)
4246 },printVisibleSQL:function(a){var c=this.formQueryHashSQL(this.liveGrid.contentStartPos-1,this.liveGrid.pageSize,a);
4247 c.hidden=this.liveGrid.listInvisible("index").join(",");
4248 var b=this.dataSource+"?"+Rico.toQueryString(c);
4249 window.open(b,"",this.liveGrid.options.exportWindow)
4250 },_printAll:function(a){this.liveGrid.exportStart();
4251 this.ajaxOptions.parameters=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint);
4253 this.ajaxOptions.onComplete=function(){b._jsExport(a)
4255 this.dataSource(this.ajaxOptions)
4256 },_jsExport:function(a,c,e,b,d){Rico.log("_jsExport: "+arguments.length);
4257 if(d){Rico.log("_jsExport: received error="+d);
4258 this.liveGrid.showMsg(Rico.getPhraseById("requestError",d));
4260 }this.exportBuffer(c,0);
4261 this.liveGrid.exportFinish(a)
4263 if(typeof Rico=="undefined"){throw ("LiveGridForms requires the Rico JavaScript framework")
4264 }Rico.TableEdit=function(a){this.initialize(a)
4266 Rico.TableEdit.prototype={initialize:function(b){Rico.log("Rico.TableEdit initialize: "+b.tableId);
4268 this.options={maxDisplayLen:20,panelHeight:200,panelWidth:500,compact:false,RecordName:Rico.getPhraseById("record"),updateURL:window.location.href,showSaveMsg:"errors"};
4269 Rico.extend(this.options,b.options);
4271 this.hasWF2=(document.implementation&&document.implementation.hasFeature&&document.implementation.hasFeature("WebForms","2.0"));
4273 this.menu.options.dataMenuHandler=function(d,f,g,e){return a.editMenu(d,f,g,e)
4275 this.menu.ignoreClicks();
4276 this.editText=Rico.getPhraseById("editRecord",this.options.RecordName);
4277 this.cloneText=Rico.getPhraseById("cloneRecord",this.options.RecordName);
4278 this.delText=Rico.getPhraseById("deleteRecord",this.options.RecordName);
4279 this.addText=Rico.getPhraseById("addRecord",this.options.RecordName);
4280 this.buttonHover=new Rico.HoverSet();
4281 this.dateRegExp=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
4282 Rico.EditControls.atLoad();
4283 this.createKeyArray();
4284 this.createEditDiv();
4285 this.saveMsg=Rico.$(b.tableId+"_savemsg");
4286 Rico.eventBind(document,"click",Rico.eventHandle(this,"clearSaveMsg"));
4287 this.extraMenuItems=[];
4288 this.responseHandler=function(){a.processResponse()
4290 Rico.log("Rico.TableEdit.initialize complete, hasWF2="+this.hasWF2)
4291 },createKeyArray:function(){this.keys=[];
4293 a<this.grid.columns.length;
4294 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.isKey){this.keys.push({colidx:a})
4295 }}},createEditDiv:function(){this.requestCount=1;
4296 this.formPopup=new Rico.Window("",{overflow:this.options.panels?"hidden":"auto"});
4297 Rico.addClass(this.formPopup.content,"ricoLG_editDiv");
4298 if(this.options.canEdit||this.options.canAdd){this.startForm();
4299 this.createForm(this.form)
4300 }else{var a=this.createButton(Rico.getPhraseById("close"));
4301 Rico.eventBind(a,"click",Rico.eventHandle(this,"cancelEdit"),false);
4302 this.createForm(this.formPopup.contentDiv)
4303 }this.editDivCreated=true;
4304 this.responseDialog=this.grid.createDiv("editResponse",document.body);
4305 this.responseDialog.style.display="none";
4306 var b=document.createElement("button");
4307 b.appendChild(document.createTextNode("OK"));
4308 Rico.eventBind(b,"click",Rico.eventHandle(this,"ackResponse"));
4309 this.responseDialog.appendChild(b);
4310 this.responseDiv=this.grid.createDiv("editResponseText",this.responseDialog);
4311 if(this.panelGroup){Rico.log("createEditDiv complete, requestCount="+this.requestCount);
4312 Rico.runLater(50,this,"initPanelGroup")
4313 }},initPanelGroup:function(){this.requestCount--;
4314 Rico.log("initPanelGroup: "+this.requestCount);
4315 if(this.requestCount>0){return
4316 }var a=parseInt(this.options.panelWidth,10);
4317 if(this.form){if(Rico.isWebKit){this.formPopup.container.style.display="block"
4318 }this.options.bgColor=Rico.Color.createColorFromBackground(this.form).toString()
4319 }this.formPopup.container.style.display="none";
4320 this.formPanels=new Rico.TabbedPanel(this.panelGroup,this.options)
4321 },notEmpty:function(a){return typeof(a)!="undefined"
4322 },startForm:function(){this.form=document.createElement("form");
4323 this.form.onsubmit=function(){return false
4325 this.form.autocomplete="off";
4326 this.formPopup.contentDiv.appendChild(this.form);
4327 var e=document.createElement("div");
4328 e.className="ButtonBar";
4329 var d=e.appendChild(this.createButton(Rico.getPhraseById("saveRecord",this.options.RecordName)));
4330 Rico.eventBind(d,"click",Rico.eventHandle(this,"TESubmit"),false);
4331 d=e.appendChild(this.createButton(Rico.getPhraseById("cancel")));
4332 Rico.eventBind(d,"click",Rico.eventHandle(this,"cancelEdit"),false);
4333 this.form.appendChild(e);
4334 this.hiddenFields=document.createElement("div");
4335 this.hiddenFields.style.display="none";
4336 this.action=this.appendHiddenField(this.grid.actionId,"");
4339 c<this.grid.columns.length;
4340 c++){a=this.grid.columns[c].format;
4341 if(a&&a.FormView&&a.FormView=="hidden"){this.appendHiddenField(a.FieldName,a.ColData)
4344 b++){this.keys[b].keyField=this.appendHiddenField("_k"+this.keys[b].colidx,"")
4345 }this.form.appendChild(this.hiddenFields)
4346 },createButton:function(b){var a=document.createElement("a");
4347 a.href="javascript:void(0)";
4349 a.className="RicoButton";
4350 if(Rico.theme.button){Rico.addClass(a,Rico.theme.button)
4351 }this.buttonHover.add(a);
4353 },createPanel:function(c){var e=false;
4355 b<this.grid.columns.length;
4356 b++){var a=this.grid.columns[b].format;
4358 }if(!a.EntryType){continue
4359 }if(a.EntryType=="H"){continue
4360 }if(a.FormView&&a.FormView=="hidden"){continue
4361 }var d=a.panelIdx||0;
4364 }}if(!e){return null
4365 }this.panelHdr[c]=document.createElement("li");
4366 this.panelHdr[c].innerHTML=this.options.panels[c];
4367 this.panelHdrs.appendChild(this.panelHdr[c]);
4368 this.panelContent[c]=document.createElement("div");
4369 this.panelContents.appendChild(this.panelContent[c]);
4370 this.panelActualIdx[c]=this.panelCnt++;
4371 return this.createFormTable(this.panelContent[c],"tabContent")
4372 },createForm:function(e){var c,f,a,d,b=[];
4375 this.panelContent=[];
4376 if(this.options.panels){this.panelGroup=document.createElement("div");
4377 this.panelGroup.className="tabPanelGroup";
4378 this.panelHdrs=document.createElement("ul");
4379 this.panelGroup.appendChild(this.panelHdrs);
4380 this.panelContents=document.createElement("div");
4381 this.panelContents.className="tabContentContainer";
4382 this.panelGroup.appendChild(this.panelContents);
4383 this.panelActualIdx=[];
4384 e.appendChild(this.panelGroup);
4385 if(this.grid.direction=="rtl"){for(c=this.options.panels.length-1;
4387 c--){b[c]=this.createPanel(c)
4389 c<this.options.panels.length;
4390 c++){b[c]=this.createPanel(c)
4391 }}e.appendChild(this.panelGroup)
4392 }else{f=document.createElement("div");
4393 f.className="noTabContent";
4394 b[0]=this.createFormTable(f);
4397 c<this.grid.columns.length;
4398 c++){a=this.grid.columns[c].format;
4401 if(b[d]){this.appendFormField(this.grid.columns[c],b[d])
4402 }if(typeof a.pattern=="string"){switch(a.pattern){case"email":a.regexp=/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
4404 case"float-unsigned":a.regexp=/^\d+(\.\d+)?$/;
4406 case"float-signed":a.regexp=/^[-+]?\d+(\.\d+)?$/;
4408 case"int-unsigned":a.regexp=/^\d+$/;
4410 case"int-signed":a.regexp=/^[-+]?\d+$/;
4412 default:a.regexp=new RegExp(a.pattern);
4414 }}}},createFormTable:function(b){var a=document.createElement("table");
4418 },appendHiddenField:function(a,b){var c=Rico.createFormField(this.hiddenFields,"input","hidden",a,a);
4421 },appendFormField:function(c,i){var b=c.format;
4422 if(!b.EntryType){return
4423 }if(b.EntryType=="H"){return
4424 }if(b.FormView){return
4425 }Rico.log("appendFormField: "+c.displayName+" - "+b.EntryType);
4426 var j=b.noFormBreak&&i.rows.length>0?i.rows[i.rows.length-1]:i.insertRow(-1);
4427 var h=j.insertCell(-1);
4429 if(h.noWrap){h.noWrap=true
4430 }var f=j.insertCell(-1);
4431 if(f.noWrap){f.noWrap=true
4432 }h.id="lbl_"+b.FieldName;
4433 var e,a=b.FieldName;
4434 switch(b.EntryType){case"TA":case"tinyMCE":e=Rico.createFormField(f,"textarea",null,a);
4435 e.cols=b.TxtAreaCols;
4436 e.rows=b.TxtAreaRows;
4437 e.innerHTML=b.ColData;
4438 h.style.verticalAlign="top";
4440 case"R":case"RL":e=Rico.createFormField(f,"div",null,a);
4441 if(b.DescriptionField){e.RicoUpdate=b.DescriptionField
4442 }if(b.MultiSelect){Rico.addClass(e,"MultiSelect")
4443 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4444 }this.selectValuesRequest(e,c);
4446 case"N":e=Rico.createFormField(f,"select",null,a);
4447 if(b.isNullable){this.addSelectNone(e)
4448 }Rico.eventBind(e,"change",Rico.eventHandle(this,"checkSelectNew"));
4449 this.selectValuesRequest(e,c);
4450 e=document.createElement("span");
4451 e.className="ricoEditLabel";
4452 e.id="labelnew__"+b.FieldName;
4453 e.innerHTML=" "+Rico.getPhraseById("formNewValue").replace(" "," ");
4455 a="textnew__"+b.FieldName;
4456 e=Rico.createFormField(f,"input","text",a,a);
4458 case"S":case"SL":if(b.ReadOnly){e=Rico.createFormField(f,"input","text",a,a);
4460 }else{e=Rico.createFormField(f,"select",null,a);
4461 if(b.MultiSelect){e.multiple=true
4462 }if(b.SelectRows){e.size=parseInt(b.SelectRows,10)
4463 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4464 }if(b.DescriptionField){e.RicoUpdate=b.DescriptionField;
4465 Rico.eventBind(e,"change",Rico.eventHandle(this,"selectClick"),false)
4466 }this.selectValuesRequest(e,c)
4468 case"D":if(!b.isNullable){b.required=true
4469 }if(!b.dateFmt){b.dateFmt=Rico.dateFmt
4470 }if(!b.Help){b.Help=b.dateFmt
4471 }if(typeof b.min=="string"){b.min=Rico.setISO8601(b.min)||new Date(b.min)
4472 }if(typeof b.max=="string"){b.max=Rico.setISO8601(b.max)||new Date(b.max)
4473 }if(this.hasWF2){e=Rico.createFormField(f,"input","date",a,a);
4474 e.required=b.required;
4475 if(b.min){e.min=Rico.toISO8601String(b.min,3)
4476 }if(b.max){e.max=Rico.toISO8601String(b.max,3)
4477 }e.required=b.required;
4479 }else{e=Rico.createFormField(f,"input","text",a,a)
4480 }this.initField(e,b);
4482 case"I":if(!b.isNullable){b.required=true
4483 }if(!b.pattern){b.pattern="int-signed"
4484 }if(this.hasWF2){e=Rico.createFormField(f,"input","number",a,a);
4485 e.required=b.required;
4489 }else{e=Rico.createFormField(f,"input","text",a,a)
4490 }if(typeof b.min=="string"){b.min=parseInt(b.min,10)
4491 }if(typeof b.max=="string"){b.max=parseInt(b.max,10)
4492 }this.initField(e,b);
4494 case"F":if(!b.isNullable){b.required=true
4495 }if(!b.pattern){b.pattern="float-signed"
4496 }e=Rico.createFormField(f,"input","text",a,a);
4497 this.initField(e,b);
4498 if(typeof b.min=="string"){b.min=parseFloat(b.min)
4499 }if(typeof b.max=="string"){b.max=parseFloat(b.max)
4501 default:e=Rico.createFormField(f,"input","text",a,a);
4502 if(!b.isNullable&&b.EntryType!="T"){b.required=true
4503 }this.initField(e,b);
4505 }if(e){if(b.SelectCtl){Rico.EditControls.applyTo(c,e)
4507 h.className="ricoEditLabel";
4508 if(b.Help){h.title=b.Help;
4509 g=" <span class='rico-icon rico-info'></span>"
4510 }var d=b.EntryType.length>1&&b.EntryType.charAt(1)=="L"?c.next.displayName:c.displayName;
4512 },addSelectNone:function(a){this.addSelectOption(a,this.options.TableSelectNone,Rico.getPhraseById("selectNone"))
4513 },initField:function(b,a){if(a.Length){b.maxLength=a.Length;
4514 b.size=Math.min(a.Length,this.options.maxDisplayLen)
4516 },selectClick:function(c){var b=Rico.eventElement(c);
4517 if(b.readOnly){Rico.eventStop(c);
4519 }if(b.RicoUpdate){var a=b.options[b.selectedIndex];
4520 Rico.$(b.RicoUpdate).value=a.innerHTML
4521 }},radioClick:function(c){var b=Rico.eventElement(c);
4522 if(b.readOnly){Rico.eventStop(c);
4524 }var a=Rico.getParentByTagName(b,"div");
4525 if(a.RicoUpdate){Rico.$(a.RicoUpdate).value=b.nextSibling.innerHTML
4526 }},checkSelectNew:function(a){this.updateSelectNew(Rico.eventElement(a))
4527 },updateSelectNew:function(b){var a=(b.value==this.options.TableSelectNew)?"":"hidden";
4528 Rico.$("labelnew__"+b.id).style.visibility=a;
4529 Rico.$("textnew__"+b.id).style.visibility=a
4530 },selectValuesRequest:function(g,f){var a=f.format;
4531 if(a.SelectValues){var b=a.SelectValues.split(",");
4534 e++){this.addSelectOption(g,b[e],b[e],e)
4535 }}else{this.requestCount++;
4537 Rico.extend(d,this.grid.buffer.ajaxOptions);
4538 d.parameters={id:this.grid.tableId,offset:"0",page_size:"-1",edit:f.index};
4539 d.parameters[this.grid.actionId]="query";
4540 d.onComplete=function(h){c.selectValuesUpdate(g,h)
4542 new Rico.ajaxRequest(this.grid.buffer.dataSource,d);
4543 Rico.log("selectValuesRequest: "+a.FieldName)
4544 }},selectValuesUpdate:function(a,c){var b=c.responseXML.getElementsByTagName("ajax-response");
4545 Rico.log("selectValuesUpdate: "+c.status);
4546 if(b==null||b.length!=1){return
4548 var j=b.getElementsByTagName("error");
4549 if(j.length>0){var g=Rico.getContentAsString(j[0],this.grid.buffer.isEncoded);
4550 Rico.log("Data provider returned an error:\n"+g);
4551 alert(Rico.getPhraseById("requestError",g));
4553 }b=b.getElementsByTagName("response")[0];
4554 var h=b.getElementsByTagName("rows")[0];
4555 var k=this.grid.buffer.dom2jstable(h);
4556 Rico.log("selectValuesUpdate: id="+a.id+" rows="+k.length);
4559 e++){if(k[e].length>0){var f=k[e][0];
4560 var d=(k[e].length>1)?k[e][1]:f;
4561 this.addSelectOption(a,f,d,e)
4562 }}if(Rico.$("textnew__"+a.id)){this.addSelectOption(a,this.options.TableSelectNew,Rico.getPhraseById("selectNewVal"))
4563 }if(this.panelGroup){Rico.runLater(50,this,"initPanelGroup")
4564 }},addSelectOption:function(c,e,f,a){switch(c.tagName.toLowerCase()){case"div":var b=Rico.createFormField(c,"input",Rico.hasClass(c,"MultiSelect")?"checkbox":"radio",c.id+"_"+a,c.id);
4566 var d=document.createElement("label");
4570 Rico.eventBind(b,"click",Rico.eventHandle(this,"radioClick"),false);
4572 case"select":Rico.addSelectOption(c,e,f);
4574 }},clearSaveMsg:function(){if(this.saveMsg){this.saveMsg.innerHTML=""
4575 }},addMenuItem:function(c,b,a){this.extraMenuItems.push({menuText:c,menuAction:b,enabled:a})
4576 },editMenu:function(d,h,j,e){this.clearSaveMsg();
4577 if(this.grid.buffer.sessionExpired==true||this.grid.buffer.startPos<0){return false
4579 var g=Rico.$("pageTitle");
4580 var f=g?g.innerHTML:document.title;
4581 this.menu.addMenuHeading(f);
4583 if(e==false){for(var b=0;
4584 b<this.extraMenuItems.length;
4585 b++){this.menu.addMenuItem(this.extraMenuItems[b].menuText,this.extraMenuItems[b].menuAction,this.extraMenuItems[b].enabled)
4586 }this.menu.addMenuItem(this.editText,function(){a.editRecord()
4588 this.menu.addMenuItem(this.delText,function(){a.deleteRecord()
4589 },this.canDelete(h));
4590 if(this.options.canClone){this.menu.addMenuItem(this.cloneText,function(){a.cloneRecord()
4591 },this.canAdd(h)&&this.canEdit(h))
4592 }}this.menu.addMenuItem(this.addText,function(){a.addRecord()
4595 },canAdd:function(a){return(typeof this.options.canAdd=="function")?this.options.canAdd(a):this.options.canAdd
4596 },canEdit:function(a){return(typeof this.options.canEdit=="function")?this.options.canEdit(a):this.options.canEdit
4597 },canDelete:function(a){return(typeof this.options.canDelete=="function")?this.options.canDelete(a):this.options.canDelete
4598 },cancelEdit:function(b){Rico.eventStop(b);
4600 a<this.grid.columns.length;
4601 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.SelectCtl){Rico.EditControls.close(this.grid.columns[a].format.SelectCtl)
4602 }}this.makeFormInvisible();
4603 this.grid.highlightEnabled=true;
4604 this.menu.cancelmenu();
4606 },setField:function(g,m){var p=this.grid.columns[g].format;
4607 var k=Rico.$(p.FieldName);
4610 }Rico.log("setField: "+p.FieldName+"="+m);
4611 switch(k.tagName.toUpperCase()){case"DIV":c=k.getElementsByTagName("INPUT");
4613 if(p.MultiSelect&&m){n=m.split(",");
4620 j++){c[j].checked=f[c[j].value]==1
4622 case"INPUT":if(p.EntryType=="D"&&m!=p.ColData){n=m.split(/\s|T/);
4624 if(this.isTextInput(k)){var l=Rico.setISO8601(m);
4625 if(l){m=Rico.formatDate(l,p.dateFmt)
4628 case"SELECT":b=k.options;
4630 if(p.MultiSelect&&m){n=m.split(",");
4636 j++){b[j].selected=f[b[j].value]==1
4639 j++){if(b[j].value==m){k.selectedIndex=j;
4641 }}}if(p.EntryType=="N"){h=Rico.$("textnew__"+k.id);
4642 if(!h){alert('Warning: unable to find id "textnew__'+k.id+'"')
4644 if(k.selectedIndex!=j){k.selectedIndex=b.length-1
4645 }this.updateSelectNew(k)
4647 case"TEXTAREA":k.value=m;
4648 if(p.EntryType=="tinyMCE"&&typeof(tinyMCE)!="undefined"&&this.initialized){if(tinyMCE.updateContent){tinyMCE.updateContent(k.id)
4649 }else{tinyMCE.execInstanceCommand(k.id,"mceSetContent",false,m)
4651 }},setReadOnly:function(h){for(var g,f=0;
4652 f<this.grid.columns.length;
4653 f++){var b=this.grid.columns[f].format;
4655 }var k=Rico.$(b.FieldName);
4657 }switch(h){case"ins":g=!b.Writeable||b.ReadOnly||b.UpdateOnly;
4659 case"upd":g=!b.Writeable||b.ReadOnly||b.InsertOnly;
4663 }switch(k.tagName.toUpperCase()){case"DIV":var c=k.getElementsByTagName("INPUT");
4666 d++){c[d].disabled=g
4668 case"SELECT":if(b.EntryType=="N"){var a=Rico.$("textnew__"+k.id);
4672 case"TEXTAREA":case"INPUT":k.disabled=g;
4673 if(b.selectIcon){b.selectIcon.style.display=g?"none":""
4675 }}},hideResponse:function(a){this.responseDiv.innerHTML=a;
4676 this.responseDialog.style.display="none"
4677 },showResponse:function(){var a=Rico.cumulativeOffset(this.grid.outerDiv);
4678 a.top+=Rico.docScrollTop();
4679 this.responseDialog.style.top=a.top+"px";
4680 this.responseDialog.style.left=a.left+"px";
4681 this.responseDialog.style.display=""
4682 },processResponse:function(g){var d,f=true;
4683 Rico.log("Processing response from form submittal");
4684 this.responseDiv.innerHTML=g.responseText;
4685 var e=Rico.select(".ricoFormResponse",this.responseDiv);
4686 if(e){var c=Rico.trim(e[0].className).split(/\s+/)[1];
4687 d=Rico.getPhraseById(c,this.options.RecordName)
4688 }else{var b=this.responseDiv.childNodes;
4689 for(var a=b.length-1;
4691 a--){if(b[a].nodeType==1&&b[a].nodeName!="P"&&b[a].nodeName!="DIV"&&b[a].nodeName!="BR"){this.responseDiv.removeChild(b[a])
4692 }}d=Rico.stripTags(this.responseDiv.innerHTML);
4693 f=(d.toLowerCase().indexOf("error")==-1)
4694 }if(f&&this.options.showSaveMsg!="full"){this.hideResponse("");
4695 this.grid.resetContents();
4696 this.grid.buffer.foundRowCount=false;
4697 this.grid.buffer.fetch(this.grid.lastRowPos||0);
4698 if(this.saveMsg){this.saveMsg.innerHTML=" "+d+" "
4699 }}this.processCallback(this.options.onSubmitResponse);
4700 Rico.log("Processing response completed")
4701 },processCallback:function(callback){switch(typeof callback){case"string":return eval(callback);
4702 case"function":return callback()
4703 }},ackResponse:function(a){this.hideResponse("");
4704 this.grid.highlightEnabled=true
4705 },cloneRecord:function(){this.formPopup.setTitle(this.cloneText);
4706 this.displayEditForm("ins")
4707 },editRecord:function(){this.formPopup.setTitle(this.editText);
4708 this.displayEditForm("upd")
4709 },displayEditForm:function(e){this.grid.highlightEnabled=false;
4710 this.menu.cancelmenu();
4711 this.hideResponse(Rico.getPhraseById("saving"));
4712 this.grid.outerDiv.style.cursor="auto";
4713 this.action.value=e;
4715 d<this.grid.columns.length;
4716 d++){var f=this.grid.columns[d];
4717 if(f.format){var b=f.getValue(this.rowIdx);
4719 if(f.format.selectDesc){if(f.format.EntryType.length>1&&f.format.EntryType.charAt(1)=="L"){b=this.grid.columns[d+1].getValue(this.rowIdx)
4721 if(b===""){b=" "
4722 }f.format.selectDesc.innerHTML=b
4723 }if(f.format.SelectCtl){Rico.EditControls.displayClrImg(f,!f.format.InsertOnly)
4724 }}}this.setReadOnly(e);
4727 a++){this.keys[a].keyField.value=this.grid.buffer.getWindowValue(this.rowIdx,this.keys[a].colidx)
4728 }this.makeFormVisible(this.rowIdx)
4729 },addPrepare:function(){this.hideResponse(Rico.getPhraseById("saving"));
4731 this.setReadOnly("ins");
4732 this.action.value="ins";
4734 a<this.grid.columns.length;
4735 a++){var b=this.grid.columns[a];
4736 if(b.format){this.setField(a,b.format.ColData);
4737 if(b.format.SelectCtl){Rico.EditControls.resetValue(b);
4738 Rico.EditControls.displayClrImg(b,!b.format.UpdateOnly)
4739 }}}},addRecord:function(){this.menu.cancelmenu();
4740 this.formPopup.setTitle(this.addText);
4742 this.makeFormVisible(-1);
4743 if(this.formPanels){this.formPanels.select(0)
4744 }},drillDown:function(b,a,c){return this.grid.drillDown.apply(this.grid,arguments)
4745 },setDetailFilter:function(a,b){this.grid.setDetailFilter(a,b)
4746 },makeFormVisible:function(k){this.formPopup.container.style.display="block";
4747 var c=this.formPopup.container.offsetWidth;
4748 var h=Rico.cumulativeOffset(this.grid.outerDiv);
4749 var d=Rico.windowWidth();
4750 this.formPopup.container.style.left=c+h.left>d?(d-c)+"px":(h.left+1)+"px";
4751 var g=Rico.docScrollTop();
4752 var a=this.formPopup.container.offsetHeight;
4753 var f=h.top+this.grid.hdrHt+g;
4754 var b=Rico.windowHeight()+g;
4755 if(k>=0){f+=(k+1)*this.grid.rowHeight;
4756 if(f+a>b){f-=(a+this.grid.rowHeight)
4757 }}else{if(f+a>b){f=b-a-2
4758 }}if(this.processCallback(this.options.formOpen)===false){return
4759 }this.formPopup.openPopup(null,Math.max(f,g));
4760 this.formPopup.container.style.visibility="visible";
4761 Rico.EditControls.setZ(Rico.getStyle(this.formPopup.container,"zIndex"));
4762 if(this.initialized){return
4765 e<this.grid.columns.length;
4766 e++){j=this.grid.columns[e].format;
4767 if(!j||!j.EntryType||!j.FieldName){continue
4768 }switch(j.EntryType){case"tinyMCE":if(typeof tinyMCE!="undefined"){tinyMCE.execCommand("mceAddControl",true,j.FieldName)
4770 }}this.initialized=true
4771 },makeFormInvisible:function(){this.formPopup.container.style.visibility="hidden";
4772 this.formPopup.closePopup();
4773 this.processCallback(this.options.formClose)
4774 },getConfirmDesc:function(a){return Rico.stripTags(this.grid.cell(a,this.options.ConfirmDeleteCol).innerHTML).replace(" "," ")
4775 },deleteRecord:function(){this.menu.cancelmenu();
4777 switch(this.options.ConfirmDeleteCol){case -1:f=Rico.getPhraseById("thisRecord",this.options.RecordName);
4779 case -2:for(var b=0;
4781 b++){var c=this.keys[b].colidx;
4782 var a=this.grid.columns[c].format;
4783 if(a.EntryType.length>1&&a.EntryType.charAt(1)=="L"){c++
4784 }var e=Rico.stripTags(this.grid.cell(rowIdx,c).innerHTML).replace(/ /g," ");
4786 }f+=this.grid.columns[c].displayName+" "+e
4788 default:f='"'+Rico.truncate(this.getConfirmDesc(this.rowIdx),50)+'"';
4790 }if(!this.options.ConfirmDelete.valueOf||confirm(Rico.getPhraseById("confirmDelete",f))){this.hideResponse(Rico.getPhraseById("deleting"));
4791 this.showResponse();
4793 d[this.grid.actionId]="del";
4796 b++){var c=this.keys[b].colidx;
4797 var e=this.grid.columns[c].getValue(this.rowIdx);
4799 }new Rico.ajaxRequest(this.options.updateURL,{parameters:d,method:"post",onComplete:this.responseHandler})
4800 }this.menu.cancelmenu()
4801 },validationMsg:function(d,c,e){var b=this.grid.columns[c];
4802 if(this.formPanels){this.formPanels.select(this.panelActualIdx[b.format.panelIdx])
4803 }var a=Rico.stripTags(b.formLabel.innerHTML).replace(/ /g," ");
4804 var f=Rico.getPhraseById(e,' "'+a+'"');
4805 Rico.log(" Validation error: "+f);
4806 if(b.format.Help){f+="\n\n"+b.format.Help
4808 setTimeout(function(){try{d.focus();
4812 },isTextInput:function(a){if(!a){return false
4813 }if(a.tagName.toLowerCase()!="input"){return false
4814 }if(a.type.toLowerCase()!="text"){return false
4815 }if(a.readOnly){return false
4816 }if(!Rico.visible(a)){return false
4818 },parseDate:function(c,e){dateParts={};
4819 if(!this.dateRegExp.exec(e)){return NaN
4820 }dateParts[RegExp.$1]=0;
4821 dateParts[RegExp.$3]=1;
4822 dateParts[RegExp.$5]=2;
4823 var i=c.split(/\D/);
4825 var b=g.getFullYear();
4826 if(i.length==2&&dateParts.yyyy==2){i.push(b)
4827 }if(i.length!=3){return NaN
4828 }var a=parseInt(i[dateParts.dd],10);
4829 if(a==0||a>31){return NaN
4830 }var f=parseInt(i[dateParts.mm],10)-1;
4832 }var h=parseInt(i[dateParts.yyyy],10);
4833 if(h<100){h+=b-(b%100)
4834 }g.setFullYear(h,f,a);
4836 },TESubmit:function(j){var g,h,k,l,f,d,c=[];
4838 Rico.log("Event: TESubmit called to validate input");
4840 g<this.grid.columns.length;
4841 g++){l=this.grid.columns[g].format;
4842 if(!l||!l.EntryType||!l.FieldName){continue
4843 }f=Rico.$(l.FieldName);
4844 if(!this.isTextInput(f)){continue
4845 }switch(this.action.value){case"ins":h=!l.Writeable||l.ReadOnly||l.UpdateOnly;
4847 case"upd":h=!l.Writeable||l.ReadOnly||l.InsertOnly;
4852 }Rico.log(" Validating field #"+g+" EntryType="+l.EntryType+" ("+l.FieldName+")");
4853 if(f.value.length==0){if(l.required){return this.validationMsg(f,g,"formPleaseEnter")
4855 }}if(f.value.length>0&&l.regexp&&!l.regexp.test(f.value)){return this.validationMsg(f,g,"formInvalidFmt")
4856 }switch(l.EntryType.charAt(0)){case"I":d=parseInt(f.value,10);
4858 case"F":d=parseFloat(f.value);
4860 case"D":d=this.parseDate(f.value,l.dateFmt);
4861 if(isNaN(d)){return this.validationMsg(f,g,"formInvalidFmt")
4866 }if(typeof l.min!="undefined"&&!isNaN(d)&&d<l.min){return this.validationMsg(f,g,"formOutOfRange")
4867 }if(typeof l.max!="undefined"&&!isNaN(d)&&d>l.max){return this.validationMsg(f,g,"formOutOfRange")
4868 }}if(this.processCallback(this.options.formSubmit)===false){return false
4870 g<this.grid.columns.length;
4871 g++){l=this.grid.columns[g].format;
4872 if(!l||!l.EntryType||!l.FieldName){continue
4873 }if(l.EntryType.charAt(0)!="N"){continue
4874 }var a=Rico.$(l.FieldName);
4875 if(!a||a.value!=this.options.TableSelectNew){continue
4876 }var b=Rico.$("textnew__"+a.id).value;
4877 this.addSelectOption(a,b,b)
4880 g++){c[g].e.value=Rico.formatDate(c[g].v,"yyyy-mm-dd")
4881 }if(typeof tinyMCE!="undefined"){tinyMCE.triggerSave()
4882 }this.makeFormInvisible();
4884 this.menu.cancelmenu();
4886 },sendForm:function(){this.setReadOnly("reset");
4887 this.showResponse();
4888 Rico.log("sendForm: "+this.grid.tableId);
4889 Rico.ajaxSubmit(this.form,this.options.updateURL,{method:"post",onComplete:this.responseHandler})
4891 Rico.EditControls={widgetList:{},elemList:{},zIndex:0,register:function(b,c){this.widgetList[b.id]={imgsrc:c,widget:b,currentEl:""};
4893 b.returnValue=function(d,e){a.setValue(b,d,e)
4895 Rico.log("Rico.EditControls.register:"+b.id)
4896 },setZ:function(a){this.zIndex=Math.max(this.zIndex,a+10)
4897 },atLoad:function(){for(var b in this.widgetList){var a=this.widgetList[b].widget;
4898 if(a.atLoad&&!a.atLoadComplete){Rico.log("Rico.EditControls.atLoad: "+b);
4900 a.atLoadComplete=true
4901 }}},applyTo:function(e,f){var c=this.widgetList[e.format.SelectCtl];
4903 }Rico.log("Rico.EditControls.applyTo: "+e.displayName+" : "+e.format.SelectCtl);
4904 var a,d=document.createElement("span");
4905 if(c.imgsrc.indexOf(".")==-1&&c.imgsrc.indexOf("/")==-1){a=document.createElement("span");
4906 a.className=c.imgsrc
4907 }else{a=document.createElement("img");
4909 }a.style.verticalAlign="top";
4910 a.style.marginLeft="4px";
4911 a.style.cursor="pointer";
4912 a.id=this.imgId(e.format.FieldName);
4913 Rico.eventBind(a,"click",Rico.eventHandle(this,"processClick"));
4914 f.parentNode.appendChild(d);
4915 f.parentNode.appendChild(a);
4916 f.style.display="none";
4918 if(e.format.isNullable){b=Rico.clearButton(Rico.eventHandle(this,"processClear"));
4920 f.parentNode.appendChild(b)
4921 }this.elemList[a.id]={descSpan:d,inputCtl:f,widget:c.widget,listObj:c,column:e,clrimg:b};
4922 e.format.selectIcon=a;
4923 e.format.selectDesc=d
4924 },displayClrImg:function(c,a){var b=this.elemList[this.imgId(c.format.FieldName)];
4925 if(b&&b.clrimg){b.clrimg.style.display=a?"inline-block":"none"
4926 }},processClear:function(c){var b=Rico.eventElement(c);
4927 var a=this.elemList[b.id.slice(0,-6)];
4929 }a.inputCtl.value="";
4930 a.descSpan.innerHTML=a.column._format("")
4931 },processClick:function(c){var b=Rico.eventElement(c);
4932 var a=this.elemList[b.id];
4934 }if(a.listObj.currentEl==b.id&&a.widget.container.style.display!="none"){a.widget.close();
4935 a.listObj.currentEl=""
4936 }else{a.listObj.currentEl=b.id;
4937 Rico.log("Rico.EditControls.processClick: "+a.widget.id+" : "+a.inputCtl.value);
4938 a.widget.container.style.zIndex=this.zIndex;
4939 a.widget.open(a.inputCtl.value,a.column);
4940 Rico.positionCtlOverIcon(a.widget.container,b)
4941 }},imgId:function(a){return"icon_"+a
4942 },resetValue:function(c){var b=this.elemList[this.imgId(c.format.FieldName)];
4944 }b.inputCtl.value=c.format.ColData;
4945 var a=c._format(c.format.ColData);
4946 if(a===""){a=" "
4947 }b.descSpan.innerHTML=a
4948 },setValue:function(e,a,d){var b=this.widgetList[e.id];
4952 }var c=this.elemList[f];
4954 }c.inputCtl.value=a;
4955 if(!d){d=c.column._format(a)
4956 }c.descSpan.innerHTML=d;
4957 if(c.column.format.DescriptionField){Rico.$(c.column.format.DescriptionField).value=d
4958 }},close:function(b){var a=this.widgetList[b];
4960 }if(a.widget.container.style.display!="none"){a.widget.close()
4963 Rico.addPhraseId("bookmarkExact","Listing records $1 - $2 of $3");
4964 Rico.addPhraseId("bookmarkAbout","Listing records $1 - $2 of more than $3");
4965 Rico.addPhraseId("bookmarkNoRec","No records");
4966 Rico.addPhraseId("bookmarkNoMatch","No matching records");
4967 Rico.addPhraseId("bookmarkLoading","Loading...");
4968 Rico.addPhraseId("sorting","Sorting...");
4969 Rico.addPhraseId("exportStatus","Exporting row $1");
4970 Rico.addPhraseId("filterAll","(all)");
4971 Rico.addPhraseId("filterBlank","(blank)");
4972 Rico.addPhraseId("filterEmpty","(empty)");
4973 Rico.addPhraseId("filterNotEmpty","(not empty)");
4974 Rico.addPhraseId("filterLike","contains: $1");
4975 Rico.addPhraseId("filterNot","not: $1");
4976 Rico.addPhraseId("requestError","The request for data returned an error:\n$1");
4977 Rico.addPhraseId("keywordPrompt","Enter keyword to search for (use * as a wildcard):");
4978 Rico.addPhraseId("keywordTitle","Keyword Search");
4979 Rico.addPhraseId("ok","OK");
4980 Rico.addPhraseId("gridmenuSortBy","Sort by: $1");
4981 Rico.addPhraseId("gridmenuSortAsc","Ascending");
4982 Rico.addPhraseId("gridmenuSortDesc","Descending");
4983 Rico.addPhraseId("gridmenuFilterBy","Filter by: $1");
4984 Rico.addPhraseId("gridmenuRefresh","Refresh");
4985 Rico.addPhraseId("gridmenuChgKeyword","Change keyword...");
4986 Rico.addPhraseId("gridmenuExcludeAlso","Exclude this value also");
4987 Rico.addPhraseId("gridmenuInclude","Include only this value");
4988 Rico.addPhraseId("gridmenuGreaterThan","Greater than or equal to this value");
4989 Rico.addPhraseId("gridmenuLessThan","Less than or equal to this value");
4990 Rico.addPhraseId("gridmenuContains","Contains keyword...");
4991 Rico.addPhraseId("gridmenuExclude","Exclude this value");
4992 Rico.addPhraseId("gridmenuRemoveFilter","Remove filter");
4993 Rico.addPhraseId("gridmenuRemoveAll","Remove all filters");
4994 Rico.addPhraseId("gridmenuExport","Print/Export");
4995 Rico.addPhraseId("gridmenuExportVis2Web","Visible rows to web page");
4996 Rico.addPhraseId("gridmenuExportAll2Web","All rows to web page");
4997 Rico.addPhraseId("gridmenuExportVis2SS","Visible rows to spreadsheet");
4998 Rico.addPhraseId("gridmenuExportAll2SS","All rows to spreadsheet");
4999 Rico.addPhraseId("gridmenuHideShow","Hide/Show");
5000 Rico.addPhraseId("gridmenuChooseCols","Choose columns...");
5001 Rico.addPhraseId("gridmenuHide","Hide: $1");
5002 Rico.addPhraseId("gridmenuShow","Show: $1");
5003 Rico.addPhraseId("gridmenuShowAll","Show All");
5004 Rico.addPhraseId("sessionExpireMinutes","minutes before your session expires");
5005 Rico.addPhraseId("sessionExpired","EXPIRED");
5006 Rico.addPhraseId("requestTimedOut","Request for data timed out!");
5007 Rico.addPhraseId("waitForData","Waiting for data...");
5008 Rico.addPhraseId("httpError","Received HTTP error: $1");
5009 Rico.addPhraseId("invalidResponse","Server returned an invalid response");
5010 Rico.addPhraseId("gridChooseCols","Choose columns");
5011 Rico.addPhraseId("exportComplete","Exporting complete");
5012 Rico.addPhraseId("exportInProgress","Export in progress...");
5013 Rico.addPhraseId("disableBlocker","You need to disable your browser's pop-up blocker before exporting.");
5014 Rico.addPhraseId("showFilterRow","Show filter row");
5015 Rico.addPhraseId("hideFilterRow","Hide filter row");
5016 Rico.addPhraseId("selectNone","(none)");
5017 Rico.addPhraseId("selectNewVal","(new value)");
5018 Rico.addPhraseId("record","record");
5019 Rico.addPhraseId("thisRecord","this $1");
5020 Rico.addPhraseId("confirmDelete","Are you sure you want to delete $1?");
5021 Rico.addPhraseId("deleting","Deleting...");
5022 Rico.addPhraseId("formPleaseEnter","Please enter a value for $1");
5023 Rico.addPhraseId("formInvalidFmt","Invalid format for $1");
5024 Rico.addPhraseId("formOutOfRange","Value is out of range for $1");
5025 Rico.addPhraseId("formNewValue","new value:");
5026 Rico.addPhraseId("saving","Saving...");
5027 Rico.addPhraseId("clear","clear");
5028 Rico.addPhraseId("close","Close");
5029 Rico.addPhraseId("saveRecord","Save $1");
5030 Rico.addPhraseId("cancel","Cancel");
5031 Rico.addPhraseId("editRecord","Edit $1");
5032 Rico.addPhraseId("deleteRecord","Delete this $1");
5033 Rico.addPhraseId("cloneRecord","Clone $1");
5034 Rico.addPhraseId("addRecord","Add new $1");
5035 Rico.addPhraseId("addedSuccessfully","$1 added successfully");
5036 Rico.addPhraseId("deletedSuccessfully","$1 deleted successfully");
5037 Rico.addPhraseId("updatedSuccessfully","$1 updated successfully");
5038 Rico.addPhraseId("treeSave","Save Selection");
5039 Rico.addPhraseId("treeClear","Clear All");
5040 Rico.addPhraseId("calToday","Today is $1 $2 $3");
5041 Rico.addPhraseId("calWeekHdg","Wk");
5042 Rico.addPhraseId("calYearRange","Year ($1-$2)");
5043 Rico.addPhraseId("calInvalidYear","Invalid year");
5046 Rico.dateFmt="mm/dd/yyyy";
5047 Rico.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
5048 Rico.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];