3 Rico.onLoadCallbacks=[];
4 Rico.windowIsLoaded=false;
5 Rico.inputtypes={search:0,number:0,range:0,color:0,tel:0,url:0,email:0,date:0,month:0,week:0,time:0,datetime:0,"datetime-local":0};
6 Rico.windowLoaded=function(){this.windowIsLoaded=true;
7 if(typeof Rico_CONFIG=="object"){if(Rico_CONFIG.enableLogging){this.enableLogging()
8 }if(Rico_CONFIG.enableHTML5){this._CheckInputTypes()
9 }}Rico.writeDebugMsg=Rico.log;
10 Rico.log("Processing callbacks");
11 while(this.onLoadCallbacks.length>0){var a=this.onLoadCallbacks.shift();
14 Rico._CheckInputTypes=function(){var a=document.createElement("input");
15 for(var b in this.inputtypes){a.setAttribute("type","text");
16 a.setAttribute("type",b);
17 this.inputtypes[b]=(a.type!=="text")
19 Rico.onLoad=function(b,a){if(this.windowIsLoaded){b()
20 }else{if(a){this.onLoadCallbacks.unshift(b)
21 }else{this.onLoadCallbacks.push(b)
23 Rico.isKonqueror=navigator.userAgent.toLowerCase().indexOf("konqueror")>-1;
24 Rico.isIE=!!(window.attachEvent&&navigator.userAgent.indexOf("Opera")===-1);
25 Rico.isOpera=navigator.userAgent.indexOf("Opera")>-1;
26 Rico.isWebKit=navigator.userAgent.indexOf("AppleWebKit/")>-1;
27 Rico.isGecko=navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")===-1;
28 Rico.ieVersion=/MSIE (\d+\.\d+);/.test(navigator.userAgent)?new Number(RegExp.$1):null;
29 Rico.startTime=new Date();
30 Rico.timeStamp=function(){var a=new Date();
31 return(a.getTime()-this.startTime.getTime())+": "
33 Rico.setDebugArea=function(c,a){if(!this.debugArea||a){var b=document.getElementById(c);
38 Rico.log=function(){};
39 Rico.enableLogging=function(){if(this.debugArea){this.log=function(b,a){if(a){this.debugArea.value=""
40 }this.debugArea.value+=this.timeStamp()+b+"\n"
42 }else{if(window.console){if(window.console.firebug){this.log=function(a){window.console.log(this.timeStamp(),a)
44 }else{this.log=function(a){window.console.log(this.timeStamp()+a)
46 }}else{if(window.opera){this.log=function(a){window.opera.postError(this.timeStamp()+a)
49 Rico.$=function(a){return typeof a=="string"?document.getElementById(a):a
51 Rico.runLater=function(){var b=Array.prototype.slice.call(arguments);
55 return setTimeout(function(){a[d].apply(a,b)
58 Rico.visible=function(a){return Rico.getStyle(a,"display")!="none"
60 Rico.show=function(a){a.style.display=""
62 Rico.hide=function(a){a.style.display="none"
64 Rico.toggle=function(a){a.style.display=a.style.display=="none"?"":"none"
66 Rico.direction=function(a){return(Rico.getStyle(a,"direction")||"ltr").toLowerCase()
68 Rico.viewportOffset=function(a){var b=Rico.cumulativeOffset(a);
69 b.left-=this.docScrollLeft();
70 b.top-=this.docScrollTop();
73 Rico.getInnerText=function(f,b,g,e){switch(typeof f){case"string":return f;
74 case"undefined":return f;
75 case"number":return f.toString()
81 c++){switch(d[c].nodeType){case 1:if(this.getStyle(d[c],"display")=="none"){continue
82 }if(e&&this.hasClass(d[c],e)){continue
83 }switch(d[c].tagName.toLowerCase()){case"img":if(!b){h+=d[c].alt||d[c].title||d[c].src
85 case"input":if(!g&&!d[c].disabled&&d[c].type.toLowerCase()=="text"){h+=d[c].value
87 case"select":if(!g&&d[c].selectedIndex>=0){h+=d[c].options[d[c].selectedIndex].text
89 case"textarea":if(!g&&!d[c].disabled){h+=d[c].value
91 default:h+=this.getInnerText(d[c],b,g,e);
94 case 3:h+=d[c].nodeValue;
98 Rico.getContentAsString=function(a,b){if(b){return this._getEncodedContent(a)
99 }if(typeof a.xml!="undefined"){return this._getContentAsStringIE(a)
100 }return this._getContentAsStringMozilla(a)
102 Rico._getEncodedContent=function(a){if(a.innerHTML){return a.innerHTML
103 }switch(a.childNodes.length){case 0:return"";
104 case 1:return a.firstChild.nodeValue;
105 default:return a.childNodes[1].nodeValue
107 Rico._getContentAsStringIE=function(a){var c="";
109 b<a.childNodes.length;
110 b++){var d=a.childNodes[b];
111 c+=(d.nodeType==4)?d.nodeValue:d.xml
114 Rico._getContentAsStringMozilla=function(b){var a=new XMLSerializer();
117 c<b.childNodes.length;
118 c++){var e=b.childNodes[c];
119 if(e.nodeType==4){d+=e.nodeValue
120 }else{d+=a.serializeToString(e)
123 Rico.nan2zero=function(a){if(typeof(a)=="string"){a=parseInt(a,10)
124 }return isNaN(a)||typeof(a)=="undefined"?0:a
126 Rico.stripTags=function(a){return a.replace(/<\/?[^>]+>/gi,"")
128 Rico.truncate=function(a,b){return a.length>b?a.substr(0,b-3)+"...":a
130 Rico.zFill=function(d,c,b){var a=d.toString(b||10);
131 while(a.length<c){a="0"+a
134 Rico.keys=function(c){var b=[];
135 for(var a in c){b.push(a)
138 Rico.eventKey=function(a){if(typeof(a.keyCode)=="number"){return a.keyCode
139 }else{if(typeof(a.which)=="number"){return a.which
140 }else{if(typeof(a.charCode)=="number"){return a.charCode
143 Rico.eventLeftClick=function(a){return(((a.which)&&(a.which==1))||((a.button)&&(a.button==1)))
145 Rico.eventRelatedTarget=function(a){return a.relatedTarget
147 Rico.getPreviosSiblingByTagName=function(c,b){var a=c.previousSibling;
148 while(a){if((a.tagName==b)&&(a.style.display!="none")){return a
152 Rico.getParentByTagName=function(d,a,c){var b=d;
154 while(b){if(b.tagName&&b.tagName.toLowerCase()==a){if(!c||b.className.indexOf(c)>=0){return b
158 Rico.wrapChildren=function(b,a,e,c){var d=document.createElement(c||"div");
161 }while(b.firstChild){d.appendChild(b.firstChild)
165 Rico.positionCtlOverIcon=function(f,j){j=this.$(j);
166 var b=this.cumulativeOffset(j);
167 var i=this.docScrollTop();
168 var a=this.windowHeight();
169 if(f.style.display=="none"){f.style.display="block"
171 if(Rico.direction(j)=="rtl"){f.style.left=(b.left+j.offsetWidth-f.offsetWidth)+"px"
172 }else{var d=this.nan2zero(this.getStyle(j,"marginLeft"));
173 f.style.left=(b.left+d+g)+"px"
175 var e=f.offsetHeight;
176 var c=j.offsetHeight;
179 }else{h=Math.max(h-e,i)
182 Rico.createFormField=function(d,b,f,g,a){var e;
183 if(typeof a!="string"){a=g
184 }if(this.isIE&&this.ieVersion<8){var c=b+' id="'+g+'"';
185 if(f){c+=' type="'+f+'"'
186 }if(b.match(/^(form|input|select|textarea|object|button|img)$/)){c+=' name="'+a+'"'
187 }e=document.createElement("<"+c+" />")
188 }else{e=document.createElement(b);
191 if(typeof e.name=="string"){e.name=a
195 Rico.addSelectOption=function(b,c,d){var a=document.createElement("option");
196 if(typeof c=="string"){a.value=c
198 if(this.isIE){b.add(a)
202 Rico.getCookie=function(g){var b=g+"=";
204 var a=document.cookie.length;
206 while(d<a){var c=d+f;
207 if(document.cookie.substring(d,c)==b){var e=document.cookie.indexOf(";",c);
208 if(e==-1){e=document.cookie.length
209 }return unescape(document.cookie.substring(c,e))
210 }d=document.cookie.indexOf(" ",d)+1;
214 Rico.getTBody=function(a){return a.tBodies.length==0?a.appendChild(document.createElement("tbody")):a.tBodies[0]
216 Rico.setCookie=function(e,g,f,d,a){var h=e+"="+escape(g);
217 if(typeof(f)=="number"){var b=new Date();
218 b.setTime(b.getTime()+(f*24*60*60*1000));
219 h+="; expires="+b.toGMTString()
220 }if(typeof(d)=="string"){h+="; path="+d
221 }if(typeof(a)=="string"){h+="; domain="+a
228 Rico.dateFmt="mm/dd/yyyy";
229 Rico.timeFmt="hh:nn:ss a/pm";
230 Rico.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
231 Rico.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
232 Rico.monthAbbr=function(a){return this.monthNamesShort?this.monthNamesShort[a]:this.monthNames[a].substr(0,3)
234 Rico.dayAbbr=function(a){return this.dayNamesShort?this.dayNamesShort[a]:this.dayNames[a].substr(0,3)
236 Rico.addPhraseId=function(b,a){this.phrasesById[b]=a
238 Rico.getPhraseById=function(d){var b=this.phrasesById[d];
239 if(!b){alert("Error: missing phrase for "+d);
241 }if(arguments.length<=1){return b
243 return b.replace(/(\$\d)/g,function(e){var a=parseInt(e.charAt(1),10);
244 return(a<c.length)?c[a]:""
247 Rico.formatPosNumber=function(e,f,c){var b=e.toFixed(f).split(/\./);
248 if(c){var d=/(\d+)(\d{3})/;
249 while(d.test(b[0])){b[0]=b[0].replace(d,"$1"+Rico.thouSep+"$2")
250 }}return b.join(Rico.decPoint)
252 Rico.formatNumber=function(b,c){if(typeof b=="string"){b=parseFloat(b.replace(/,/,"."),10)
253 }if(isNaN(b)){return"NaN"
254 }if(typeof c.multiplier=="number"){b*=c.multiplier
255 }var h=typeof c.decPlaces=="number"?c.decPlaces:0;
256 var e=typeof c.thouSep=="undefined"?true:c.thouSep;
259 var a=typeof c.negSign=="string"?c.negSign:"L";
262 if(b<0){i=this.formatPosNumber(-b,h,e);
263 if(a=="P"){i="("+i+")"
268 }else{g=b==0?"zeroNumber":"posNumber";
269 i=d+this.formatPosNumber(b,h,e)
270 }return"<span class='"+g+"'>"+i+f+"</span>"
272 Rico.formatDate=function(c,a){var b=(typeof a=="string")?a:"translateDate";
273 switch(b){case"locale":case"localeDateTime":return c.toLocaleString();
274 case"Long Date":case"localeDate":return c.toLocaleDateString();
275 case"translate":case"translateDateTime":b=this.dateFmt+" "+this.timeFmt;
277 case"Short Date":case"translateDate":b=this.dateFmt;
279 }return b.replace(/(yyyy|yy|mmmm|mmm|mm|dddd|ddd|dd|d|hh|nn|ss|a\/p)/gi,function(d){var e;
280 switch(d){case"yyyy":return c.getFullYear();
281 case"yy":return c.getFullYear().toString().substr(2);
282 case"mmmm":return Rico.monthNames[c.getMonth()];
283 case"mmm":return Rico.monthAbbr(c.getMonth());
284 case"mm":return Rico.zFill(c.getMonth()+1,2);
285 case"m":return(c.getMonth()+1);
286 case"dddd":return Rico.dayNames[c.getDay()];
287 case"ddd":return Rico.dayAbbr(c.getDay());
288 case"dd":return Rico.zFill(c.getDate(),2);
289 case"d":return c.getDate();
290 case"hh":return Rico.zFill((e=c.getHours()%12)?e:12,2);
291 case"h":return((e=c.getHours()%12)?e:12);
292 case"HH":return Rico.zFill(c.getHours(),2);
293 case"H":return c.getHours();
294 case"nn":return Rico.zFill(c.getMinutes(),2);
295 case"ss":return Rico.zFill(c.getSeconds(),2);
296 case"a/p":return c.getHours()<12?"a":"p"
299 Rico.setISO8601=function(b,f){if(!b){return false
300 }var e=b.match(/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|(?:([-+])(\d\d)(?::?(\d\d))?)?)?)?)?)?/);
303 }var a=new Date(e[1],0,1);
304 if(e[2]){a.setMonth(e[2]-1)
305 }if(e[3]){a.setDate(e[3])
306 }if(e[4]){a.setHours(e[4])
307 }if(e[5]){a.setMinutes(e[5])
308 }if(e[6]){a.setSeconds(e[6])
309 }if(e[7]){a.setMilliseconds(Number("0."+e[7])*1000)
310 }if(e[8]){if(e[10]&&e[11]){f=(Number(e[10])*60)+Number(e[11])
311 }f*=((e[9]=="-")?1:-1);
312 f-=a.getTimezoneOffset()
313 }var c=(Number(a)+(f*60*1000));
314 a.setTime(Number(c));
317 Rico.toISO8601String=function(a,e,h){if(!e){e=6
319 }else{var g=h.match(/([-+])([0-9]{2}):([0-9]{2})/);
320 var c=(Number(g[2])*60)+Number(g[3]);
321 c*=((g[1]=="-")?-1:1);
322 a=new Date(Number(Number(a)+(c*60000)))
323 }var i=function(d){return((d<10)?"0":"")+d
325 var f=a.getUTCFullYear();
326 if(e>1){f+="-"+i(a.getUTCMonth()+1)
327 }if(e>2){f+="-"+i(a.getUTCDate())
328 }if(e>3){f+="T"+i(a.getUTCHours())+":"+i(a.getUTCMinutes())
329 }if(e>5){var b=Number(a.getUTCSeconds()+"."+((a.getUTCMilliseconds()<100)?"0":"")+i(a.getUTCMilliseconds()));
331 }else{if(e>4){f+=":"+i(a.getUTCSeconds())
335 Rico.createXmlDocument=function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);
336 if(a.readyState==null){a.readyState=1;
337 a.addEventListener("load",function(){a.readyState=4;
338 if(typeof a.onreadystatechange=="function"){a.onreadystatechange()
341 }if(window.ActiveXObject){return Rico.tryFunctions(function(){return new ActiveXObject("MSXML2.DomDocument")
342 },function(){return new ActiveXObject("Microsoft.DomDocument")
343 },function(){return new ActiveXObject("MSXML.DomDocument")
344 },function(){return new ActiveXObject("MSXML3.DomDocument")
348 Rico.ajaxUpdater=function(c,b,a){this.updateSend(c,b,a)
350 Rico.ajaxUpdater.prototype={updateSend:function(d,c,b){this.element=d;
351 this.onComplete=b.onComplete;
353 b.onComplete=function(e){a.updateComplete(e)
355 new Rico.ajaxRequest(c,b)
356 },updateComplete:function(a){this.element.innerHTML=a.responseText;
357 if(this.onComplete){this.onComplete(a)
359 try{document.execCommand("BackgroundImageCache",false,true)
360 }catch(err){}Rico.eventBind(window,"load",Rico.eventHandle(Rico,"windowLoaded"));
361 Rico.applyShadow=function(b,a){if(typeof a=="undefined"){a=true
362 }if(a){Rico.addClass(b,"ricoShadow")
365 Rico._OpenPopupList=[];
366 Rico._RemoveOpenPopup=function(a){if(a.openIndex>=0&&a.openIndex<Rico._OpenPopupList.length){Rico._OpenPopupList.splice(a.openIndex,1)
369 Rico._AddOpenPopup=function(a){a.openIndex=Rico._OpenPopupList.push(a)-1
371 Rico._checkEscKey=function(b){if(Rico.eventKey(b)!=27){return true
372 }while(Rico._OpenPopupList.length>0){var a=Rico._OpenPopupList.pop();
373 if(a&&a.visible()){a.openIndex=-1;
379 Rico.eventBind(document,"keyup",Rico.eventHandle(Rico,"_checkEscKey"));
380 Rico.Popup=function(b,a){this.initialize(b,a)
382 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};
384 if(b){this.setDiv(b,a)
385 }},createContainer:function(a){this.setDiv(document.createElement("div"),a);
386 if(a&&a.parent){a.parent.appendChild(this.container)
387 }else{document.getElementsByTagName("body")[0].appendChild(this.container)
388 }},setDiv:function(c,b){Rico.extend(this.options,b||{});
389 this.container=Rico.$(c);
390 if(this.options.position=="auto"){this.position=Rico.getStyle(this.container,"position").toLowerCase()
391 }else{this.position=this.container.style.position=this.options.position
392 }this.content=document.createElement("div");
393 while(this.container.firstChild){this.content.appendChild(this.container.firstChild)
394 }this.container.appendChild(this.content);
395 this.content.className="RicoPopupContent";
396 if(this.position!="absolute"){return
397 }if(this.options.closeFunc){this.closeFunc=this.options.closeFunc
399 this.closeFunc=function(){a.closePopup()
401 }this.container.style.top="0px";
402 this.container.style.left="0px";
403 this.container.style.display="none";
404 if(this.options.zIndex>=0){this.container.style.zIndex=this.options.zIndex
405 }if(Rico.isIE&&Rico.ieVersion<7&&this.options.shim!==false){this.content.style.position="relative";
406 this.content.style.zIndex=2;
407 this.ifr=document.createElement("iframe");
408 this.ifr.className="RicoShim";
409 this.ifr.frameBorder=0;
410 this.ifr.src="javascript:'';";
411 this.container.appendChild(this.ifr)
412 }Rico.applyShadow(this.container,this.options.shadow);
413 if(this.options.hideOnClick){Rico.eventBind(document,"click",Rico.eventHandle(this,"_docClick"))
414 }this.dragEnabled=false;
415 this.mousedownHandler=Rico.eventHandle(this,"_startDrag");
416 this.dragHandler=Rico.eventHandle(this,"_drag");
417 this.dropHandler=Rico.eventHandle(this,"_endDrag");
418 if(this.options.canDrag){this.enableDragging()
419 }if(this.options.ignoreClicks||this.options.canDrag){this.ignoreClicks()
420 }},clearContent:function(){this.content.innerHTML=""
421 },setContent:function(a){this.content.innerHTML=a
422 },enableDragging:function(){if(!this.dragEnabled&&this.options.dragElement){Rico.eventBind(this.options.dragElement,"mousedown",this.mousedownHandler);
423 this.dragEnabled=true
424 }return this.dragEnabled
425 },disableDragging:function(){if(!this.dragEnabled){return
426 }Rico.eventUnbind(this.options.dragElement,"mousedown",this.mousedownHandler);
427 this.dragEnabled=false
428 },setZ:function(a){this.container.style.zIndex=a
429 },ignoreClicks:function(){Rico.eventBind(this.container,"click",Rico.eventHandle(this,"_ignoreClick"))
430 },_ignoreClick:function(a){if(a.stopPropagation){a.stopPropagation()
431 }else{a.cancelBubble=true
433 },_docClick:function(a){this.closeFunc();
435 },move:function(b,a){if(typeof b=="number"){this.container.style.left=b+"px"
436 }if(typeof a=="number"){this.container.style.top=a+"px"
437 }},_startDrag:function(b){var a=Rico.eventElement(b);
438 this.container.style.cursor="move";
439 this.lastMouse=Rico.eventClient(b);
440 Rico.eventBind(document,"mousemove",this.dragHandler);
441 Rico.eventBind(document,"mouseup",this.dropHandler);
443 },_drag:function(d){var b=Rico.eventClient(d);
444 var c=parseInt(this.container.style.left,10)+b.x-this.lastMouse.x;
445 var a=parseInt(this.container.style.top,10)+b.y-this.lastMouse.y;
449 },_endDrag:function(){this.container.style.cursor="";
450 Rico.eventUnbind(document,"mousemove",this.dragHandler);
451 Rico.eventUnbind(document,"mouseup",this.dropHandler)
452 },openPopup:function(b,a){this.move(b,a);
453 this.container.style.display="";
454 if(this.container.id){Rico.log("openPopup "+this.container.id+" at "+b+","+a)
455 }Rico._AddOpenPopup(this)
456 },centerPopup:function(){this.openPopup();
457 var d=this.container.offsetWidth;
458 var c=this.container.offsetHeight;
459 var a=this.container.parentNode.offsetWidth;
460 var b=this.container.parentNode.offsetHeight;
461 this.move(parseInt(Math.max((a-d)/2,0),10),parseInt(Math.max((b-c)/2,0),10))
462 },visible:function(){return Rico.visible(this.container)
463 },closePopup:function(){Rico._RemoveOpenPopup(this);
464 if(!Rico.visible(this.container)){return
465 }if(this.container.id){Rico.log("closePopup "+this.container.id)
466 }if(this.dragEnabled){this._endDrag()
467 }this.container.style.display="none";
468 if(this.options.onClose){this.options.onClose()
470 Rico.closeButton=function(d){var b=document.createElement("a");
471 b.className="RicoCloseAnchor";
472 if(Rico.theme.closeAnchor){Rico.addClass(b,Rico.theme.closeAnchor)
473 }var c=b.appendChild(document.createElement("span"));
474 c.title=Rico.getPhraseById("close");
475 new Rico.HoverSet([b],{hoverClass:Rico.theme.hover||"ricoCloseHover"});
476 Rico.addClass(c,Rico.theme.close||"rico-icon RicoClose");
477 Rico.eventBind(b,"click",d);
480 Rico.floatButton=function(b,e,f){var c=document.createElement("a");
481 c.className="RicoButtonAnchor";
482 Rico.addClass(c,Rico.theme.buttonAnchor||"RicoButtonAnchorNative");
483 var d=c.appendChild(document.createElement("span"));
485 }d.className=Rico.theme[b.toLowerCase()]||"rico-icon Rico"+b;
486 Rico.eventBind(c,"click",e,false);
487 new Rico.HoverSet([c]);
490 Rico.clearButton=function(b){var a=document.createElement("span");
491 a.title=Rico.getPhraseById("clear");
492 a.className="ricoClear";
493 Rico.addClass(a,Rico.theme.clear||"rico-icon ricoClearNative");
494 Rico.eventBind(a,"click",b);
497 Rico.Window=function(c,a,b){this.initialize(c,a,b)
499 Rico.Window.prototype={initialize:function(c,a,b){a=a||{overflow:"auto"};
500 Rico.extend(this,new Rico.Popup());
501 this.titleDiv=document.createElement("div");
502 this.options.canDrag=true;
503 this.options.dragElement=this.titleDiv;
504 this.createContainer(a);
505 this.content.appendChild(this.titleDiv);
507 if(b){this.contentDiv=b;
508 b.parentNode.insertBefore(this.container,b)
509 }else{this.contentDiv=document.createElement("div")
510 }this.content.appendChild(this.contentDiv);
511 this.titleDiv.className="ricoTitle";
512 if(Rico.theme.dialogTitle){Rico.addClass(this.titleDiv,Rico.theme.dialogTitle)
513 }this.titleDiv.style.position="relative";
514 this.titleContent=document.createElement("span");
515 this.titleContent.className="ricoTitleSpan";
516 this.titleDiv.appendChild(this.titleContent);
517 this.titleDiv.appendChild(Rico.closeButton(Rico.eventHandle(this,"closeFunc")));
520 }this.setTitle(c||" ");
521 this.contentDiv.className="ricoContent";
522 if(Rico.theme.dialogContent){Rico.addClass(this.contentDiv,Rico.theme.dialogContent)
523 }this.contentDiv.style.position="relative";
524 if(a.height){this.contentDiv.style.height=a.height
525 }if(a.width){this.contentDiv.style.width=a.width
526 }if(a.overflow){this.contentDiv.style.overflow=a.overflow
527 }Rico.addClass(this.container,"ricoWindow");
528 if(Rico.theme.dialog){Rico.addClass(this.container,Rico.theme.dialog)
529 }this.content=this.contentDiv
530 },setTitle:function(a){this.titleContent.innerHTML=a
532 Rico.Menu=function(a){this.initialize(a)
534 Rico.Menu.prototype={initialize:function(a){Rico.extend(this,new Rico.Popup());
535 Rico.extend(this.options,{width:"15em",arrowColor:"b",showDisabled:false,hideOnClick:true});
536 if(typeof a=="string"){this.options.width=a
537 }else{Rico.extend(this.options,a||{})
539 this.highlightElem=null
540 },createDiv:function(a){if(this.container){return
542 var c={closeFunc:function(){b.cancelmenu()
545 }this.createContainer(c);
546 this.content.className=Rico.isWebKit?"ricoMenuSafari":"ricoMenu";
547 this.content.style.width=this.options.width;
548 this.direction=Rico.direction(this.container);
551 },showmenu:function(b,c){Rico.eventStop(b);
553 if(this.content.childNodes.length==0){this.cancelmenu();
555 }var a=Rico.eventClient(b);
556 this.openmenu(a.x,a.y,0,0)
557 },openmenu:function(g,f,j,e,a){var h=g+(a?0:Rico.docScrollLeft());
558 this.container.style.visibility="hidden";
559 this.container.style.display="block";
560 var i=this.container.offsetWidth;
561 var b=this.content.offsetWidth;
562 if(this.direction=="rtl"){if(h>i+j){h-=b+j
563 }}else{if(g+i>Rico.windowWidth()){h-=b+j-2
564 }}var d=Rico.docScrollTop();
566 if(f+this.container.offsetHeight-d>Rico.windowHeight()){c=Math.max(c-this.content.offsetHeight+e,0)
567 }this.openPopup(h,c);
568 this.container.style.visibility="visible";
570 },clearMenu:function(){this.clearContent();
571 this.defaultAction=null;
573 },addMenuHeading:function(b){var a=document.createElement("div");
575 a.className="ricoMenuHeading";
576 this.content.appendChild(a)
577 },addMenuBreak:function(){var a=document.createElement("div");
578 a.className="ricoMenuBreak";
579 this.content.appendChild(a)
580 },addSubMenuItem:function(b,e,g){var d=this.direction=="rtl"?"left":"right";
581 var c=this.addMenuItem(b,null,true,null,g);
582 c.className="ricoSubMenu";
583 var f=c.appendChild(document.createElement("div"));
584 f.className="rico-icon rico-"+d+"-"+this.options.arrowColor;
585 Rico.setStyle(f,{position:"absolute",top:"2px"});
588 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"showSubMenu"))
589 },showSubMenu:function(c){if(this.openSubMenu){this.hideSubMenu()
590 }var b=Rico.eventElement(c);
591 if(!b.RicoSubmenu){b=b.parentNode
592 }if(!b.RicoSubmenu){return
593 }this.openSubMenu=b.RicoSubmenu;
594 this.openMenuAnchor=b;
595 if(Rico.hasClass(b,"ricoSubMenu")){Rico.removeClass(b,"ricoSubMenu");
596 Rico.addClass(b,"ricoSubMenuOpen")
597 }b.RicoSubmenu.openmenu(parseInt(this.container.style.left)+b.offsetWidth,parseInt(this.container.style.top)+b.offsetTop,b.offsetWidth-2,b.offsetHeight+2,true)
598 },hideSubMenu:function(){if(this.openMenuAnchor){Rico.removeClass(this.openMenuAnchor,"ricoSubMenuOpen");
599 Rico.addClass(this.openMenuAnchor,"ricoSubMenu");
600 this.openMenuAnchor=null
601 }if(this.openSubMenu){this.openSubMenu.hidemenu();
602 this.openSubMenu=null
603 }},addMenuItemId:function(c,b,a,e,d){if(arguments.length<3){a=true
604 }this.addMenuItem(Rico.getPhraseById(c),b,a,e,d)
605 },addMenuItem:function(b,e,d,g,f){if(arguments.length>=3&&!d&&!this.options.showDisabled){return null
607 var c=document.createElement(typeof e=="string"?"a":"div");
608 if(arguments.length<3||d){if(typeof e=="string"){c.href=e;
610 }}else{if(f=="event"){Rico.eventBind(c,"click",e)
612 }}c.className="enabled";
613 if(this.defaultAction==null){this.defaultAction=e
614 }}else{c.disabled=true;
615 c.className="disabled"
617 if(typeof g=="string"){c.title=g
618 }c=this.content.appendChild(c);
619 Rico.eventBind(c,"mouseover",Rico.eventHandle(this,"mouseOver"));
620 Rico.eventBind(c,"mouseout",Rico.eventHandle(this,"mouseOut"));
622 },mouseOver:function(b){if(this.highlightElem&&this.highlightElem.className=="enabled-hover"){this.highlightElem.className="enabled";
623 this.highlightElem=null
624 }var a=Rico.eventElement(b);
625 if(a.parentNode==this.openMenuAnchor){a=a.parentNode
626 }if(this.openMenuAnchor&&this.openMenuAnchor!=a){this.hideSubMenu()
627 }if(a.className=="enabled"){a.className="enabled-hover";
629 }},mouseOut:function(b){var a=Rico.eventElement(b);
630 if(a.className=="enabled-hover"){a.className="enabled"
631 }if(this.highlightElem==a){this.highlightElem=null
632 }},cancelmenu:function(){if(!this.visible()){return
633 }if(this.hideFunc){this.hideFunc()
636 },hidemenu:function(){if(this.openSubMenu){this.openSubMenu.hidemenu()
639 Rico.SelectionSet=function(b,a){this.initialize(b,a)
641 Rico.SelectionSet.prototype={initialize:function(e,b){Rico.log("SelectionSet#initialize");
643 if(typeof e=="string"){e=Rico.select(e)
644 }this.previouslySelected=[];
645 this.selectionSet=[];
646 this.selectedClassName=this.options.selectedClass||Rico.theme.selected||"selected";
647 this.selectNode=this.options.selectNode||function(f){return f
649 this.onSelect=this.options.onSelect;
650 this.onFirstSelect=this.options.onFirstSelect;
652 this.clickHandler=function(f){a.selectIndex(f)
654 this.selectedIndex=-1;
658 }if(!this.options.noDefault){var d=this.options.cookieName?this.getCookie():0;
659 this.selectIndex(d||this.options.selectedIndex||0)
660 }},getCookie:function(){var b=Rico.getCookie(this.options.cookieName);
663 return a<this.selectionSet.length?a:0
664 },reset:function(){this.previouslySelected=[];
665 this._notifySelected(this.selectedIndex)
666 },clearSelected:function(){if(this.selected){Rico.removeClass(this.selectNode(this.selected),this.selectedClassName)
667 }},getIndex:function(b){for(var a=0;
668 a<this.selectionSet.length;
669 a++){if(b==this.selectionSet[a]){return a
671 },select:function(b){if(this.selected==b){return
672 }var a=this.getIndex(b);
673 if(a>=0){this.selectIndex(a)
674 }},_notifySelected:function(a){if(a<0){return
675 }var b=this.selectionSet[a];
676 if(this.options.cookieName){Rico.setCookie(this.options.cookieName,a,this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
677 }if(this.onFirstSelect&&!this.previouslySelected[a]){this.onFirstSelect(b,a);
678 this.previouslySelected[a]=true
679 }if(this.onSelect){try{this.onSelect(a)
680 }catch(c){}}},selectIndex:function(a){if(this.selectedIndex==a||a>=this.selectionSet.length){return
681 }this.clearSelected();
682 this._notifySelected(a);
683 this.selectedIndex=a;
684 this.selected=this.selectionSet[a].element;
685 Rico.addClass(this.selectNode(this.selected),this.selectedClassName)
686 },nextSelectIndex:function(){return(this.selectedIndex+1)%this.selectionSet.length
687 },nextSelectItem:function(){return this.selectionSet[this.nextSelectIndex()]
688 },selectNext:function(){this.selectIndex(this.nextSelectIndex())
689 },add:function(b){var a=this.selectionSet.length;
690 this.selectionSet[a]=new Rico._SelectionItem(b,a,this.clickHandler)
691 },remove:function(b){if(b==this.selected){this.clearSelected()
692 }var a=this.getIndex(b);
694 }this.selectionSet[a].remove();
695 this.selectionSet.splice(a,1)
696 },removeAll:function(){this.clearSelected();
697 while(this.selectionSet.length>0){this.selectionSet.pop().remove()
699 Rico._SelectionItem=function(b,a,c){this.add(b,a,c)
701 Rico._SelectionItem.prototype={add:function(b,a,c){this.element=b;
704 this.handle=Rico.eventHandle(this,"click");
705 Rico.eventBind(b,"click",this.handle)
706 },click:function(a){this.callback(this.index)
707 },remove:function(){Rico.eventUnbind(this.element,"click",this.handle)
709 Rico.HoverSet=function(b,a){this.initialize(b,a)
711 Rico.HoverSet.prototype={initialize:function(c,a){Rico.log("HoverSet#initialize");
713 this.hoverClass=a.hoverClass||Rico.theme.hover||"hover";
714 this.hoverFunc=a.hoverNodes||function(d){return[d]
721 }},add:function(a){this.hoverSet.push(new Rico._HoverItem(a,this.hoverFunc,this.hoverClass))
722 },removeAll:function(){while(this.hoverSet.length>0){this.hoverSet.pop().remove()
724 Rico._HoverItem=function(b,a,c){this.add(b,a,c)
726 Rico._HoverItem.prototype={add:function(b,a,c){this.element=b;
729 this.movehandle=Rico.eventHandle(this,"move");
730 this.outhandle=Rico.eventHandle(this,"mouseout");
731 Rico.eventBind(b,"mousemove",this.movehandle);
732 Rico.eventBind(b,"mouseout",this.outhandle)
733 },move:function(c){var a=this.selectFunc(this.element);
736 b++){Rico.addClass(a[b],this.hoverClass)
737 }},mouseout:function(c){var a=this.selectFunc(this.element);
740 b++){Rico.removeClass(a[b],this.hoverClass)
741 }},remove:function(){Rico.eventUnbind(element,"mousemove",this.movehandle);
742 Rico.eventUnbind(element,"mouseout",this.outhandle)
744 Rico.ContentTransitionBase=function(){};
745 Rico.ContentTransitionBase.prototype={initBase:function(e,d,b){this.options=b||{};
748 this.hoverSet=new Rico.HoverSet(e,b);
751 c++){if(d[c]){Rico.hide(d[c])
753 this.selectionSet=new Rico.SelectionSet(e,Rico.extend(b,{onSelect:function(f){a._finishSelect(f)
755 },reset:function(){this.selectionSet.reset()
756 },select:function(a){this.selectionSet.selectIndex(a)
757 },_finishSelect:function(b){Rico.log("ContentTransitionBase#_finishSelect");
758 var a=this.contents[b];
759 if(!a){alert("Internal error: no panel @index="+b);
761 }if(this.selected==a){return
762 }if(this.transition){if(this.selected){this.transition(a)
763 }else{a.style.display="block"
764 }}else{if(this.selected){Rico.hide(this.selected)
765 }a.style.display="block"
767 },addBase:function(b,a){this.titles.push(b);
768 this.contents.push(a);
769 this.hoverSet.add(b);
770 this.selectionSet.add(b);
772 },removeAll:function(){this.hoverSet.removeAll();
773 this.selectionSet.removeAll()
775 Rico.Accordion=function(b,a){this.initialize(b,a)
777 Rico.Accordion.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(g,e){g=Rico.$(g);
778 g.style.overflow="hidden";
779 g.className=e.accClass||Rico.theme.accordion||"Rico_accordion";
780 if(typeof e.panelWidth=="number"){e.panelWidth+="px"
781 }if(e.panelWidth){g.style.width=e.panelWidth
782 }var d=Rico.getDirectChildrenByTag(g,"div");
786 f++){c=Rico.getDirectChildrenByTag(d[f],"div");
787 if(c.length>=2){c[0].className=e.titleClass||Rico.theme.accTitle||"Rico_accTitle";
788 c[1].className=e.contentClass||Rico.theme.accContent||"Rico_accContent";
791 var b=Rico.wrapChildren(c[0],"","","a");
792 b.href="javascript:void(0)"
793 }}Rico.log("creating Rico.Accordion for "+g.id+" with "+j.length+" panels");
794 this.initBase(j,h,e);
795 this.selected.style.height=this.options.panelHeight+"px";
796 this.totSteps=(typeof e.duration=="number"?e.duration:200)/25
797 },transition:function(b){if(!this.options.noAnimate){this.closing=this.selected;
801 this.timer=setInterval(function(){a.step()
803 }else{b.style.height=this.options.panelHeight+"px";
804 if(this.selected){Rico.hide(this.selected)
805 }b.style.display="block"
806 }},step:function(){this.curStep++;
807 var a=Math.round(this.curStep/this.totSteps*this.options.panelHeight);
808 this.opening.style.height=a+"px";
809 this.closing.style.height=(this.options.panelHeight-a)+"px";
810 if(this.curStep==1){this.opening.style.paddingTop=this.opening.style.paddingBottom="0px";
811 this.opening.style.display="block"
812 }if(this.curStep==this.totSteps){clearInterval(this.timer);
813 this.opening.style.paddingTop=this.opening.style.paddingBottom="";
814 Rico.hide(this.closing)
815 }},setPanelHeight:function(a){this.options.panelHeight=a;
816 this.selected.style.height=this.options.panelHeight+"px"
818 Rico.TabbedPanel=function(b,a){this.initialize(b,a)
820 Rico.TabbedPanel.prototype=Rico.extend(new Rico.ContentTransitionBase(),{initialize:function(d,l){d=Rico.$(d);
822 if(typeof l.panelWidth=="number"){l.panelWidth+="px"
823 }if(typeof l.panelHeight=="number"){l.panelHeight+="px"
824 }d.className=l.tabClass||Rico.theme.tabPanel||"Rico_tabPanel";
825 if(l.panelWidth){d.style.width=l.panelWidth
830 e++){if(k[e]&&k[e].tagName&&k[e].tagName.match(/^div|ul$/i)){g.push(k[e])
831 }}if(g.length<2){return
832 }var c=g[0].tagName.toLowerCase()=="ul"?"li":"div";
833 g[0].className=l.navContainerClass||Rico.theme.tabNavContainer||"Rico_tabNavContainer";
834 g[0].style.listStyle="none";
835 g[1].className=l.contentContainerClass||Rico.theme.tabContentContainer||"Rico_tabContentContainer";
836 var f=Rico.getDirectChildrenByTag(g[0],c);
837 var b=Rico.getDirectChildrenByTag(g[1],"div");
838 var j=Rico.direction(d);
839 if(!l.corners){l.corners="top"
842 e++){if(j=="rtl"){Rico.setStyle(f[e],{"float":"right"})
843 }f[e].className=l.titleClass||Rico.theme.tabTitle||"Rico_tabTitle";
844 var h=Rico.wrapChildren(f[e],"","","a");
845 h.href="javascript:void(0)";
846 b[e].className=l.contentClass||Rico.theme.tabContent||"Rico_tabContent";
847 if(l.panelHeight){b[e].style.overflow="auto"
848 }if(l.corners!="none"){if(l.panelHdrWidth){f[e].style.width=l.panelHdrWidth
849 }Rico.Corner.round(f[e],Rico.theme.tabCornerOptions||l)
850 }}l.selectedClass=Rico.theme.tabSelected||"selected";
851 this.initBase(f,b,l);
852 if(this.selected){this.transition(this.selected)
853 }},transition:function(a){Rico.log("TabbedPanel#transition "+typeof(a));
854 if(this.selected){Rico.hide(this.selected)
856 if(this.options.panelHeight){a.style.height=this.options.panelHeight
858 Rico.Corner={round:function(b,a){b=Rico.$(b);
859 this.options={corners:"all",bgColor:"fromParent",compact:false,nativeCorners:false};
860 Rico.extend(this.options,a||{});
861 if(typeof(Rico.getStyle(b,"border-radius"))=="string"){this._roundCornersStdCss(b)
862 }else{if(typeof(Rico.getStyle(b,"-webkit-border-radius"))=="string"){this._roundCornersWebKit(b)
863 }else{if(typeof(Rico.getStyle(b,"-moz-border-radius"))=="string"){this._roundCornersMoz(b)
864 }else{if(!this.options.nativeCorners){this._roundCornersImpl(b)
865 }}}}},_roundCornersStdCss:function(b){var a=this.options.compact?"4px":"8px";
866 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{borderRadius:a})
867 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{borderTopLeftRadius:a})
868 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{borderTopRightRadius:a})
869 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{borderBottomLeftRadius:a})
870 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{borderBottomRightRadius:a})
871 }}},_roundCornersWebKit:function(b){var a=this.options.compact?"4px":"8px";
872 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{WebkitBorderRadius:a})
873 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{WebkitBorderTopLeftRadius:a})
874 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{WebkitBorderTopRightRadius:a})
875 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{WebkitBorderBottomLeftRadius:a})
876 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{WebkitBorderBottomRightRadius:a})
877 }}},_roundCornersMoz:function(b){var a=this.options.compact?"4px":"8px";
878 if(this._hasString(this.options.corners,"all")){Rico.setStyle(b,{MozBorderRadius:a})
879 }else{if(this._hasString(this.options.corners,"top","tl")){Rico.setStyle(b,{MozBorderRadiusTopleft:a})
880 }if(this._hasString(this.options.corners,"top","tr")){Rico.setStyle(b,{MozBorderRadiusTopright:a})
881 }if(this._hasString(this.options.corners,"bottom","bl")){Rico.setStyle(b,{MozBorderRadiusBottomleft:a})
882 }if(this._hasString(this.options.corners,"bottom","br")){Rico.setStyle(b,{MozBorderRadiusBottomright:a})
883 }}},_roundCornersImpl:function(b){var a=this.options.bgColor=="fromParent"?this._background(b.parentNode):this.options.bgColor;
884 b.style.position="relative";
885 if(this._hasString(this.options.corners,"all","top","tl")){this._createCorner(b,"top","left",a)
886 }if(this._hasString(this.options.corners,"all","top","tr")){this._createCorner(b,"top","right",a)
887 }if(this._hasString(this.options.corners,"all","bottom","bl")){this._createCorner(b,"bottom","left",a)
888 }if(this._hasString(this.options.corners,"all","bottom","br")){this._createCorner(b,"bottom","right",a)
889 }},_createCorner:function(b,c,f,k){var n=document.createElement("div");
890 n.className="ricoCorner";
891 Rico.setStyle(n,{width:"6px",height:"5px"});
892 var o=Rico.getStyle(b,"border-"+c+"-style");
893 var a=o=="none"?k:Rico.getStyle(b,"border-"+c+"-color");
894 var j=o=="none"?"0px":"-1px";
896 n.style[f]=Rico.isIE&&Rico.ieVersion<7&&f=="right"&&o!="none"?"-2px":"-1px";
899 if(c=="bottom"){h.reverse()
900 }var m=o=="none"?"0px none":"1px solid "+a;
901 var g=f=="left"?"Right":"Left";
904 e++){var l=document.createElement("div");
905 Rico.setStyle(l,{backgroundColor:k,height:"1px"});
906 l.style["margin"+g]=h[e]+"px";
907 l.style["border"+g]=m;
909 }},_background:function(c){try{var a=Rico.getStyle(c,"backgroundColor");
910 if(a.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&c.parentNode){return this._background(c.parentNode)
911 }return a==null?"#ffffff":a
912 }catch(b){return"#ffffff"
913 }},_hasString:function(b){for(var a=1;
915 a++){if(b.indexOf(arguments[a])>=0){return true
918 Rico.toColorPart=function(a){return Rico.zFill(a,2,16)
920 Rico.Color=function(c,b,a){this.initialize(c,b,a)
922 Rico.Color.prototype={initialize:function(c,b,a){this.rgb={r:c,g:b,b:a}
923 },setRed:function(a){this.rgb.r=a
924 },setGreen:function(a){this.rgb.g=a
925 },setBlue:function(a){this.rgb.b=a
926 },setHue:function(b){var a=this.asHSB();
928 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
929 },setSaturation:function(b){var a=this.asHSB();
931 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,a.b)
932 },setBrightness:function(a){var c=this.asHSB();
934 this.rgb=Rico.Color.HSBtoRGB(c.h,c.s,c.b)
935 },darken:function(b){var a=this.asHSB();
936 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.max(a.b-b,0))
937 },brighten:function(b){var a=this.asHSB();
938 this.rgb=Rico.Color.HSBtoRGB(a.h,a.s,Math.min(a.b+b,1))
939 },blend:function(a){this.rgb.r=Math.floor((this.rgb.r+a.rgb.r)/2);
940 this.rgb.g=Math.floor((this.rgb.g+a.rgb.g)/2);
941 this.rgb.b=Math.floor((this.rgb.b+a.rgb.b)/2)
942 },isBright:function(){var a=this.asHSB();
943 return this.asHSB().b>0.5
944 },isDark:function(){return !this.isBright()
945 },asRGB:function(){return"rgb("+this.rgb.r+","+this.rgb.g+","+this.rgb.b+")"
946 },asHex:function(){return"#"+Rico.toColorPart(this.rgb.r)+Rico.toColorPart(this.rgb.g)+Rico.toColorPart(this.rgb.b)
947 },asHSB:function(){return Rico.Color.RGBtoHSB(this.rgb.r,this.rgb.g,this.rgb.b)
948 },toString:function(){return this.asHex()
950 Rico.Color.createFromHex=function(d){if(d.length==4){var b=d;
954 c++){d+=(b.charAt(c)+b.charAt(c))
955 }}if(d.indexOf("#")==0){d=d.substring(1)
956 }if(!d.match(/^[0-9A-Fa-f]{6}$/)){return null
957 }var f=d.substring(0,2);
958 var e=d.substring(2,4);
959 var a=d.substring(4,6);
960 return new Rico.Color(parseInt(f,16),parseInt(e,16),parseInt(a,16))
962 Rico.Color.createColorFromBackground=function(d){if(!d.style){return new Rico.Color(255,255,255)
963 }var b=Rico.getStyle(d,"background-color");
964 if(b.match(/^(transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i)&&d.parentNode){return Rico.Color.createColorFromBackground(d.parentNode)
965 }if(b==null){return new Rico.Color(255,255,255)
966 }if(b.indexOf("rgb(")==0){var a=b.substring(4,b.length-1);
968 return new Rico.Color(parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10))
969 }else{if(b.indexOf("#")==0){return Rico.Color.createFromHex(b)
970 }else{return new Rico.Color(255,255,255)
972 Rico.Color.HSBtoRGB=function(i,e,k){var c=0;
975 if(e==0){c=parseInt(k*255+0.5,10);
978 }else{var g=(i-Math.floor(i))*6;
979 var j=g-Math.floor(g);
982 var m=k*(1-(e*(1-j)));
983 switch(parseInt(g,10)){case 0:c=(k*255+0.5);
987 case 1:c=(a*255+0.5);
991 case 2:c=(b*255+0.5);
995 case 3:c=(b*255+0.5);
999 case 4:c=(m*255+0.5);
1003 case 5:c=(k*255+0.5);
1007 }}return{r:parseInt(c,10),g:parseInt(d,10),b:parseInt(l,10)}
1009 Rico.Color.RGBtoHSB=function(a,f,l){var h;
1020 }else{var c=(m-a)/(m-i);
1024 }else{if(f==m){h=2+c-d
1028 }}return{h:h,s:e,b:k}
1030 Rico.createXmlDocument=function(){if(document.implementation&&document.implementation.createDocument){var a=document.implementation.createDocument("","",null);
1031 if(a.readyState==null){a.readyState=1;
1032 a.addEventListener("load",function(){a.readyState=4;
1033 if(typeof a.onreadystatechange=="function"){a.onreadystatechange()
1036 }if(window.ActiveXObject){return Rico.tryFunctions(function(){return new ActiveXObject("MSXML2.DomDocument")
1037 },function(){return new ActiveXObject("Microsoft.DomDocument")
1038 },function(){return new ActiveXObject("MSXML.DomDocument")
1039 },function(){return new ActiveXObject("MSXML3.DomDocument")
1043 Rico.CalendarControl=function(b,a){this.initialize(b,a)
1045 Rico.CalendarControl.prototype={initialize:function(d,c){this.id=d;
1047 this.defaultMin=new Date(b.getFullYear()-50,0,1);
1048 this.defaultMax=new Date(b.getFullYear()+50,11,31);
1049 Rico.extend(this,new Rico.Popup());
1050 Rico.extend(this.options,{ignoreClicks:true,startAt:0,showWeekNumber:0,showToday:1,dateFmt:"ISO8601",minDate:this.defaultMin,maxDate:this.defaultMax});
1051 Rico.extend(this.options,c||{});
1052 this.bPageLoaded=false;
1054 this.re=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
1055 this.setDateFmt(this.options.dateFmt);
1057 Rico.onLoad(function(){a.atLoad()
1059 },setDateFmt:function(a){this.dateFmt=(a=="rico")?Rico.dateFmt:a;
1060 Rico.log(this.id+" date format set to "+this.dateFmt);
1062 if(this.re.exec(this.dateFmt)){this.dateParts[RegExp.$1]=0;
1063 this.dateParts[RegExp.$3]=1;
1064 this.dateParts[RegExp.$5]=2
1065 }},addHoliday:function(f,a,g,e,c,b){this.Holidays[this.holidayKey(g,a-1,f)]={desc:e,txtColor:b,bgColor:c||"#DDF"}
1066 },holidayKey:function(c,a,b){return"h"+Rico.zFill(c,4)+Rico.zFill(a,2)+Rico.zFill(b,2)
1067 },atLoad:function(){Rico.log("Calendar#atLoad: "+this.id);
1068 var d=Rico.$(this.id);
1069 if(d){this.setDiv(d)
1070 }else{this.createContainer();
1071 this.container.id=this.id
1072 }Rico.addClass(this.content,Rico.theme.calendar||"ricoCalContainer");
1073 this.direction=Rico.direction(this.container);
1074 var b,h,g,f,n,l,o,e;
1075 this.colStart=this.options.showWeekNumber?1:0;
1076 var k=7+this.colStart;
1077 this.maintab=document.createElement("table");
1078 this.maintab.cellSpacing=2;
1079 this.maintab.cellPadding=0;
1080 this.maintab.border=0;
1081 this.maintab.style.borderCollapse="separate";
1082 this.maintab.className=Rico.theme.calendarTable||"ricoCalTab";
1083 this.thead=this.maintab.createTHead();
1084 b=this.thead.insertRow(-1);
1085 this.heading=b.insertCell(-1);
1086 this.heading.colSpan=k;
1087 this.heading.className="RicoCalHeading";
1088 if(Rico.theme.calendarHeading){Rico.addClass(this.heading,Rico.theme.calendarHeading)
1089 }if(this.options.showToday){this.tfoot=this.maintab.createTFoot();
1090 this.tfoot.className="ricoCalFoot";
1091 b=this.tfoot.insertRow(-1);
1092 this.todayCell=b.insertCell(-1);
1093 this.todayCell.colSpan=k;
1094 this.todayCell.className=Rico.theme.calendarFooter||"ricoCalFoot";
1095 Rico.eventBind(this.todayCell,"click",Rico.eventHandle(this,"selectNow"),false)
1096 }this.tbody=Rico.getTBody(this.maintab);
1097 this.tbody.className="ricoCalBody";
1098 this.content.style.display="block";
1099 if(this.position=="absolute"){this.content.style.width="auto";
1100 this.maintab.style.width="auto"
1101 }else{this.container.style.position="relative";
1102 this.heading.style.position="static";
1103 this.content.style.padding="0px";
1104 this.content.style.width="15em";
1105 this.maintab.style.width="100%"
1109 g++){b=this.tbody.insertRow(-1);
1110 b.className=g==0?"ricoCalDayNames":"row"+g;
1111 if(this.options.showWeekNumber){h=b.insertCell(-1);
1112 h.className="ricoCalWeekNum";
1113 if(g==0){h.innerHTML=Rico.getPhraseById("calWeekHdg")
1116 f++){h=b.insertCell(-1);
1117 if(g==0){n=(f+this.options.startAt)%7;
1118 h.innerHTML=Rico.dayAbbr(n);
1119 this.styles[f]="ricoCal"+n
1120 }else{h.className=this.styles[f];
1121 if(Rico.theme.calendarDay){Rico.addClass(h,Rico.theme.calendarDay)
1122 }}}}this.content.appendChild(this.maintab);
1123 new Rico.HoverSet(this.tbody.getElementsByTagName("td"),{hoverNodes:function(a){return a.innerHTML.match(/^\d+$/)?[a]:[]
1125 this.navtab=this.heading.appendChild(document.createElement("table"));
1126 this.navrow=this.navtab.insertRow(-1);
1127 this._createTitleSection("Month");
1128 this.navrow.insertCell(-1).innerHTML=" ";
1129 this._createTitleSection("Year");
1130 new Rico.HoverSet(this.heading.getElementsByTagName("a"));
1131 if(this.position=="absolute"){this.heading.appendChild(Rico.closeButton(Rico.eventHandle(this,"close")))
1132 }this.monthPopup=new Rico.Popup(document.createElement("div"),{shim:false,zIndex:10});
1133 this.monthPopup.content.className="ricoCalMonthPrompt";
1134 e=document.createElement("table");
1135 e.className="ricoCalMenu";
1136 if(Rico.theme.calendarPopdown){Rico.addClass(e,Rico.theme.calendarPopdown)
1140 e.style.borderCollapse="separate";
1141 e.style.margin="0px";
1144 g++){b=e.insertRow(-1);
1147 f++){h=b.insertCell(-1);
1148 l=document.createElement("a");
1149 l.innerHTML=Rico.monthAbbr(g*3+f);
1151 if(Rico.theme.calendarDay){Rico.addClass(l,Rico.theme.calendarDay)
1153 Rico.eventBind(l,"click",Rico.eventHandle(this,"selectMonth"),false)
1154 }}new Rico.HoverSet(e.getElementsByTagName("a"));
1155 this.monthPopup.content.appendChild(e);
1156 this.container.appendChild(this.monthPopup.container);
1157 this.monthPopup.closePopup();
1158 this.yearPopup=new Rico.Popup(document.createElement("div"),{shim:false,zIndex:10});
1159 this.yearPopup.content.className="ricoCalYearPrompt";
1160 if(Rico.theme.calendarPopdown){Rico.addClass(this.yearPopup.content,Rico.theme.calendarPopdown)
1161 }this.yearPrompt=document.createElement("p");
1162 this.yearPrompt.innerHTML=" ";
1163 var m=document.createElement("p");
1164 this.yearInput=m.appendChild(document.createElement("input"));
1165 this.yearInput.maxlength=4;
1166 this.yearInput.size=4;
1167 Rico.eventBind(this.yearInput,"keyup",Rico.eventHandle(this,"yearKey"),false);
1168 l=Rico.floatButton("Checkmark",Rico.eventHandle(this,"processPopUpYear"));
1170 l=Rico.floatButton("Cancel",Rico.eventHandle(this,"popDownYear"));
1172 this.yearPopup.content.appendChild(this.yearPrompt);
1173 this.yearPopup.content.appendChild(m);
1174 this.container.appendChild(this.yearPopup.container);
1175 this.yearPopup.closePopup();
1176 l=this.content.getElementsByTagName("a");
1179 g++){l[g].href="javascript:void(0)"
1180 }Rico.eventBind(this.tbody,"click",Rico.eventHandle(this,"saveAndClose"));
1181 this.bPageLoaded=true
1182 },_createTitleSection:function(e){var d=["left","right"];
1183 if(this.direction=="rtl"){d.reverse()
1184 }var f=this.navrow.insertCell(-1);
1185 var b=f.appendChild(document.createElement("a"));
1186 b.className="Rico_"+d[0]+"Arrow";
1187 b.appendChild(this._createNavArrow(d[0]));
1188 Rico.eventBind(b,"click",Rico.eventHandle(this,"dec"+e),false);
1189 f=this.navrow.insertCell(-1);
1190 b=f.appendChild(document.createElement("a"));
1191 Rico.eventBind(b,"click",Rico.eventHandle(this,"popUp"+e),false);
1193 f=this.navrow.insertCell(-1);
1194 b=f.appendChild(document.createElement("a"));
1195 b.className="Rico_"+d[1]+"Arrow";
1196 b.appendChild(this._createNavArrow(d[1]));
1197 Rico.eventBind(b,"click",Rico.eventHandle(this,"inc"+e),false)
1198 },_createNavArrow:function(b){var a=document.createElement("span");
1199 a.className=Rico.theme[b+"Arrow"]||"rico-icon Rico_"+b+"Arrow";
1200 a.style.display="inline-block";
1202 },selectNow:function(){var a=new Date();
1203 this.dateNow=a.getDate();
1204 this.monthNow=a.getMonth();
1205 this.yearNow=a.getFullYear();
1206 this.monthSelected=this.monthNow;
1207 this.yearSelected=this.yearNow;
1208 this.constructCalendar()
1209 },isValidMonth:function(a,b){if(a<this.options.minDate.getFullYear()){return false
1210 }if(a==this.options.minDate.getFullYear()&&b<this.options.minDate.getMonth()){return false
1211 }if(a>this.options.maxDate.getFullYear()){return false
1212 }if(a==this.options.maxDate.getFullYear()&&b>this.options.maxDate.getMonth()){return false
1214 },incMonth:function(b){if(b){Rico.eventStop(b)
1215 }var c=this.monthSelected+1;
1216 var a=this.yearSelected;
1219 }if(!this.isValidMonth(a,c)){return
1220 }this.monthSelected=c;
1221 this.yearSelected=a;
1222 this.constructCalendar()
1223 },decMonth:function(b){if(b){Rico.eventStop(b)
1224 }var c=this.monthSelected-1;
1225 var a=this.yearSelected;
1228 }if(!this.isValidMonth(a,c)){return
1229 }this.monthSelected=c;
1230 this.yearSelected=a;
1231 this.constructCalendar()
1232 },selectMonth:function(b){var a=Rico.eventElement(b);
1233 this.monthSelected=parseInt(a.name,10);
1234 this.constructCalendar();
1236 },openYrMo:function(b,a){if(this.direction=="rtl"){a=1-a
1238 var c=a?this.content.offsetWidth-b.container.offsetWidth-5:3;
1239 b.move(c,this.heading.offsetHeight+2)
1240 },popUpMonth:function(a){Rico.eventStop(a);
1241 if(this.monthPopup.visible()){this.popDownMonth();
1243 }this.popDownYear();
1244 this.openYrMo(this.monthPopup,0);
1246 },popDownMonth:function(){this.monthPopup.closePopup()
1247 },popDownYear:function(){this.yearPopup.closePopup();
1248 this.yearInput.disabled=true
1249 },popUpYear:function(b){Rico.eventStop(b);
1250 if(this.yearPopup.visible()){this.popDownYear();
1252 }this.popDownMonth();
1253 this.yearPrompt.innerHTML=Rico.getPhraseById("calYearRange",this.options.minDate.getFullYear(),this.options.maxDate.getFullYear());
1254 this.yearInput.disabled=false;
1255 this.yearInput.value="";
1256 this.openYrMo(this.yearPopup,1);
1258 setTimeout(function(){a.yearInput.focus()
1261 },yearKey:function(a){switch(Rico.eventKey(a)){case 27:this.popDownYear();
1264 case 13:this.processPopUpYear();
1268 },processPopUpYear:function(){var a=this.yearInput.value;
1270 if(isNaN(a)||a<this.options.minDate.getFullYear()||a>this.options.maxDate.getFullYear()){alert(Rico.getPhraseById("calInvalidYear"))
1271 }else{this.yearSelected=a;
1273 this.constructCalendar()
1274 }},incYear:function(a){if(a){Rico.eventStop(a)
1275 }if(this.yearSelected>=this.options.maxDate.getFullYear()){return
1276 }this.yearSelected++;
1277 this.constructCalendar()
1278 },decYear:function(a){if(a){Rico.eventStop(a)
1279 }if(this.yearSelected<=this.options.minDate.getFullYear()){return
1280 }this.yearSelected--;
1281 this.constructCalendar()
1282 },WeekNbr:function(h,f,j){var g=new Date(h,f,j);
1283 var c=new Date(h,0,1);
1284 var e=7+1-c.getDay();
1286 }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;
1287 var d=Math.floor((b-e+7)/7);
1289 var a=new Date(h,0,1);
1290 var i=7+1-a.getDay();
1291 d=(i==2||i==8)?53:52
1293 },constructCalendar:function(){var l=[31,0,31,30,31,30,31,31,30,31,30,31];
1294 var d=new Date(this.yearSelected,this.monthSelected,1);
1296 if(typeof this.monthSelected!="number"||this.monthSelected>=12||this.monthSelected<0){alert("ERROR in calendar: monthSelected="+this.monthSelected);
1298 }if(this.monthSelected==1){j=new Date(this.yearSelected,this.monthSelected+1,1);
1299 j=new Date(j-(24*60*60*1000));
1301 }else{e=l[this.monthSelected]
1302 }var n=d.getDay()-this.options.startAt;
1304 }this.popDownMonth();
1306 if(this.options.showWeekNumber){for(f=1;
1308 f++){this.tbody.rows[f].cells[0].innerHTML=" "
1311 f++){this.resetCell(this.tbody.rows[1].cells[f+this.colStart])
1315 if(this.options.showWeekNumber&&b==0){this.tbody.rows[a].cells[0].innerHTML=this.WeekNbr(this.yearSelected,this.monthSelected,k)
1316 }var m=this.tbody.rows[a].cells[b+this.colStart];
1318 m.className=this.styles[b];
1319 if((k==this.dateNow)&&(this.monthSelected==this.monthNow)&&(this.yearSelected==this.yearNow)){Rico.addClass(m,Rico.theme.calendarToday||"ricoCalToday")
1320 }if(Rico.theme.calendarDay){Rico.addClass(m,Rico.theme.calendarDay)
1321 }if((k==this.odateSelected)&&(this.monthSelected==this.omonthSelected)&&(this.yearSelected==this.oyearSelected)){Rico.addClass(m,Rico.theme.calendarSelectedDay||"ricoSelectedDay")
1322 }var g=this.Holidays[this.holidayKey(this.yearSelected,this.monthSelected,k)];
1323 if(!g){g=this.Holidays[this.holidayKey(0,this.monthSelected,k)]
1324 }m.style.color=g?g.txtColor:"";
1325 m.style.backgroundColor=g?g.bgColor:"";
1326 m.title=g?g.desc:"";
1327 m.style.visibility="visible";
1329 }}while(n<42){b=n%7;
1330 this.resetCell(this.tbody.rows[a].cells[b+this.colStart]);
1333 }}this.titleMonth.innerHTML=Rico.monthAbbr(this.monthSelected);
1334 this.titleYear.innerHTML=this.yearSelected;
1335 if(this.todayCell){this.todayCell.innerHTML=Rico.getPhraseById("calToday",this.dateNow,Rico.monthAbbr(this.monthNow),this.yearNow,this.monthNow+1)
1336 }},resetCell:function(a){a.innerHTML=" ";
1338 a.style.visibility="hidden"
1339 },close:function(a){if(a){Rico.eventStop(a)
1341 },saveAndClose:function(g){Rico.eventStop(g);
1342 var f=Rico.eventElement(g);
1343 var c=f.innerHTML.replace(/ /g,"");
1344 if(c==""||f.className=="ricoCalWeekNum"){return
1345 }var b=parseInt(c,10);
1347 }var h=new Date(this.yearSelected,this.monthSelected,b);
1348 var a=Rico.formatDate(h,this.dateFmt=="ISO8601"?"yyyy-mm-dd":this.dateFmt);
1349 if(this.returnValue){this.returnValue(a);
1351 }},open:function(c,b){if(!this.bPageLoaded){return
1352 }if(b){this.setDateFmt(b.format.dateFmt);
1353 this.options.minDate=b.format.min||this.defaultMin;
1354 this.options.maxDate=b.format.max||this.defaultMax
1356 this.dateNow=a.getDate();
1357 this.monthNow=a.getMonth();
1358 this.yearNow=a.getFullYear();
1359 this.oyearSelected=-1;
1360 if(typeof c=="object"){this.odateSelected=c.getDate();
1361 this.omonthSelected=c.getMonth();
1362 this.oyearSelected=c.getFullYear()
1363 }else{if(this.dateFmt=="ISO8601"){var e=Rico.setISO8601(c);
1364 if(e){this.odateSelected=e.getDate();
1365 this.omonthSelected=e.getMonth();
1366 this.oyearSelected=e.getFullYear()
1367 }}else{if(this.re.exec(c)){var g=[RegExp.$1,RegExp.$3,RegExp.$5];
1368 this.odateSelected=parseInt(g[this.dateParts.dd],10);
1369 this.omonthSelected=parseInt(g[this.dateParts.mm],10)-1;
1370 this.oyearSelected=parseInt(g[this.dateParts.yyyy],10);
1371 if(this.oyearSelected<100){this.oyearSelected+=this.yearNow-(this.yearNow%100);
1372 var f=this.options.maxDate.getFullYear();
1373 while(this.oyearSelected>f){this.oyearSelected-=100
1374 }}}else{if(c){alert("ERROR: invalid date passed to calendar ("+c+")")
1375 }}}}if(this.oyearSelected>0){this.dateSelected=this.odateSelected;
1376 this.monthSelected=this.omonthSelected;
1377 this.yearSelected=this.oyearSelected
1378 }else{this.dateSelected=this.dateNow;
1379 this.monthSelected=this.monthNow;
1380 this.yearSelected=this.yearNow
1381 }this.constructCalendar();
1384 Rico.ColorPicker=function(b,a){this.initialize(b,a)
1386 Rico.ColorPicker.prototype={initialize:function(i,d){this.id=i;
1387 this.currentValue="#FFFFFF";
1388 Rico.extend(this,new Rico.Popup());
1389 Rico.extend(this.options,{showColorCode:false,cellsPerRow:18,palette:[]});
1390 var h=["00","33","66","99","CC","FF"];
1397 a++){this.options.palette.push(h[e]+h[f]+h[a])
1398 }}}Rico.extend(this.options,d||{});
1400 Rico.onLoad(function(){c.atLoad()
1402 },atLoad:function(){this.createContainer();
1403 this.content.className="ricoColorPicker";
1404 var c=this.options.cellsPerRow;
1405 var d="<TABLE BORDER='1' CELLSPACING='1' CELLPADDING='0'>";
1407 b<this.options.palette.length;
1408 b++){if((b%c)==0){d+="<TR>"
1409 }d+='<TD BGCOLOR="#'+this.options.palette[b]+'"> </TD>';
1410 if(((b+1)>=this.options.palette.length)||(((b+1)%c)==0)){d+="</TR>"
1411 }}var a=Math.floor(c/2);
1412 if(this.options.showColorCode){d+="<TR><TD COLSPAN='"+a+"' ID='colorPickerSelectedColor'> </TD><TD COLSPAN='"+(c-a)+"' ALIGN='CENTER' ID='colorPickerSelectedColorValue'>#FFFFFF</TD></TR>"
1413 }else{d+="<TR><TD COLSPAN='"+c+"' ID='colorPickerSelectedColor'> </TD></TR>"
1415 this.content.innerHTML=d;
1416 this.open=this.openPopup;
1417 this.close=this.closePopup;
1418 Rico.eventBind(this.container,"mouseover",Rico.eventHandle(this,"highlightColor"),false);
1419 Rico.eventBind(this.container,"click",Rico.eventHandle(this,"selectColor"),false);
1421 },selectColor:function(a){Rico.eventStop(a);
1422 if(this.returnValue){this.returnValue(this.currentValue)
1424 },highlightColor:function(b){var a=Rico.eventElement(b);
1425 if(!a.tagName||a.tagName.toLowerCase()!="td"){return
1426 }var g=Rico.Color.createColorFromBackground(a).toString();
1427 this.currentValue=g;
1428 Rico.setStyle("colorPickerSelectedColor",{backgroundColor:g});
1429 var f=Rico.$("colorPickerSelectedColorValue");
1433 Rico.registerDraggable=function(b,a){if(typeof a!="number"){a=0
1434 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1435 }Rico.dndMgrList[a].registerDraggable(b)
1437 Rico.registerDropZone=function(b,a){if(typeof a!="number"){a=0
1438 }if(typeof Rico.dndMgrList[a]!="object"){Rico.dndMgrList[a]=new Rico.dndMgr()
1439 }Rico.dndMgrList[a].registerDropZone(b)
1441 Rico.dndMgr=function(){this.initialize()
1443 Rico.dndMgr.prototype={initialize:function(){this.dropZones=[];
1445 this.currentDragObjects=[];
1446 this.dragElement=null;
1447 this.lastSelectedDraggable=null;
1448 this.currentDragObjectVisible=false;
1449 this.interestedInMotionEvents=false;
1450 this._mouseDown=Rico.eventHandle(this,"_mouseDownHandler");
1451 this._mouseMove=Rico.eventHandle(this,"_mouseMoveHandler");
1452 this._mouseUp=Rico.eventHandle(this,"_mouseUpHandler")
1453 },registerDropZone:function(a){this.dropZones[this.dropZones.length]=a
1454 },deregisterDropZone:function(a){var d=new Array();
1457 c<this.dropZones.length;
1458 c++){if(this.dropZones[c]!=a){d[b++]=this.dropZones[c]
1460 },clearDropZones:function(){this.dropZones=new Array()
1461 },registerDraggable:function(a){this.draggables[this.draggables.length]=a;
1462 var b=a.getMouseDownHTMLElement();
1463 if(b!=null){b.ricoDraggable=a;
1464 Rico.eventBind(b,"mousedown",Rico.eventHandle(this,"_attachEvents"));
1465 Rico.eventBind(b,"mousedown",this._mouseDown)
1466 }},clearSelection:function(){for(var a=0;
1467 a<this.currentDragObjects.length;
1468 a++){this.currentDragObjects[a].deselect()
1469 }this.currentDragObjects=new Array();
1470 this.lastSelectedDraggable=null
1471 },hasSelection:function(){return this.currentDragObjects.length>0
1472 },setStartDragFromElement:function(a,c){this.origPos=Rico.cumulativeOffset(c);
1473 var b=Rico.eventClient(a);
1474 this.startx=b.x-this.origPos.left;
1475 this.starty=b.y-this.origPos.top;
1476 this.interestedInMotionEvents=this.hasSelection();
1478 },updateSelection:function(a,b){if(!b){this.clearSelection()
1479 }if(a.isSelected()){this.currentDragObjects=this.currentDragObjects.without(a);
1481 if(a==this.lastSelectedDraggable){this.lastSelectedDraggable=null
1483 if(a.isSelected()){this.currentDragObjects.push(a);
1484 this.lastSelectedDraggable=a
1485 }}},_mouseDownHandler:function(f){if(!Rico.eventLeftClick(f)){return
1486 }var d=Rico.eventElement(f);
1487 var a=d.ricoDraggable;
1489 while(a==null&&c.parentNode){c=c.parentNode;
1492 }this.updateSelection(a,f.ctrlKey);
1493 if(this.hasSelection()){for(var b=0;
1494 b<this.dropZones.length;
1495 b++){this.dropZones[b].clearPositionCache()
1496 }}this.setStartDragFromElement(f,a.getMouseDownHTMLElement())
1497 },_mouseMoveHandler:function(a){if(!this.interestedInMotionEvents){return
1498 }if(!this.hasSelection()){return
1499 }if(!this.currentDragObjectVisible){this._startDrag(a)
1500 }if(!this.activatedDropZones){this._activateRegisteredDropZones()
1501 }this._updateDraggableLocation(a);
1502 this._updateDropZonesHover(a);
1504 },_makeDraggableObjectVisible:function(b){if(!this.hasSelection()){return
1506 if(this.currentDragObjects.length>1){a=this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects)
1507 }else{a=this.currentDragObjects[0].getSingleObjectDragGUI()
1508 }this.dragElemPosition=Rico.getStyle(a,"position");
1509 if(this.dragElemPosition!="absolute"){a.style.position="absolute"
1510 }if(a.parentNode==null||a.parentNode.nodeType==11){document.body.appendChild(a)
1511 }this.dragElement=a;
1512 this._updateDraggableLocation(b);
1513 this.currentDragObjectVisible=true
1514 },_leftOffset:function(a){return a.offsetX?document.body.scrollLeft:0
1515 },_topOffset:function(a){return a.offsetY?document.body.scrollTop:0
1516 },_updateDraggableLocation:function(b){var a=this.dragElement.style;
1517 var c=Rico.eventClient(b);
1518 a.left=(c.x+this._leftOffset(b)-this.startx)+"px";
1519 a.top=(c.y+this._topOffset(b)-this.starty)+"px"
1520 },_updateDropZonesHover:function(b){var a,c=this.dropZones.length;
1523 a++){if(!this._mousePointInDropZone(b,this.dropZones[a])){this.dropZones[a].hideHover()
1526 a++){if(this._mousePointInDropZone(b,this.dropZones[a])){if(this.dropZones[a].canAccept(this.currentDragObjects)){this.dropZones[a].showHover()
1527 }}}},_startDrag:function(b){for(var a=0;
1528 a<this.currentDragObjects.length;
1529 a++){this.currentDragObjects[a].startDrag()
1530 }this._makeDraggableObjectVisible(b)
1531 },_mouseUpHandler:function(b){if(!this.hasSelection()){return
1532 }if(!Rico.eventLeftClick(b)){return
1533 }this.interestedInMotionEvents=false;
1534 if(this._placeDraggableInDropZone(b)){this._completeDropOperation(b)
1535 }else{if(this.dragElement!=null){Rico.eventStop(b);
1537 Rico.animate(this.dragElement,{duration:300,onEnd:function(){a._doCancelDragProcessing()
1538 }},{left:this.origPos.left,top:this.origPos.top})
1539 }}Rico.eventUnbind(document.body,"mousemove",this._mouseMove);
1540 Rico.eventUnbind(document.body,"mouseup",this._mouseUp)
1541 },_retTrue:function(){return true
1542 },_completeDropOperation:function(a){if(this.dragElement!=this.currentDragObjects[0].getMouseDownHTMLElement()){if(this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1543 }}this._deactivateRegisteredDropZones();
1545 this.clearSelection();
1546 this.dragElement=null;
1547 this.currentDragObjectVisible=false;
1549 },_doCancelDragProcessing:function(){this._cancelDrag();
1550 if(this.dragElement==this.currentDragObjects[0].getMouseDownHTMLElement()){this.dragElement.style.position=this.dragElemPosition
1551 }else{if(this.dragElement&&this.dragElement.parentNode!=null){this.dragElement.parentNode.removeChild(this.dragElement)
1552 }}this._deactivateRegisteredDropZones();
1553 this.dragElement=null;
1554 this.currentDragObjectVisible=false
1555 },_placeDraggableInDropZone:function(c){var a=false;
1556 var d=this.dropZones.length;
1559 b++){if(this._mousePointInDropZone(c,this.dropZones[b])){if(this.dropZones[b].canAccept(this.currentDragObjects)){this.dropZones[b].hideHover();
1560 this.dropZones[b].accept(this.currentDragObjects);
1564 },_cancelDrag:function(){for(var a=0;
1565 a<this.currentDragObjects.length;
1566 a++){this.currentDragObjects[a].cancelDrag()
1567 }},_endDrag:function(){for(var a=0;
1568 a<this.currentDragObjects.length;
1569 a++){this.currentDragObjects[a].endDrag()
1570 }},_mousePointInDropZone:function(b,c){var a=c.getAbsoluteRect();
1571 var d=Rico.eventClient(b);
1572 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)
1573 },_activateRegisteredDropZones:function(){var c=this.dropZones.length;
1576 a++){var b=this.dropZones[a];
1577 if(b.canAccept(this.currentDragObjects)){b.activate()
1578 }}this.activatedDropZones=true
1579 },_deactivateRegisteredDropZones:function(){var b=this.dropZones.length;
1582 a++){this.dropZones[a].deactivate()
1583 }this.activatedDropZones=false
1584 },_attachEvents:function(){Rico.eventBind(document.body,"mousemove",this._mouseMove);
1585 Rico.eventBind(document.body,"mouseup",this._mouseUp)
1587 Rico.Draggable=function(a,b){this.initialize(a,b)
1589 Rico.Draggable.prototype={initialize:function(a,b){this.type=a;
1590 this.htmlElement=Rico.$(b);
1592 },getMouseDownHTMLElement:function(){return this.htmlElement
1593 },select:function(){this._select()
1594 },_select:function(){this.selected=true;
1595 if(this.showingSelected){return
1596 }this.showingSelected=true;
1597 var b=this.getMouseDownHTMLElement();
1598 var a=Rico.Color.createColorFromBackground(b);
1599 a.isBright()?a.darken(0.033):a.brighten(0.033);
1600 this.saveBackground=Rico.getStyle(b,"backgroundColor","background-color");
1601 b.style.backgroundColor=a.asHex()
1602 },deselect:function(){this.selected=false;
1603 if(!this.showingSelected){return
1604 }var a=this.getMouseDownHTMLElement();
1605 a.style.backgroundColor=this.saveBackground;
1606 this.showingSelected=false
1607 },isSelected:function(){return this.selected
1608 },startDrag:function(){},cancelDrag:function(){},endDrag:function(){},getSingleObjectDragGUI:function(){return this.htmlElement
1609 },getMultiObjectDragGUI:function(a){return this.htmlElement
1610 },getDroppedGUI:function(){return this.htmlElement
1611 },toString:function(){return this.type+":"+this.htmlElement+":"
1613 Rico.LiveGridDraggable=function(b,a,c){this.initialize(b,a,c)
1615 Rico.LiveGridDraggable.prototype=Rico.extend(new Rico.Draggable(),{initialize:function(b,a,c){this.type="RicoCell";
1616 this.htmlElement=b.cell(a,c);
1620 },select:function(){if(this.dragRow>=this.liveGrid.buffer.totalRows){return
1621 }this.selected=true;
1622 this.showingSelected=true
1623 },deselect:function(){this.selected=false;
1624 this.showingSelected=false
1625 },getSingleObjectDragGUI:function(){var a=document.createElement("div");
1626 a.className="LiveGridDraggable";
1627 a.style.width=(this.htmlElement.offsetWidth-10)+"px";
1628 a.innerHTML=this.htmlElement.innerHTML;
1631 Rico.Dropzone=function(a){this.initialize(a)
1633 Rico.Dropzone.prototype={initialize:function(a){this.htmlElement=Rico.$(a);
1634 this.absoluteRect=null
1635 },getHTMLElement:function(){return this.htmlElement
1636 },clearPositionCache:function(){this.absoluteRect=null
1637 },getAbsoluteRect:function(){if(this.absoluteRect==null){var a=this.getHTMLElement();
1638 var b=Rico.viewportOffset(a);
1639 this.absoluteRect={top:b.top,left:b.left,bottom:b.top+a.offsetHeight,right:b.left+a.offsetWidth}
1640 }return this.absoluteRect
1641 },activate:function(){var c=this.getHTMLElement();
1642 if(c==null||this.showingActive){return
1643 }this.showingActive=true;
1644 this.saveBackgroundColor=c.style.backgroundColor;
1646 var a=Rico.Color.createColorFromBackground(c);
1647 if(a==null){c.style.backgroundColor=b
1648 }else{a.isBright()?a.darken(0.2):a.brighten(0.2);
1649 c.style.backgroundColor=a.asHex()
1650 }},deactivate:function(){var a=this.getHTMLElement();
1651 if(a==null||!this.showingActive){return
1652 }a.style.backgroundColor=this.saveBackgroundColor;
1653 this.showingActive=false;
1654 this.saveBackgroundColor=null
1655 },showHover:function(){var a=this.getHTMLElement();
1656 if(a==null||this.showingHover){return
1657 }this.saveBorderWidth=a.style.borderWidth;
1658 this.saveBorderStyle=a.style.borderStyle;
1659 this.saveBorderColor=a.style.borderColor;
1660 this.showingHover=true;
1661 a.style.borderWidth="1px";
1662 a.style.borderStyle="solid";
1663 a.style.borderColor="#ffff00"
1664 },hideHover:function(){var a=this.getHTMLElement();
1665 if(a==null||!this.showingHover){return
1666 }a.style.borderWidth=this.saveBorderWidth;
1667 a.style.borderStyle=this.saveBorderStyle;
1668 a.style.borderColor=this.saveBorderColor;
1669 this.showingHover=false
1670 },canAccept:function(a){return true
1671 },accept:function(b){var d=this.getHTMLElement();
1676 a++){var c=b[a].getDroppedGUI();
1677 if(Rico.getStyle(c,"position")=="absolute"){c.style.position="static";
1682 Rico.KeywordSearch=function(b,a){this.initialize(b,a)
1684 Rico.KeywordSearch.prototype={initialize:function(c,b){this.id=c;
1685 Rico.extend(this,new Rico.Window(Rico.getPhraseById("keywordTitle"),b));
1686 Rico.addClass(this.content,"ricoKeywordSearch");
1687 Rico.extend(this.options,{listLength:10,maxSuggest:20,width:"12em"});
1689 Rico.onLoad(function(){a.atLoad()
1691 },atLoad:function(){this.searchField=Rico.createFormField(this.contentDiv,"input","text",this.id+"_search");
1692 this.searchField.style.display="block";
1693 this.searchField.style.width=this.options.width;
1694 Rico.eventBind(this.searchField,"keyup",Rico.eventHandle(this,"filterKeypress"),false);
1695 this.selectList=Rico.createFormField(this.contentDiv,"select",null,this.id+"_list");
1696 this.selectList.size=this.options.listLength;
1697 this.selectList.style.display="block";
1698 this.selectList.style.width=this.options.width;
1699 Rico.eventBind(this.selectList,"change",Rico.eventHandle(this,"listClick"),false);
1700 this.close=this.closePopup;
1702 },open:function(a,b){this.column=b;
1703 this.grid=this.column.liveGrid;
1704 this.searchField.value="";
1705 this.selectList.options.length=0;
1707 this.searchField.focus();
1708 this.selectValuesRequest("")
1709 },selectValuesRequest:function(c){var d=this.column.index;
1711 Rico.extend(b,this.grid.buffer.ajaxOptions);
1712 b.parameters={id:this.grid.tableId,offset:"0",page_size:this.options.maxSuggest,edit:d};
1713 b.parameters[this.grid.actionId]="query";
1714 if(c!=""&&c!="*"){if(c.indexOf("*")==-1){c="*"+c+"*"
1715 }b.parameters["f[1][op]"]="LIKE";
1716 b.parameters["f[1][len]"]=1;
1717 b.parameters["f[1][0]"]=c
1719 b.onComplete=function(e){a.selectValuesUpdate(e)
1721 new Rico.ajaxRequest(this.grid.buffer.dataSource,b)
1722 },selectValuesUpdate:function(b){var a=b.responseXML.getElementsByTagName("ajax-response");
1723 Rico.log("selectValuesUpdate: "+b.status);
1724 if(a==null||a.length!=1){return
1726 var h=a.getElementsByTagName("error");
1727 if(h.length>0){var f=Rico.getContentAsString(h[0],this.grid.buffer.isEncoded);
1728 Rico.log("Data provider returned an error:\n"+f);
1729 alert(Rico.getPhraseById("requestError",f));
1731 }this.selectList.options.length=0;
1732 a=a.getElementsByTagName("response")[0];
1733 var g=a.getElementsByTagName("rows")[0];
1734 var j=this.grid.buffer.dom2jstable(g);
1735 Rico.log("selectValuesUpdate: id="+this.selectList.id+" rows="+j.length);
1738 d++){if(j[d].length>0){var e=j[d][0];
1739 var c=(j[d].length>1)?j[d][1]:e;
1740 Rico.addSelectOption(this.selectList,e,c)
1741 }}},filterKeypress:function(c){var a=Rico.eventElement(c);
1742 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
1743 }if(this.lastKeyFilter==a.value){return
1745 Rico.log("filterKeypress: "+this.index+" "+b);
1746 this.lastKeyFilter=b;
1747 this.selectValuesRequest(b)
1748 },listClick:function(c){var b=Rico.eventElement(c);
1749 if(b.tagName.toLowerCase()!="select"){return
1750 }if(this.returnValue){var a=b.options[b.selectedIndex];
1751 this.returnValue(a.value,a.innerHTML)
1754 Rico.TreeControl=function(c,b,a){this.initialize(c,b,a)
1756 Rico.TreeControl.prototype={initialize:function(d,c,b){Rico.extend(this,new Rico.Popup());
1757 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"});
1758 Rico.extend(this.options,b||{});
1761 this.close=this.closePopup;
1762 this.hoverSet=new Rico.HoverSet([]);
1764 Rico.onLoad(function(){a.atLoad()
1766 },atLoad:function(){this.treeDiv=document.createElement("div");
1767 this.treeDiv.className="ricoTree";
1768 if(Rico.theme.treeContent){Rico.addClass(this.treeDiv,Rico.theme.treeContent)
1769 }var b=Rico.$(this.id);
1770 if(b){this.setDiv(b,{position:"auto"})
1771 }else{this.treeDiv.id=this.id;
1772 this.createContainer()
1773 }this.treeDiv.style.height=this.options.height;
1774 this.treeDiv.style.width=this.options.width;
1775 this.content.className=Rico.theme.tree||"ricoTreeContainer";
1776 this.content.appendChild(this.treeDiv);
1777 if(this.options.showCheckBox){this.buttonDiv=document.createElement("div");
1778 this.buttonDiv.style.width=this.options.width;
1779 this.buttonDiv.className="ricoTreeButtons";
1780 if(Rico.getStyle(this.container,"position")=="absolute"){var a=document.createElement("span");
1781 a.innerHTML=Rico.getPhraseById("treeSave");
1782 Rico.setStyle(a,{"float":"left",cursor:"pointer"});
1783 this.buttonDiv.appendChild(a);
1784 Rico.eventBind(a,"click",Rico.eventHandle(this,"saveSelection"))
1785 }var a=document.createElement("span");
1786 a.innerHTML=Rico.getPhraseById("treeClear");
1787 Rico.setStyle(a,{"float":"right",cursor:"pointer"});
1788 this.buttonDiv.appendChild(a);
1789 this.content.appendChild(this.buttonDiv);
1790 Rico.eventBind(a,"click",Rico.eventHandle(this,"clrCheckBoxEvent"))
1791 }if(this.position=="absolute"){this.close()
1792 }},setTreeDiv:function(a){this.treeDiv=Rico.$(a);
1793 this.openPopup=function(){}
1794 },open:function(){this.openPopup();
1795 if(this.treeDiv.childNodes.length==0&&this.dataSource){this.loadXMLDoc()
1796 }},loadXMLDoc:function(c){var b={id:this.id};
1798 }Rico.log("Tree loadXMLDoc: "+this.id);
1800 new Rico.ajaxRequest(this.dataSource,{parameters:b,method:"get",onComplete:function(d){a.processResponse(d)
1802 },domID:function(b,a){return"RicoTree_"+a+"_"+this.id+"_"+b
1803 },processResponse:function(d){var b=d.responseXML.getElementsByTagName("ajax-response");
1804 if(b==null||b.length!=1){return
1805 }var f=b[0].getElementsByTagName("rows")[0];
1806 var g=f.getElementsByTagName("tr");
1810 e++){var l=g[e].getElementsByTagName("td");
1811 if(l.length<5){continue
1813 h[5]=this.options.leafIcon;
1816 c++){h[c]=Rico.getContentAsString(l[c],true)
1817 }h[3]=h[3].match(/^0|L$/i)?0:1;
1818 h[4]=parseInt(h[4]);
1822 e++){var a=(e<k.length-1)&&(k[e][0]==k[e+1][0]);
1823 this.addNode(k[e][0],k[e][1],k[e][2],k[e][3],k[e][4],k[e][5],!a)
1824 }},addNode:function(q,l,t,f,u,s,k){var h=Rico.$(this.domID(q,"Parent"));
1825 var v=Rico.$(this.domID(q,"Children"));
1826 var a=h?h.TreeLevel+1:0;
1827 var b=document.createElement("table");
1828 var m=document.createElement("div");
1829 m.id=this.domID(l,"Children");
1830 m.className="ricoTreeBranch";
1831 m.style.display=h?"none":"";
1835 b.id=this.domID(l,"Parent");
1838 b.TreeFetchedChildren=this.dataSource?false:true;
1839 var d=b.insertRow(0);
1843 r++){g[r]=d.insertCell(-1)
1844 }if(a>1){var e=h.getElementsByTagName("td");
1847 r++){g[r].innerHTML=e[r].innerHTML
1848 }var w=document.createElement("div");
1849 w.className="rico-icon rico-tree-"+(v.nextSibling&&this.options.showLines?"nodeline":"nodeblank");
1850 g[a-2].appendChild(w)
1851 }if(a>0){var c=k&&this.options.showLines?"last":"";
1852 var o=this.options.showLines?"node":"";
1853 if(this.options.showPlusMinus&&f){var w=document.createElement("div");
1855 w.style.cursor="pointer";
1856 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1857 w.className="rico-icon rico-tree-"+o+"p"+c;
1858 d.insertCell(-1).appendChild(w)
1859 }else{if(this.options.showLines){var w=document.createElement("div");
1860 w.className="rico-icon rico-tree-node"+c;
1861 d.insertCell(-1).appendChild(w)
1862 }}if(this.options.showFolders&&(f||(s&&s!="none"))){var w=document.createElement("div");
1863 if(!f){w.className=s
1865 w.style.cursor="pointer";
1866 Rico.eventBind(w,"click",Rico.eventHandle(this,"clickBranch"));
1867 w.className="rico-icon rico-folderclosed"
1868 }d.insertCell(-1).appendChild(w)
1869 }}if(u&&this.options.showCheckBox){var n=document.createElement("input");
1872 d.insertCell(-1).appendChild(n)
1873 }if(u&&!this.options.showCheckBox){var p=document.createElement("a");
1874 if(typeof u=="string"){p.href=u
1875 }else{p.href="javascript:void(0)";
1876 Rico.eventBind(p,"click",this.options.defaultAction)
1877 }this.hoverSet.add(p)
1878 }else{var p=document.createElement("p")
1879 }p.id=this.domID(l,"Desc");
1880 p.className="ricoTreeLevel"+a;
1881 switch(this.options.nodeIdDisplay){case"last":t+=" ("+l+")";
1883 case"first":t=l+" - "+t;
1885 case"tooltip":p.title=l;
1887 }p.appendChild(document.createTextNode(t));
1888 d.insertCell(-1).appendChild(p);
1889 var j=v||this.treeDiv;
1892 },nodeClick:function(c){var b=Rico.eventElement(c);
1893 if(this.returnValue){var a=this.domID("","Desc");
1894 this.returnValue(b.id.substr(a.length),b.innerHTML)
1896 },saveSelection:function(a){if(this.returnValue){this.returnValue(this.getCheckedItems())
1898 },getCheckedItems:function(){var b=this.treeDiv.getElementsByTagName("input");
1902 a++){if(b[a].type=="checkbox"&&b[a].checked){c.push(b[a].value)
1904 },setCheckBoxes:function(c){var b=this.treeDiv.getElementsByTagName("input");
1907 a++){if(b[a].type=="checkbox"){b[a].checked=c
1908 }}},clrCheckBoxEvent:function(a){Rico.eventStop(a);
1909 this.setCheckBoxes(false)
1910 },clickBranch:function(h){var g=Rico.eventElement(h);
1911 var f=Rico.getParentByTagName(g,"table");
1912 if(!f||!f.TreeContainer){return
1913 }var c=f.id.split("_");
1915 var b=Rico.$(c.join("_"));
1917 if(g.tagName=="DIV"){var d=Rico.visible(b);
1918 if(g.className.match(/node(p|m)(last)?$/)){g.className=g.className.replace(/nodep|nodem/,"node"+(d?"m":"p"))
1919 }else{if(g.className.match(/folder(open|closed)$/)){g.className=g.className.replace(/folder(open|closed)/,"folder"+(d?"open":"closed"))
1920 }else{if(g.className.match(/\b(m|p)$/)){g.className=g.className.replace(/(p|m)$/,d?"m":"p")
1921 }}}}if(!f.TreeFetchedChildren){f.TreeFetchedChildren=1;
1922 this.loadXMLDoc(g.name)
1924 if(typeof Rico=="undefined"){throw ("GridCommon requires the Rico JavaScript framework")
1925 }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:null,defaultWidth:-1,scrollBarWidth:19,minScrollWidth:100,frozenColumns:0,exportWindow:"height=400,width=500,scrollbars=1,menubar=1,resizable=1,location=0,toolbar=0,status=0",exportStyleList:["background-color","color","text-align","font-weight","font-size","font-family"],exportImgTags:false,exportFormFields:true,FilterLocation:null,FilterAllToken:"___ALL___",columnSpecs:[]};
1927 this.headerColCnt=0;
1928 this.headerRowIdx=0;
1929 this.tabs=new Array(2);
1930 this.thead=new Array(2);
1931 this.tbody=new Array(2)
1932 },attachMenuEvents:function(){var a;
1933 if(!this.options.menuEvent||this.options.menuEvent=="none"){return
1934 }this.hideScroll=navigator.userAgent.match(/Macintosh\b.*\b(Firefox|Camino)\b/i)||(Rico.isOpera&&parseFloat(window.opera.version())<9.5);
1935 this.options[this.options.menuEvent]=Rico.eventHandle(this,"handleMenuClick");
1936 if(this.highlightDiv){switch(this.options.highlightElem){case"cursorRow":this.attachMenu(this.highlightDiv[0]);
1938 case"cursorCell":for(a=0;
1940 a++){this.attachMenu(this.highlightDiv[a])
1944 a++){this.attachMenu(this.tbody[a])
1945 }},attachMenu:function(a){if(this.options.click){Rico.eventBind(a,"click",this.options.click,false)
1946 }if(this.options.dblclick){if(Rico.isWebKit||Rico.isOpera){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleDblClick"),false)
1947 }else{Rico.eventBind(a,"dblclick",this.options.dblclick,false)
1948 }}if(this.options.contextmenu){if(Rico.isOpera||Rico.isKonqueror){Rico.eventBind(a,"click",Rico.eventHandle(this,"handleContextMenu"),false)
1949 }else{Rico.eventBind(a,"contextmenu",this.options.contextmenu,false)
1950 }}},handleDblClick:function(b){var a=Rico.eventElement(b);
1951 if(this.dblClickElem==a){this.options.dblclick(b)
1952 }else{this.dblClickElem=a;
1953 this.safariTimer=Rico.runLater(300,this,"clearDblClick")
1954 }},clearDblClick:function(){this.dblClickElem=null
1955 },handleContextMenu:function(c){var a;
1956 if(typeof(c.which)=="number"){a=c.which
1957 }else{if(typeof(c.button)=="number"){a=c.button
1959 }}if(a==1&&c.ctrlKey){this.options.contextmenu(c)
1960 }},cancelMenu:function(){if(this.menu){this.menu.cancelmenu()
1961 }},getColumnInfo:function(f){Rico.log("getColumnInfo: len="+f.length);
1962 if(f.length==0){return 0
1963 }this.headerRowCnt=f.length;
1966 d<this.headerRowCnt;
1969 if(d>=this.hdrCells.length){this.hdrCells[d]=[]
1974 g.colSpan=a[h].colSpan||1;
1975 if(this.options.defaultWidth<0){g.initWidth=a[h].offsetWidth
1976 }this.hdrCells[d].push(g)
1977 }if(b.id.slice(-5)=="_main"){e=this.hdrCells[d].length;
1979 }}if(!e){this.headerRowIdx=this.headerRowCnt-1;
1980 e=this.hdrCells[this.headerRowIdx].length
1981 }Rico.log("getColumnInfo: colcnt="+e);
1983 },addHeadingRow:function(g){var a=this.headerRowCnt++;
1984 this.hdrCells[a]=[];
1987 e++){var k=this.thead[e].insertRow(-1);
1988 var f="ricoLG_hdg "+this.tableId+"_hdg"+a;
1991 var b=e==0?this.options.frozenColumns:this.headerColCnt-this.options.frozenColumns;
1994 j++){var d=k.insertCell(-1);
1995 var i=Rico.wrapChildren(d,"ricoLG_col");
1996 Rico.wrapChildren(i,"ricoLG_cell");
1997 this.hdrCells[a].push({cell:d,colSpan:1})
1999 },createColumnArray:function(d){this.direction=Rico.getStyle(this.outerDiv,"direction").toLowerCase();
2000 this.align=this.direction=="rtl"?["right","left"]:["left","right"];
2001 Rico.log("createColumnArray: dir="+this.direction);
2004 b++){Rico.addClass(this.thead[b].rows[this.headerRowIdx],"rico_ResizeRow")
2007 f<this.headerColCnt;
2008 f++){Rico.log("createColumnArray: c="+f);
2009 var e=f<this.options.frozenColumns?0:1;
2010 var a=new Rico[d](this,f,this.hdrCells[this.headerRowIdx][f],e);
2011 this.columns.push(a);
2012 if(f>0){this.columns[f-1].next=a
2014 Rico.runLater(100,this,"insertResizers")
2015 },insertResizers:function(){if(!this.options.allowColResize){return
2017 a<this.columns.length;
2018 a++){this.columns[a].insertResizer()
2019 }},createDivs:function(){Rico.log("createDivs start");
2020 this.outerDiv=this.createDiv("outer");
2021 if(Rico.theme.gridContainer){Rico.addClass(this.outerDiv,Rico.theme.gridContainer)
2022 }if(this.outerDiv.firstChild&&this.outerDiv.firstChild.tagName&&this.outerDiv.firstChild.tagName.toUpperCase()=="TABLE"){this.structTab=this.outerDiv.firstChild;
2023 this.structTabLeft=this.structTab.rows[0].cells[0];
2024 this.structTabUR=this.structTab.rows[0].cells[1];
2025 this.structTabLR=this.structTab.rows[1].cells[0]
2026 }else{this.structTab=document.createElement("table");
2027 this.structTab.border=0;
2028 this.structTab.cellPadding=0;
2029 this.structTab.cellSpacing=0;
2030 var b=this.structTab.insertRow(-1);
2032 this.structTabLeft=b.insertCell(-1);
2033 this.structTabLeft.rowSpan=2;
2034 this.structTabLeft.style.padding="0px";
2035 this.structTabLeft.style.border="none";
2036 var d=this.structTab.insertRow(-1);
2038 this.structTabUR=b.insertCell(-1);
2039 this.structTabUR.style.padding="0px";
2040 this.structTabUR.style.border="none";
2041 this.structTabLR=d.insertCell(-1);
2042 this.structTabLR.style.padding="0px";
2043 this.structTabLR.style.border="none";
2044 this.outerDiv.appendChild(this.structTab)
2045 }Rico.addClass(this.structTab,"ricoLG_StructTab");
2046 this.frozenTabs=this.createDiv("frozenTabs",this.structTabLeft);
2047 this.innerDiv=this.createDiv("inner",this.structTabUR);
2048 this.scrollDiv=this.createDiv("scroll",this.structTabLR);
2049 this.resizeDiv=this.createDiv("resize",this.outerDiv,true);
2050 this.messagePopup=new Rico.Popup();
2051 this.messagePopup.createContainer({hideOnEscape:false,hideOnClick:false,parent:this.outerDiv});
2052 this.messagePopup.content.className="ricoLG_messageDiv";
2053 if(Rico.theme.gridMessage){Rico.addClass(this.messagePopup.content,Rico.theme.gridMessage)
2054 }this.keywordPopup=new Rico.Window("",{zIndex:-1,parent:this.outerDiv});
2055 Rico.addClass(this.keywordPopup.container,"ricoLG_keywordDiv");
2056 var a=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
2057 a.innerHTML=Rico.getPhraseById("keywordPrompt");
2058 this.keywordBox=this.keywordPopup.contentDiv.appendChild(document.createElement("input"));
2059 this.keywordBox.size=20;
2060 Rico.eventBind(this.keywordBox,"keypress",Rico.eventHandle(this,"keywordKey"),false);
2061 this.keywordPopup.contentDiv.appendChild(Rico.floatButton("Checkmark",Rico.eventHandle(this,"processKeyword")));
2062 var c=this.keywordPopup.contentDiv.appendChild(document.createElement("p"));
2063 Rico.setStyle(c,{clear:"both"});
2064 Rico.log("createDivs end")
2065 },keywordKey:function(a){switch(Rico.eventKey(a)){case 27:this.closeKeyword();
2068 case 13:this.processKeyword();
2072 },openKeyword:function(a){this.keywordCol=a;
2073 this.keywordBox.value="";
2074 this.keywordPopup.setTitle(this.columns[a].displayName);
2075 this.keywordPopup.centerPopup();
2076 this.keywordBox.focus()
2077 },closeKeyword:function(){this.keywordPopup.closePopup();
2079 },processKeyword:function(){var a=this.keywordBox.value;
2080 this.closeKeyword();
2081 this.columns[this.keywordCol].setFilterKW(a)
2082 },createDiv:function(c,a,b){var e=this.tableId+"_"+c+"Div";
2083 var d=document.getElementById(e);
2084 if(!d){d=document.createElement("div");
2086 if(a){a.appendChild(d)
2087 }}d.className="ricoLG_"+c+"Div";
2090 },baseSizeDivs:function(){this.setOtherHdrCellWidths();
2091 if(this.options.frozenColumns){Rico.show(this.tabs[0]);
2092 Rico.show(this.frozenTabs);
2093 this.hdrHt=Math.max(Rico.nan2zero(this.thead[0].offsetHeight),this.thead[1].offsetHeight);
2094 this.dataHt=Math.max(Rico.nan2zero(this.tbody[0].offsetHeight),this.tbody[1].offsetHeight);
2095 this.frzWi=this.borderWidth(this.tabs[0])
2096 }else{Rico.hide(this.tabs[0]);
2097 Rico.hide(this.frozenTabs);
2099 this.hdrHt=this.thead[1].offsetHeight;
2100 this.dataHt=this.tbody[1].offsetHeight
2102 var c=this.borderWidth(this.columns[0].dataCell);
2103 Rico.log("baseSizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2104 Rico.log(this.tableId+" frzWi="+this.frzWi+" borderWi="+c);
2106 b<this.options.frozenColumns;
2107 b++){if(this.columns[b].visible){this.frzWi+=parseInt(this.columns[b].colWidth,10)+c
2108 }}this.scrTabWi=this.borderWidth(this.tabs[1]);
2109 this.scrTabWi0=this.scrTabWi;
2110 Rico.log("scrTabWi: "+this.scrTabWi);
2111 for(b=this.options.frozenColumns;
2112 b<this.columns.length;
2113 b++){if(this.columns[b].visible){this.scrTabWi+=parseInt(this.columns[b].colWidth,10)+c
2114 }}this.scrWi=this.scrTabWi+this.options.scrollBarWidth;
2115 if(this.sizeTo=="parent"){if(Rico.isIE){Rico.hide(this.outerDiv)
2116 }d=this.outerDiv.parentNode.offsetWidth;
2117 if(Rico.isIE){Rico.show(this.outerDiv)
2118 }}else{d=Rico.windowWidth()-this.options.scrollBarWidth-8
2119 }if(this.outerDiv.parentNode.clientWidth>0){d=Math.min(this.outerDiv.parentNode.clientWidth,d)
2120 }var a=this.frzWi+this.scrWi-d;
2121 Rico.log("baseSizeDivs "+this.tableId+": scrWi="+this.scrWi+" wiLimit="+d+" overage="+a+" clientWidth="+this.outerDiv.parentNode.clientWidth);
2122 if(a>0&&this.options.frozenColumns<this.columns.length){this.scrWi=Math.max(this.scrWi-a,this.options.minScrollWidth)
2123 }this.scrollDiv.style.width=this.scrWi+"px";
2124 this.frozenTabs.style.width=this.frzWi+"px";
2125 this.outerDiv.style.width=(this.frzWi+this.scrWi)+"px"
2126 },borderWidth:function(c){var a=Rico.nan2zero(Rico.getStyle(c,"borderLeftWidth"));
2127 var b=Rico.nan2zero(Rico.getStyle(c,"borderRightWidth"));
2128 Rico.log((c.id||c.tagName)+" borderWidth: L="+a+", R="+b);
2130 },setOtherHdrCellWidths:function(){var k,g,f,a,l,b,m,d,e,h;
2132 a<this.hdrCells.length;
2133 a++){if(a==this.headerRowIdx){continue
2134 }Rico.log("setOtherHdrCellWidths: r="+a);
2136 while(g<this.headerColCnt&&k<this.hdrCells[a].length){b=this.hdrCells[a][k];
2141 f++,g++){if(this.columns[g].hdrCell.style.display=="none"){e--
2142 }else{if(this.columns[g].hdrColDiv.style.display!="none"){l+=parseInt(this.columns[g].colWidth,10)
2143 }}}if(!b.hdrColDiv||!b.hdrCellDiv){h=m.getElementsByTagName("div");
2144 b.hdrColDiv=(h.length<1)?Rico.wrapChildren(m,"ricoLG_col"):h[0];
2145 b.hdrCellDiv=(h.length<2)?Rico.wrapChildren(b.hdrColDiv,"ricoLG_cell"):h[1]
2146 }if(e==0){m.style.display="none"
2147 }else{if(l==0){b.hdrColDiv.style.display="none";
2149 }else{m.style.display="";
2150 b.hdrColDiv.style.display="";
2152 b.hdrColDiv.style.width=l+"px"
2154 }}},initFilterImage:function(a){this.filterAnchor=document.getElementById(this.tableId+"_filterLink");
2155 if(!this.filterAnchor){return
2156 }this.filterRows=Rico.select("tr."+this.tableId+"_hdg"+a);
2157 if(this.filterRows.length!=2){return
2160 c++){d[c]=Rico.select(".ricoLG_cell",this.filterRows[c])
2161 }this.filterElements=d[0].concat(d[1]);
2162 this.saveHeight=this.filterElements[0].offsetHeight;
2163 var e=Rico.getStyle(this.filterElements[0],"paddingTop");
2164 var b=Rico.getStyle(this.filterElements[0],"paddingBottom");
2165 if(e){this.saveHeight-=parseInt(e,10)
2166 }if(b){this.saveHeight-=parseInt(b,10)
2168 this.setFilterImage(false)
2169 },toggleFilterRow:function(){if(Rico.visible(this.filterRows[0])){this.slideFilterUp()
2170 }else{this.slideFilterDown()
2171 }},setFilterImage:function(b){var a=Rico.getPhraseById((b?"show":"hide")+"FilterRow");
2172 this.filterAnchor.innerHTML='<img src="'+Rico.imgDir+"tableFilter"+(b?"Expand":"Collapse")+'.gif" alt="'+a+'" border="0">'
2173 },cell:function(a,b){return(0<=b&&b<this.columns.length&&a>=0)?this.columns[b].cell(a):null
2174 },availHt:function(){var a=Rico.cumulativeOffset(this.outerDiv);
2175 return Rico.windowHeight()-a.top-2*this.options.scrollBarWidth-15
2176 },hideMsg:function(){this.messagePopup.closePopup()
2177 },showMsg:function(a){this.messagePopup.setContent(a);
2178 this.messagePopup.centerPopup();
2179 Rico.log("showMsg: "+a)
2180 },listInvisible:function(b){var c=[];
2182 a<this.columns.length;
2183 a++){if(!this.columns[a].visible){c.push(b?this.columns[a][b]:this.columns[a])
2185 },firstVisible:function(){for(var a=0;
2186 a<this.columns.length;
2187 a++){if(this.columns[a].visible){return a
2189 },showAll:function(){var b=this.listInvisible();
2192 a++){b[a].showColumn()
2193 }},chooseColumns:function(){this.menu.cancelmenu();
2195 if(!this.columnChooser){Rico.log("creating columnChooser");
2196 f=Rico.getStyle(this.outerDiv.offsetParent,"zIndex");
2197 if(typeof f!="number"){f=0
2198 }this.columnChooser=new Rico.Window(Rico.getPhraseById("gridChooseCols"),{zIndex:f+2,parent:this.outerDiv});
2199 Rico.addClass(this.columnChooser.container,"ricoLG_chooserDiv");
2200 c=this.columnChooser.contentDiv;
2202 a<this.columns.length;
2203 a++){b=this.columns[a];
2204 e=c.appendChild(document.createElement("div"));
2205 b.ChooserBox=Rico.createFormField(e,"input","checkbox");
2206 d=e.appendChild(document.createElement("span"));
2207 d.innerHTML=b.displayName;
2208 Rico.eventBind(b.ChooserBox,"click",Rico.eventHandle(b,"chooseColumn"),false)
2209 }}Rico.log("opening columnChooser");
2210 this.columnChooser.openPopup(3,this.hdrHt+3);
2212 a<this.columns.length;
2213 a++){this.columns[a].ChooserBox.checked=this.columns[a].visible;
2214 this.columns[a].ChooserBox.disabled=!this.columns[a].canHideShow()
2215 }},blankRow:function(a){for(var b=0;
2216 b<this.columns.length;
2217 b++){this.columns[b].clearCell(a)
2218 }},getExportStyles:function(a){var e=this.options.exportStyleList;
2219 var b=Rico.getStyle(a,"backgroundImage");
2220 if(!b||b=="none"){return e
2223 c++){if(e[c]!="background-color"&&e[c]!="color"){d.push(e[c])
2225 },exportStart:function(){var a,h,f,d,b,e,k,l;
2226 var g=this.getExportStyles(this.thead[0]);
2228 this.exportText="<html><head></head><body><table border='1' cellspacing='0'>";
2230 h<this.columns.length;
2231 h++){if(this.columns[h].visible){this.exportText+="<col width='"+parseInt(this.columns[h].colWidth,10)+"'>"
2232 }}this.exportText+="<thead style='display: table-header-group;'>";
2233 if(this.exportHeader){this.exportText+=this.exportHeader
2235 a<this.hdrCells.length;
2236 a++){if(this.hdrCells[a].length==0||!Rico.visible(this.hdrCells[a][0].cell.parentNode)){continue
2237 }this.exportText+="<tr>";
2239 h<this.hdrCells[a].length;
2240 h++){b=this.hdrCells[a][h];
2244 d++,f++){if(!this.columns[f].visible){e--
2245 }}if(e>0){k=Rico.select(".ricoLG_cell",b.cell);
2246 l=k&&k.length>0?k[0]:b.cell;
2247 this.exportText+="<td style='"+this.exportStyle(l,g)+"'";
2248 if(b.colSpan>1){this.exportText+=" colspan='"+e+"'"
2249 }this.exportText+=">"+Rico.getInnerText(l,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport")+"</td>"
2250 }}this.exportText+="</tr>"
2251 }this.exportText+="</thead><tbody>"
2252 },exportFinish:function(){if(this.hideMsg){this.hideMsg()
2253 }window.status=Rico.getPhraseById("exportComplete");
2254 if(this.exportRows.length>0){this.exportText+="<tr>"+this.exportRows.join("</tr><tr>")+"</tr>"
2255 }if(this.exportFooter){this.exportText+=this.exportFooter
2256 }this.exportText+="</tbody></table></body></html>";
2257 if(this.cancelMenu){this.cancelMenu()
2258 }var a=window.open("","_blank",this.options.exportWindow);
2259 if(a==null){alert(Rico.getPhraseById("disableBlocker"))
2260 }else{a.document.open();
2261 a.document.write(this.exportText);
2263 }this.exportText=undefined;
2264 this.exportRows=undefined
2265 },exportStyle:function(d,g){for(var b=0,c="";
2267 b++){try{var a=Rico.getStyle(d,g[b]);
2268 if(a){c+=g[b]+":"+a+";"
2269 }}catch(f){}}return c
2270 },getCookie:function(){var k=Rico.getCookie(this.options.cookiePrefix+this.tableId);
2272 }var f=k.split(",");
2275 g++){var a=f[g].split(":");
2276 if(a.length!=2){continue
2277 }var h=parseInt(a[0].slice(1),10);
2278 if(h<0||h>=this.columns.length){continue
2279 }var e=this.columns[h];
2280 switch(a[0].charAt(0)){case"w":e.setColWidth(a[1]);
2283 case"h":if(a[1].toLowerCase()=="true"){e.hideshow(true,true)
2284 }else{e.hideshow(false,true)
2286 case"s":if(!this.options.saveColumnInfo.sort||!e.sortable){break
2289 case"f":if(!this.options.saveColumnInfo.filter||!e.filterable){break
2290 }var d=a[1].split("~");
2291 e.filterOp=d.shift();
2293 e.filterType=Rico.ColumnConst.USERFILTER;
2296 b++){e.filterValues.push(unescape(d[b]))
2298 }}},setCookie:function(){var d=[];
2300 e<this.columns.length;
2301 e++){var c=this.columns[e];
2302 if(this.options.saveColumnInfo.width){if(c.customWidth){d.push("w"+e+":"+c.colWidth)
2303 }if(c.customVisible){d.push("h"+e+":"+c.visible)
2304 }}if(this.options.saveColumnInfo.sort){if(c.currentSort!=Rico.ColumnConst.UNSORTED){d.push("s"+e+":"+c.currentSort)
2305 }}if(this.options.saveColumnInfo.filter&&c.filterType==Rico.ColumnConst.USERFILTER){var b=[c.filterOp];
2307 a<c.filterValues.length;
2308 a++){b.push(escape(c.filterValues[a]))
2309 }d.push("f"+e+":"+b.join("~"))
2310 }}Rico.setCookie(this.options.cookiePrefix+this.tableId,d.join(","),this.options.cookieDays,this.options.cookiePath,this.options.cookieDomain)
2312 Rico.ColumnConst={UNFILTERED:0,SYSTEMFILTER:1,USERFILTER:2,UNSORTED:0,SORT_ASC:"ASC",SORT_DESC:"DESC",MINWIDTH:10};
2313 Rico.TableColumnBase=function(){};
2314 Rico.TableColumnBase.prototype={baseInit:function(h,g,e,d){Rico.log("TableColumnBase.baseInit index="+g+" tabIdx="+d);
2317 this.hideWidth=Rico.isKonqueror||Rico.isWebKit||h.headerRowCnt>1?5:2;
2318 this.options=h.options;
2320 this.hdrCell=e.cell;
2321 this.body=document.getElementsByTagName("body")[0];
2322 this.displayName=this.getDisplayName(this.hdrCell);
2323 var c=this.hdrCell.getElementsByTagName("div");
2324 this.hdrColDiv=(c.length<1)?Rico.wrapChildren(this.hdrCell,"ricoLG_col"):c[0];
2325 this.hdrCellDiv=(c.length<2)?Rico.wrapChildren(this.hdrColDiv,"ricoLG_cell"):c[1];
2326 var f=d==0?g:g-h.options.frozenColumns;
2327 this.dataCell=h.tbody[d].rows[0].cells[f];
2328 c=this.dataCell.getElementsByTagName("div");
2329 this.dataColDiv=(c.length<1)?Rico.wrapChildren(this.dataCell,"ricoLG_col"):c[0];
2330 this.mouseDownHandler=Rico.eventHandle(this,"handleMouseDown");
2331 this.mouseMoveHandler=Rico.eventHandle(this,"handleMouseMove");
2332 this.mouseUpHandler=Rico.eventHandle(this,"handleMouseUp");
2333 this.mouseOutHandler=Rico.eventHandle(this,"handleMouseOut");
2334 this.format={type:"text"};
2335 var b=h.options.columnSpecs[g];
2336 if(typeof b=="object"){Rico.extend(this.format,b)
2337 }Rico.addClass(this.dataColDiv,this.colClassName());
2339 if(typeof this.format.visible=="boolean"){this.visible=this.format.visible
2340 }this.sortable=typeof this.format.canSort=="boolean"?this.format.canSort:h.options.canSortDefault;
2341 this.currentSort=Rico.ColumnConst.UNSORTED;
2342 this.filterable=typeof this.format.canFilter=="boolean"?this.format.canFilter:h.options.canFilterDefault;
2343 this.filterType=Rico.ColumnConst.UNFILTERED;
2344 this.hideable=typeof this.format.canHide=="boolean"?this.format.canHide:h.options.canHideDefault;
2346 switch(typeof this.format.width){case"number":a=this.format.width;
2348 case"string":a=parseInt(this.format.width,10);
2350 default:a=e.initWidth;
2352 }a=(typeof(a)=="number")?Math.max(a,Rico.ColumnConst.MINWIDTH):h.options.defaultWidth;
2353 this.setColWidth(a);
2354 if(!this.visible){this.setDisplay("none")
2355 }},colClassName:function(){return this.format.ClassName?this.format.ClassName:this.liveGrid.tableId+"_col"+this.index
2356 },insertResizer:function(){if(this.format.noResize){return
2357 }var a=document.createElement("div");
2358 a.className="ricoLG_Resize";
2359 a.style[this.liveGrid.align[1]]="0px";
2360 this.hdrCellDiv.appendChild(a);
2361 Rico.eventBind(a,"mousedown",this.mouseDownHandler,false)
2362 },getDisplayName:function(b){var c=b.getElementsByTagName("A");
2363 var a=c.length>0?c[0].innerHTML:Rico.stripTags(b.innerHTML);
2365 },_clear:function(a){a.innerHTML=" "
2366 },clearCell:function(b){var a=this.cell(b);
2368 if(this.liveGrid.buffer&&this.liveGrid.buffer.options.acceptStyle){a.style.cssText=""
2369 }},dataTable:function(){return this.liveGrid.tabs[this.tabIdx]
2370 },numRows:function(){return this.dataColDiv.childNodes.length
2371 },clearColumn:function(){var b=this.numRows();
2374 a++){this.clearCell(a)
2375 }},cell:function(a){return this.dataColDiv.childNodes[a]
2376 },getFormattedValue:function(c,a,d,b){return Rico.getInnerText(this.cell(c),a,d,b)
2377 },setColWidth:function(a){if(typeof a=="number"){a=parseInt(a,10);
2378 if(a<Rico.ColumnConst.MINWIDTH){return
2380 }Rico.log("setColWidth "+this.index+": "+a);
2382 this.hdrColDiv.style.width=a;
2383 this.dataColDiv.style.width=a
2384 },pluginMouseEvents:function(){if(this.mousePluggedIn==true){return
2385 }Rico.eventBind(this.body,"mousemove",this.mouseMoveHandler,false);
2386 Rico.eventBind(this.body,"mouseup",this.mouseUpHandler,false);
2387 Rico.eventBind(this.body,"mouseout",this.mouseOutHandler,false);
2388 this.mousePluggedIn=true
2389 },unplugMouseEvents:function(){Rico.eventUnbind(this.body,"mousemove",this.mouseMoveHandler,false);
2390 Rico.eventUnbind(this.body,"mouseup",this.mouseUpHandler,false);
2391 Rico.eventUnbind(this.body,"mouseout",this.mouseOutHandler,false);
2392 this.mousePluggedIn=false
2393 },handleMouseDown:function(b){this.resizeStart=Rico.eventClient(b).x;
2394 this.origWidth=parseInt(this.colWidth,10);
2395 var a=Rico.positionedOffset(this.hdrCell);
2396 if(this.liveGrid.direction=="rtl"){this.edge=a.left;
2397 switch(this.tabIdx){case 0:this.edge+=this.liveGrid.innerDiv.offsetWidth;
2399 case 1:this.edge-=this.liveGrid.scrollDiv.scrollLeft;
2401 }}else{this.edge=a.left+this.hdrCell.offsetWidth;
2402 if(this.tabIdx>0){this.edge+=Rico.nan2zero(this.liveGrid.tabs[0].offsetWidth)
2403 }}this.liveGrid.resizeDiv.style.left=this.edge+"px";
2404 this.liveGrid.resizeDiv.style.display="";
2405 this.liveGrid.outerDiv.style.cursor="e-resize";
2406 this.tmpHighlight=this.liveGrid.highlightEnabled;
2407 this.liveGrid.highlightEnabled=false;
2408 this.pluginMouseEvents();
2410 },handleMouseMove:function(b){var c=Rico.eventClient(b).x-this.resizeStart;
2411 var a=(this.liveGrid.direction=="rtl")?this.origWidth-c:this.origWidth+c;
2412 if(a<Rico.ColumnConst.MINWIDTH){return
2413 }this.liveGrid.resizeDiv.style.left=(this.edge+c)+"px";
2416 },handleMouseUp:function(a){this.unplugMouseEvents();
2417 Rico.log("handleMouseUp "+this.liveGrid.tableId);
2418 this.liveGrid.outerDiv.style.cursor="";
2419 this.liveGrid.resizeDiv.style.display="none";
2420 this.setColWidth(this.colWidth);
2421 this.customWidth=true;
2422 this.liveGrid.setCookie();
2423 this.liveGrid.highlightEnabled=this.tmpHighlight;
2424 this.liveGrid.sizeDivs();
2426 },handleMouseOut:function(b){var a=Rico.eventRelatedTarget(b)||b.toElement;
2427 while(a!=null&&a.nodeName.toLowerCase()!="body"){a=a.parentNode
2428 }if(a!=null&&a.nodeName.toLowerCase()=="body"){return true
2429 }this.handleMouseUp(b);
2431 },setDisplay:function(a){this.hdrCell.style.display=a;
2432 this.hdrColDiv.style.display=a;
2433 this.dataCell.style.display=a;
2434 this.dataColDiv.style.display=a
2435 },hideshow:function(b,a){this.setDisplay(b?"":"none");
2436 this.liveGrid.cancelMenu();
2438 this.customVisible=true;
2440 }this.liveGrid.setCookie();
2441 this.liveGrid.sizeDivs()
2442 },hideColumn:function(){Rico.log("hideColumn "+this.liveGrid.tableId);
2443 this.hideshow(false,false)
2444 },showColumn:function(){Rico.log("showColumn "+this.liveGrid.tableId);
2445 this.hideshow(true,false)
2446 },chooseColumn:function(b){var a=Rico.eventElement(b);
2447 this.hideshow(a.checked,false)
2448 },setImage:function(){if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.imgSort.style.display="inline-block";
2449 this.imgSort.className=Rico.theme.sortAsc||"rico-icon ricoLG_sortAsc"
2450 }else{if(this.currentSort==Rico.ColumnConst.SORT_DESC){this.imgSort.style.display="inline-block";
2451 this.imgSort.className=Rico.theme.sortDesc||"rico-icon ricoLG_sortDesc"
2452 }else{this.imgSort.style.display="none"
2453 }}if(this.filterType==Rico.ColumnConst.USERFILTER){this.imgFilter.style.display="inline-block";
2454 this.imgFilter.title=this.getFilterText()
2455 }else{this.imgFilter.style.display="none"
2456 }},canHideShow:function(){return this.hideable
2458 if(typeof Rico=="undefined"){throw ("SimpleGrid requires the Rico JavaScript framework")
2459 }Rico.SimpleGrid=function(b,a){this.initialize(b,a)
2461 Rico.SimpleGrid.prototype={initialize:function(b,a){Rico.extend(this,Rico.GridCommon);
2463 Rico.setDebugArea(b+"_debugmsgs");
2464 Rico.extend(this.options,a||{});
2466 Rico.log("SimpleGrid initialize start: "+b);
2468 this.hdrTabs=new Array(2);
2469 this.simpleGridInit();
2470 Rico.log("SimpleGrid initialize end: "+b)
2471 },simpleGridInit:function(){var a;
2474 a++){Rico.log("simpleGridInit "+a);
2475 this.tabs[a]=Rico.$(this.tableId+"_tab"+a);
2476 if(!this.tabs[a]){return
2477 }this.hdrTabs[a]=Rico.$(this.tableId+"_tab"+a+"h");
2478 if(!this.hdrTabs[a]){return
2479 }this.thead[a]=this.hdrTabs[a];
2480 this.tbody[a]=this.tabs[a];
2481 this.headerColCnt=this.getColumnInfo(this.hdrTabs[a].rows);
2482 if(a==0){this.options.frozenColumns=this.headerColCnt
2483 }if(Rico.theme.gridheader){Rico.addClass(this.thead[a],Rico.theme.gridheader)
2484 }if(Rico.theme.gridcontent){Rico.addClass(this.tbody[a],Rico.theme.gridcontent)
2485 }}if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2487 }this.createColumnArray("SimpleGridColumn");
2488 this.pageSize=this.columns[0].dataColDiv.childNodes.length;
2490 if(typeof(this.options.FilterLocation)=="number"){this.createFilters(this.options.FilterLocation)
2491 }this.attachMenuEvents();
2492 this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
2493 this.scrollFrozenEventFunc=Rico.eventHandle(this,"handleScrollFrozen");
2494 this.scrollHeadingEventFunc=Rico.eventHandle(this,"handleScrollHeading");
2495 this.pluginScroll();
2496 if(this.options.windowResize){Rico.eventBind(window,"resize",Rico.eventHandle(this,"sizeDivs"),false)
2497 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
2498 },createFilters:function(a){if(a<0){a=this.addHeadingRow();
2501 g<this.headerColCnt;
2502 g++){var d=this.columns[g];
2504 if(typeof e.filterUI!="string"){continue
2505 }var k=this.hdrCells[a][g].cell;
2506 var j,b=this.filterId(g);
2507 var h=k.getElementsByTagName("div");
2508 switch(e.filterUI.charAt(0)){case"t":j=Rico.createFormField(h[1],"input","text",b,b);
2509 var m=e.filterUI.match(/\d+/);
2510 j.maxLength=e.Length||50;
2511 j.size=m?parseInt(m,10):10;
2512 Rico.eventBind(j,"keyup",Rico.eventHandle(d,"filterKeypress"),false);
2514 case"s":j=Rico.createFormField(h[1],"select",null,b);
2515 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
2516 this.getFilterValues(d);
2517 var l=Rico.keys(d.filterHash);
2521 f++){Rico.addSelectOption(j,l[f],l[f]||Rico.getPhraseById("filterBlank"))
2522 }Rico.eventBind(j,"change",Rico.eventHandle(d,"filterChange"),false);
2524 }}this.initFilterImage(a)
2525 },getFilterValues:function(b){var e={};
2529 c++){var a=Rico.getInnerText(b.cell(c));
2534 },applyFilters:function(){var b=[];
2536 f<this.columns.length;
2537 f++){if(this.columns[f].filterRows){b.push(this.columns[f].filterRows)
2538 }}if(b.length==0){this.showAllRows();
2545 a++){if(b[a].indexOf(d)==-1){e=false;
2547 }}if(e){this.showRow(d)
2548 }else{this.hideRow(d)
2550 },pluginScroll:function(){if(this.scrollPluggedIn){return
2551 }Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
2552 Rico.eventBind(this.frozenTabs,"scroll",this.scrollFrozenEventFunc,false);
2553 Rico.eventBind(this.innerDiv,"scroll",this.scrollHeadingEventFunc,false);
2554 this.scrollPluggedIn=true
2555 },unplugScroll:function(){Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
2556 Rico.eventUnbind(this.frozenTabs,"scroll",this.scrollFrozenEventFunc,false);
2557 Rico.eventUnbind(this.innerDiv,"scroll",this.scrollHeadingEventFunc,false);
2558 this.scrollPluggedIn=false
2559 },handleScroll:function(a){this.frozenTabs.scrollTop=this.scrollDiv.scrollTop;
2560 this.innerDiv.scrollLeft=this.scrollDiv.scrollLeft
2561 },handleScrollFrozen:function(a){this.scrollDiv.scrollTop=this.frozenTabs.scrollTop
2562 },handleScrollHeading:function(a){this.scrollDiv.scrollLeft=this.innerDiv.scrollLeft
2563 },registerScrollMenu:function(a){if(!this.menu){this.menu=a
2565 a.showmenu=a.showSimpleMenu;
2566 a.showSubMenu=a.showSimpleSubMenu;
2567 a.createDiv(this.outerDiv)
2568 },handleMenuClick:function(a){if(!this.menu){return
2570 this.menuCell=Rico.getParentByTagName(Rico.eventElement(a),"div");
2571 this.highlightEnabled=false;
2572 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
2573 }if(this.menu.buildGridMenu){this.menu.buildGridMenu(this.menuCell)
2574 }this.menu.showmenu(a,this.closeMenu.bind(this))
2575 },closeMenu:function(){if(this.hideScroll){this.scrollDiv.style.overflow=""
2576 }this.highlightEnabled=true
2577 },sizeDivs:function(){if(this.outerDiv.offsetParent.style.display=="none"){return
2578 }this.baseSizeDivs();
2579 var c=Math.max(this.options.maxHt||this.availHt(),50);
2580 var b=Math.min(this.hdrHt+this.dataHt,c);
2581 Rico.log("sizeDivs "+this.tableId+": hdrHt="+this.hdrHt+" dataHt="+this.dataHt);
2582 this.dataHt=b-this.hdrHt;
2583 if(this.scrWi>0){this.dataHt+=this.options.scrollBarWidth
2584 }this.scrollDiv.style.height=this.dataHt+"px";
2585 this.frozenTabs.style.height=this.scrollDiv.clientHeight+"px";
2587 this.innerDiv.style.width=(this.scrWi-this.options.scrollBarWidth+a)+"px";
2589 this.resizeDiv.style.height=b+"px";
2591 },printVisible:function(){this.showMsg(Rico.getPhraseById("exportInProgress"));
2592 Rico.runLater(10,this,"_printVisible")
2593 },_printVisible:function(){this.exportStart();
2594 var f=this.getExportStyles(this.tbody[0]);
2597 e++){if(this.columns[0].cell(e).style.display=="none"){continue
2600 g<this.columns.length;
2601 g++){var b=this.columns[g];
2602 if(b.visible){var a=b.getFormattedValue(e,!this.options.exportImgTags,!this.options.exportFormFields,"NoExport");
2603 if(b.format.exportPrefix){a=b.format.exportPrefix+a
2604 }if(a==""){a=" "
2605 }d+="<td style='"+this.exportStyle(b.cell(e),f)+"'>"+a+"</td>"
2606 }}this.exportRows.push(d)
2607 }this.exportFinish()
2608 },hideRow:function(a){if(this.columns[0].cell(a).style.display=="none"){return
2610 b<this.columns.length;
2611 b++){this.columns[b].cell(a).style.display="none"
2612 }},showRow:function(a){if(this.columns[0].cell(a).style.display==""){return
2614 b<this.columns.length;
2615 b++){this.columns[b].cell(a).style.display=""
2616 }},searchRows:function(h,e,c){if(!e){return
2617 }var f=new RegExp(e);
2618 var d=this.columns[h].numRows();
2621 g++){var b=this.cell(g,h).innerHTML;
2622 var a=(b.match(f)!=null);
2623 if(a!=c){this.hideRow(g)
2626 },showAllRows:function(){for(var a=0;
2628 a++){this.showRow(a)
2630 },openPopup:function(d,e){while(d&&!Rico.hasClass(d,"ricoLG_cell")){d=d.parentNode
2631 }if(!d){return false
2632 }var f=Rico.getParentByTagName(d,"td");
2633 var c=Math.floor(f.offsetLeft-this.scrollDiv.scrollLeft+f.offsetWidth/2);
2634 if(this.direction=="rtl"){if(c>this.width){c-=this.width
2635 }}else{if(c+this.width+this.options.margin>this.scrollDiv.clientWidth){c-=this.width
2636 }}e.divPopup.style.visibility="hidden";
2637 e.divPopup.style.display="block";
2638 var b=e.divPopup.offsetHeight;
2639 var a=Math.floor(d.offsetTop-this.scrollDiv.scrollTop+d.offsetHeight/2);
2640 if(a+b+e.options.margin>this.scrollDiv.clientHeight){a=Math.max(a-b,0)
2641 }e.openPopup(this.frzWi+c,this.hdrHt+a);
2642 e.divPopup.style.visibility="visible";
2645 if(Rico.Menu){Rico.extend(Rico.Menu.prototype,{showSimpleMenu:function(b,c){Rico.eventStop(b);
2647 if(this.div.childNodes.length==0){this.cancelmenu();
2649 }var a=Rico.eventElement(b);
2650 this.grid.openPopup(a,this);
2652 },showSimpleSubMenu:function(b,c){if(this.openSubMenu){this.hideSubMenu()
2653 }this.openSubMenu=c;
2654 this.openMenuAnchor=b;
2655 if(b.className=="ricoSubMenu"){b.className="ricoSubMenuOpen"
2656 }var e=parseInt(this.div.style.top,10);
2657 var d=parseInt(this.div.style.left,10);
2658 c.openPopup(d+b.offsetWidth,e+b.offsetTop);
2659 c.div.style.visibility="visible"
2661 }Rico.SimpleGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
2663 Rico.SimpleGridColumn.prototype={initialize:function(a,d,c,b){Rico.extend(this,new Rico.TableColumnBase());
2664 this.baseInit(a,d,c,b)
2665 },setUnfiltered:function(){this.filterRows=null
2666 },filterChange:function(a){var b=Rico.eventElement(a);
2667 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
2668 }else{this.filterRows=this.filterHash[b.value]
2669 }this.liveGrid.applyFilters()
2670 },filterKeypress:function(f){var a=Rico.eventElement(f);
2671 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
2672 }if(this.lastKeyFilter==a.value){return
2674 Rico.log("filterKeypress: "+this.index+" "+b);
2675 this.lastKeyFilter=b;
2676 if(b){b=b.replace("\\","\\\\");
2677 b=b.replace("(","\\(").replace(")","\\)");
2678 b=b.replace(".","\\.");
2679 if(this.format.filterUI.indexOf("^")>0){b="^"+b
2680 }var d=new RegExp(b,"i");
2682 var h=this.numRows();
2685 c++){var g=Rico.getInnerText(this.cell(c));
2686 if(g.match(d)){this.filterRows.push(c)
2687 }}}else{this.setUnfiltered()
2688 }this.liveGrid.applyFilters()
2690 if(!Rico.Buffer){Rico.Buffer={}
2691 }Rico.Buffer.Base=function(b,a){this.initialize(b,a)
2693 Rico.Buffer.Base.prototype={initialize:function(b,a){this.clear();
2694 this.updateInProgress=false;
2696 this.rcvdRowCount=false;
2697 this.foundRowCount=false;
2699 this.rowcntContent="";
2701 this.options={fixedHdrRows:0,canFilter:true,isEncoded:true,acceptStyle:false,canRefresh:false};
2702 Rico.extend(this.options,a||{});
2703 if(b){this.loadRowsFromTable(b,this.options.fixedHdrRows);
2704 b.parentNode.removeChild(b)
2705 }},registerGrid:function(a){this.liveGrid=a
2706 },setTotalRows:function(a){if(typeof(a)!="number"){a=this.size
2707 }if(this.totalRows==a){return
2709 if(!this.liveGrid){return
2710 }Rico.log("setTotalRows, newTotalRows="+a);
2711 switch(this.liveGrid.sizeTo){case"data":this.liveGrid.resizeWindow();
2713 case"datamax":this.liveGrid.setPageSize(a);
2715 default:this.liveGrid.updateHeightDiv();
2717 }},loadRowsFromTable:function(h,g){var e=[];
2718 var a=h.getElementsByTagName("tr");
2722 var c=a[d].getElementsByTagName("td");
2725 b++){f[b]=c[b].innerHTML
2728 },loadRowsFromArray:function(b){for(var c=0;
2732 a++){b[c][a]=b[c][a].toString()
2734 },loadRows:function(a){this.baseRows=a;
2736 this.size=this.baseRows.length
2737 },dom2jstable:function(f){Rico.log("dom2jstable: encoded="+this.options.isEncoded);
2739 var a=f.getElementsByTagName("tr");
2743 var c=a[d].getElementsByTagName("td");
2746 b++){g[b]=Rico.getContentAsString(c[b],this.options.isEncoded)
2749 },_blankRow:function(){var a=[];
2751 b<this.liveGrid.columns.length;
2754 },deleteRows:function(b,a){this.baseRows.splice(b,typeof(a)=="number"?a:1);
2755 this.liveGrid.isPartialBlank=true;
2756 this.size=this.baseRows.length
2757 },insertRow:function(a){var b=this._blankRow();
2758 this.baseRows.splice(a,0,b);
2759 this.size=this.baseRows.length;
2760 this.liveGrid.isPartialBlank=true;
2761 if(this.startPos<0){this.startPos=0
2763 },appendRows:function(b){var c=[];
2766 a++){var d=this._blankRow();
2767 this.baseRows.push(d);
2769 }this.size=this.baseRows.length;
2770 this.liveGrid.isPartialBlank=true;
2771 if(this.startPos<0){this.startPos=0
2773 },sortFunc:function(b){var a=this;
2774 switch(b){case"number":return function(d,c){return a._sortNumeric(d,c)
2776 case"control":return function(d,c){return a._sortControl(d,c)
2778 default:return function(d,c){return a._sortAlpha(d,c)
2780 }},sortBuffer:function(b){if(!this.baseRows){this.delayedSortCol=b;
2782 }this.liveGrid.showMsg(Rico.getPhraseById("sorting"));
2784 var a=this.liveGrid.columns[b];
2785 this.getValFunc=a._sortfunc;
2786 this.baseRows.sort(this.sortFunc(a.format.type));
2787 if(a.getSortDirection()=="DESC"){this.baseRows.reverse()
2788 }},_sortAlpha:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2789 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2793 },_sortNumeric:function(d,c){var e=this.sortColumn<d.length?this.nan2zero(Rico.getInnerText(d[this.sortColumn])):0;
2794 var f=this.sortColumn<c.length?this.nan2zero(Rico.getInnerText(c[this.sortColumn])):0;
2796 },nan2zero:function(a){if(typeof(a)=="string"){a=parseFloat(a)
2797 }return isNaN(a)||typeof(a)=="undefined"?0:a
2798 },_sortControl:function(d,c){var e=this.sortColumn<d.length?Rico.getInnerText(d[this.sortColumn]):"";
2799 var f=this.sortColumn<c.length?Rico.getInnerText(c[this.sortColumn]):"";
2800 if(this.getValFunc){e=this.getValFunc(e);
2801 f=this.getValFunc(f)
2805 },clear:function(){this.baseRows=[];
2812 },isInRange:function(a){var b=Math.min(this.totalRows,a+this.liveGrid.pageSize);
2813 return(a>=this.startPos)&&(b<=this.endPos())
2814 },endPos:function(){return this.startPos+this.rows.length
2815 },fetch:function(a){Rico.log("fetch "+this.liveGrid.tableId+": offset="+a);
2816 this.applyFilters();
2817 this.setTotalRows();
2818 this.rcvdRowCount=true;
2819 this.foundRowCount=true;
2821 }this.liveGrid.refreshContents(a);
2823 },visibleRows:function(){return this.rows.slice(this.windowStart,this.windowEnd)
2824 },setWindow:function(b,a){this.windowStart=b-this.startPos;
2825 Rico.log("setWindow "+this.liveGrid.tableId+": "+b+", "+a+", newstart="+this.windowStart);
2826 this.windowEnd=Math.min(a,this.size);
2828 },isVisible:function(a){return a<this.rows.length&&a>=this.windowStart&&a<this.windowEnd
2829 },bufferRow:function(a){return this.windowStart+a
2830 },getWindowCell:function(c,b){var a=this.bufferRow(c);
2831 return this.isVisible(a)&&b<this.rows[a].length?this.rows[a][b]:null
2832 },getWindowStyle:function(c,b){var a=this.bufferRow(c);
2833 return this.attr&&this.isVisible(a)&&this.attr[a]&&b<this.attr[a].length?this.attr[a][b]:""
2834 },getWindowValue:function(b,a){return this.getWindowCell(b,a)
2835 },setWindowValue:function(d,b,c){var a=this.bufferRow(d);
2836 if(a>=this.windowEnd){return false
2837 }return this.setValue(a,b,c)
2838 },getCell:function(b,a){return b<this.size?this.rows[b][a]:null
2839 },getValue:function(b,a){return this.getCell(b,a)
2840 },setValue:function(d,b,c,a){if(d>=this.size){return false
2841 }if(!this.rows[d][b]){this.rows[d][b]={}
2843 if(this.options.acceptStyle&&typeof a=="string"){if(!this.attr){this.attr=[]
2844 }if(!this.attr[d]){this.attr[d]=[]
2846 }if(!this.modified[d]){this.modified[d]=[]
2847 }this.modified[d][b]=true;
2849 },getRows:function(f,d){var e=f-this.startPos;
2850 var a=Math.min(e+d,this.size);
2854 b++){c.push(this.rows[b])
2856 },applyFilters:function(){var g=[],k=[];
2858 var j=this.liveGrid.columns;
2862 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2864 if(h.filterOp=="LIKE"){k[d]=new RegExp(h.filterValues[0],"i")
2865 }}Rico.log("applyFilters: # of filters="+b);
2866 if(b==0){this.rows=this.baseRows
2868 a<this.baseRows.length;
2873 if(h.filterType==Rico.ColumnConst.UNFILTERED){continue
2874 }switch(h.filterOp){case"LIKE":f=k[d].test(this.baseRows[a][d]);
2876 case"EQ":f=this.baseRows[a][d]==h.filterValues[0];
2879 e<h.filterValues.length&&f;
2880 e++){f=this.baseRows[a][d]!=h.filterValues[e]
2882 case"LE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])<=this.nan2zero(h.filterValues[0])
2883 }else{f=this.baseRows[a][d]<=h.filterValues[0]
2885 case"GE":if(h.format.type=="number"){f=this.nan2zero(this.baseRows[a][d])>=this.nan2zero(h.filterValues[0])
2886 }else{f=this.baseRows[a][d]>=h.filterValues[0]
2888 case"NULL":f=this.baseRows[a][d]=="";
2890 case"NOTNULL":f=this.baseRows[a][d]!="";
2892 }}if(f){g.push(this.baseRows[a])
2894 }this.rowcntContent=this.size=this.rows.length
2895 },printAll:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2896 Rico.runLater(10,this,"_printAll")
2897 },_printAll:function(){this.liveGrid.exportStart();
2898 this.exportBuffer(this.getRows(0,this.totalRows));
2899 this.liveGrid.exportFinish()
2900 },printVisible:function(){this.liveGrid.showMsg(Rico.getPhraseById("exportInProgress"));
2901 Rico.runLater(10,this,"_printVisible")
2902 },_printVisible:function(){this.liveGrid.exportStart();
2903 this.exportBuffer(this.visibleRows());
2904 this.liveGrid.exportFinish()
2905 },exportBuffer:function(l,f){var a,g,k,b,j;
2906 Rico.log("exportBuffer: "+l.length+" rows");
2907 var e=this.liveGrid.getExportStyles(this.liveGrid.tbody[0]);
2910 var h=this.liveGrid.columns;
2913 g++){if(h[g].visible){i[g]=this.liveGrid.exportStyle(h[g].cell(0),e)
2919 g++){if(!h[g].visible){continue
2922 k=b._export(l[a][g],l[a]);
2923 if(k==""){k=" "
2924 }j+="<td style='"+b.expStyle+"'>"+k+"</td>"
2925 }this.liveGrid.exportRows.push(j);
2927 if(d%10==0){window.status=Rico.getPhraseById("exportStatus",d)
2929 Rico.LiveGrid=function(c,a,b){this.initialize(c,a,b)
2931 Rico.LiveGrid.prototype={initialize:function(e,b,d){Rico.extend(this,Rico.GridCommon);
2932 Rico.extend(this,Rico.LiveGridMethods);
2936 this.actionId="_action_"+e;
2937 Rico.setDebugArea(e+"_debugmsgs");
2938 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});
2940 this.options.sortHandler=function(){c.sortHandler()
2942 this.options.filterHandler=function(){c.filterHandler()
2944 this.options.onRefreshComplete=function(f,g){c.bookmarkHandler(f,g)
2946 this.options.rowOverHandler=Rico.eventHandle(this,"rowMouseOver");
2947 this.options.mouseDownHandler=Rico.eventHandle(this,"selectMouseDown");
2948 this.options.mouseOverHandler=Rico.eventHandle(this,"selectMouseOver");
2949 this.options.mouseUpHandler=Rico.eventHandle(this,"selectMouseUp");
2950 Rico.extend(this.options,d||{});
2951 switch(typeof this.options.visibleRows){case"string":this.sizeTo=this.options.visibleRows;
2952 switch(this.options.visibleRows){case"data":this.options.visibleRows=-2;
2954 case"body":this.options.visibleRows=-3;
2956 case"parent":this.options.visibleRows=-4;
2958 case"datamax":this.options.visibleRows=-5;
2960 default:this.options.visibleRows=-1;
2963 case"number":switch(this.options.visibleRows){case -1:this.sizeTo="window";
2965 case -2:this.sizeTo="data";
2967 case -3:this.sizeTo="body";
2969 case -4:this.sizeTo="parent";
2971 case -5:this.sizeTo="datamax";
2973 default:this.sizeTo="fixed";
2976 default:this.sizeTo="body";
2977 this.options.visibleRows=-3;
2979 }this.highlightEnabled=this.options.highlightSection>0;
2981 this.createTables();
2982 if(this.headerColCnt==0){alert('ERROR: no columns found in "'+this.tableId+'"');
2984 }this.createColumnArray("LiveGridColumn");
2985 if(this.options.headingSort=="hover"){this.createHoverSet()
2986 }this.bookmark=document.getElementById(this.tableId+"_bookmark");
2989 if(this.buffer.options.canFilter&&this.options.AutoFilter){a=this.addHeadingRow("ricoLG_FilterRow")
2990 }this.createDataCells(this.options.visibleRows);
2991 if(this.pageSize==0){return
2992 }this.buffer.registerGrid(this);
2993 if(this.buffer.setBufferSize){this.buffer.setBufferSize(this.pageSize)
2994 }this.scrollTimeout=null;
2995 this.lastScrollPos=0;
2996 this.attachMenuEvents();
2997 this.setSortUI(this.options.sortCol,this.options.sortDir);
2999 if(this.listInvisible().length==this.columns.length){this.columns[0].showColumn()
3001 this.scrollDiv.style.display="";
3002 if(this.buffer.totalRows>0){this.updateHeightDiv()
3003 }if(this.options.prefetchBuffer){if(this.bookmark){this.bookmark.innerHTML=Rico.getPhraseById("bookmarkLoading")
3004 }if(this.options.canFilterDefault&&this.options.getQueryParms){this.checkForFilterParms()
3005 }this.scrollToRow(this.options.offset);
3006 this.buffer.fetch(this.options.offset)
3007 }if(a>=0){this.createFilters(a)
3008 }this.scrollEventFunc=Rico.eventHandle(this,"handleScroll");
3009 this.wheelEventFunc=Rico.eventHandle(this,"handleWheel");
3010 this.wheelEvent=(Rico.isIE||Rico.isOpera||Rico.isWebKit)?"mousewheel":"DOMMouseScroll";
3011 if(this.options.offset&&this.options.offset<this.buffer.totalRows){Rico.runLater(50,this,"scrollToRow",this.options.offset)
3012 }this.pluginScroll();
3013 this.setHorizontalScroll();
3014 Rico.log("setHorizontalScroll done");
3015 if(this.options.windowResize){Rico.runLater(100,this,"pluginWindowResize")
3016 }Rico.log("initialize complete for "+this.tableId);
3017 if(this.direction=="rtl"&&(!Rico.isWebKit||this.scrollDiv.clientLeft>0)){this.scrollTab.style.right="0px"
3018 }else{this.scrollTab.style.left="0px";
3019 Rico.setStyle(this.tabs[1],{"float":"left"})
3021 Rico.LiveGridMethods={createHoverSet:function(){var a=[];
3023 b<this.headerColCnt;
3024 b++){if(this.columns[b].sortable){a.push(this.columns[b].hdrCellDiv)
3025 }}this.hoverSet=new Rico.HoverSet(a)
3026 },checkForFilterParms:function(){var b=window.location.search;
3027 if(b.charAt(0)=="?"){b=b.substring(1)
3028 }var c=b.split("&");
3031 a++){if(c[a].match(/^f\[\d+\]/)){this.buffer.options.requestParameters.push(c[a])
3032 }}},drillDown:function(g,f,h){var b=Rico.eventElement(g||window.event);
3033 b=Rico.getParentByTagName(b,"div","ricoLG_cell");
3035 }var a=this.winCellIndex(b);
3036 if(a.row>=this.buffer.totalRows){return -1
3037 }this.unhighlight();
3040 var c=this.buffer.getWindowCell(a.row,f);
3043 d++){arguments[d].setDetailFilter(h,c)
3045 },setDetailFilter:function(a,d){var b=this.columns[a];
3047 b.setSystemFilter("EQ",d)
3048 },createTables:function(){var f,g,b;
3049 var e=document.getElementById(this.tableId)||document.getElementById(this.tableId+"_outerDiv");
3051 }if(e.tagName.toLowerCase()=="table"){var a=e.getElementsByTagName("thead");
3052 if(a.length==1){Rico.log("createTables: using thead section, id="+this.tableId);
3053 if(this.options.ColGroupsOnTabHdr&&this.options.ColGroups){var d=a[0].insertRow(0);
3054 this.insertPanelNames(d,0,this.options.frozenColumns,"ricoFrozen");
3055 this.insertPanelNames(d,this.options.frozenColumns,this.options.columnSpecs.length)
3057 }else{Rico.log("createTables: using tbody section, id="+this.tableId);
3058 g=new Array(e.rows[0])
3060 }else{if(this.options.columnSpecs.length>0){if(!e.id.match(/_outerDiv$/)){f=e
3061 }Rico.log("createTables: inserting at "+e.tagName+", id="+this.tableId)
3062 }else{alert("ERROR!\n\nUnable to initialize '"+this.tableId+"'\n\nLiveGrid terminated");
3064 }}this.createDivs();
3065 this.scrollContainer=this.createDiv("scrollContainer",this.structTabLR);
3066 this.scrollContainer.appendChild(this.scrollDiv);
3067 this.scrollTab=this.createDiv("scrollTab",this.scrollContainer);
3068 this.shadowDiv=this.createDiv("shadow",this.scrollDiv);
3069 this.shadowDiv.style.direction="ltr";
3070 this.scrollDiv.style.display="none";
3071 this.scrollDiv.scrollTop=0;
3072 if(this.options.highlightMethod!="class"){this.highlightDiv=[];
3073 switch(this.options.highlightElem){case"menuRow":case"cursorRow":this.highlightDiv[0]=this.createDiv("highlight",this.outerDiv);
3074 this.highlightDiv[0].style.display="none";
3076 case"menuCell":case"cursorCell":for(b=0;
3078 b++){this.highlightDiv[b]=this.createDiv("highlight",b==0?this.frozenTabs:this.scrollTab);
3079 this.highlightDiv[b].style.display="none";
3080 this.highlightDiv[b].id+=b
3082 case"selection":var h=this.options.highlightSection==1?this.frozenTabs:this.scrollTab;
3085 b++){this.highlightDiv[b]=this.createDiv("highlight",h);
3086 this.highlightDiv[b].style.display="none";
3087 this.highlightDiv[b].style.overflow="hidden";
3088 this.highlightDiv[b].id+=b;
3089 this.highlightDiv[b].style[b%2==0?"height":"width"]="0px"
3093 b++){this.tabs[b]=document.createElement("table");
3094 this.tabs[b].className=(b<2)?"ricoLG_table":"ricoLG_scrollTab";
3095 this.tabs[b].border=0;
3096 this.tabs[b].cellPadding=0;
3097 this.tabs[b].cellSpacing=0;
3098 this.tabs[b].id=this.tableId+"_tab"+b
3101 b++){this.thead[b]=this.tabs[b].createTHead();
3102 this.thead[b].className="ricoLG_top";
3103 if(Rico.theme.gridheader){Rico.addClass(this.thead[b],Rico.theme.gridheader)
3106 b++){this.tbody[b]=Rico.getTBody(this.tabs[b==0?0:2]);
3107 this.tbody[b].className="ricoLG_bottom";
3108 if(Rico.theme.gridcontent){Rico.addClass(this.tbody[b],Rico.theme.gridcontent)
3109 }this.tbody[b].insertRow(-1)
3110 }this.frozenTabs.appendChild(this.tabs[0]);
3111 this.innerDiv.appendChild(this.tabs[1]);
3112 this.scrollTab.appendChild(this.tabs[2]);
3113 if(f){f.parentNode.insertBefore(this.outerDiv,f)
3114 }if(g){this.headerColCnt=this.getColumnInfo(g);
3116 }else{this.createHdr(0,0,this.options.frozenColumns);
3117 this.createHdr(1,this.options.frozenColumns,this.options.columnSpecs.length);
3118 if(this.options.ColGroupsOnTabHdr&&this.options.ColGroups){this.insertPanelNames(this.thead[0].insertRow(0),0,this.options.frozenColumns);
3119 this.insertPanelNames(this.thead[1].insertRow(0),this.options.frozenColumns,this.options.columnSpecs.length)
3122 b++){this.headerColCnt=this.getColumnInfo(this.thead[b].rows)
3124 j<this.headerColCnt;
3125 j++){this.tbody[j<this.options.frozenColumns?0:1].rows[0].insertCell(-1)
3126 }if(f){e.parentNode.removeChild(e)
3127 }Rico.log("createTables end");
3129 },createDataCells:function(d){if(d<0){for(var a=0;
3130 a<this.options.minPageRows;
3131 a++){this.appendBlankRow()
3133 this.autoAppendRows(this.remainingHt())
3136 c++){this.appendBlankRow()
3137 }}var b=this.options.highlightSection;
3138 if(b&1){this.attachHighlightEvents(this.tbody[0])
3139 }if(b&2){this.attachHighlightEvents(this.tbody[1])
3140 }},filterId:function(a){return"RicoFilter_"+this.tableId+"_"+a
3141 },createFilters:function(b){for(var h=0;
3142 h<this.headerColCnt;
3143 h++){var e=this.columns[h];
3145 if(typeof f.filterUI!="string"){continue
3146 }var l=this.hdrCells[b][h].cell;
3147 var j,d=this.filterId(h);
3148 var i=l.getElementsByTagName("div");
3149 var g=Rico.getStyle(this.cell(0,h),"textAlign");
3150 i[1].style.textAlign=g;
3151 switch(f.filterUI.charAt(0)){case"t":j=Rico.createFormField(i[1],"input",Rico.inputtypes.search?"search":"text",d,"RicoFilter");
3152 var o=f.filterUI.match(/\d+/);
3153 j.maxLength=f.Length||50;
3154 j.size=o?parseInt(o,10):10;
3155 if(j.type!="search"){i[1].appendChild(Rico.clearButton(Rico.eventHandle(e,"filterClear")))
3156 }if(e.filterType==Rico.ColumnConst.USERFILTER&&e.filterOp=="LIKE"){var k=e.filterValues[0];
3157 if(k.charAt(0)=="*"){k=k.substr(1)
3158 }if(k.slice(-1)=="*"){k=k.slice(0,-1)
3161 }Rico.eventBind(j,"keyup",Rico.eventHandle(e,"filterKeypress"),false);
3164 case"m":case"s":j=Rico.createFormField(i[1],"select",null,d,"RicoFilter");
3165 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
3168 Rico.extend(n,this.buffer.ajaxOptions);
3169 var a=typeof(f.filterCol)=="number"?f.filterCol:h;
3170 n.parameters=this.buffer.formQueryHashXML(0,-1);
3171 n.parameters.distinct=a;
3172 n.onComplete=this.filterValuesUpdateFunc(h);
3173 new Rico.ajaxRequest(this.buffer.dataSource,n);
3175 case"n":j=Rico.createFormField(i[1],"select",null,d,"RicoFilter");
3176 Rico.addSelectOption(j,this.options.FilterAllToken,Rico.getPhraseById("filterAll"));
3178 var m=f.filterUI.length==1?"-0+":f.filterUI.substr(1);
3179 if(m.indexOf("-")>=0){Rico.addSelectOption(j,"LT0","< 0")
3180 }if(m.indexOf("0")>=0){Rico.addSelectOption(j,"EQ0","= 0")
3181 }if(m.indexOf("+")>=0){Rico.addSelectOption(j,"GT0","> 0")
3182 }Rico.eventBind(e.filterField,"change",Rico.eventHandle(e,"nFilterChange"));
3184 case"c":if(typeof e._createFilters=="function"){e._createFilters(i[1],d)
3186 }}this.initFilterImage(b)
3187 },filterValuesUpdateFunc:function(b){var a=this;
3188 return function(c){a.filterValuesUpdate(b,c)
3190 },filterValuesUpdate:function(a,g){var f=g.responseXML.getElementsByTagName("ajax-response");
3191 Rico.log("filterValuesUpdate: "+g.status);
3192 if(f==null||f.length!=1){return false
3194 var n=f.getElementsByTagName("error");
3195 if(n.length>0){Rico.log("Data provider returned an error:\n"+Rico.getContentAsString(n[0],this.buffer.isEncoded));
3196 alert(Rico.getPhraseById("requestError",Rico.getContentAsString(n[0],this.buffer.isEncoded)));
3198 }f=f.getElementsByTagName("response")[0];
3199 var l=f.getElementsByTagName("rows")[0];
3200 var d=this.columns[parseInt(a,10)];
3201 var r=this.buffer.dom2jstable(l);
3203 if(d.filterType==Rico.ColumnConst.USERFILTER&&d.filterOp=="EQ"){q=d.filterValues[0]
3204 }Rico.log("filterValuesUpdate: col="+a+" rows="+r.length);
3205 switch(d.format.filterUI.charAt(0)){case"m":d.mFilter=document.body.appendChild(document.createElement("div"));
3206 d.mFilter.className="ricoLG_mFilter";
3207 Rico.hide(d.mFilter);
3208 var e=d.mFilter.appendChild(document.createElement("div"));
3209 e.className="ricoLG_mFilter_content";
3210 var o=d.mFilter.appendChild(document.createElement("div"));
3211 o.className="ricoLG_mFilter_button";
3212 d.mFilterButton=o.appendChild(document.createElement("button"));
3213 d.mFilterButton.innerHTML=Rico.getPhraseById("apply");
3214 var j=Rico.isWebKit?"mousedown":"click";
3215 Rico.eventBind(d.filterField,j,Rico.eventHandle(d,"mFilterSelectClick"));
3216 Rico.eventBind(d.mFilterButton,"click",Rico.eventHandle(d,"mFilterFinish"));
3217 tab=e.appendChild(document.createElement("table"));
3221 var p=this.filterId(a)+"_";
3222 this.createMFilterItem(tab,this.options.FilterAllToken,Rico.getPhraseById("filterAll"),p+"all",Rico.eventHandle(d,"mFilterAllClick"));
3223 var k=Rico.eventHandle(d,"mFilterOtherClick");
3226 h++){if(r[h].length>0){m=r[h][0];
3227 this.createMFilterItem(tab,m,m||Rico.getPhraseById("filterBlank"),p+h,k)
3228 }}d.mFilterInputs=e.getElementsByTagName("input");
3229 d.mFilterLabels=e.getElementsByTagName("label");
3230 d.mFilterFocus=d.mFilterInputs.length?d.mFilterInputs[0]:d.mFilterButton;
3232 case"s":for(var h=0;
3234 h++){if(r[h].length>0){m=r[h][0];
3235 b=Rico.addSelectOption(d.filterField,m,m||Rico.getPhraseById("filterBlank"));
3236 if(d.filterType==Rico.ColumnConst.USERFILTER&&m==q){b.selected=true
3237 }}}Rico.eventBind(d.filterField,"change",Rico.eventHandle(d,"filterChange"));
3240 },createMFilterItem:function(j,b,i,a,e){var f=j.insertRow(-1);
3242 if(f.rowIndex%2==1){f.className="ricoLG_mFilter_oddrow"
3243 }var d=f.insertCell(-1);
3244 var c=f.insertCell(-1);
3245 var h=Rico.createFormField(d,"input","checkbox",a);
3248 var g=c.appendChild(document.createElement("label"));
3251 Rico.eventBind(h,"click",e)
3252 },unplugHighlightEvents:function(){var a=this.options.highlightSection;
3253 if(a&1){this.detachHighlightEvents(this.tbody[0])
3254 }if(a&2){this.detachHighlightEvents(this.tbody[1])
3255 }},insertPanelNames:function(a,b,d,f){Rico.log("insertPanelNames: start="+b+" limit="+d);
3256 a.className="ricoLG_hdg";
3257 var i=-1,j,e=null,g=0;
3260 h++){if(i==this.options.columnSpecs[h].ColGroupIdx){j++
3261 }else{if(e){e.colSpan=j
3262 }e=a.insertCell(-1);
3265 i=this.options.columnSpecs[h].ColGroupIdx;
3266 e.innerHTML=this.options.ColGroups[i]
3268 }},createHdr:function(d,g,b){Rico.log("createHdr: i="+d+" start="+g+" limit="+b);
3269 var a=this.thead[d].insertRow(-1);
3270 a.id=this.tableId+"_tab"+d+"h_main";
3271 a.className="ricoLG_hdg";
3274 f++){var e=a.insertCell(-1);
3275 e.innerHTML=this.options.columnSpecs[f].Hdg
3276 }},loadHdrSrc:function(g){var b,d,j,e,f,a;
3277 Rico.log("loadHdrSrc start");
3282 e++){f=this.thead[b].insertRow(-1);
3283 f.className="ricoLG_hdg "+this.tableId+"_hdg"+e
3284 }}if(g.length==1){a=g[0].cells;
3287 j++){this.thead[j<this.options.frozenColumns?0:1].rows[0].appendChild(a[0])
3293 j++){if(Rico.hasClass(a[0],"ricoFrozen")){if(e==this.headerRowIdx){this.options.frozenColumns=j+1
3295 }this.thead[d].rows[e].appendChild(a[0])
3296 }}}Rico.log("loadHdrSrc end")
3297 },sizeDivs:function(){Rico.log("sizeDivs: "+this.tableId);
3299 this.baseSizeDivs();
3300 var d=this.firstVisible();
3301 if(this.pageSize==0||d<0){return
3302 }var c=this.columns[d].dataColDiv.offsetHeight;
3303 this.rowHeight=Math.round(c/this.pageSize);
3305 if(this.scrTabWi0==this.scrTabWi){this.innerDiv.style.height=(this.hdrHt+1)+"px";
3306 this.scrollDiv.style.overflowX="hidden"
3307 }else{this.scrollDiv.style.overflowX="scroll";
3308 b+=this.options.scrollBarWidth
3309 }this.scrollDiv.style.height=b+"px";
3310 this.innerDiv.style.width=(this.scrWi)+"px";
3311 this.scrollTab.style.width=(this.scrWi-this.options.scrollBarWidth)+"px";
3312 this.resizeDiv.style.height=(this.hdrHt+this.dataHt+1)+"px";
3313 Rico.log("sizeDivs scrHt="+b+" innerHt="+this.innerDiv.style.height+" rowHt="+this.rowHeight+" pageSize="+this.pageSize);
3314 var a=(this.scrWi-this.scrTabWi<this.options.scrollBarWidth)?2:0;
3315 this.shadowDiv.style.width=(this.scrTabWi+a)+"px";
3316 this.outerDiv.style.height=(this.hdrHt+b)+"px";
3317 this.setHorizontalScroll()
3318 },setHorizontalScroll:function(){var a=(-this.scrollDiv.scrollLeft)+"px";
3319 this.tabs[1].style.marginLeft=a;
3320 this.tabs[2].style.marginLeft=a
3321 },remainingHt:function(){var f=this.outerDiv.offsetHeight;
3322 var g=Rico.windowHeight();
3323 var e=Rico.isIE?15:10;
3324 if(!Rico.isIE&&window.frameElement&&window.frameElement.scrolling=="yes"&&this.sizeTo!="parent"){e+=this.options.scrollBarWidth
3325 }switch(this.sizeTo){case"window":var d=Rico.cumulativeOffset(this.outerDiv).top;
3326 Rico.log("remainingHt/window, winHt="+g+" tabHt="+f+" gridY="+d);
3328 case"parent":var h=this.offsetFromParent(this.outerDiv);
3329 if(Rico.isIE){Rico.hide(this.outerDiv)
3330 }var b=this.outerDiv.parentNode.clientHeight;
3331 if(Rico.isIE){Rico.show(this.outerDiv)
3332 }Rico.log("remainingHt/parent, parentHt="+b+" offset="+h+" tabHt="+f);
3334 case"data":case"body":var a=Rico.isIE?document.body.scrollHeight:document.body.offsetHeight;
3336 if(!Rico.isWebKit){c-=this.options.scrollBarWidth
3337 }Rico.log("remainingHt, winHt="+g+" pageHt="+a+" remHt="+c);
3339 default:Rico.log("remainingHt, winHt="+g+" tabHt="+f);
3340 if(this.sizeTo.slice(-1)=="%"){g*=parseFloat(this.sizeTo)/100
3341 }else{if(this.sizeTo.slice(-2)=="px"){g=parseInt(this.sizeTo,10)
3343 }},offsetFromParent:function(b){var a=0;
3345 do{a+=b.offsetTop||0;
3347 if(!b||b==null){break
3348 }var d=Rico.getStyle(b,"position");
3349 if(b.tagName=="BODY"||b.tagName=="HTML"||d=="absolute"){return a-c.offsetTop
3352 },adjustPageSize:function(){Rico.log("adjustPageSize start");
3353 var a=this.remainingHt();
3354 Rico.log("adjustPageSize remHt="+a+" lastRow="+this.lastRowPos);
3355 if(a>this.rowHeight){this.autoAppendRows(a)
3356 }else{if(a<0||this.sizeTo=="data"){this.autoRemoveRows(-a)
3357 }}Rico.log("adjustPageSize end")
3358 },setPageSize:function(b){Rico.log("setPageSize "+this.tableId+" newRowCount="+b);
3359 b=Math.min(b,this.options.maxPageRows);
3360 b=Math.max(b,this.options.minPageRows);
3361 this.sizeTo="fixed";
3362 var a=this.pageSize;
3363 while(this.pageSize>b){this.removeRow()
3364 }while(this.pageSize<b){this.appendBlankRow()
3365 }this.finishResize(a)
3366 },pluginWindowResize:function(){Rico.log("pluginWindowResize");
3367 this.resizeWindowHandler=Rico.eventHandle(this,"resizeWindow");
3368 Rico.eventBind(window,"resize",this.resizeWindowHandler,false)
3369 },unplugWindowResize:function(){if(!this.resizeWindowHandler){return
3370 }Rico.eventUnbind(window,"resize",this.resizeWindowHandler,false);
3371 this.resizeWindowHandler=null
3372 },resizeWindow:function(){Rico.log("resizeWindow "+this.tableId+" lastRow="+this.lastRowPos+" resizeState="+this.resizeState);
3373 if(this.resizeState=="finish"){Rico.log("resizeWindow postponed");
3374 this.resizeState="resize";
3376 }if(!this.sizeTo||this.sizeTo=="fixed"){this.sizeDivs();
3378 }if(this.sizeTo=="parent"&&Rico.getStyle(this.outerDiv.parentNode,"display")=="none"){return
3379 }Rico.log("resizeWindow: about to adjustPageSize");
3380 var a=this.pageSize;
3381 this.adjustPageSize();
3382 this.finishResize(a)
3383 },finishResize:function(b){Rico.log("finishResize "+this.tableId);
3384 if(this.pageSize>b&&this.buffer.totalRows>0){this.isPartialBlank=true;
3385 var a=this.adjustRow(this.lastRowPos);
3386 this.buffer.fetch(a)
3387 }else{if(this.pageSize<b){if(this.options.onRefreshComplete){this.options.onRefreshComplete(this.contentStartPos,this.contentStartPos+this.pageSize-1)
3388 }}}this.resizeState="finish";
3389 Rico.runLater(20,this,"finishResize2");
3390 Rico.log("Resize "+this.tableId+" complete. old size="+b+" new size="+this.pageSize)
3391 },finishResize2:function(){Rico.log("finishResize2 "+this.tableId+": resizeState="+this.resizeState);
3393 this.updateHeightDiv();
3394 if(this.resizeState=="resize"){this.resizeWindow()
3395 }else{this.resizeState=""
3396 }},topOfLastPage:function(){return Math.max(this.buffer.totalRows-this.pageSize,0)
3397 },updateHeightDiv:function(){var b=this.topOfLastPage();
3398 var a=b?this.scrollDiv.clientHeight+Math.floor(this.rowHeight*(b+0.4)):1;
3399 Rico.log("updateHeightDiv, ht="+a+" scrollDiv.clientHeight="+this.scrollDiv.clientHeight+" rowsNotDisplayed="+b);
3400 this.shadowDiv.style.height=a+"px"
3401 },autoRemoveRows:function(a){if(!this.rowHeight){return
3402 }var c=Math.ceil(a/this.rowHeight);
3403 if(this.sizeTo=="data"){c=Math.max(c,this.pageSize-this.buffer.totalRows)
3404 }Rico.log("autoRemoveRows overage="+a+" removeCnt="+c);
3407 b++){this.removeRow()
3408 }},removeRow:function(){if(this.pageSize<=this.options.minPageRows){return
3411 b<this.headerColCnt;
3412 b++){var a=this.columns[b].cell(this.pageSize);
3413 this.columns[b].dataColDiv.removeChild(a)
3414 }},autoAppendRows:function(a){if(!this.rowHeight){return
3415 }var c=Math.floor(a/this.rowHeight);
3416 Rico.log("autoAppendRows overage="+a+" cnt="+c+" rowHt="+this.rowHeight);
3419 b++){if(this.sizeTo=="data"&&this.pageSize>=this.buffer.totalRows){break
3420 }this.appendBlankRow()
3421 }},appendBlankRow:function(){if(this.pageSize>=this.options.maxPageRows){return
3422 }Rico.log("appendBlankRow #"+this.pageSize);
3423 var a=this.defaultRowClass(this.pageSize);
3425 d<this.headerColCnt;
3426 d++){var b=document.createElement("div");
3427 b.className="ricoLG_cell "+a;
3428 b.id=this.tableId+"_"+this.pageSize+"_"+d;
3429 this.columns[d].dataColDiv.appendChild(b);
3430 if(this.columns[d]._create){this.columns[d]._create(b,this.pageSize)
3431 }else{b.innerHTML=" "
3432 }if(this.columns[d].format.canDrag&&Rico.registerDraggable){Rico.registerDraggable(new Rico.LiveGridDraggable(this,this.pageSize,d),this.options.dndMgrIdx)
3434 },defaultRowClass:function(b){var a;
3435 if(b%2==0){a="ricoLG_evenRow"
3436 }else{a="ricoLG_oddRow"
3438 },handleMenuClick:function(f){if(!this.menu){return
3442 var a=Rico.eventElement(f);
3443 if(a.className=="ricoLG_highlightDiv"){b=this.highlightIdx
3444 }else{a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3446 }b=this.winCellIndex(a);
3447 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3448 }}this.highlight(b);
3449 this.highlightEnabled=false;
3450 if(this.hideScroll){this.scrollDiv.style.overflow="hidden"
3452 if(!this.menu.div){this.menu.createDiv()
3453 }this.menu.liveGrid=this;
3454 if(this.menu.buildGridMenu){var d=this.menu.buildGridMenu(b.row,b.column,b.tabIdx);
3456 }}if(this.options.highlightElem=="selection"&&!this.isSelected(b.cell)){this.selectCell(b.cell)
3458 this.menu.showmenu(f,function(){c.closeMenu()
3461 },closeMenu:function(){if(!this.menuIdx){return
3462 }if(this.hideScroll){this.scrollDiv.style.overflow=""
3463 }this.highlightEnabled=true;
3465 },winCellIndex:function(b){var d=b.id.lastIndexOf("_",b.id.length);
3466 var a=b.id.lastIndexOf("_",d-1)+1;
3467 var f=parseInt(b.id.substr(d+1));
3468 var e=parseInt(b.id.substr(a,d));
3469 return{row:e,column:f,tabIdx:this.columns[f].tabIdx,cell:b}
3470 },datasetIndex:function(b){var a=this.winCellIndex(b);
3471 a.row+=this.buffer.windowPos;
3472 a.onBlankRow=(a.row>=this.buffer.endPos());
3474 },attachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventBind(a,"mousedown",this.options.mouseDownHandler,false);
3475 a.ondrag=function(){return false
3477 a.onselectstart=function(){return false
3480 case"cursorRow":case"cursorCell":Rico.eventBind(a,"mouseover",this.options.rowOverHandler,false);
3482 }},detachHighlightEvents:function(a){switch(this.options.highlightElem){case"selection":Rico.eventUnbind(a,"mousedown",this.options.mouseDownHandler,false);
3484 a.onselectstart=null;
3486 case"cursorRow":case"cursorCell":Rico.eventUnbind(a,"mouseover",this.options.rowOverHandler,false);
3488 }},getVisibleSelection:function(){var d=[];
3489 if(this.SelectIdxStart&&this.SelectIdxEnd){var b=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowStart);
3490 var a=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row)-this.buffer.startPos,this.buffer.windowEnd-1);
3491 var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3492 var f=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3497 j++){d.push({row:h-this.buffer.windowStart,column:j})
3498 }}}if(this.SelectCtrl){for(var e=0;
3499 e<this.SelectCtrl.length;
3500 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})
3502 },updateSelectOutline:function(){if(!this.SelectIdxStart||!this.SelectIdxEnd){return
3503 }var d=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3504 var c=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3505 if(d>c){this.HideSelection();
3507 }var g=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3508 var e=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3509 var h=this.columns[g].cell(d-this.buffer.windowStart).offsetTop;
3510 var j=this.columns[g].cell(c-this.buffer.windowStart);
3511 var b=j.offsetTop+j.offsetHeight;
3512 var l=this.columns[g].dataCell.offsetLeft;
3513 var k=this.columns[e].dataCell.offsetLeft;
3514 var a=k+this.columns[e].dataCell.offsetWidth;
3515 this.highlightDiv[0].style.top=this.highlightDiv[3].style.top=this.highlightDiv[1].style.top=(this.hdrHt+h-1)+"px";
3516 this.highlightDiv[2].style.top=(this.hdrHt+b-1)+"px";
3517 this.highlightDiv[3].style.left=(l-2)+"px";
3518 this.highlightDiv[0].style.left=this.highlightDiv[2].style.left=(l-1)+"px";
3519 this.highlightDiv[1].style.left=(a-1)+"px";
3520 this.highlightDiv[0].style.width=this.highlightDiv[2].style.width=(a-l-1)+"px";
3521 this.highlightDiv[1].style.height=this.highlightDiv[3].style.height=(b-h)+"px";
3524 f++){this.highlightDiv[f].style.display=""
3525 }},HideSelection:function(){var b;
3526 if(this.options.highlightMethod!="class"){for(b=0;
3527 b<this.highlightDiv.length;
3528 b++){this.highlightDiv[b].style.display="none"
3529 }}if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3530 Rico.log("HideSelection "+a.length);
3533 b++){this.unhighlightCell(this.columns[a[b].column].cell(a[b].row))
3534 }}},ShowSelection:function(){if(this.options.highlightMethod!="class"){this.updateSelectOutline()
3535 }if(this.options.highlightMethod!="outline"){var a=this.getVisibleSelection();
3538 b++){this.highlightCell(this.columns[a[b].column].cell(a[b].row))
3539 }}},ClearSelection:function(){Rico.log("ClearSelection");
3540 this.HideSelection();
3541 this.SelectIdxStart=null;
3542 this.SelectIdxEnd=null;
3544 },selectCell:function(a){this.ClearSelection();
3545 this.SelectIdxStart=this.SelectIdxEnd=this.datasetIndex(a);
3546 this.ShowSelection()
3547 },AdjustSelection:function(a){var b=this.datasetIndex(a);
3548 if(this.SelectIdxStart.tabIdx!=b.tabIdx){return
3549 }this.HideSelection();
3550 this.SelectIdxEnd=b;
3551 this.ShowSelection()
3552 },RefreshSelection:function(){var a=this.getVisibleSelection();
3555 b++){this.columns[a[b].column].displayValue(a[b].row)
3556 }},FillSelection:function(b,f){if(this.SelectIdxStart&&this.SelectIdxEnd){var e=Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3557 var d=Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row);
3558 var j=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3559 var g=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3564 k++){this.buffer.setValue(a,k,b,f)
3565 }}}if(this.SelectCtrl){for(var h=0;
3566 h<this.SelectCtrl.length;
3567 h++){this.buffer.setValue(this.SelectCtrl[h].row,this.SelectCtrl[h].column,b,f)
3568 }}this.RefreshSelection()
3569 },selectMouseDown:function(d){if(this.highlightEnabled==false){return true
3571 var a=Rico.eventElement(d);
3572 if(!Rico.eventLeftClick(d)){return true
3573 }a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3576 var c=this.datasetIndex(a);
3577 if(c.onBlankRow){return true
3578 }Rico.log("selectMouseDown @"+c.row+","+c.column);
3579 if(d.ctrlKey){if(!this.SelectIdxStart||this.options.highlightMethod!="class"){return true
3580 }if(!this.isSelected(a)){this.highlightCell(a);
3581 this.SelectCtrl.push(this.datasetIndex(a))
3583 b<this.SelectCtrl.length;
3584 b++){if(this.SelectCtrl[b].row==c.row&&this.SelectCtrl[b].column==c.column){this.unhighlightCell(a);
3585 this.SelectCtrl.splice(b,1);
3587 }}}}else{if(d.shiftKey){if(!this.SelectIdxStart){return true
3588 }this.AdjustSelection(a)
3589 }else{this.selectCell(a);
3592 },pluginSelect:function(){if(this.selectPluggedIn){return
3593 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3594 Rico.eventBind(a,"mouseover",this.options.mouseOverHandler,false);
3595 Rico.eventBind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3596 this.selectPluggedIn=true
3597 },unplugSelect:function(){if(!this.selectPluggedIn){return
3598 }var a=this.tbody[this.SelectIdxStart.tabIdx];
3599 Rico.eventUnbind(a,"mouseover",this.options.mouseOverHandler,false);
3600 Rico.eventUnbind(this.outerDiv,"mouseup",this.options.mouseUpHandler,false);
3601 this.selectPluggedIn=false
3602 },selectMouseUp:function(b){this.unplugSelect();
3603 var a=Rico.eventElement(b);
3604 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3606 }if(this.SelectIdxStart&&this.SelectIdxEnd){this.AdjustSelection(a)
3607 }else{this.ClearSelection()
3608 }},selectMouseOver:function(b){var a=Rico.eventElement(b);
3609 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3611 }this.AdjustSelection(a);
3613 },isSelected:function(a){if(this.options.highlightMethod!="outline"){return Rico.hasClass(a,this.options.highlightClass)
3614 }if(!this.SelectIdxStart||!this.SelectIdxEnd){return false
3615 }var c=Math.max(Math.min(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowStart);
3616 var b=Math.min(Math.max(this.SelectIdxEnd.row,this.SelectIdxStart.row),this.buffer.windowEnd-1);
3617 if(c>b){return false
3618 }var e=Math.min(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3619 var d=Math.max(this.SelectIdxEnd.column,this.SelectIdxStart.column);
3620 var f=this.datasetIndex(a);
3621 return(c<=f.row&&f.row<=b&&e<=f.column&&f.column<=d)
3622 },highlightCell:function(a){Rico.addClass(a,this.options.highlightClass)
3623 },unhighlightCell:function(a){if(a){Rico.removeClass(a,this.options.highlightClass)
3624 }},selectRow:function(a){for(var b=0;
3625 b<this.columns.length;
3626 b++){this.highlightCell(this.columns[b].cell(a))
3627 }},unselectRow:function(a){for(var b=0;
3628 b<this.columns.length;
3629 b++){this.unhighlightCell(this.columns[b].cell(a))
3630 }},rowMouseOver:function(c){if(!this.highlightEnabled){return
3631 }var a=Rico.eventElement(c);
3632 a=Rico.getParentByTagName(a,"div","ricoLG_cell");
3634 }var b=this.winCellIndex(a);
3635 if((this.options.highlightSection&(b.tabIdx+1))==0){return
3637 },highlight:function(a){if(this.options.highlightMethod!="outline"){this.cursorSetClass(a)
3638 }if(this.options.highlightMethod!="class"){this.cursorOutline(a)
3639 }this.highlightIdx=a
3640 },cursorSetClass:function(e){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3641 }this.highlightCell(e.cell);
3643 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3644 }var b=this.options.highlightSection&1;
3645 var a=this.options.highlightSection&2;
3646 var f=b?0:this.options.frozenColumns;
3647 var d=a?this.columns.length:this.options.frozenColumns;
3650 g++){this.highlightCell(this.columns[g].cell(e.row))
3653 }},cursorOutline:function(c){var d;
3654 switch(this.options.highlightElem){case"menuCell":case"cursorCell":d=this.highlightDiv[c.tabIdx];
3655 d.style.left=(this.columns[c.column].dataCell.offsetLeft-1)+"px";
3656 d.style.width=this.columns[c.column].colWidth;
3657 this.highlightDiv[1-c.tabIdx].style.display="none";
3659 case"menuRow":case"cursorRow":d=this.highlightDiv[0];
3660 var b=this.options.highlightSection&1;
3661 var a=this.options.highlightSection&2;
3662 d.style.left=b?"0px":this.frozenTabs.style.width;
3663 d.style.width=((b?this.frozenTabs.offsetWidth:0)+(a?this.innerDiv.offsetWidth:0)-4)+"px";
3666 }d.style.top=(this.hdrHt+c.row*this.rowHeight-1)+"px";
3667 d.style.height=(this.rowHeight-1)+"px";
3669 },unhighlight:function(){switch(this.options.highlightElem){case"menuCell":case"cursorCell":if(this.highlightIdx){this.unhighlightCell(this.highlightIdx.cell)
3670 }if(!this.highlightDiv){return
3673 a++){this.highlightDiv[a].style.display="none"
3675 case"menuRow":case"cursorRow":if(this.highlightIdx){this.unselectRow(this.highlightIdx.row)
3676 }if(this.highlightDiv){this.highlightDiv[0].style.display="none"
3678 }},resetContents:function(){Rico.log("resetContents");
3679 this.ClearSelection();
3680 this.buffer.clear();
3682 this.clearBookmark()
3683 },setImages:function(){for(var a=0;
3684 a<this.columns.length;
3685 a++){this.columns[a].setImage()
3686 }},findSortedColumn:function(){for(var a=0;
3687 a<this.columns.length;
3688 a++){if(this.columns[a].isSorted()){return a
3690 },findColumnsBySpec:function(b,c){var a=[];
3692 d<this.options.columnSpecs.length;
3693 d++){if(this.options.columnSpecs[d][b]==c){a.push(d)
3695 },setSortUI:function(c,b){Rico.log("setSortUI: "+c+" "+b);
3696 var a=this.findSortedColumn();
3697 if(a>=0){b=this.columns[a].getSortDirection()
3698 }else{if(typeof b!="string"){b=Rico.ColumnConst.SORT_ASC
3699 }else{b=b.toUpperCase();
3700 if(b!=Rico.ColumnConst.SORT_DESC){b=Rico.ColumnConst.SORT_ASC
3701 }}switch(typeof c){case"string":a=this.findColumnsBySpec("id",c);
3705 }}if(typeof(a)!="number"||a<0){return
3707 this.columns[a].setSorted(b);
3708 this.buffer.sortBuffer(a)
3709 },clearSort:function(){for(var a=0;
3710 a<this.columns.length;
3711 a++){this.columns[a].setUnsorted()
3712 }},clearFilters:function(){for(var a=0;
3713 a<this.columns.length;
3714 a++){this.columns[a].setUnfiltered(true)
3715 }if(this.options.filterHandler){this.options.filterHandler()
3716 }},filterCount:function(){for(var a=0,b=0;
3717 a<this.columns.length;
3718 a++){if(this.columns[a].isFiltered()){b++
3720 },sortHandler:function(){this.cancelMenu();
3721 this.ClearSelection();
3723 var a=this.findSortedColumn();
3725 }Rico.log("sortHandler: sorting column "+a);
3726 this.buffer.sortBuffer(a);
3728 this.scrollDiv.scrollTop=0;
3729 this.buffer.fetch(0)
3730 },filterHandler:function(){Rico.log("filterHandler");
3732 if(this.buffer.processingRequest){this.queueFilter=true;
3734 }this.unplugScroll();
3735 this.ClearSelection();
3737 this.clearBookmark();
3739 this.buffer.fetch(-1);
3740 Rico.runLater(10,this,"pluginScroll")
3741 },clearBookmark:function(){if(this.bookmark){this.bookmark.innerHTML=" "
3742 }},bookmarkHandler:function(a,d){var b;
3743 if(isNaN(a)||!this.bookmark){return
3744 }var c=this.buffer.totalRows;
3746 }if(c<=0){b=Rico.getPhraseById("bookmarkNoMatch")
3747 }else{if(d<0){b=Rico.getPhraseById("bookmarkNoRec")
3748 }else{if(this.buffer.foundRowCount){b=Rico.getPhraseById("bookmarkExact",a,d,c)
3749 }else{b=Rico.getPhraseById("bookmarkAbout",a,d,c)
3750 }}}this.bookmark.innerHTML=b
3751 },clearRows:function(){if(this.isBlank==true){return
3753 a<this.columns.length;
3754 a++){this.columns[a].clearColumn()
3756 },refreshContents:function(j){Rico.log("refreshContents1 "+this.tableId+": startPos="+j+" lastRow="+this.lastRowPos+" PartBlank="+this.isPartialBlank+" pageSize="+this.pageSize);
3760 if(this.queueFilter){Rico.log("refreshContents: cancelling refresh because filter has changed");
3761 this.queueFilter=false;
3762 this.filterHandler();
3764 }this.highlightEnabled=this.options.highlightSection!="none";
3765 var h=this.buffer.startPos>j;
3766 var d=h?this.buffer.startPos:j;
3767 this.contentStartPos=d+1;
3768 var b=Math.min(this.buffer.startPos+this.buffer.size,j+this.pageSize);
3769 this.buffer.setWindow(d,b);
3770 Rico.log("refreshContents2 "+this.tableId+": cStartPos="+d+" cEndPos="+b+" vPrecedesBuf="+h+" b.startPos="+this.buffer.startPos);
3771 if(j==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3772 }this.isBlank=false;
3773 var m=this.options.onRefreshComplete;
3774 if((j+this.pageSize<this.buffer.startPos)||(this.buffer.startPos+this.buffer.size<j)||(this.buffer.size==0)){this.clearRows();
3775 if(m){m(this.contentStartPos,b)
3777 }Rico.log("refreshContents: contentStartPos="+d+" contentEndPos="+b+" viewPrecedesBuffer="+h);
3779 var f=this.pageSize-n;
3785 l<this.columns.length;
3786 l++){this.columns[l].displayValue(a+e)
3789 g++){this.blankRow(g+k)
3790 }if(this.options.highlightElem=="selection"){this.ShowSelection()
3791 }this.isPartialBlank=f>0;
3793 Rico.log("refreshContents complete, startPos="+j);
3794 if(m){m(this.contentStartPos,b)
3795 }},scrollToRow:function(a){var b=this.rowToPixel(a);
3796 Rico.log("scrollToRow, rowOffset="+a+" pixel="+b);
3797 this.scrollDiv.scrollTop=b;
3798 if(this.options.onscroll){this.options.onscroll(this,a)
3799 }},scrollUp:function(){this.moveRelative(-1)
3800 },scrollDown:function(){this.moveRelative(1)
3801 },pageUp:function(){this.moveRelative(-this.pageSize)
3802 },pageDown:function(){this.moveRelative(this.pageSize)
3803 },adjustRow:function(a){var b=this.topOfLastPage();
3804 if(b==0||!a){return 0
3805 }return Math.min(b,a)
3806 },rowToPixel:function(a){return this.adjustRow(a)*this.rowHeight
3807 },pixeltorow:function(c){var b=this.topOfLastPage();
3809 }var a=parseInt(c/this.rowHeight,10);
3810 return Math.min(b,a)
3811 },moveRelative:function(b){var a=Math.max(this.scrollDiv.scrollTop+b*this.rowHeight,0);
3812 a=Math.min(a,this.scrollDiv.scrollHeight);
3813 this.scrollDiv.scrollTop=a
3814 },pluginScroll:function(){if(this.scrollPluggedIn){return
3815 }Rico.log("pluginScroll: wheelEvent="+this.wheelEvent);
3816 Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3819 a++){Rico.eventBind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3820 }this.scrollPluggedIn=true
3821 },unplugScroll:function(){if(!this.scrollPluggedIn){return
3822 }Rico.log("unplugScroll");
3823 Rico.eventUnbind(this.scrollDiv,"scroll",this.scrollEventFunc,false);
3826 a++){Rico.eventUnbind(this.tabs[a],this.wheelEvent,this.wheelEventFunc,false)
3827 }this.scrollPluggedIn=false
3828 },handleWheel:function(a){var b=0;
3829 if(a.wheelDelta){if(Rico.isOpera){b=a.wheelDelta/120
3830 }else{if(Rico.isWebKit){b=-a.wheelDelta/12
3831 }else{b=-a.wheelDelta/120
3832 }}}else{if(a.detail){b=a.detail/3
3833 }}if(b){this.moveRelative(b)
3836 },handleScroll:function(g){if(this.scrollTimeout){clearTimeout(this.scrollTimeout)
3837 }this.setHorizontalScroll();
3838 var a=this.scrollDiv.scrollTop;
3839 var b=this.lastScrollPos-a;
3841 }var d=this.pixeltorow(a);
3842 if(d==this.lastRowPos&&!this.isPartialBlank&&!this.isBlank){return
3844 Rico.log("handleScroll, newrow="+d+" scrtop="+a);
3845 if(this.options.highlightElem=="selection"){this.HideSelection()
3846 }this.buffer.fetch(d);
3847 if(this.options.onscroll){this.options.onscroll(this,d)
3848 }this.scrollTimeout=Rico.runLater(1200,this,"scrollIdle");
3849 this.lastScrollPos=this.scrollDiv.scrollTop;
3851 },scrollIdle:function(){if(this.options.onscrollidle){this.options.onscrollidle()
3853 Rico.LiveGridColumn=function(a,d,c,b){this.initialize(a,d,c,b)
3855 Rico.LiveGridColumn.prototype={initialize:function(liveGrid,colIdx,hdrInfo,tabIdx){Rico.extend(this,new Rico.TableColumnBase());
3856 this.baseInit(liveGrid,colIdx,hdrInfo,tabIdx);
3857 this.buffer=liveGrid.buffer;
3858 if(typeof(this.format.type)!="string"||this.format.EntryType=="tinyMCE"){this.format.type="html"
3859 }if(typeof this.isNullable!="boolean"){this.isNullable=/number|date/.test(this.format.type)
3860 }this.isText=/html|text/.test(this.format.type);
3861 Rico.log(" sortable="+this.sortable+" filterable="+this.filterable+" hideable="+this.hideable+" isNullable="+this.isNullable+" isText="+this.isText);
3862 this.fixHeaders(this.liveGrid.tableId,this.options.hdrIconsFirst);
3863 if(this["format_"+this.format.type]){this._format=this["format_"+this.format.type]
3864 }if(this.format.control){if(typeof this.format.control=="string"){this.format.control=eval(this.format.control)
3865 }for(var property in this.format.control){if(property.charAt(0)=="_"){Rico.log("Copying control property "+property+" to "+this);
3866 this[property]=this.format.control[property]
3867 }}}},sortAsc:function(){this.setColumnSort(Rico.ColumnConst.SORT_ASC)
3868 },sortDesc:function(){this.setColumnSort(Rico.ColumnConst.SORT_DESC)
3869 },setColumnSort:function(a){this.liveGrid.clearSort();
3871 if(this.liveGrid.options.saveColumnInfo.sort){this.liveGrid.setCookie()
3872 }if(this.options.sortHandler){this.options.sortHandler()
3873 }},isSortable:function(){return this.sortable
3874 },isSorted:function(){return this.currentSort!=Rico.ColumnConst.UNSORTED
3875 },getSortDirection:function(){return this.currentSort
3876 },toggleSort:function(){if(this.buffer&&this.buffer.totalRows==0){return
3877 }if(this.currentSort==Rico.ColumnConst.SORT_ASC){this.sortDesc()
3878 }else{this.sortAsc()
3879 }},setUnsorted:function(){this.setSorted(Rico.ColumnConst.UNSORTED)
3880 },setSorted:function(a){this.currentSort=a
3881 },canFilter:function(){return this.filterable
3882 },getFilterText:function(){var c=[];
3884 b<this.filterValues.length;
3885 b++){var a=this.filterValues[b];
3886 c.push(a==""?Rico.getPhraseById("filterBlank"):a)
3887 }switch(this.filterOp){case"EQ":return"= "+c.join(", ");
3888 case"NE":return Rico.getPhraseById("filterNot",c.join(", "));
3889 case"LT":return"< "+c[0];
3890 case"GT":return"> "+c[0];
3891 case"LE":return"<= "+c[0];
3892 case"GE":return">= "+c[0];
3893 case"LIKE":return Rico.getPhraseById("filterLike",c[0]);
3894 case"NULL":return Rico.getPhraseById("filterEmpty");
3895 case"NOTNULL":return Rico.getPhraseById("filterNotEmpty")
3897 },getFilterQueryParm:function(){if(this.filterType==Rico.ColumnConst.UNFILTERED){return""
3898 }var a="&f["+this.index+"][op]="+this.filterOp;
3899 a+="&f["+this.index+"][len]="+this.filterValues.length;
3901 b<this.filterValues.length;
3902 b++){a+="&f["+this.index+"]["+b+"]="+escape(this.filterValues[b])
3904 },setUnfiltered:function(a){this.filterType=Rico.ColumnConst.UNFILTERED;
3905 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3906 }if(this.removeFilterFunc){this.removeFilterFunc()
3907 }if(this.options.filterHandler&&!a){this.options.filterHandler()
3908 }},setFilterEQ:function(){this.setUserFilter("EQ")
3909 },setFilterNE:function(){this.setUserFilter("NE")
3910 },addFilterNE:function(){this.filterValues.push(this.userFilter);
3911 if(this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3912 }if(this.options.filterHandler){this.options.filterHandler()
3913 }},setFilterGE:function(){this.setUserFilter("GE")
3914 },setFilterLE:function(){this.setUserFilter("LE")
3915 },setFilterKW:function(a){if(a!=""&&a!=null){this.setFilter("LIKE",a,Rico.ColumnConst.USERFILTER)
3916 }else{this.setUnfiltered(false)
3917 }},setUserFilter:function(a){this.setFilter(a,this.userFilter,Rico.ColumnConst.USERFILTER)
3918 },setSystemFilter:function(a,b){this.setFilter(a,b,Rico.ColumnConst.SYSTEMFILTER)
3919 },setFilter:function(a,c,b,d){this.filterValues=typeof(c)=="object"?c:[c];
3922 if(b==Rico.ColumnConst.USERFILTER&&this.liveGrid.options.saveColumnInfo.filter){this.liveGrid.setCookie()
3923 }this.removeFilterFunc=d;
3924 if(this.options.filterHandler){this.options.filterHandler()
3925 }},isFiltered:function(){return this.filterType==Rico.ColumnConst.USERFILTER
3926 },filterChange:function(a){var b=Rico.eventElement(a);
3927 if(b.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
3928 }else{this.setFilter("EQ",b.value,Rico.ColumnConst.USERFILTER,function(){b.selectedIndex=0
3930 }},nFilterChange:function(b){var d=Rico.eventElement(b);
3931 if(d.value==this.liveGrid.options.FilterAllToken){this.setUnfiltered()
3932 }else{var c=d.value.substr(0,2);
3933 var a=d.value.substr(2);
3934 this.setFilter(c,a,Rico.ColumnConst.USERFILTER,function(){d.selectedIndex=0
3936 }},filterClear:function(a){this.filterField.value="";
3937 this.setUnfiltered()
3938 },filterKeypress:function(c){var a=Rico.eventElement(c);
3939 if(typeof this.lastKeyFilter!="string"){this.lastKeyFilter=""
3940 }if(this.lastKeyFilter==a.value){return
3942 Rico.log("filterKeypress: "+this.index+" "+b);
3943 this.lastKeyFilter=b;
3944 if(b==""||b=="*"){this.setUnfiltered()
3945 }else{this.setFilter("LIKE",b,Rico.ColumnConst.USERFILTER,function(){a.value=""
3947 }},mFilterSelectClick:function(a){Rico.eventStop(a);
3948 if(this.mFilter.style.display!="none"){this.mFilterFinish(a);
3949 if(Rico.isIE&&Rico.ieVersion<=6){this.filterField.focus()
3950 }else{this.filterField.blur()
3951 }}else{var b=Rico.cumulativeOffset(this.filterField);
3952 this.mFilter.style.top=(b.top+this.filterField.offsetHeight)+"px";
3953 this.mFilter.style.left=b.left+"px";
3954 this.mFilter.style.width=Math.min(this.filterField.offsetWidth,parseInt(this.colWidth,10))+"px";
3955 Rico.show(this.mFilter);
3956 this.mFilterFocus.focus()
3957 }},mFilterFinish:function(g){if(!this.mFilterChange){Rico.hide(this.mFilter);
3959 }if(this.mFilterInputs[0].checked){this.mFilterReset();
3960 Rico.hide(this.mFilter);
3961 this.setUnfiltered();
3966 d<this.mFilterInputs.length;
3967 d++){if(this.mFilterInputs[d].checked){c.push(this.mFilterInputs[d].value);
3968 a.push(this.mFilterLabels[d].innerHTML)
3969 }}if(c.length>0){var f=a.join(", ");
3970 this.filterField.options[0].text=f;
3971 this.filterField.title=f;
3972 Rico.hide(this.mFilter);
3973 this.mFilterChange=false;
3975 this.setFilter("EQ",c,Rico.ColumnConst.USERFILTER,function(){b.mFilterReset()
3977 }else{alert("Please select at least one value")
3978 }},mFilterReset:function(){var a=this.mFilterLabels[0].innerHTML;
3979 this.filterField.options[0].text=a;
3980 this.filterField.title=a
3981 },mFilterAllClick:function(c){var a=this.mFilterInputs[0].checked;
3983 b<this.mFilterInputs.length;
3984 b++){this.mFilterInputs[b].checked=a
3985 }this.mFilterChange=true
3986 },mFilterOtherClick:function(a){this.mFilterInputs[0].checked=false;
3987 this.mFilterChange=true
3988 },format_text:function(a){if(typeof a!="string"){return" "
3989 }else{return a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")
3990 }},format_number:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3991 }else{return Rico.formatNumber(a,this.format)
3992 }},format_datetime:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3993 }else{var b=Rico.setISO8601(a);
3995 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
3996 }},format_utcaslocaltime:function(a){if(typeof a=="undefined"||a==""||a==null){return" "
3997 }else{var c=new Date();
3998 var b=Rico.setISO8601(a,-c.getTimezoneOffset());
4000 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDateTime")+(this.format.suffix||"")
4001 }},format_date:function(a){if(typeof a=="undefined"||a==null||a==""){return" "
4002 }else{var b=Rico.setISO8601(a);
4004 }return(this.format.prefix||"")+Rico.formatDate(b,this.format.dateFmt||"translateDate")+(this.format.suffix||"")
4005 }},fixHeaders:function(d,e){if(this.sortable){var c=Rico.eventHandle(this,"toggleSort");
4006 switch(this.options.headingSort){case"link":var b=Rico.wrapChildren(this.hdrCellDiv,"ricoSort",undefined,"a");
4007 b.href="javascript:void(0)";
4008 Rico.eventBind(b,"click",c);
4010 case"hover":Rico.eventBind(this.hdrCellDiv,"click",c);
4012 }}this.imgFilter=document.createElement("span");
4013 this.imgFilter.style.display="none";
4014 this.imgFilter.className="rico-icon ricoLG_filterCol";
4015 this.imgSort=document.createElement("span");
4016 this.imgSort.style.display="none";
4017 this.imgSort.style.verticalAlign="top";
4018 if(e){this.hdrCellDiv.insertBefore(this.imgSort,this.hdrCellDiv.firstChild);
4019 this.hdrCellDiv.insertBefore(this.imgFilter,this.hdrCellDiv.firstChild)
4020 }else{this.hdrCellDiv.appendChild(this.imgFilter);
4021 this.hdrCellDiv.appendChild(this.imgSort)
4022 }if(!this.format.filterUI){Rico.eventBind(this.imgFilter,"click",Rico.eventHandle(this,"filterClick"),false)
4023 }},filterClick:function(a){if(this.filterType==Rico.ColumnConst.USERFILTER&&this.filterOp=="LIKE"){this.liveGrid.openKeyword(this.index)
4024 }},getValue:function(a){return this.buffer.getWindowCell(a,this.index)
4025 },getBufferStyle:function(a){return this.buffer.getWindowStyle(a,this.index)
4026 },setValue:function(b,a){this.buffer.setWindowValue(b,this.index,a)
4027 },_format:function(a){return a
4028 },_display:function(a,b){b.innerHTML=this._format(a)
4029 },_export:function(a){return this._format(a)
4030 },exportBuffer:function(a){return this._export(this.buffer.getValue(a,this.index))
4031 },displayValue:function(c){var a=this.getValue(c);
4032 if(a==null){this.clearCell(c);
4034 }var b=this.cell(c);
4035 this._display(a,b,c);
4036 if(this.buffer.options.acceptStyle){b.style.cssText=this.getBufferStyle(c)
4038 Rico.TableColumn={};
4039 Rico.TableColumn.checkboxKey=function(a){this.initialize(a)
4041 Rico.TableColumn.checkboxKey.prototype={initialize:function(a){this._checkboxes=[];
4045 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
4046 this._spans[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
4048 Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
4049 },_onclick:function(c){var b=Rico.eventElement(c);
4050 var d=parseInt(b.id.substr((b.id.lastIndexOf("_",b.id.length)+1)));
4051 var a=this.getValue(d);
4052 if(b.checked){this._addChecked(a)
4053 }else{this._remChecked(a)
4054 }},_clear:function(b,c){var a=this._checkboxes[c];
4056 a.style.display="none";
4057 this._spans[c].innerHTML=""
4058 },_display:function(a,c,d){var b=this._checkboxes[d];
4060 b.checked=this._KeyHash[a];
4061 if(this._showKey){this._spans[d].innerHTML=a
4062 }},_SelectedKeys:function(){return Rico.keys(this._KeyHash)
4063 },_addChecked:function(a){this._KeyHash[a]=1
4064 },_remChecked:function(a){delete this._KeyHash[a]
4066 Rico.TableColumn.checkbox=function(b,c,a,d){this.initialize(b,c,a,d)
4068 Rico.TableColumn.checkbox.prototype={initialize:function(b,c,a,d){this._checkedValue=b;
4069 this._uncheckedValue=c;
4070 this._defaultValue=a||false;
4071 this._readOnly=d||false;
4073 },_create:function(a,b){this._checkboxes[b]=Rico.createFormField(a,"input","checkbox",this.liveGrid.tableId+"_chkbox_"+this.index+"_"+b);
4075 if(this._readOnly){this._checkboxes[b].disabled=true
4076 }else{Rico.eventBind(this._checkboxes[b],"click",Rico.eventHandle(this,"_onclick"))
4077 }},_onclick:function(c){var a=Rico.eventElement(c);
4078 var d=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
4079 var b=a.checked?this._checkedValue:this._uncheckedValue;
4081 },_clear:function(b,c){var a=this._checkboxes[c];
4082 a.checked=this._defaultValue;
4083 a.style.display="none"
4084 },_display:function(a,c,d){var b=this._checkboxes[d];
4086 b.checked=(a==this._checkedValue)
4088 Rico.TableColumn.textbox=function(c,b,a){this.initialize(c,b,a)
4090 Rico.TableColumn.textbox.prototype={initialize:function(c,b,a){this._boxSize=c;
4092 this._readOnly=a||false;
4094 },_create:function(b,c){var a=Rico.createFormField(b,"input","text",this.liveGrid.tableId+"_txtbox_"+this.index+"_"+c);
4095 a.size=this._boxSize;
4096 a.maxLength=this._boxMaxLen;
4097 this._textboxes[c]=a;
4099 if(this._readOnly){a.disabled=true
4100 }else{Rico.eventBind(a,"change",Rico.eventHandle(this,"_onchange"))
4101 }},_onchange:function(b){var a=Event.element(b);
4102 var c=parseInt(a.id.substr((a.id.lastIndexOf("_",a.id.length)+1)));
4103 this.setValue(c,a.value)
4104 },_clear:function(b,c){var a=this._textboxes[c];
4106 a.style.display="none"
4107 },_display:function(a,c,d){var b=this._textboxes[d];
4111 Rico.TableColumn.bgColor=function(){};
4112 Rico.TableColumn.bgColor.prototype={_clear:function(a,b){a.style.backgroundColor=""
4113 },_display:function(a,b,c){b.style.backgroundColor=a
4115 Rico.TableColumn.link=function(a,c,b){this.initialize(a,c,b)
4117 Rico.TableColumn.link.prototype={initialize:function(a,c,b){this._href=a;
4121 },_create:function(c,d){var b=c.appendChild(document.createElement("a"));
4122 if(this._target){b.target=this._target
4124 b.innerHTML=Rico.isIE?" ":"";
4126 },_clear:function(a,b){this._anchors[b].style.display="none"
4127 },_display:function(b,d,f){var c=this.liveGrid.buffer;
4128 var a=this._href=="self"?b:this._href.replace(/\{\d+\}/g,function(g){var h=parseInt(g.substr(1),10);
4129 return encodeURIComponent(c.getWindowValue(f,h))
4131 var e=this._linktext||b;
4132 if(a&&e){this._anchors[f].href=a;
4133 this._anchors[f].innerHTML=e;
4134 this._anchors[f].style.display=Rico.isIE?"inline-block":""
4135 }else{this._clear(d,f)
4137 Rico.TableColumn.image=function(a,b){this.initialize(a,b)
4139 Rico.TableColumn.image.prototype={initialize:function(a,b){this._img=[];
4142 },_create:function(a,b){this._img[b]=Rico.createFormField(a,"img",null,this.liveGrid.tableId+"_img_"+this.index+"_"+b);
4144 },_clear:function(b,c){var a=this._img[c];
4145 a.style.display="none";
4147 },_display:function(b,c,d){var a=this._img[d];
4148 this._img[d].src=this._prefix+b+this._suffix;
4151 Rico.TableColumn.lookup=function(c,a,b){this.initialize(c,a,b)
4153 Rico.TableColumn.lookup.prototype={initialize:function(d,a,c){this._map=d;
4154 this._defaultCode=a||"";
4155 this._defaultDesc=c||" ";
4157 this._sortfunc=function(e){return b._sortvalue(e)
4160 this._descriptions=[]
4161 },_create:function(a,b){this._descriptions[b]=Rico.createFormField(a,"span",null,this.liveGrid.tableId+"_desc_"+this.index+"_"+b);
4162 this._codes[b]=Rico.createFormField(a,"input","hidden",this.liveGrid.tableId+"_code_"+this.index+"_"+b);
4164 },_clear:function(a,b){this._codes[b].value=this._defaultCode;
4165 this._descriptions[b].innerHTML=this._defaultDesc
4166 },_sortvalue:function(a){return this._getdesc(a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")
4167 },_getdesc:function(a){var b=this._map[a];
4168 return(typeof b=="string")?b:this._defaultDesc
4169 },_export:function(a){return this._getdesc(a)
4170 },_display:function(a,b,c){this._codes[c].value=a;
4171 this._descriptions[c].innerHTML=this._getdesc(a)
4173 Rico.TableColumn.MultiLine=function(){};
4174 Rico.TableColumn.MultiLine.prototype={_display:function(a,c,d){var b=document.createElement("div");
4175 b.innerHTML=this._format(a);
4176 b.style.height="100%";
4177 if(c.firstChild){c.replaceChild(b,c.firstChild)
4178 }else{c.appendChild(b)
4180 Rico.GridMenu=function(a){this.initialize(a)
4182 Rico.GridMenu.prototype={initialize:function(a){this.options={width:"18em",dataMenuHandler:null};
4183 Rico.extend(this.options,a||{});
4184 Rico.extend(this,new Rico.Menu(this.options));
4185 this.sortmenu=new Rico.Menu({width:"15em"});
4186 this.filtermenu=new Rico.Menu({width:"22em"});
4187 this.exportmenu=new Rico.Menu({width:"24em"});
4188 this.hideshowmenu=new Rico.Menu({width:"22em"});
4190 this.sortmenu.createDiv();
4191 this.filtermenu.createDiv();
4192 this.exportmenu.createDiv();
4193 this.hideshowmenu.createDiv()
4194 },buildGridMenu:function(a,i){this.clearMenu();
4195 var o=this.liveGrid;
4198 var n=o.options.maxPrint;
4201 if(this.options.dataMenuHandler){var l=this.options.dataMenuHandler(o,a,i,b);
4202 if(!l){return(this.itemCount>0)
4203 }}if(d.sortable&&m>0){this.sortmenu.clearMenu();
4204 this.addSubMenuItem(Rico.getPhraseById("gridmenuSortBy",d.displayName),this.sortmenu,false);
4205 this.sortmenu.addMenuItemId("gridmenuSortAsc",function(){d.sortAsc()
4207 this.sortmenu.addMenuItemId("gridmenuSortDesc",function(){d.sortDesc()
4209 }this.filtermenu.clearMenu();
4210 if(d.canFilter()){this.addSubMenuItem(Rico.getPhraseById("gridmenuFilterBy",d.displayName),this.filtermenu,false);
4211 if(!d.format.filterUI&&(!b||d.filterType==Rico.ColumnConst.USERFILTER)){d.userFilter=d.getValue(a);
4212 if(d.filterType==Rico.ColumnConst.USERFILTER){this.filtermenu.addMenuItemId("gridmenuRemoveFilter",function(){d.setUnfiltered(false)
4214 if(d.filterOp=="LIKE"){this.filtermenu.addMenuItemId("gridmenuChgKeyword",function(){o.openKeyword(i)
4216 }if(d.filterOp=="NE"&&!b){this.filtermenu.addMenuItemId("gridmenuExcludeAlso",function(){d.addFilterNE()
4218 }}else{if(!b){this.filtermenu.addMenuItemId("gridmenuInclude",function(){d.setFilterEQ()
4220 this.filtermenu.addMenuItemId("gridmenuGreaterThan",function(){d.setFilterGE()
4221 },d.userFilter!="");
4222 this.filtermenu.addMenuItemId("gridmenuLessThan",function(){d.setFilterLE()
4223 },d.userFilter!="");
4224 if(d.isText){this.filtermenu.addMenuItemId("gridmenuContains",function(){o.openKeyword(i)
4226 }this.filtermenu.addMenuItemId("gridmenuExclude",function(){d.setFilterNE()
4228 }}}if(o.filterCount()>0){this.filtermenu.addMenuItemId("gridmenuRemoveAll",function(){o.clearFilters()
4230 }if(f.options.canRefresh){this.filtermenu.addMenuItemId("gridmenuRefresh",function(){o.filterHandler()
4232 }}this.exportmenu.clearMenu();
4233 if(n>0){this.addSubMenuItem(Rico.getPhraseById("gridmenuExport"),this.exportmenu,false);
4234 if(f.printVisibleSQL&&typeof(f.dataSource)=="string"){this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisibleSQL("html")
4236 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAllSQL("html")
4238 this.exportmenu.addMenuBreak();
4239 this.exportmenu.addMenuItemId("gridmenuExportVis2SS",function(){f.printVisibleSQL("xl")
4241 this.exportmenu.addMenuItemId("gridmenuExportAll2SS",function(){f.printAllSQL("xl")
4243 }else{this.exportmenu.addMenuItemId("gridmenuExportVis2Web",function(){f.printVisible()
4245 this.exportmenu.addMenuItemId("gridmenuExportAll2Web",function(){f.printAll()
4247 }}var k=o.listInvisible();
4250 j++){if(k[j].canHideShow()){e++
4251 }}if(e>0||d.canHideShow()){this.hideshowmenu.clearMenu();
4252 this.addSubMenuItem(Rico.getPhraseById("gridmenuHideShow"),this.hideshowmenu,false);
4253 this.hideshowmenu.addMenuItemId("gridmenuChooseCols",function(){o.chooseColumns()
4255 var h=o.columns.length-k.length;
4256 var g=(h>1&&d.visible&&d.canHideShow());
4257 this.hideshowmenu.addMenuItem(Rico.getPhraseById("gridmenuHide",d.displayName),function(){d.hideColumn()
4259 if(k.length>1){this.hideshowmenu.addMenuItemId("gridmenuShowAll",function(){o.showAll()
4263 if(typeof Rico=="undefined"){throw ("LiveGridAjax requires the Rico JavaScript framework")
4264 }if(!Rico.Buffer){Rico.Buffer={}
4265 }Rico.Buffer.AjaxLoadOnce=function(c,b,a){this.initialize(c,b,a)
4267 Rico.Buffer.AjaxLoadOnce.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.Base());
4268 Rico.extend(this,Rico.Buffer.AjaxXMLMethods);
4270 this.options.bufferTimeout=20000;
4271 this.options.requestParameters=[];
4272 this.options.waitMsg=Rico.getPhraseById("waitForData");
4273 this.options.canFilter=true;
4274 this.options.fmt="xml";
4275 Rico.extend(this.options,b||{});
4276 this.ajaxOptions={parameters:null,method:"get"};
4277 Rico.extend(this.ajaxOptions,a||{});
4278 this.requestCount=0;
4279 this.processingRequest=false;
4280 this.pendingRequest=-2;
4281 this.fetchData=true;
4284 Rico.Buffer.AjaxXMLMethods={fetch:function(b){if(this.fetchData){this.foundRowCount=true;
4285 this.fetchData=false;
4286 this.processingRequest=true;
4287 this.liveGrid.showMsg(this.options.waitMsg);
4288 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
4289 this.ajaxOptions.parameters=this.formQueryHashXML(0,-1);
4290 Rico.log("sending request");
4292 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(c){a.ajaxUpdate(b,c)
4294 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
4295 }else{this.ajaxOptions.onComplete=function(d,f,c,e){a.jsUpdate(b,d,f,c,e)
4297 this.dataSource(this.ajaxOptions)
4298 }}else{if(b<0){this.applyFilters();
4299 this.setTotalRows(this.size);
4301 }this.liveGrid.refreshContents(b)
4302 }},handleTimedOut:function(){Rico.log("Request Timed Out");
4303 this.liveGrid.showMsg(Rico.getPhraseById("requestTimedOut"))
4304 },formQueryHashXML:function(e,c){var d={id:this.liveGrid.tableId,page_size:(typeof c=="number")?c:this.totalRows,offset:e.toString()};
4305 d[this.liveGrid.actionId]="query";
4306 if(this.options.requestParameters){for(var f=0;
4307 f<this.options.requestParameters.length;
4308 f++){var g=this.options.requestParameters[f];
4309 if(g.name!=undefined&&g.value!=undefined){d[g.name]=g.value
4310 }else{var b=g.indexOf("=");
4311 var h=g.substring(0,b);
4312 var a=g.substring(b+1);
4315 },clearTimer:function(){if(typeof this.timeoutHandler!="number"){return
4316 }window.clearTimeout(this.timeoutHandler);
4317 delete this.timeoutHandler
4318 },jsUpdate:function(a,c,e,b,d){this.clearTimer();
4319 this.processingRequest=false;
4320 Rico.log("jsUpdate: "+arguments.length);
4321 if(d){Rico.log("jsUpdate: received error="+d);
4322 this.liveGrid.showMsg(Rico.getPhraseById("requestError",d));
4324 }this.rcvdRows=c.length;
4325 if(typeof b=="number"){this.rowcntContent=b.toString();
4326 this.rcvdRowCount=true;
4327 this.foundRowCount=true;
4328 Rico.log("jsUpdate: found RowCount="+this.rowcntContent)
4329 }this.updateBuffer(a,c,e);
4330 if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
4331 }this.updateGrid(a);
4332 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
4333 }if(this.pendingRequest>=-1){var f=this.pendingRequest;
4334 Rico.log("jsUpdate: found pending request for offset="+f);
4335 this.pendingRequest=-2;
4337 }},ajaxUpdate:function(a,c){this.clearTimer();
4338 this.processingRequest=false;
4339 if(c.status!=200){Rico.log("ajaxUpdate: received http error="+c.status);
4340 this.liveGrid.showMsg(Rico.getPhraseById("httpError",c.status));
4342 }Rico.log("ajaxUpdate: startPos="+a);
4343 this._responseHandler=this["processResponse"+this.options.fmt.toUpperCase()];
4344 if(!this._responseHandler(a,c)){return
4345 }if(this.options.onAjaxUpdate){this.options.onAjaxUpdate()
4346 }this.updateGrid(a);
4347 if(this.options.TimeOut&&this.timerMsg){this.restartSessionTimer()
4348 }if(this.pendingRequest>=-1){var b=this.pendingRequest;
4349 Rico.log("ajaxUpdate: found pending request for offset="+b);
4350 this.pendingRequest=-2;
4352 }},processResponseXML:function(k,f){var o=f.responseXML;
4353 if(f.responseText.substring(0,4)=="<!--"){var m=f.responseText.indexOf("-->");
4354 if(m==-1){this.liveGrid.showMsg("Web server error - client side debugging may be enabled");
4356 }o=Rico.createXmlDocument();
4357 o.loadXML(f.responseText.substring(m+3))
4358 }if(!o){alert("Data provider returned an invalid XML response");
4359 Rico.log("Data provider returned an invalid XML response");
4361 }var d=o.getElementsByTagName("ajax-response");
4362 if(d==null||d.length!=1){alert("Received invalid response from server");
4364 }Rico.log("Processing ajax-response");
4366 this.rcvdRowCount=false;
4368 var a=b.getElementsByTagName("debug");
4371 g++){Rico.log("ajaxUpdate: debug msg "+g+": "+Rico.getContentAsString(a[g],this.options.isEncoded))
4372 }var l=b.getElementsByTagName("error");
4373 if(l.length>0){var c=Rico.getContentAsString(l[0],this.options.isEncoded);
4374 alert("Data provider returned an error:\n"+c);
4375 Rico.log("Data provider returned an error:\n"+c);
4377 }var j=b.getElementsByTagName("rows")[0];
4378 if(!j){Rico.log("ajaxUpdate: invalid response");
4379 this.liveGrid.showMsg(Rico.getPhraseById("invalidResponse"));
4381 }var n=b.getElementsByTagName("rowcount");
4382 if(n&&n.length==1){this.rowcntContent=Rico.getContentAsString(n[0],this.options.isEncoded);
4383 this.rcvdRowCount=true;
4384 this.foundRowCount=true;
4385 Rico.log("ajaxUpdate: found RowCount="+this.rowcntContent)
4386 }this.updateUI=j.getAttribute("update_ui")=="true";
4387 this.rcvdOffset=j.getAttribute("offset");
4388 Rico.log("ajaxUpdate: rcvdOffset="+this.rcvdOffset);
4389 var h=this.dom2jstable(j);
4390 var e=(this.options.acceptStyle)?this.dom2jstableStyle(j):false;
4391 this.rcvdRows=h.length;
4392 this.updateBuffer(k,h,e);
4394 },dom2jstableStyle:function(f,h){Rico.log("dom2jstableStyle start");
4396 var a=f.getElementsByTagName("tr");
4400 var c=a[d].getElementsByTagName("td");
4403 b++){g[b]=c[b].getAttribute("style")||""
4405 }Rico.log("dom2jstableStyle end");
4407 },processResponseJSON:function(a,d){var c=Rico.getJSON(d);
4408 if(!c||c==null){alert("Data provider returned an invalid JSON response");
4409 Rico.log("Data provider returned an invalid JSON response");
4411 }if(c.debug){for(var b=0;
4413 b++){Rico.writeDebugMsg("debug msg "+b+": "+c.debug[b])
4414 }}if(c.error){alert("Data provider returned an error:\n"+c.error);
4415 Rico.writeDebugMsg("Data provider returned an error:\n"+c.error);
4417 }if(c.rowcount){this.rowcntContent=c.rowcount;
4418 this.rcvdRowCount=true;
4419 this.foundRowCount=true;
4420 Rico.writeDebugMsg("loadRows, found RowCount="+c.rowcount)
4421 }this.rcvdRows=c.rows.length;
4422 this.updateBuffer(a,c.rows,c.styles);
4424 },updateBuffer:function(c,a,b){this.baseRows=a;
4426 Rico.log("updateBuffer: # of rows="+this.rcvdRows);
4427 this.rcvdRowCount=true;
4428 this.rowcntContent=this.rcvdRows;
4429 if(typeof this.delayedSortCol=="number"){this.sortBuffer(this.delayedSortCol)
4430 }this.applyFilters();
4432 },updateGrid:function(f){Rico.log("updateGrid, size="+this.size+" rcv cnt type="+typeof(this.rowcntContent));
4434 if(this.rcvdRowCount==true){Rico.log("found row cnt: "+this.rowcntContent);
4435 var d=parseInt(this.rowcntContent,10);
4436 var b=this.totalRows;
4437 if(!isNaN(d)&&d!=b){this.setTotalRows(d);
4438 e=Math.min(this.liveGrid.topOfLastPage(),f);
4439 Rico.log("updateGrid: new rowcnt="+d+" newpos="+e);
4440 this.liveGrid.scrollToRow(e);
4441 if(this.isInRange(e)){this.liveGrid.refreshContents(e)
4444 }}else{var a=f+this.rcvdRows;
4445 if(a>this.totalRows){var c=a;
4446 Rico.log("extending totrows to "+c);
4447 this.setTotalRows(c)
4448 }}e=this.liveGrid.pixeltorow(this.liveGrid.scrollDiv.scrollTop);
4449 Rico.log("updateGrid: newpos="+e);
4450 this.liveGrid.refreshContents(e)
4452 Rico.Buffer.AjaxSQL=function(c,b,a){this.initialize(c,b,a)
4454 Rico.Buffer.AjaxSQL.prototype={initialize:function(c,b,a){Rico.extend(this,new Rico.Buffer.AjaxLoadOnce());
4455 Rico.extend(this,Rico.Buffer.AjaxSQLMethods);
4457 this.options.canFilter=true;
4458 this.options.largeBufferSize=7;
4459 this.options.nearLimitFactor=1;
4460 this.options.canRefresh=true;
4461 Rico.extend(this.options,b||{});
4462 Rico.extend(this.ajaxOptions,a||{})
4464 Rico.Buffer.AjaxSQLMethods={registerGrid:function(a){this.liveGrid=a;
4465 this.sessionExpired=false;
4466 this.timerMsg=document.getElementById(a.tableId+"_timer");
4467 if(this.options.TimeOut&&this.timerMsg){if(!this.timerMsg.title){this.timerMsg.title=Rico.getPhraseById("sessionExpireMinutes")
4468 }this.restartSessionTimer()
4469 }},setBufferSize:function(a){this.maxFetchSize=Math.max(50,parseInt(this.options.largeBufferSize*a,10));
4470 this.nearLimit=parseInt(this.options.nearLimitFactor*a,10);
4471 this.maxBufferSize=this.maxFetchSize*3
4472 },restartSessionTimer:function(){if(this.sessionExpired==true){return
4473 }this.sessionEndTime=(new Date()).getTime()+this.options.TimeOut*60000;
4474 if(this.sessionTimer){clearTimeout(this.sessionTimer)
4475 }this.updateSessionTimer()
4476 },updateSessionTimer:function(){var b=(new Date()).getTime();
4477 if(b>this.sessionEndTime){this.displaySessionTimer(Rico.getPhraseById("sessionExpired"));
4478 this.timerMsg.style.backgroundColor="red";
4479 this.sessionExpired=true
4480 }else{var a=Math.ceil((this.sessionEndTime-b)/60000);
4481 this.displaySessionTimer(a);
4482 this.sessionTimer=Rico.runLater(10000,this,"updateSessionTimer")
4483 }},displaySessionTimer:function(a){this.timerMsg.innerHTML=" "+a+" "
4484 },refresh:function(b){var a=this.liveGrid.lastRowPos;
4486 if(b){this.setTotalRows(0);
4487 this.foundRowCount=false
4488 }this.liveGrid.clearBookmark();
4489 this.liveGrid.clearRows();
4491 },fetch:function(e){Rico.log("AjaxSQL fetch: offset="+e+", lastOffset="+this.lastOffset);
4492 if(this.processingRequest){Rico.log("AjaxSQL fetch: queue request");
4493 this.pendingRequest=e;
4495 }if((typeof e=="undefined")||(e<0)){this.clear();
4496 this.setTotalRows(0);
4497 this.foundRowCount=false;
4499 }var d=this.lastOffset;
4501 if(this.isInRange(e)){Rico.log("AjaxSQL fetch: in buffer");
4502 this.liveGrid.refreshContents(e);
4503 if(e>d){if(e+this.liveGrid.pageSize<this.endPos()-this.nearLimit){return
4504 }if(this.endPos()==this.totalRows&&this.foundRowCount){return
4505 }}else{if(e<d){if(e>this.startPos+this.nearLimit){return
4506 }if(this.startPos==0){return
4508 }}}if(e>=this.totalRows&&this.foundRowCount){return
4509 }this.processingRequest=true;
4510 Rico.log("AjaxSQL fetch: processing offset="+e);
4511 var c=this.getFetchOffset(e);
4512 var a=this.getFetchSize(c);
4514 this.liveGrid.showMsg(this.options.waitMsg);
4515 this.timeoutHandler=Rico.runLater(this.options.bufferTimeout,this,"handleTimedOut");
4516 this.ajaxOptions.parameters=this.formQueryHashSQL(c,a,this.options.fmt);
4517 this.requestCount++;
4518 Rico.log("sending req #"+this.requestCount);
4520 if(typeof this.dataSource=="string"){this.ajaxOptions.onComplete=function(g){b.ajaxUpdate(c,g)
4522 new Rico.ajaxRequest(this.dataSource,this.ajaxOptions)
4523 }else{this.ajaxOptions.onComplete=function(h,j,g,i){b.jsUpdate(c,h,j,g,i)
4525 this.dataSource(this.ajaxOptions)
4526 }},formQueryHashSQL:function(g,h,d){var k=this.formQueryHashXML(g,h);
4527 if(!this.foundRowCount){k.get_total="true"
4529 }Rico.extend(k,this.sortParm);
4531 b<this.liveGrid.columns.length;
4532 b++){var j=this.liveGrid.columns[b];
4533 if(j.filterType==Rico.ColumnConst.UNFILTERED){continue
4534 }var a=typeof(j.format.filterCol)=="number"?j.format.filterCol:j.index;
4535 k["f["+a+"][op]"]=j.filterOp;
4536 k["f["+a+"][len]"]=j.filterValues.length;
4538 e<j.filterValues.length;
4539 e++){var f=j.filterValues[e];
4540 if(j.filterOp=="LIKE"&&f.indexOf("*")==-1){f="*"+f+"*"
4541 }k["f["+a+"]["+e+"]"]=f
4543 },getFetchSize:function(a){var b=0;
4544 if(a>=this.startPos){var c=this.maxFetchSize+a;
4546 if(a==0&&b<this.maxFetchSize){b=this.maxFetchSize
4547 }Rico.log("getFetchSize/append, adjustedSize="+b+" adjustedOffset="+a+" endFetchOffset="+c)
4548 }else{b=Math.min(this.startPos-a,this.maxFetchSize)
4550 },getFetchOffset:function(b){var a=b;
4551 if(b>this.startPos){a=Math.max(b,this.endPos())
4552 }else{if(b+this.maxFetchSize>=this.startPos){a=Math.max(this.startPos-this.maxFetchSize,0)
4554 },updateBuffer:function(d,a,b){Rico.log("updateBuffer: start="+d+", # of rows="+this.rcvdRows);
4555 if(this.rows.length==0){this.rows=a;
4558 }else{if(d>this.startPos){if(this.startPos+this.rows.length<d){this.rows=a;
4561 }else{this.rows=this.rows.concat(a.slice(0,a.length));
4562 if(this.attr&&b){this.attr=this.attr.concat(b.slice(0,b.length))
4563 }if(this.rows.length>this.maxBufferSize){var c=this.rows.length;
4564 this.rows=this.rows.slice(this.rows.length-this.maxBufferSize,this.rows.length);
4565 if(this.attr){this.attr=this.attr.slice(this.attr.length-this.maxBufferSize,this.attr.length)
4566 }this.startPos=this.startPos+(c-this.rows.length)
4567 }}}else{if(d+a.length<this.startPos){this.rows=a;
4569 }else{this.rows=a.slice(0,this.startPos).concat(this.rows);
4570 if(b){this.attr=b.slice(0,this.startPos).concat(this.attr)
4571 }if(this.maxBufferSize&&this.rows.length>this.maxBufferSize){this.rows=this.rows.slice(0,this.maxBufferSize);
4572 if(this.attr){this.attr=this.attr.slice(0,this.maxBufferSize)
4574 }}this.size=this.rows.length
4575 },sortBuffer:function(b){this.sortParm={};
4576 var a=this.liveGrid.columns[b];
4577 if(this.options.sortParmFmt){this.sortParm.sort_col=a[this.options.sortParmFmt];
4578 this.sortParm.sort_dir=a.getSortDirection()
4579 }else{this.sortParm["s"+b]=a.getSortDirection()
4581 },printAllSQL:function(a){var c=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint,a);
4582 c.hidden=this.liveGrid.listInvisible("index").join(",");
4583 var b=this.dataSource+"?"+Rico.toQueryString(c);
4584 window.open(b,"",this.liveGrid.options.exportWindow)
4585 },printVisibleSQL:function(a){var c=this.formQueryHashSQL(this.liveGrid.contentStartPos-1,this.liveGrid.pageSize,a);
4586 c.hidden=this.liveGrid.listInvisible("index").join(",");
4587 var b=this.dataSource+"?"+Rico.toQueryString(c);
4588 window.open(b,"",this.liveGrid.options.exportWindow)
4589 },_printAll:function(){this.liveGrid.exportStart();
4590 this.ajaxOptions.parameters=this.formQueryHashSQL(0,this.liveGrid.options.maxPrint);
4592 this.ajaxOptions.onComplete=function(){a._jsExport()
4594 this.dataSource(this.ajaxOptions)
4595 },_jsExport:function(b,d,a,c){Rico.log("_jsExport: "+arguments.length);
4596 if(c){Rico.log("_jsExport: received error="+c);
4597 this.liveGrid.showMsg(Rico.getPhraseById("requestError",c));
4599 }this.exportBuffer(b,0);
4600 this.liveGrid.exportFinish()
4602 if(typeof Rico=="undefined"){throw ("LiveGridForms requires the Rico JavaScript framework")
4603 }Rico.TableEdit=function(a){this.initialize(a)
4605 Rico.TableEdit.prototype={initialize:function(b){Rico.log("Rico.TableEdit initialize: "+b.tableId);
4607 this.options={maxDisplayLen:20,panelHeight:200,panelWidth:500,compact:false,RecordName:Rico.getPhraseById("record"),updateURL:window.location.href,showSaveMsg:"errors"};
4608 Rico.extend(this.options,b.options);
4611 this.menu.options.dataMenuHandler=function(d,f,g,e){return a.editMenu(d,f,g,e)
4613 this.menu.ignoreClicks();
4614 this.editText=Rico.getPhraseById("editRecord",this.options.RecordName);
4615 this.cloneText=Rico.getPhraseById("cloneRecord",this.options.RecordName);
4616 this.delText=Rico.getPhraseById("deleteRecord",this.options.RecordName);
4617 this.addText=Rico.getPhraseById("addRecord",this.options.RecordName);
4618 this.buttonHover=new Rico.HoverSet();
4619 this.dateRegExp=/^\s*(\w+)(\W)(\w+)(\W)(\w+)/i;
4620 this.createKeyArray();
4621 if(typeof(this.options.ConfirmDeleteCol)!="number"){this.options.ConfirmDeleteCol=this.keys.length>0?-2:-1
4622 }this.createEditDiv();
4623 this.saveMsg=Rico.$(b.tableId+"_savemsg");
4624 Rico.eventBind(document,"click",Rico.eventHandle(this,"clearSaveMsg"));
4625 this.extraMenuItems=[];
4626 this.responseHandler=function(c){a.processResponse(c)
4628 Rico.log("Rico.TableEdit.initialize complete")
4629 },createKeyArray:function(){this.keys=[];
4631 a<this.grid.columns.length;
4632 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.isKey){this.keys.push({colidx:a})
4633 }}},createEditDiv:function(){this.requestCount=1;
4634 this.formPopup=this.createWindow();
4635 Rico.addClass(this.formPopup.content.parentNode,"ricoLG_editDiv");
4636 if(this.options.canEdit||this.options.canAdd){this.startForm();
4637 this.createForm(this.form)
4638 }else{var a=this.createButton(Rico.getPhraseById("close"));
4639 Rico.eventBind(a,"click",Rico.eventHandle(this,"cancelEdit"),false);
4640 this.createForm(this.formPopup.contentDiv)
4641 }this.editDivCreated=true;
4642 this.responseDialog=this.grid.createDiv("editResponse",document.body);
4643 this.responseDialog.style.display="none";
4644 var b=document.createElement("button");
4645 b.appendChild(document.createTextNode(Rico.getPhraseById("ok")));
4646 Rico.eventBind(b,"click",Rico.eventHandle(this,"ackResponse"));
4647 this.responseDialog.appendChild(b);
4648 this.responseDiv=this.grid.createDiv("editResponseText",this.responseDialog);
4649 if(this.panelGroup){Rico.log("createEditDiv complete, requestCount="+this.requestCount);
4650 Rico.runLater(50,this,"initPanelGroup")
4651 }},createWindow:function(){var a=this;
4652 return new Rico.Window("",{closeFunc:function(){a.makeFormInvisible()
4653 },overflow:this.options.ColGroups?"hidden":"auto"})
4654 },initPanelGroup:function(){this.requestCount--;
4655 Rico.log("initPanelGroup: "+this.requestCount);
4656 if(this.requestCount>0){return
4657 }var a=parseInt(this.options.panelWidth,10);
4658 if(this.form){if(Rico.isWebKit){this.formPopup.container.style.display="block"
4659 }this.options.bgColor=Rico.Color.createColorFromBackground(this.form).toString()
4660 }this.formPopup.container.style.display="none";
4661 this.formPanels=new Rico.TabbedPanel(this.panelGroup,this.options)
4662 },notEmpty:function(a){return typeof(a)!="undefined"
4663 },startForm:function(){this.form=document.createElement("form");
4664 this.form.onsubmit=function(){return false
4666 this.form.autocomplete="off";
4667 this.formPopup.contentDiv.appendChild(this.form);
4668 var e=document.createElement("div");
4669 e.className="ButtonBar";
4670 var d=e.appendChild(this.createButton(Rico.getPhraseById("saveRecord",this.options.RecordName)));
4671 Rico.eventBind(d,"click",Rico.eventHandle(this,"TESubmit"),false);
4672 d=e.appendChild(this.createButton(Rico.getPhraseById("cancel")));
4673 Rico.eventBind(d,"click",Rico.eventHandle(this,"cancelEdit"),false);
4674 this.form.appendChild(e);
4675 this.hiddenFields=document.createElement("div");
4676 this.hiddenFields.style.display="none";
4677 this.action=this.appendHiddenField(this.grid.actionId,"");
4680 c<this.grid.columns.length;
4681 c++){a=this.grid.columns[c].format;
4682 if(a&&a.FormView&&a.FormView=="hidden"){this.appendHiddenField(a.FieldName,a.ColData)
4685 b++){this.keys[b].keyField=this.appendHiddenField("_k"+this.keys[b].colidx,"")
4686 }this.form.appendChild(this.hiddenFields)
4687 },createButton:function(b){var a=document.createElement("a");
4688 a.href="javascript:void(0)";
4690 a.className="RicoButton";
4691 if(Rico.theme.button){Rico.addClass(a,Rico.theme.button)
4692 }this.buttonHover.add(a);
4694 },createPanel:function(c){var e=false;
4696 b<this.grid.columns.length;
4697 b++){var a=this.grid.columns[b].format;
4699 }if(!a.EntryType){continue
4700 }if(a.EntryType=="H"){continue
4701 }if(a.FormView&&a.FormView=="hidden"){continue
4702 }var d=a.ColGroupIdx||0;
4705 }}if(!e){return null
4706 }this.panelHdr[c]=document.createElement("li");
4707 this.panelHdr[c].innerHTML=this.options.ColGroups[c];
4708 this.panelHdrs.appendChild(this.panelHdr[c]);
4709 this.panelContent[c]=document.createElement("div");
4710 this.panelContents.appendChild(this.panelContent[c]);
4711 this.panelActualIdx[c]=this.panelCnt++;
4712 return this.createFormTable(this.panelContent[c],"tabContent")
4713 },createForm:function(e){var c,f,a,d,b=[];
4716 this.panelContent=[];
4717 if(this.options.ColGroups){this.panelGroup=document.createElement("div");
4718 this.panelGroup.className="tabPanelGroup";
4719 this.panelHdrs=document.createElement("ul");
4720 this.panelGroup.appendChild(this.panelHdrs);
4721 this.panelContents=document.createElement("div");
4722 this.panelContents.className="tabContentContainer";
4723 this.panelGroup.appendChild(this.panelContents);
4724 this.panelActualIdx=[];
4725 e.appendChild(this.panelGroup);
4726 if(this.grid.direction=="rtl"){for(c=this.options.ColGroups.length-1;
4728 c--){b[c]=this.createPanel(c)
4730 c<this.options.ColGroups.length;
4731 c++){b[c]=this.createPanel(c)
4732 }}e.appendChild(this.panelGroup)
4733 }else{f=document.createElement("div");
4734 f.className="noTabContent";
4735 b[0]=this.createFormTable(f);
4738 c<this.grid.columns.length;
4739 c++){a=this.grid.columns[c].format;
4741 }d=a.ColGroupIdx||0;
4742 if(b[d]){this.appendFormField(this.grid.columns[c],b[d])
4743 }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))$/;
4745 case"float-unsigned":a.regexp=/^\d+(\.\d+)?$/;
4747 case"float-signed":a.regexp=/^[-+]?\d+(\.\d+)?$/;
4749 case"int-unsigned":a.regexp=/^\d+$/;
4751 case"int-signed":a.regexp=/^[-+]?\d+$/;
4753 default:a.regexp=new RegExp(a.pattern);
4755 }}}},createFormTable:function(b){var a=document.createElement("table");
4759 },appendHiddenField:function(a,b){var c=Rico.createFormField(this.hiddenFields,"input","hidden",a,a);
4762 },appendFormField:function(c,i){var b=c.format;
4763 if(!b.EntryType){return
4764 }if(b.EntryType=="H"){return
4765 }if(b.FormView){return
4766 }Rico.log("appendFormField: "+c.displayName+" - "+b.EntryType);
4767 var j=b.noFormBreak&&i.rows.length>0?i.rows[i.rows.length-1]:i.insertRow(-1);
4768 var h=j.insertCell(-1);
4770 if(h.noWrap){h.noWrap=true
4771 }var f=j.insertCell(-1);
4772 if(f.noWrap){f.noWrap=true
4773 }h.id="lbl_"+b.FieldName;
4774 var e,a=b.FieldName;
4775 switch(b.EntryType){case"TA":case"tinyMCE":e=Rico.createFormField(f,"textarea",null,a);
4776 e.cols=b.TxtAreaCols;
4777 e.rows=b.TxtAreaRows;
4778 e.innerHTML=b.ColData;
4779 h.style.verticalAlign="top";
4781 case"R":case"RL":e=Rico.createFormField(f,"div",null,a);
4782 if(b.DescriptionField){e.RicoUpdate=b.DescriptionField
4783 }if(b.MultiSelect){Rico.addClass(e,"MultiSelect")
4784 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4785 }this.selectValuesRequest(e,c);
4787 case"N":e=Rico.createFormField(f,"select",null,a);
4788 if(b.isNullable){this.addSelectNone(e)
4789 }Rico.eventBind(e,"change",Rico.eventHandle(this,"checkSelectNew"));
4790 this.selectValuesRequest(e,c);
4791 e=document.createElement("span");
4792 e.className="ricoEditLabel";
4793 e.id="labelnew__"+b.FieldName;
4794 e.innerHTML=" "+Rico.getPhraseById("formNewValue").replace(" "," ");
4796 a="textnew__"+b.FieldName;
4797 e=Rico.createFormField(f,"input","text",a,a);
4799 case"S":case"SL":if(b.ReadOnly){e=Rico.createFormField(f,"input","text",a,a);
4801 }else{e=Rico.createFormField(f,"select",null,a);
4802 if(b.MultiSelect){e.multiple=true
4803 }if(b.SelectRows){e.size=parseInt(b.SelectRows,10)
4804 }if(b.isNullable&&!b.MultiSelect){this.addSelectNone(e)
4805 }if(b.DescriptionField){e.RicoUpdate=b.DescriptionField;
4806 Rico.eventBind(e,"change",Rico.eventHandle(this,"selectClick"),false)
4807 }this.selectValuesRequest(e,c)
4809 case"D":if(!b.isNullable){b.required=true
4810 }if(!b.dateFmt){b.dateFmt=Rico.dateFmt
4811 }if(!b.Help){b.Help=b.dateFmt
4812 }if(typeof b.min=="string"){b.min=Rico.setISO8601(b.min)||new Date(b.min)
4813 }if(typeof b.max=="string"){b.max=Rico.setISO8601(b.max)||new Date(b.max)
4814 }b.Length=Math.max(b.dateFmt.length,10);
4815 if(Rico.inputtypes.date){e=Rico.createFormField(f,"input","date",a,a);
4816 e.required=b.required;
4817 if(b.min){e.min=Rico.toISO8601String(b.min,3)
4818 }if(b.max){e.max=Rico.toISO8601String(b.max,3)
4819 }e.required=b.required;
4821 }else{e=Rico.createFormField(f,"input","text",a,a)
4822 }this.initField(e,b);
4824 case"I":if(!b.isNullable){b.required=true
4825 }if(!b.pattern){b.pattern="int-signed"
4826 }if(Rico.inputtypes.number){e=Rico.createFormField(f,"input","number",a,a);
4827 e.required=b.required;
4831 }else{e=Rico.createFormField(f,"input","text",a,a)
4832 }if(typeof b.min=="string"){b.min=parseInt(b.min,10)
4833 }if(typeof b.max=="string"){b.max=parseInt(b.max,10)
4834 }this.initField(e,b);
4836 case"F":if(!b.isNullable){b.required=true
4837 }if(!b.pattern){b.pattern="float-signed"
4838 }e=Rico.createFormField(f,"input","text",a,a);
4839 this.initField(e,b);
4840 if(typeof b.min=="string"){b.min=parseFloat(b.min)
4841 }if(typeof b.max=="string"){b.max=parseFloat(b.max)
4843 default:e=Rico.createFormField(f,"input","text",a,a);
4844 if(!b.isNullable&&b.EntryType!="T"){b.required=true
4845 }this.initField(e,b);
4847 }if(e&&b.SelectCtl){Rico.EditControls.applyTo(c,e,b.EntryType=="D")
4849 h.className="ricoEditLabel";
4850 if(b.Help){h.title=b.Help;
4851 g=" <span class='rico-icon rico-info'></span>"
4852 }var d=b.EntryType.length>1&&b.EntryType.charAt(1)=="L"?c.next.displayName:c.displayName;
4854 },addSelectNone:function(a){this.addSelectOption(a,this.options.TableSelectNone,Rico.getPhraseById("selectNone"))
4855 },initField:function(b,a){if(a.Length){b.maxLength=a.Length;
4856 b.size=Math.min(a.Length,this.options.maxDisplayLen)
4858 },selectClick:function(c){var b=Rico.eventElement(c);
4859 if(b.readOnly){Rico.eventStop(c);
4861 }if(b.RicoUpdate){var a=b.options[b.selectedIndex];
4862 Rico.$(b.RicoUpdate).value=a.innerHTML
4863 }},radioClick:function(c){var b=Rico.eventElement(c);
4864 if(b.readOnly){Rico.eventStop(c);
4866 }var a=Rico.getParentByTagName(b,"div");
4867 if(a.RicoUpdate){Rico.$(a.RicoUpdate).value=b.nextSibling.innerHTML
4868 }},checkSelectNew:function(a){this.updateSelectNew(Rico.eventElement(a))
4869 },updateSelectNew:function(b){var a=(b.value==this.options.TableSelectNew)?"":"hidden";
4870 Rico.$("labelnew__"+b.id).style.visibility=a;
4871 Rico.$("textnew__"+b.id).style.visibility=a
4872 },selectValuesRequest:function(g,f){var a=f.format;
4873 if(a.SelectValues){var b=a.SelectValues.split(",");
4876 e++){this.addSelectOption(g,b[e],b[e],e)
4877 }}else{this.requestCount++;
4879 Rico.extend(d,this.grid.buffer.ajaxOptions);
4880 d.parameters=this.grid.buffer.formQueryHashXML(0,-1);
4881 d.parameters.edit=f.index;
4882 d.onComplete=function(h){c.selectValuesUpdate(g,h)
4884 new Rico.ajaxRequest(this.grid.buffer.dataSource,d);
4885 Rico.log("selectValuesRequest: "+a.FieldName)
4886 }},selectValuesUpdate:function(a,c){var b=c.responseXML.getElementsByTagName("ajax-response");
4887 Rico.log("selectValuesUpdate: "+c.status);
4888 if(b==null||b.length!=1){return
4890 var j=b.getElementsByTagName("error");
4891 if(j.length>0){var g=Rico.getContentAsString(j[0],this.grid.buffer.isEncoded);
4892 Rico.log("Data provider returned an error:\n"+g);
4893 alert(Rico.getPhraseById("requestError",g));
4895 }b=b.getElementsByTagName("response")[0];
4896 var h=b.getElementsByTagName("rows")[0];
4897 var k=this.grid.buffer.dom2jstable(h);
4898 Rico.log("selectValuesUpdate: id="+a.id+" rows="+k.length);
4901 e++){if(k[e].length>0){var f=k[e][0];
4902 var d=(k[e].length>1)?k[e][1]:f;
4903 this.addSelectOption(a,f,d,e)
4904 }}if(Rico.$("textnew__"+a.id)){this.addSelectOption(a,this.options.TableSelectNew,Rico.getPhraseById("selectNewVal"))
4905 }if(this.panelGroup){Rico.runLater(50,this,"initPanelGroup")
4906 }},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);
4908 var d=document.createElement("label");
4912 Rico.eventBind(b,"click",Rico.eventHandle(this,"radioClick"),false);
4914 case"select":Rico.addSelectOption(c,e,f);
4916 }},clearSaveMsg:function(){if(this.saveMsg){this.saveMsg.innerHTML=""
4917 }},addMenuItem:function(c,b,a){this.extraMenuItems.push({menuText:c,menuAction:b,enabled:a})
4918 },editMenu:function(d,h,j,e){this.clearSaveMsg();
4919 if(this.grid.buffer.sessionExpired==true||this.grid.buffer.startPos<0){return false
4921 var g=Rico.$("pageTitle");
4922 var f=g?g.innerHTML:document.title;
4923 this.menu.addMenuHeading(f);
4925 if(e==false){for(var b=0;
4926 b<this.extraMenuItems.length;
4927 b++){this.menu.addMenuItem(this.extraMenuItems[b].menuText,this.extraMenuItems[b].menuAction,this.extraMenuItems[b].enabled)
4928 }this.menu.addMenuItem(this.editText,function(){a.editRecord()
4930 this.menu.addMenuItem(this.delText,function(){a.deleteRecord()
4931 },this.canDelete(h));
4932 if(this.options.canClone){this.menu.addMenuItem(this.cloneText,function(){a.cloneRecord()
4933 },this.canAdd(h)&&this.canEdit(h))
4934 }}this.menu.addMenuItem(this.addText,function(){a.addRecord()
4937 },canAdd:function(a){return(typeof this.options.canAdd=="function")?this.options.canAdd(a):this.options.canAdd
4938 },canEdit:function(a){return(typeof this.options.canEdit=="function")?this.options.canEdit(a):this.options.canEdit
4939 },canDelete:function(a){return(typeof this.options.canDelete=="function")?this.options.canDelete(a):this.options.canDelete
4940 },cancelEdit:function(a){Rico.eventStop(a);
4941 this.makeFormInvisible();
4942 this.grid.highlightEnabled=true;
4943 this.menu.cancelmenu();
4945 },setField:function(g,m){var p=this.grid.columns[g].format;
4946 var k=Rico.$(p.FieldName);
4949 }Rico.log("setField: "+p.FieldName+"="+m);
4950 switch(k.tagName.toUpperCase()){case"DIV":c=k.getElementsByTagName("INPUT");
4952 if(p.MultiSelect&&m){n=m.split(",");
4959 j++){c[j].checked=f[c[j].value]==1
4961 case"INPUT":if(p.EntryType=="D"){n=m.split(/\s|T/);
4963 if(this.isTextInput(k)){var l=m.toLowerCase()=="today"?new Date():Rico.setISO8601(m);
4964 if(l){m=Rico.formatDate(l,p.dateFmt)
4967 case"SELECT":b=k.options;
4969 if(p.MultiSelect&&m){n=m.split(",");
4975 j++){b[j].selected=f[b[j].value]==1
4978 j++){if(b[j].value==m){k.selectedIndex=j;
4980 }}}if(p.EntryType=="N"){h=Rico.$("textnew__"+k.id);
4981 if(!h){alert('Warning: unable to find id "textnew__'+k.id+'"')
4983 if(k.selectedIndex!=j){k.selectedIndex=b.length-1
4984 }this.updateSelectNew(k)
4986 case"TEXTAREA":k.value=m;
4987 if(p.EntryType=="tinyMCE"&&typeof(tinyMCE)!="undefined"&&this.initialized){if(tinyMCE.updateContent){tinyMCE.updateContent(k.id)
4988 }else{tinyMCE.execInstanceCommand(k.id,"mceSetContent",false,m)
4990 }},setReadOnly:function(h){for(var g,f=0;
4991 f<this.grid.columns.length;
4992 f++){var b=this.grid.columns[f].format;
4994 }var k=Rico.$(b.FieldName);
4996 }switch(h){case"ins":g=!b.Writeable||b.ReadOnly||b.UpdateOnly;
4998 case"upd":g=!b.Writeable||b.ReadOnly||b.InsertOnly;
5002 }switch(k.tagName.toUpperCase()){case"DIV":var c=k.getElementsByTagName("INPUT");
5005 d++){c[d].disabled=g
5007 case"SELECT":if(b.EntryType=="N"){var a=Rico.$("textnew__"+k.id);
5011 case"TEXTAREA":case"INPUT":k.disabled=g;
5012 if(b.selectIcon){b.selectIcon.style.display=g?"none":""
5014 }}},hideResponse:function(a){this.responseDiv.innerHTML=a;
5015 this.responseDialog.style.display="none"
5016 },showResponse:function(){var a=Rico.cumulativeOffset(this.grid.outerDiv);
5017 a.top+=Rico.docScrollTop();
5018 this.responseDialog.style.top=a.top+"px";
5019 this.responseDialog.style.left=a.left+"px";
5020 this.responseDialog.style.display=""
5021 },processResponse:function(g){var d,f=true;
5022 Rico.log("Processing response from form submittal: "+typeof(g));
5023 this.responseDiv.innerHTML=g.responseText;
5024 var e=Rico.select(".ricoFormResponse",this.responseDiv);
5025 if(e){Rico.log("Found ricoFormResponse");
5026 var c=Rico.trim(e[0].className).split(/\s+/)[1];
5027 d=Rico.getPhraseById(c,this.options.RecordName)
5028 }else{Rico.log("Processing response text");
5029 var b=this.responseDiv.childNodes;
5030 for(var a=b.length-1;
5032 a--){if(b[a].nodeType==1&&b[a].nodeName!="P"&&b[a].nodeName!="DIV"&&b[a].nodeName!="BR"){this.responseDiv.removeChild(b[a])
5033 }}d=Rico.stripTags(this.responseDiv.innerHTML);
5034 f=(d.toLowerCase().indexOf("error")==-1)
5035 }if(f&&this.options.showSaveMsg!="full"){this.hideResponse("");
5036 this.grid.resetContents();
5037 this.grid.buffer.foundRowCount=false;
5038 this.grid.buffer.fetch(this.grid.lastRowPos||0);
5039 if(this.saveMsg){this.saveMsg.innerHTML=" "+d+" "
5040 }}this.processCallback(this.options.onSubmitResponse);
5041 Rico.log("Processing response completed")
5042 },processCallback:function(callback){switch(typeof callback){case"string":return eval(callback);
5043 case"function":return callback()
5044 }},ackResponse:function(a){this.hideResponse("");
5045 this.grid.highlightEnabled=true
5046 },cloneRecord:function(){this.formPopup.setTitle(this.cloneText);
5047 this.displayEditForm("ins")
5048 },editRecord:function(){this.formPopup.setTitle(this.editText);
5049 this.displayEditForm("upd")
5050 },displayEditForm:function(e){this.grid.highlightEnabled=false;
5051 this.menu.cancelmenu();
5052 this.hideResponse(Rico.getPhraseById("saving"));
5053 this.grid.outerDiv.style.cursor="auto";
5054 this.action.value=e;
5056 d<this.grid.columns.length;
5057 d++){var f=this.grid.columns[d];
5058 if(f.format){var b=f.getValue(this.rowIdx);
5060 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)
5062 if(b===""){b=" "
5063 }f.format.selectDesc.innerHTML=b
5064 }if(f.format.SelectCtl){Rico.EditControls.displayClrImg(f,!f.format.InsertOnly)
5065 }}}this.setReadOnly(e);
5068 a++){this.keys[a].keyField.value=this.grid.buffer.getWindowValue(this.rowIdx,this.keys[a].colidx)
5069 }this.makeFormVisible(this.rowIdx)
5070 },addPrepare:function(){this.hideResponse(Rico.getPhraseById("saving"));
5072 this.setReadOnly("ins");
5073 this.action.value="ins";
5075 a<this.grid.columns.length;
5076 a++){var b=this.grid.columns[a];
5077 if(b.format){this.setField(a,b.format.ColData);
5078 if(b.format.SelectCtl){if(b.format.EntryType!="D"){Rico.EditControls.resetValue(b)
5079 }Rico.EditControls.displayClrImg(b,!b.format.UpdateOnly)
5080 }}}},addRecord:function(){this.menu.cancelmenu();
5081 this.formPopup.setTitle(this.addText);
5083 this.makeFormVisible(-1);
5084 if(this.formPanels){this.formPanels.select(0)
5085 }},drillDown:function(b,a,c){return this.grid.drillDown.apply(this.grid,arguments)
5086 },setDetailFilter:function(a,b){this.grid.setDetailFilter(a,b)
5087 },makeFormVisible:function(k){this.formPopup.container.style.display="block";
5088 var c=this.formPopup.container.offsetWidth;
5089 var h=Rico.cumulativeOffset(this.grid.outerDiv);
5090 var d=Rico.windowWidth();
5091 this.formPopup.container.style.left=c+h.left>d?(d-c)+"px":(h.left+1)+"px";
5092 var g=Rico.docScrollTop();
5093 var a=this.formPopup.container.offsetHeight;
5094 var f=h.top+this.grid.hdrHt+g;
5095 var b=Rico.windowHeight()+g;
5096 if(k>=0){f+=(k+1)*this.grid.rowHeight;
5097 if(f+a>b){f-=(a+this.grid.rowHeight)
5098 }}else{if(f+a>b){f=b-a-2
5099 }}if(this.processCallback(this.options.formOpen)===false){return
5100 }this.formPopup.openPopup(null,Math.max(f,g));
5101 this.formPopup.container.style.visibility="visible";
5102 Rico.EditControls.setZ(Rico.getStyle(this.formPopup.container,"zIndex"));
5103 if(this.initialized){return
5106 e<this.grid.columns.length;
5107 e++){j=this.grid.columns[e].format;
5108 if(!j||!j.EntryType||!j.FieldName){continue
5109 }switch(j.EntryType){case"tinyMCE":if(typeof tinyMCE!="undefined"){tinyMCE.execCommand("mceAddControl",true,j.FieldName)
5111 }}this.initialized=true
5112 },makeFormInvisible:function(){for(var a=0;
5113 a<this.grid.columns.length;
5114 a++){if(this.grid.columns[a].format&&this.grid.columns[a].format.SelectCtl){Rico.EditControls.close(this.grid.columns[a].format.SelectCtl)
5115 }}this.formPopup.container.style.visibility="hidden";
5116 this.formPopup.closePopup();
5117 this.processCallback(this.options.formClose)
5118 },getConfirmDesc:function(a){return Rico.stripTags(this.grid.cell(a,this.options.ConfirmDeleteCol).innerHTML).replace(" "," ")
5119 },deleteRecord:function(){this.menu.cancelmenu();
5121 switch(this.options.ConfirmDeleteCol){case -1:f=Rico.getPhraseById("thisRecord",this.options.RecordName);
5126 b++){var c=this.keys[b].colidx;
5127 var a=this.grid.columns[c].format;
5128 if(a.EntryType.length>1&&a.EntryType.charAt(1)=="L"){c++
5129 }var e=Rico.trim(Rico.stripTags(this.grid.cell(this.rowIdx,c).innerHTML).replace(/ /g," "));
5131 }f+=this.grid.columns[c].displayName+' "'+e+'"'
5133 default:f='"'+Rico.truncate(this.getConfirmDesc(this.rowIdx),50)+'"';
5135 }if(!this.options.ConfirmDelete.valueOf||confirm(Rico.getPhraseById("confirmDelete",f))){this.hideResponse(Rico.getPhraseById("deleting"));
5136 this.showResponse();
5138 d[this.grid.actionId]="del";
5141 b++){var c=this.keys[b].colidx;
5142 var e=this.grid.columns[c].getValue(this.rowIdx);
5144 }new Rico.ajaxRequest(this.options.updateURL,{parameters:d,method:"post",onComplete:this.responseHandler})
5145 }this.menu.cancelmenu()
5146 },validationMsg:function(d,c,e){var b=this.grid.columns[c];
5147 if(this.formPanels){this.formPanels.select(this.panelActualIdx[b.format.ColGroupIdx])
5148 }var a=Rico.stripTags(b.formLabel.innerHTML).replace(/ /g," ");
5149 var f=Rico.getPhraseById(e,' "'+a+'"');
5150 Rico.log(" Validation error: "+f);
5151 if(b.format.Help){f+="\n\n"+b.format.Help
5153 setTimeout(function(){try{d.focus();
5157 },isTextInput:function(a){if(!a){return false
5158 }if(a.tagName.toLowerCase()!="input"){return false
5159 }if(a.type.toLowerCase()!="text"){return false
5160 }if(a.readOnly){return false
5161 }if(!Rico.visible(a)){return false
5163 },parseDate:function(c,e){dateParts={};
5164 if(!this.dateRegExp.exec(e)){return NaN
5165 }dateParts[RegExp.$1]=0;
5166 dateParts[RegExp.$3]=1;
5167 dateParts[RegExp.$5]=2;
5168 var i=c.split(/\D/);
5170 var b=g.getFullYear();
5171 if(i.length==2&&dateParts.yyyy==2){i.push(b)
5172 }if(i.length!=3){return NaN
5173 }var a=parseInt(i[dateParts.dd],10);
5174 if(a==0||a>31){return NaN
5175 }var f=parseInt(i[dateParts.mm],10)-1;
5177 }var h=parseInt(i[dateParts.yyyy],10);
5178 if(h<100){h+=b-(b%100)
5179 }return new Date(h,f,a,0,0,0)
5180 },TESubmit:function(j){var g,h,k,l,f,d,c=[];
5182 Rico.log("Event: TESubmit called to validate input");
5184 g<this.grid.columns.length;
5185 g++){l=this.grid.columns[g].format;
5186 if(!l||!l.EntryType||!l.FieldName){continue
5187 }f=Rico.$(l.FieldName);
5188 if(!this.isTextInput(f)){continue
5189 }switch(this.action.value){case"ins":h=!l.Writeable||l.ReadOnly||l.UpdateOnly;
5191 case"upd":h=!l.Writeable||l.ReadOnly||l.InsertOnly;
5196 }Rico.log(" Validating field #"+g+" EntryType="+l.EntryType+" ("+l.FieldName+")");
5197 if(f.value.length==0){if(l.required){return this.validationMsg(f,g,"formPleaseEnter")
5199 }}if(f.value.length>0&&l.regexp&&!l.regexp.test(f.value)){return this.validationMsg(f,g,"formInvalidFmt")
5200 }switch(l.EntryType.charAt(0)){case"I":d=parseInt(f.value,10);
5202 case"F":d=parseFloat(f.value);
5204 case"D":d=this.parseDate(f.value,l.dateFmt);
5205 if(isNaN(d)){return this.validationMsg(f,g,"formInvalidFmt")
5210 }if(typeof l.min!="undefined"&&!isNaN(d)&&d<l.min){return this.validationMsg(f,g,"formOutOfRange")
5211 }if(typeof l.max!="undefined"&&!isNaN(d)&&d>l.max){return this.validationMsg(f,g,"formOutOfRange")
5212 }}if(this.processCallback(this.options.formSubmit)===false){return false
5214 g<this.grid.columns.length;
5215 g++){l=this.grid.columns[g].format;
5216 if(!l||!l.EntryType||!l.FieldName){continue
5217 }if(l.EntryType.charAt(0)!="N"){continue
5218 }var a=Rico.$(l.FieldName);
5219 if(!a||a.value!=this.options.TableSelectNew){continue
5220 }var b=Rico.$("textnew__"+a.id).value;
5221 this.addSelectOption(a,b,b)
5224 g++){c[g].e.value=Rico.formatDate(c[g].v,"yyyy-mm-dd")
5225 }if(typeof tinyMCE!="undefined"){tinyMCE.triggerSave()
5226 }this.makeFormInvisible();
5228 this.menu.cancelmenu();
5230 },sendForm:function(){this.setReadOnly("reset");
5231 this.showResponse();
5232 Rico.log("sendForm: "+this.grid.tableId);
5233 Rico.ajaxSubmit(this.form,this.options.updateURL,{method:"post",onComplete:this.responseHandler})
5235 Rico.EditControls={widgetList:{},elemList:{},zIndex:0,register:function(b,c){this.widgetList[b.id]={imgsrc:c,widget:b,currentEl:""};
5237 b.returnValue=function(d,e){a.setValue(b,d,e)
5239 Rico.log("Rico.EditControls.register:"+b.id)
5240 },setZ:function(a){this.zIndex=Math.max(this.zIndex,a+10)
5241 },applyTo:function(f,g,b){var d=this.widgetList[f.format.SelectCtl];
5243 }Rico.log("Rico.EditControls.applyTo: "+f.displayName+" : "+f.format.SelectCtl);
5244 var a,e=document.createElement("span");
5245 if(d.imgsrc.indexOf(".")==-1&&d.imgsrc.indexOf("/")==-1){a=document.createElement("span");
5246 a.className=d.imgsrc
5247 }else{a=document.createElement("img");
5249 }a.style.verticalAlign="top";
5250 a.style.marginLeft="4px";
5251 a.style.cursor="pointer";
5252 a.id=this.imgId(f.format.FieldName);
5253 Rico.eventBind(a,"click",Rico.eventHandle(this,"processClick"));
5254 g.parentNode.appendChild(e);
5255 g.parentNode.appendChild(a);
5256 if(b){e.style.display="none"
5257 }else{g.style.display="none"
5259 if(f.format.isNullable){c=Rico.clearButton(Rico.eventHandle(this,"processClear"));
5261 g.parentNode.appendChild(c)
5262 }this.elemList[a.id]={descSpan:e,inputCtl:g,widget:d.widget,listObj:d,column:f,clrimg:c};
5263 f.format.selectIcon=a;
5264 f.format.selectDesc=e
5265 },displayClrImg:function(c,a){var b=this.elemList[this.imgId(c.format.FieldName)];
5266 if(b&&b.clrimg){b.clrimg.style.display=a?"inline-block":"none"
5267 }},processClear:function(c){var b=Rico.eventElement(c);
5268 var a=this.elemList[b.id.slice(0,-6)];
5270 }a.inputCtl.value="";
5271 a.descSpan.innerHTML=a.column._format("")
5272 },processClick:function(c){var b=Rico.eventElement(c);
5273 var a=this.elemList[b.id];
5275 }if(a.listObj.currentEl==b.id&&a.widget.container.style.display!="none"){a.widget.close();
5276 a.listObj.currentEl=""
5277 }else{a.listObj.currentEl=b.id;
5278 Rico.log("Rico.EditControls.processClick: "+a.widget.id+" : "+a.inputCtl.value);
5279 a.widget.container.style.zIndex=this.zIndex;
5280 a.widget.open(a.inputCtl.value,a.column);
5281 Rico.positionCtlOverIcon(a.widget.container,b)
5282 }},imgId:function(a){return"icon_"+a
5283 },resetValue:function(c){var b=this.elemList[this.imgId(c.format.FieldName)];
5285 }b.inputCtl.value=c.format.ColData;
5286 var a=c._format(c.format.ColData);
5287 if(a===""){a=" "
5288 }b.descSpan.innerHTML=a
5289 },setValue:function(e,a,d){var b=this.widgetList[e.id];
5293 }var c=this.elemList[f];
5295 }c.inputCtl.value=a;
5296 if(!d){d=c.column._format(a)
5297 }c.descSpan.innerHTML=d;
5298 if(c.column.format.DescriptionField){Rico.$(c.column.format.DescriptionField).value=d
5299 }},close:function(b){var a=this.widgetList[b];
5301 }if(a.widget.container.style.display!="none"){a.widget.close()
5304 Rico.addPhraseId("bookmarkExact","Listing records $1 - $2 of $3");
5305 Rico.addPhraseId("bookmarkAbout","Listing records $1 - $2 of more than $3");
5306 Rico.addPhraseId("bookmarkNoRec","No records");
5307 Rico.addPhraseId("bookmarkNoMatch","No matching records");
5308 Rico.addPhraseId("bookmarkLoading","Loading...");
5309 Rico.addPhraseId("sorting","Sorting...");
5310 Rico.addPhraseId("exportStatus","Exporting row $1");
5311 Rico.addPhraseId("filterAll","(all)");
5312 Rico.addPhraseId("filterBlank","(blank)");
5313 Rico.addPhraseId("filterEmpty","(empty)");
5314 Rico.addPhraseId("filterNotEmpty","(not empty)");
5315 Rico.addPhraseId("filterLike","contains: $1");
5316 Rico.addPhraseId("filterNot","not: $1");
5317 Rico.addPhraseId("requestError","The request for data returned an error:\n$1");
5318 Rico.addPhraseId("keywordPrompt","Enter keyword to search for (use * as a wildcard):");
5319 Rico.addPhraseId("keywordTitle","Keyword Search");
5320 Rico.addPhraseId("apply","Apply");
5321 Rico.addPhraseId("gridmenuSortBy","Sort by: $1");
5322 Rico.addPhraseId("gridmenuSortAsc","Ascending");
5323 Rico.addPhraseId("gridmenuSortDesc","Descending");
5324 Rico.addPhraseId("gridmenuFilterBy","Filter by: $1");
5325 Rico.addPhraseId("gridmenuRefresh","Refresh");
5326 Rico.addPhraseId("gridmenuChgKeyword","Change keyword...");
5327 Rico.addPhraseId("gridmenuExcludeAlso","Exclude this value also");
5328 Rico.addPhraseId("gridmenuInclude","Include only this value");
5329 Rico.addPhraseId("gridmenuGreaterThan","Greater than or equal to this value");
5330 Rico.addPhraseId("gridmenuLessThan","Less than or equal to this value");
5331 Rico.addPhraseId("gridmenuContains","Contains keyword...");
5332 Rico.addPhraseId("gridmenuExclude","Exclude this value");
5333 Rico.addPhraseId("gridmenuRemoveFilter","Remove filter");
5334 Rico.addPhraseId("gridmenuRemoveAll","Remove all filters");
5335 Rico.addPhraseId("gridmenuExport","Print/Export");
5336 Rico.addPhraseId("gridmenuExportVis2Web","Visible rows to web page");
5337 Rico.addPhraseId("gridmenuExportAll2Web","All rows to web page");
5338 Rico.addPhraseId("gridmenuExportVis2SS","Visible rows to spreadsheet");
5339 Rico.addPhraseId("gridmenuExportAll2SS","All rows to spreadsheet");
5340 Rico.addPhraseId("gridmenuHideShow","Hide/Show");
5341 Rico.addPhraseId("gridmenuChooseCols","Choose columns...");
5342 Rico.addPhraseId("gridmenuHide","Hide: $1");
5343 Rico.addPhraseId("gridmenuShow","Show: $1");
5344 Rico.addPhraseId("gridmenuShowAll","Show All");
5345 Rico.addPhraseId("sessionExpireMinutes","minutes before your session expires");
5346 Rico.addPhraseId("sessionExpired","EXPIRED");
5347 Rico.addPhraseId("requestTimedOut","Request for data timed out!");
5348 Rico.addPhraseId("waitForData","Waiting for data...");
5349 Rico.addPhraseId("httpError","Received HTTP error: $1");
5350 Rico.addPhraseId("invalidResponse","Server returned an invalid response");
5351 Rico.addPhraseId("gridChooseCols","Choose columns");
5352 Rico.addPhraseId("exportComplete","Exporting complete");
5353 Rico.addPhraseId("exportInProgress","Export in progress...");
5354 Rico.addPhraseId("disableBlocker","You need to disable your browser's pop-up blocker before exporting.");
5355 Rico.addPhraseId("showFilterRow","Show filter row");
5356 Rico.addPhraseId("hideFilterRow","Hide filter row");
5357 Rico.addPhraseId("ok","OK");
5358 Rico.addPhraseId("selectNone","(none)");
5359 Rico.addPhraseId("selectNewVal","(new value)");
5360 Rico.addPhraseId("record","record");
5361 Rico.addPhraseId("thisRecord","this $1");
5362 Rico.addPhraseId("confirmDelete","Are you sure you want to delete $1?");
5363 Rico.addPhraseId("deleting","Deleting...");
5364 Rico.addPhraseId("formPleaseEnter","Please enter a value for $1");
5365 Rico.addPhraseId("formInvalidFmt","Invalid format for $1");
5366 Rico.addPhraseId("formOutOfRange","Value is out of range for $1");
5367 Rico.addPhraseId("formNewValue","new value:");
5368 Rico.addPhraseId("saving","Saving...");
5369 Rico.addPhraseId("clear","clear");
5370 Rico.addPhraseId("close","Close");
5371 Rico.addPhraseId("saveRecord","Save $1");
5372 Rico.addPhraseId("cancel","Cancel");
5373 Rico.addPhraseId("editRecord","Edit $1");
5374 Rico.addPhraseId("deleteRecord","Delete this $1");
5375 Rico.addPhraseId("cloneRecord","Clone $1");
5376 Rico.addPhraseId("addRecord","Add new $1");
5377 Rico.addPhraseId("addedSuccessfully","$1 added successfully");
5378 Rico.addPhraseId("deletedSuccessfully","$1 deleted successfully");
5379 Rico.addPhraseId("updatedSuccessfully","$1 updated successfully");
5380 Rico.addPhraseId("treeSave","Save Selection");
5381 Rico.addPhraseId("treeClear","Clear All");
5382 Rico.addPhraseId("calToday","Today is $1 $2 $3");
5383 Rico.addPhraseId("calWeekHdg","Wk");
5384 Rico.addPhraseId("calYearRange","Year ($1-$2)");
5385 Rico.addPhraseId("calInvalidYear","Invalid year");
5388 Rico.dateFmt="mm/dd/yyyy";
5389 Rico.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];
5390 Rico.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];