function alertCriteria(msg) { //alert("GridCriteria:"+msg); } var EdealGridCriteria = function(renderElement,fShow,buttonElement) { alertCriteria("start"); this.renderElement = renderElement; this.showCriteria = fShow; this.gridCriteria=this; this.gridDataHeight=null; this.tabFooterHeight=null; this.previewHeight=null; this.dataTopPosition=null; this.windowHeight=null; if (fShow) { this.show(buttonElement,fShow); } } EdealGridCriteria.prototype.test = function(fShow) { alertCriteria("test ?"+fShow); } EdealGridCriteria.prototype.show=function(fromElement,fShow) { alertCriteria("show ?"+fShow+" "+fromElement); if (fShow==null) { alertCriteria("show:toggle"); this.showCriteria=!this.showCriteria; $(this.renderElement).slideToggle('slow'); } else { this.showCriteria=fShow; if (fShow) { alertCriteria("show:yes"); $(this.renderElement).slideDown('slow'); } else { alertCriteria("show:no"); $(this.renderElement).slideUp('slow'); } } alertCriteria("change class?"); if (fromElement!=null) { $(fromElement).removeClass(); $(fromElement).addClass(this.showCriteria?"bShowCriteria":"bHideCriteria"); } alertCriteria("end"); } // Height function here to optimize processing EdealGridCriteria.prototype.resetHeights=function() { this.gridDataHeight=null; this.tabFooterHeight=null; this.previewHeight=null; this.dataTopPosition=null; this.windowHeight=null; } EdealGridCriteria.prototype.processHeights=function() { alertCriteria("processHeights start"); this.tabFooterHeight=(this.tabFooterHeight==null)?$("#BTFoot").height():this.tabFooterHeight; //this.previewHeight=(this.previewHeight==null)?$("#grid-preview").height():this.previewHeight; this.dataTopPosition=(this.dataTopPosition==null)?$("#grid-data").offset().top:this.dataTopPosition; this.windowHeight=(this.windowHeight==null)?$(window).height():this.windowHeight; this.gridDataHeight=(this.gridDataHeight==null)?$("#grid-data").height():this.gridDataHeight; } EdealGridCriteria.prototype.resizeGrid_old=function(fForceReset) { alertCriteria("resizeGrid start"); if (fForceReset) { this.resetHeights(); } this.processHeights(); //the preview may change, so get it again this.previewHeight=$("#grid-preview").height(); alertCriteria("=> taille grid :"+this.gridDataHeight); // get the max grid size var maxGridSize=this.windowHeight-this.dataTopPosition-this.previewHeight-this.tabFooterHeight-20; alertCriteria("=> taille max:"+maxGridSize); // If the grid is smaller, don't need to resize it, else resize it if (this.gridDataHeight>maxGridSize) { alertCriteria("resize!!!"); //$("#grid-data").height(maxGridSize); } } EdealGridCriteria.prototype.resizeGrid=function(fForceReset) { } EdealGridCriteria.prototype.displayHelp=function(listCode) { if (listCode) { doAjax('get_list_help_ajax.fl?lc='+listCode, function(arrIndex) { if (eDealXmlhttpArr[arrIndex].readyState == 4) { hideWaiting(); gGridCriteria.showInfoTab(eDealXmlhttpArr[arrIndex].responseText,$("#valid-button")); } }); } } EdealGridCriteria.prototype.showInfoTab=function(text,elementToBeNextTo) { var itab=$("#infoTab"); $("#infoTab .body").html(text); itab.click(function(){ $("#infoTab").hide() }); // add a click event handler in order to hide it pos=$(elementToBeNextTo).position(); if (!pos) { pos={top:100,left:100}; } itab.css({ position: "absolute", marginLeft: 0, marginTop: 0, top:pos.top-10, left: pos.left-10 }); itab.show('slow'); // and finally show it } EdealGridCriteria.prototype.hightLightMandatory=function() { if($("#criteriaTableDiv .mandatory-group").length!=0) { this.checkMandatory(); $("#criteriaTableDiv input.mandatory-group").hover( this.enableMandatory, this.disableMandatory ); $("#criteriaTableDiv .mandatory-group").focus( this.enableMandatory); $("#criteriaTableDiv .mandatory-group").blur( this.disableMandatory); $("#criteriaTableDiv .mandatory-group").change(this.enableMandatory); } } EdealGridCriteria.prototype.enableMandatory=function() { var classes = $(this).attr("class").split(" "); var minFldReq = 10000; var idMandatoryGpMin = ""; var prefix = "mandatory-group-id-"; $.each(classes,function(i,classe){ if(classe.indexOf(prefix)>=0){ $("#criteriaTableDiv ."+classe).addClass("active"); var id = classe.indexOf(prefix)+prefix.length; var idMdGp = classe.substring(id,classe.length); if(minFldReq>mandatoryGroups[idMdGp]){ miniFldReq = mandatoryGroups[idMdGp]; idMandatoryGpMin = "msg-"+idMdGp; } } }); if(idMandatoryGpMin!="" && $("#valid-button").hasClass("inactive")){ var tmp = $("#"+idMandatoryGpMin); $("#"+idMandatoryGpMin).show(); } } EdealGridCriteria.prototype.disableMandatory=function() { $(".active").removeClass("active"); $("#zone-mandatory-message span").hide(); } EdealGridCriteria.prototype.checkMandatory=function() { var mdGps = {}; var vide=true; for(key in mandatoryGroups){ vide=false; mdGps[key] = mandatoryGroups[key]; } if(vide) return true; var valid = false; for(classe in mdGps){ var mdGpClasse = "mandatory-group-id-"+classe; var cpt=0; $("input."+mdGpClasse+", select."+mdGpClasse).each(function(i,obj){ var val = $(obj).val(); if(val.length > 0 && val.charAt(0)!='<' && val.charAt(val.length-1)!='>'){ cpt++; } }) mdGps[classe]=mdGps[classe]-cpt; if(mdGps[classe]<=0){ valid=true; } }; if (valid){ $("#valid-button").removeClass("inactive"); $("#valid-button-preview").removeClass("inactive"); return true; } else{ $("#valid-button").addClass("inactive"); $("#valid-button-preview").addClass("inactive"); return false; } } EdealGridCriteria.prototype.doDisplayPreview=function() { var previewElement=document.getElementById("$$preview"); return $(previewElement).is(':checked'); }