/************************** * This derivative version of subModal can be downloaded from http://gabrito.com/files/subModal/ * Original By Seth Banks (webmaster at subimage dot com) http://www.subimage.com/ * Contributions by Eric Angel (tab index code), Scott (hiding/showing selects for IE users), Todd Huss (submodal class on hrefs, moving div containers into javascript, phark method for putting close.gif into CSS), Thomas Risberg (safari fixes for scroll amount), Dave Campbell (improved parsing of submodal-width-height class) **************************/ var activeCentreAuto = false; var retourId = 0; /** * Initializes popup code on load. */ function initPopUp(BtFermer,titre,id) { // Add the HTML to the body var body = document.getElementsByTagName('body')[0]; //on crée le fond (masque ) ... var popmask = document.createElement('div'); popmask.id = 'popupMask'; //on crée la popup en elle même .... var popcont = document.createElement('div'); popcont.id = 'popupContainer'; //s'il y a un titre on l'affiche sinon non if(titre!='' || BtFermer){ //on crée la barre du haut .. var barreHaut = document.createElement('div'); barreHaut.id = 'popupTitleBar'; //dans la barre il y a le titre var barreTitre = document.createElement('div'); barreTitre.id = 'popupTitle'; barreHaut.appendChild(barreTitre); //et le bouton fermer if(BtFermer){ var barreOptions = document.createElement('div'); barreOptions.id = 'popupControls'; if(id){ /* Si == true */ var retour = document.createElement('a'); retour.setAttribute('onclick',"afficheModal('','modal_ajout_selection.php?id="+retourId+"&aj=0','500','400','La franchise a été ajoutée à votre sélection','',true)"); retour.onclick=function(){ afficheModal('','modal_ajout_selection.php?id='+retourId+'&aj=0','500','400','La franchise a été ajoutée à votre sélection','',true); }; var retourTxt = document.createTextNode('Retour'); retour.appendChild(retourTxt); barreOptions.appendChild(retour); var txt = document.createTextNode(' | '); barreOptions.appendChild(txt); /* ----------- */ } /* Si BtFermer == true */ var fermer = document.createElement('a'); fermer.setAttribute('onclick','closeModal();'); fermer.onclick=closeModal; var fermerTxt = document.createTextNode('Fermer '); fermer.appendChild(fermerTxt); var croix = document.createElement('img'); croix.setAttribute('src','images/picto_fermer.gif'); fermer.appendChild(croix); barreOptions.appendChild(fermer); /* ------------------- */ barreHaut.appendChild(barreOptions); } popcont.appendChild(barreHaut); } //on creer la div de contenu .. var contenuPop = document.createElement('div'); contenuPop.id = 'contenuPop'; popcont.appendChild(contenuPop); body.appendChild(popmask); body.appendChild(popcont); //hauteur total de l'ecran .... document.getElementById("popupMask").style.height = getViewportHeight(1) + "px"; } ////// function pour centrer la fenetre sur la page .... var gi = 0; function centerPopWin(width, height) { if (activeCentreAuto == true) { if (width == null || isNaN(width)) width = document.getElementById("popupContainer").offsetWidth; if (height == null) height = document.getElementById("popupContainer").offsetHeight; var fullHeight = getViewportHeight(); var fullWidth = getViewportWidth(); widthChange = Math.round(fullWidth*0.9); // document.getElementById("popupContainer").style.width = widthChange + "px"; // width = widthChange; if(height>getViewportHeight()){ heightChange = Math.round(fullHeight*0.9); document.getElementById("popupContainer").style.height = heightChange + "px"; height = heightChange; // document.getElementById("contenuPop").style.height = (heightChange-25) + "px"; }else{ document.getElementById("popupContainer").style.height = height + "px"; // document.getElementById("contenuPop").style.height = (height-25) + "px"; } // scLeft and scTop changes by Thomas Risberg var scLeft; if (self.pageYOffset) { scLeft = self.pageXOffset; } else if (document.documentElement && document.documentElement.scrollTop) { scLeft = document.documentElement.scrollLeft; } else if (document.body) { scLeft = document.body.scrollLeft; } if(isFirefox){ //selon s'il y a la scrollbar ou pas ... if(document.body.offsetWidth!=fullWidth) document.getElementById("popupMask").style.width = (document.body.offsetWidth) + "px"; else document.getElementById("popupMask").style.width = (fullWidth) + "px"; }else{ document.getElementById("popupMask").style.width = fullWidth + "px"; } var navScrollTop = 0; if(document.documentElement.scrollTop){ navScrollTop = document.documentElement.scrollTop; }else{ navScrollTop = document.body.scrollTop; } var marginTop= Math.round(((fullHeight - height)/2) + navScrollTop); // alert(fullHeight +" - "+ height +" - "+document.documentElement.scrollTop); document.getElementById("popupContainer").style.top = marginTop + "px"; document.getElementById("popupContainer").style.left = Math.round((scLeft + ((fullWidth - width) / 2))) + "px"; } } function centerPopWinNo(width, height) { if (activeCentreAuto == true) { if (width == null || isNaN(width)) width = document.getElementById("popupContainer").offsetWidth; if (height == null) height = document.getElementById("popupContainer").offsetHeight; var fullHeight = getViewportHeight(); var fullWidth = getViewportWidth(); // scLeft and scTop changes by Thomas Risberg var scLeft; if (self.pageYOffset) { scLeft = self.pageXOffset; } else if (document.documentElement && document.documentElement.scrollTop) { scLeft = document.documentElement.scrollLeft; } else if (document.body) { scLeft = document.body.scrollLeft; } if(isFirefox){ //selon s'il y a la scrollbar ou pas ... if(document.body.offsetWidth!=fullWidth) document.getElementById("popupMask").style.width = (document.body.offsetWidth) + "px"; else document.getElementById("popupMask").style.width = (fullWidth) + "px"; }else{ document.getElementById("popupMask").style.width = fullWidth + "px"; } var navScrollTop = 0; if(document.documentElement.scrollTop){ navScrollTop = document.documentElement.scrollTop; }else{ navScrollTop = document.body.scrollTop; } var marginTop= Math.round(((fullHeight - height)/2) + navScrollTop); // alert(fullHeight +" - "+ height +" - "+document.documentElement.scrollTop); document.getElementById("popupContainer").style.top = marginTop + "px"; document.getElementById("popupContainer").style.left = Math.round((scLeft + ((fullWidth - width) / 2))) + "px"; } } addEvent(window, "resize", centerPopWin);// quand on retaille la fenetre ... // quand on se déplace avec la scroll Bar .... window.onscroll = function() { var hauteurTotal = document.documentElement.scrollHeight; if(isMSIE)var hauteurScroll=document.body.scrollTop; else var hauteurScroll= document.documentElement.scrollTop; if(hauteurScroll height) { height = document.documentElement.clientHeight; } // last for safari if(document.body.scrollHeight > height) { height = document.body.scrollHeight; } return height; }else{ // Taille visible du navigateur var height = isMSIE ? window.document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight : window.innerHeight; return height; } } function getViewportWidth() { if (document.body) return document.body.clientWidth; else if (window.innerWidth!=window.undefined) return window.innerWidth; else if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; else return window.undefined; } // traitement AJAX des fenêtres modales (message) //savoir si on garde en cache ou pas ////// chargement du contenu ....... var enableCache = false; var jsCache = new Array(); var dynamicContent_ajaxObjects = new Array(); function ajax_showContent(divId,ajaxIndex,url){ var targetObj = document.getElementById(divId); targetObj.innerHTML = dynamicContent_ajaxObjects[ajaxIndex].response; if(enableCache){ jsCache[url] = dynamicContent_ajaxObjects[ajaxIndex].response; } dynamicContent_ajaxObjects[ajaxIndex] = false; ajax_parseJs(targetObj); } function ajax_loadContent(divId,url){ if(enableCache && jsCache[url]){ document.getElementById(divId).innerHTML = jsCache[url]; return; } var ajaxIndex = dynamicContent_ajaxObjects.length; document.getElementById(divId).innerHTML = "Chargement ..."; dynamicContent_ajaxObjects[ajaxIndex] = new sack(); dynamicContent_ajaxObjects[ajaxIndex].method ="GET"; dynamicContent_ajaxObjects[ajaxIndex].requestFile = url; // Specifying which file to get dynamicContent_ajaxObjects[ajaxIndex].onCompletion = function(){ ajax_showContent(divId,ajaxIndex,url); //style pour les checkbox ....... if(typeof(styleCheckboxesAndRadiobuttons)!='undefined') styleCheckboxesAndRadiobuttons(); if(typeof(checkForLabels)!='undefined') checkForLabels(); //pour les inputs if(typeof(initInput)!='undefined') initInput(); }; // Specify function that will be executed after file has been found dynamicContent_ajaxObjects[ajaxIndex].runAJAX();// Execute AJAX function } function ajax_parseJs(inputObj){ var jsTags = inputObj.getElementsByTagName('SCRIPT'); for(var no=0;no