////////////////////////////////////////////////////////// // // // COPYRIGHT 2007 MENTASOLUTIONS ALL RIGHTS RESERVED // // utilisation de ce script sans autoridation interdite // // // ////////////////////////////////////////////////////////// // //Tableau associatif contenant le lignes sélectionnée par table // var selectedLignesByTable=new Array(); // // //objet Select // // // // valueNameString est une liste de type : name|=|value|!|name|=|value|!|name|=|value|!|name|=|value|!|name|=|value|!|... function SelectElement(pName,pCurSelectedId,pPrevSelectedId,pNameValueList,pOnchangefunction,pSize){ this.name=pName; var GetCurValue=pCurSelectedId; var prevSelectedValue=pPrevSelectedId; var nameValueList=pNameValueList; var selectElmt=document.createElement("SELECT"); this.selectElmt=selectElmt; if(pOnchangefunction!="" && pOnchangefunction!="function(){}"){ eval("selectElmt.onchange=function(){"+pOnchangefunction+"}"); } //selectElmt.style.width=pSize; var textElmt=document.createTextNode(""); var divElmt=document.createElement('div'); divElmt.setAttribute('id',this.name); divElmt.setAttribute('width',pSize); this.AddMe=addMe; this.EditModeIN=editModeIN; this.EditModeOUT=editModeOUT; this.GetCurValue=getCurValue; this.HasChanged=hasChanged; this.RestoreValue=restoreValue; this.Focus=Focus; this.isEditable=true; this.SetUnEditable=setUnEditable; this.selectElmt=selectElmt; this.AcceptChanges=acceptChanges; function setUnEditable(){ selectElmt.setAttribute("disabled","disabled"); this.isEditable=false; } function acceptChanges(){ prevSelectedValue=selectElmt.options[selectElmt.selectedIndex].value; } function setEditable(){ this.isEditable=true; } SelectElement.prototype.buildSelectElement=function(){ selectElmt.setAttribute("name","select_"+this.name); selectElmt.setAttribute("id","select_"+this.name); selectElmt.setAttribute("class","selectBox"); selectElmt.setAttribute("className","selectBox"); optionsAdd(selectElmt,nameValueList,GetCurValue); } function Focus(){ selectElmt.focus(); } function buildTextElement(){ theText=selectElmt.options[selectElmt.selectedIndex].text; textElmt.data=theText; } this.buildSelectElement(); buildTextElement(); function getprevSelectedValue(){ return prevSelectedValue; } function getCurValue(){ if(currentMode=="editing")return selectElmt.options[selectElmt.selectedIndex].value; return GetCurValue; } function editModeIN(){ if(this.isEditable==false){ selectElmt.setAttribute("disabled","disabled"); } prevSelectedValue=GetCurValue; divElmt.replaceChild(selectElmt,textElmt); currentMode="editing"; } function editModeOUT(){ GetCurValue=selectElmt.options[selectElmt.selectedIndex].value; buildTextElement(); if(textElmt!=null && selectElmt!=null)divElmt.replaceChild(textElmt,selectElmt); currentMode="displaying"; } function restoreValue(){ selectElmt.value=prevSelectedValue; } function addMe(pDestination){ divElmt.appendChild(textElmt); pDestination.appendChild(divElmt); } function hasChanged(){ if(getprevSelectedValue()!=getCurValue()&&(getprevSelectedValue()!=undefined&&getCurValue()!=undefined))return true; return false; } function optionsAdd(pSelect,listNameValue,selectedId){ var arrayOptions=listNameValue.split("|!|"); for(i=0;i=2){ //this.imgwidth=firstDimensionArray[0]; this.imgheight=firstDimensionArray[1]; this.myImg=document.createElement("img"); this.myHiddenInput=document.createElement("input"); this.myHiddenInput.type="hidden"; this.myHiddenInput.id=this.name+"_input"; var arrTmp = pcurValue.split("/"); var sFilename = arrTmp[arrTmp.length-1]; if(pRoot=="/medias/")this.curValue=pRoot+arrayDirectories[0]+""+sFilename; if(pRoot!="/medias/")this.curValue=pRoot+""+sFilename; this.myHiddenInput.value=this.curValue; this.prevValue=this.curValue; this.myImg.src=this.curValue; //this.myImg.width=this.imgwidth; //this.myImg.height=this.imgheight; this.myImg.parentObj=this; this.myImg.id=this.name; this.myImg.onclick=function(){ UploadImg(pDirectories,pDimensions,this.id+"_input",this.id); } }else{ this.myImg=document.createElement("div"); this.myImg.createTextNode("Erreur valeurs dimensions/répertoire"); } }else{ this.myImg=document.createElement("div"); this.myImg.createTextNode("Erreur valeurs dimensions/répertoire "); } } ImageElement.prototype.Focus=function(){ document.getElementById(this.name).focus(); } ImageElement.prototype.RestoreValue=function(){ this.myHiddenInput.value=this.prevValue; this.myImg.src=this.prevValue; } ImageElement.prototype.AddMe=function(pDestination){ pDestination.appendChild(this.myImg); pDestination.appendChild(this.myHiddenInput); } ImageElement.prototype.HasChanged=function(){ if(this.GetPrevValue().replace(/\r|\n|\r\n/g,"")!=this.GetCurValue().replace(/\r|\n|\r\n/g,""))return true; return false; } ImageElement.prototype.AcceptChanges=function(){ this.prevValue=this.myHiddenInput.value; this.curValue=this.prevValue; } ImageElement.prototype.EditModeOUT=function(){ } ImageElement.prototype.EditModeIN=function (){ } ImageElement.prototype.GetPrevValue=function(){ return this.prevValue; } ImageElement.prototype.GetCurValue=function (){ return this.myHiddenInput.value; } // // //objet TextBox // // // function TextBoxElement(pname,pcurValue,pSize,pType,pLineNumber,pOnclick){ if(pLineNumber==undefined)pLineNumber=1; this.lineNumber=pLineNumber; this.type=pType; this.name=pname; this.curValue=pcurValue; this.prevValue=pcurValue; this.currentMode="displaying"; this.bSize=75; if(pSize!=null && pSize!=undefined){ this.bSize=pSize; } this.onclickstr=pOnclick } TextBoxElement.prototype.Focus=function(){ document.getElementById(this.name).focus(); } TextBoxElement.prototype.RestoreValue=function(){ if(document.getElementById(this.name)!=null){ document.getElementById(this.name).value=this.prevValue; }else{ if(this.type=='password'){ document.getElementById('div_'+this.name).innerHTML="xxxxxxxxxx"; }else{ andMore=""; if(this.prevValue.length>30)andMore="..."; document.getElementById('div_'+this.name).innerHTML=this.prevValue.substring(0,30)+andMore; if(this.prevValue=="")document.getElementById('div_'+this.name).innerHTML=" "; } } } TextBoxElement.prototype.AddMe=function(pDestination){ var divElmt=document.createElement("div"); divElmt.setAttribute("id","div_"+this.name); divElmt.width=this.bSize; if(this.type=='password'){ var tNode=document.createTextNode("xxxxxxxxxx"); }else{ andMore=""; if(this.curValue.length>30)andMore="..."; var tNode=document.createTextNode(this.curValue.substring(0,30)+andMore); } divElmt.appendChild(tNode); pDestination.appendChild(divElmt); } TextBoxElement.prototype.HasChanged=function(){ if(this.GetPrevValue().replace(/\r|\n|\r\n/g,"")!=this.GetCurValue().replace(/\r|\n|\r\n/g,""))return true; return false; } TextBoxElement.prototype.AcceptChanges=function(){ if(this.currentMode=="displaying"){ this.prevValue=document.getElementById('div_'+this.name).innerHTML; } if(this.currentMode=="editing"){ this.prevValue=document.getElementById(this.name).value; } this.curValue=this.prevValue; } TextBoxElement.prototype.EditModeOUT=function(){ try{ /*this.curValue=document.getElementById(this.name).value; this.prevValue=this.curValue;*/ if(this.type=='password'){ document.getElementById('div_'+this.name).innerHTML="xxxxxxxxxx"; }else{ andMore=""; if(this.curValue.length>30)andMore="..."; document.getElementById('div_'+this.name).innerHTML=this.curValue.substring(0,30)+andMore; } this.currentMode="displaying"; }catch(ex) {DebugAlert("editModeOutError")} return false; } TextBoxElement.prototype.EditModeIN=function (){ this.prevValue=this.curValue; try{ if(this.lineNumber>1&&this.type!="password"){ document.getElementById('div_'+this.name).innerHTML=''; }else{ document.getElementById('div_'+this.name).innerHTML=''; } } catch(ex){ DebugAlert("EditModeINError:"+this.name); } this.currentMode="editing"; } TextBoxElement.prototype.GetPrevValue=function(){ return this.prevValue; } TextBoxElement.prototype.GetCurValue=function (){ try{ if(this.currentMode=="editing")return document.getElementById(this.name).value; }catch(e){ DebugAlert("ERREUR:common/TextBoxElement-getCurValue"+this.name+" - "+e.message); } return this.curValue; } var previousLigne; var previousClass; function SelectLigne(currentLigneName){ //retourne true si une nouvelle ligen est selectionnée, false si la ligne est déjà selectionné. currentLigne=document.getElementById(currentLigneName); if(currentLigne!=previousLigne){ if(previousLigne!=null ){ previousLigne.className=previousClass; } previousLigne=currentLigne previousClass=currentLigne.className; currentLigne.className='ligneselected'; return true; } return false; } var editingTextBoxArray=new Array(); function TextBoxEditModeIn(cell){ thisCell=document.getElementById(cell); thisCellInfo=new Array(); thisCellInfo.push(cell); cellText=thisCell.innerHTML; thisCellInfo.push(cellText); thisCell.innerHTML=''; editingTextBoxArray.push(thisCellInfo); } function TextBoxEditModeOut(){ modified=false; for(i=0;i50){ //myTD.innerHTML="
"+insideTextValue+"
"; myTD.innerHTML="
"+insideTextValue+"
"; }else{ var tNode=document.createTextNode(insideTextValue); myTD.appendChild(tNode); } return myTD; } function CreateTdURLTextNode(pLigne,tdClassName,insideTextValue,pSize,pURL){ var myTD=pLigne.insertCell(-1); var bSize=100; if(pSize!=null && pSize!=undefined)bSize=pSize; var bStyle="cell"; if(tdClassName!=null && tdClassName!=undefined)bStyle=tdClassName; myTD.setAttribute("class",bStyle); myTD.setAttribute("className",bStyle); myTD.setAttribute("width",bSize+"px"); var aNode=document.createElement('A'); aNode.href=pURL; //myTD.width=bSize+"px";alert("2"); var tNode=document.createTextNode(insideTextValue); aNode.appendChild(tNode); myTD.appendChild(aNode); return myTD; } function CreateButton(pValue,pClass,pOnClick){ var myButton=document.createElement('INPUT'); myButton.setAttribute("type","button"); myButton.setAttribute("value",pValue); myButton.setAttribute("class",pClass); myButton.setAttribute("className",pClass); myButton.onclick=function(){ eval(pOnClick); }; return myButton; } /////////////// // CHECKBOX//// /////////////// function CheckBoxElement(pName,pChecked,inputName){ this.name=pName; this.myCheckBox=document.createElement('INPUT'); this.myCheckBox.id=pName; this.myCheckBox.setAttribute("type","checkbox"); this.myCheckBox.setAttribute("name",inputName); this.ligneSelected=false; this.fieldName=inputName; this.curValue=pChecked; this.prevValue=pChecked; this.myCheckBox._parent=this; this.selectedByCheckBox=false; this.myCheckBox.onclick=function(){ if(this._parent.ligneSelected==true){ this._parent.curValue=0; if(this.checked==true)this._parent.curValue=1; this._parent.selectedByCheckBox=false; }else{ this._parent.selectedByCheckBox=true; } } return this; } CheckBoxElement.prototype.RestoreValue=function(){ this.myCheckBox.checked=false; if(this.prevValue==1)this.myCheckBox.checked=true; } CheckBoxElement.prototype.HasChanged=function(){ if(this.GetPrevValue()!=this.GetCurValue())return true; return false; } CheckBoxElement.prototype.AcceptChanges=function(){ this.prevValue=0; if(this.myCheckBox.checked==true)this.prevValue=1; } CheckBoxElement.prototype.GetPrevValue=function(){ return this.prevValue; } CheckBoxElement.prototype.GetCurValue=function(){ return this.curValue; } CheckBoxElement.prototype.EditModeOUT=function(){ this.ligneSelected=false; this.curValue=(this.myCheckBox.checked==true)?1:0; this.prevValue=this.curValue; //this.myCheckBox.disabled=true; } CheckBoxElement.prototype.EditModeIN=function (){ this.ligneSelected=true; this.prevValue=this.curValue; if(this.selectedByCheckBox==true){ this.curValue=1-this.prevValue; } } function AbsolutePositionInTable(pLigne,pTableName){ var trArray=GetTableElementsByTagName(pTableName,"tr"); for(g=0;g=GetTableNbLigne(tableName)){ GetTypeOneTableNode(tableName).appendChild(ligne); }else{ var lineToPush=((((document.getElementById(tableName)).getElementsByTagName('tbody'))[0]).getElementsByTagName('tr'))[position]; (((document.getElementById(tableName)).getElementsByTagName("tbody"))[0]).insertBefore(ligne,lineToPush); } for(p=1;p0){ rootElement=curTable.getElementsByTagName("tbody")[0]; } for(i=0;i0){ trList=tbody[0].getElementsByTagName("TR"); limitDel=0; positionDel=0; } while(trList.length>limitDel){ GetTypeOneTableNode(curTable).removeChild(trList[positionDel]); trList=GetTableElementsByTagName(curTable,"TR"); } curTable.selectedLigne=null; curTable.nbLigne=1; } xmlObj=pXMLDoc.documentElement; //var parentTableNode=curTable.parentNode; //curTable=parentTableNode.removeChild(curTable); //récupère les listes pour les selects et on construit les variables qui vont contenir les listes if(xmlObj!=null){ var xmlListOptionsValues=xmlObj.getElementsByTagName("valuesOptionsList"); if(xmlListOptionsValues[0]!=null){ for(var v=0;v0){ document.selectedElmtArray[0].UnSelectMe(); } //curLigne.myTr.SelectMe();"); } } } /*var tBodyArray=GetTableElementsByTagName(curTable,"TBODY"); var thisTBody=tBodyArray[0]; thisTBody.style.height="200px"; thisTBody.style.overflow="scroll";*/ } function Trim(s) { return s.replace(/^\s+/, '').replace(/\s+$/, ''); } function Swap(origin,destination){ if (document.getElementById(origin).selectedIndex!=-1){ originText=document.getElementById(origin).options[document.getElementById(origin).selectedIndex].text; originValue=document.getElementById(origin).value; document.getElementById(origin).options[document.getElementById(origin).selectedIndex]=null; document.getElementById(destination).options[document.getElementById(destination).options.length] = new Option(originText,originValue,1); } } function ExpandDiv(pThis,pOriginalBgColor,pTd){ var objTD = document.getElementById(pTd); objTD.fullDiv = pThis.cloneNode(true); objTD.fullDiv.onmouseover=null; objTD.fullDiv.onmouseout=null; objTD.fullDiv.style.overflow="visible"; objTD.fullDiv.style.position="absolute"; objTD.fullDiv.style.top=ds_gettop(objTD)+2; objTD.fullDiv.style.left=ds_getleft(objTD); objTD.fullDiv.style.width=objTD.offsetWidth+10; objTD.fullDiv.style.height=objTD.offsetHeight; objTD.fullDiv.onmouseout=function (){ CollapseDiv(objTD.id); } document.getElementById(pTd).appendChild(objTD.fullDiv); objTD.fullDiv.style.backgroundColor=pOriginalBgColor; } function CollapseDiv(pTd){ objTD = document.getElementById(pTd); objTD.removeChild(objTD.fullDiv); } function ds_gettop(el) { var elZindex=el.style.zIndex; var tmp = el.offsetTop; el = el.offsetParent; while(el) { if(elZindex!=el.style.zIndex)break; tmp += el.offsetTop; el = el.offsetParent; } return tmp; } function ds_getleft(el) { var elZindex=el.style.zIndex; var tmp = el.offsetLeft; el = el.offsetParent; while(el) { if(elZindex!=el.style.zIndex)break; tmp += el.offsetLeft; el = el.offsetParent; } return tmp; } function UploadImg(pDirectories,pResizevalues,pTargetsVal,pTargetsSrc,pUploadPath){ if(typeof(pUploadPath)=="undefined")pUploadPath="/commun/image_processing/upload_image.php"; LoadScript("/commun/scripts/upImageFlashCom.js?targetsValue="+pTargetsVal+"&targetsSrc="+pTargetsSrc); OpenDisabled(); upWindow=new Windoz(pUploadPath+"?rootDirectories="+pDirectories+"&resizeValues="+pResizevalues); upWindow.OnClose=function(){ _disabled.Hide(); } } if(typeof(_commonTools_loaded)!="undefined")_commonTools_loaded();//2012© Copyright Menta Solutions. All rights reserved.