alpha_full/pages/produits/gondoleScript.js
2026-04-06 22:58:51 +02:00

1 line
11 KiB
JavaScript
Executable File

// ---------------------------------------------------
// Produits->panier
// a optimiser ==>
// ne pas rediriger vers la page panier mais include du panier
// on ira dans le panier via menu
// ---------------------------------------------------
function changeQteGondole(idNum, idPrd){
var debugLocal=0;
if (debugLocal==1) {alert('idNum='+idNum+' idPrd='+idPrd);}
var item='select'+idNum;
if (document.getElementById(item)){
var quantite= document.getElementById(item).value;
if (document.getElementById('qte')) document.getElementById('qte').value = quantite;
else if (debugLocal==1) {alert(' erreur qte injoignable par Id =>' +document.getElementById('qte') ) ;}
}
else{
if (debugLocal==1) {alert(' erreur item : '+item+' injoignable par Id' );}
}
document.formProduit.target='_self';
document.formProduit.action='panier-encours-'+idPrd+'-'+quantite+'';
if (debugLocal==1) {alert('action='+ document.formProduit.action);}
document.formProduit.submit();
}
// ---------------------------------------------------
// Image grande zoom
// ---------------------------------------------------
function openImgGrand( adresse, titre ){
var width=580;
var height=720;
var left=(screen.availWidth - width )/2;
var top=(screen.availHeight - height )/2;
// alert(' Adresse = '+adresse);
// alert('titre='+titre);
var myNewWindow=window.open( adresse, '', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes');
myNewWindow.document.writeln("<!DOCTYPE html><html>");
myNewWindow.document.writeln("<head><title>"+titre+"</title>");
myNewWindow.document.writeln("<link rel=\"stylesheet\" type=\"text/css\" media=\"only screen\" href=\"https://www.123ventes.com/include/fa-web/css/all.css\" >");
myNewWindow.document.writeln("<script type=\"text/javascript\" src=\"./pages/produits/zoomImgScript.js\"></script>");
myNewWindow.document.writeln("<style>");
myNewWindow.document.writeln(".img-zoom-container { position: relative; max-height:300px; max-width:300px; text-align:center; margin:auto;}");
myNewWindow.document.writeln("#imgToZoom { position: relative; max-width: 98%; max-height: 98%; cursor: none; margin-top:10px; } ");
/* la taille de la lentille:*/
myNewWindow.document.writeln(".img-zoom-lens { z-index:10; position: absolute; border: 1px solid #d4d4d4; width: 40px; height: 40px; border-radius:50%} ");
/* la taille du résultat div:*/
myNewWindow.document.writeln("#myresult { border: 1px solid #d4d4d4; box-shadow: 4px 4px 8px rgba(0,0,0,0.5); width: 170px; height: 170px; margin:auto; margin-top:2px; display:block; padding-top:5px;} ");
myNewWindow.document.writeln("</style>");
myNewWindow.document.writeln("</head>");
myNewWindow.document.writeln("<body style=\"height:100%; background:white; \" >");
// ---------------------------------------------------
// Bouton fermer
// ---------------------------------------------------
myNewWindow.document.writeln("<div onClick=\"window.close();\" title=\"Fermer la fenêtre\" style=\"display: flex; align-items: center; justify-content: center; position:absolute; z-index:1000; text-align:center; padding:5px;border-radius:50%; height:30px; width:30px; margin:5px; background:lightgreen; cursor:pointer; right:10px;\" onmouseover=\"this.style.background='green';\" onmouseout=\"this.style.background='lightgreen';\" >✖</div>");
// ---------------------------------------------------
// Page
// ---------------------------------------------------
myNewWindow.document.writeln("<div style=\"position:relative; display:block; height:100%; \" >");
myNewWindow.document.writeln("<div class=\"img-zoom-container\" onmouseover=\"this.style.cursor=none;\" onMouseLeave=\"this.cursor:;\" >");
myNewWindow.document.writeln("<img id=\"imgToZoom\" title=\""+titre+"\" src=\"" + adresse + "\" >");
myNewWindow.document.writeln("</div>");
myNewWindow.document.writeln("<div style=\"margin-top:30px;\">");
myNewWindow.document.writeln("<br><br><div id=\"myresult\" ><span style=\"font-size:14px; font-style:italic; color:grey; font-familly: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\">zoom</span></div>");
myNewWindow.document.writeln("</div>");
myNewWindow.document.writeln("<div style=\"margin-top:15px;font-size:14px; font-style:italic; color:grey; font-familly: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\">Déplacez la souris sur l'image pour zoomer</div>");
myNewWindow.document.writeln("<div style=\"background:lightgrey; margin:10px; display:flex; justify-content: space-between; padding:10px; border-radius:5px;\" >");
myNewWindow.document.writeln("<span style=\"cursor:zoom-out\"; onClick=\"document.getElementById(\'imgToZoom\').style.transform=\'scale(0.5)\' ;\" >🔍 -- </span>");
myNewWindow.document.writeln("<span style=\"cursor:zoom-out\"; onClick=\"document.getElementById(\'imgToZoom\').style.transform=\'scale(0.8)\' ;\" >🔍 - </span>");
myNewWindow.document.writeln("&#160;<span style=\"cursor:zoom-in\"; onClick=\"document.getElementById(\'imgToZoom\').style.transform=\'scale(1.2)\' ;\" >🔎 + </span>");
myNewWindow.document.writeln("&#160;<span style=\"cursor:zoom-in\"; onClick=\"document.getElementById(\'imgToZoom\').style.transform=\'scale(1.5)\' ;\" >🔎 ++ </span>");
myNewWindow.document.writeln("</div>");
myNewWindow.document.writeln("</div>");
myNewWindow.document.writeln("<script type=\"text/javascript\">imageZoom(\'imgToZoom\', \'myresult\'); </script>");
myNewWindow.document.writeln("</body></html>");
myNewWindow.document.close();
}
// ---------------------------------------------------
// Diapo
// ---------------------------------------------------
//var compteur;
// ---------------------------------------------------
var liste = new Array('lienImageGd','lienImgGauche','lienImgDroite','lienImgDessus','lienImgDessous','lienVideo');
// flag EDT traduction
var legende = new Array('Image de gauche','Image de droite','Image de dessus','Image de dessous','Vidéo');
// ---------------------------------------------------
// Monter
// ---------------------------------------------------
function monter(totalImg){
var debugLocal;
var z;
var indice = 0;
var cpt = 0;
debugLocal=3;
if (debugLocal==1) alert('totalImg = ' +totalImg );
if (document.getElementById('cpt').value ) {cpt = parseInt(document.getElementById('cpt').value);}
if (debugLocal<=1) alert('Cpt = ' +cpt );
cpt=parseInt(cpt)+1;
if (cpt>totalImg ) {cpt=0;if (debugLocal<=2) alert('Remise CPt a 0') ;}
if (debugLocal<=1) alert('Cpt +1 = ' + cpt );
document.getElementById('cpt').value=cpt;
// On va affecter l'image grande a la vignette cliquée
test=liste[cpt].trim();
if (debugLocal<=2) alert('test = ' + test );
if (document.getElementById(test).value!='' && document.getElementById(test).value!='-'){
document.getElementById('imgPrd').style.display="block";
document.imgPrd.src = document.getElementById(test).value;
}
else {
test=liste[cpt+1].trim();
cpt=parseInt(cpt)+1;
if (document.getElementById(test).value!='' && document.getElementById(test).value!='-'){
document.getElementById('imgPrd').style.display="block";
document.imgPrd.src = document.getElementById(test).value;
}
else {
test=liste[cpt+2].trim();
cpt=parseInt(cpt)+1;
if (document.getElementById(test).value!='' && document.getElementById(test).value!='-'){
document.getElementById('imgPrd').style.display="block";
document.imgPrd.src = document.getElementById(test).value;
}
}
// document.getElementById('imgPrd').style.display="none";
}
if (debugLocal<=2) alert('imgPrd = ' +document.getElementById(test).value );
// on veut afficher les 3 prochaines vignettes, si 6 on revient à 1
for(z=0; z<3; z++){
indice = cpt + z;
if (indice > 3 ){
if (cpt==3 ) { indice=z; } ; // serie 561
if (cpt==4 ) { indice=z-1; } ; // serie 612
if (cpt==5 ) { indice=z-2; } ; // serie 123
}
if (debugLocal==1) alert('indice = ' +indice );
//Le tableau legende commence a zero
if(liste[indice]!='' && liste[indice]!="-"){
document.getElementById('vignette'+z).style.display="block";
}
else {
document.getElementById('vignette'+z).style.display="none";
}
document.getElementById('vignette'+z).value = document.getElementById(liste[indice]).value;
if (debugLocal==2) alert ('vignette['+z+'] = '+document.getElementById(liste[$z]).value);
} //for+
if (debugLocal<=2) alert('Fin monter');
document.formProduit.submit();
}
// ---------------------------------------------------
// Descendre
// ---------------------------------------------------
function descendre(totalImg){
var debugLocal;
var z;
var indice = 0;
var cpt = 0;
debugLocal=3;
if (document.getElementById('cpt') ) {
if (debugLocal==1) alert('Cpt = ' +document.getElementById('cpt').value );
if (document.getElementById('cpt').value ) cpt = document.getElementById('cpt').value;
}
cpt=parseInt(cpt)-1;
if (cpt == 0 ) {cpt = totalImg;}
if (cpt == -1 ) {cpt = 0;}
document.getElementById('cpt').value=cpt;
//Le tableau liste commence a zero
test=liste[cpt-1].trim();
if (document.getElementById(test).value!='' && document.getElementById(test).value!='-'){
document.getElementById('imgPrd').style.display="block";
document.imgPrd.src = document.getElementById(test).value;
// document.getElementById('legende').value = legende[cpt-1];
}
else {
test=liste[cpt-2].trim();cpt=parseInt(cpt)-1;
if (document.getElementById(test).value!='' && document.getElementById(test).value!='-'){
document.getElementById('imgPrd').style.display="block";
document.imgPrd.src = document.getElementById(test).value;
// document.getElementById('legende').value = legende[cpt-1];
}
else {
test=liste[cpt-2].trim();cpt=parseInt(cpt)-1;
if (document.getElementById(test).value!='' && document.getElementById(test).value!='-'){
document.getElementById('imgPrd').style.display="block";
document.imgPrd.src = document.getElementById(test).value;
// document.getElementById('legende').value = legende[cpt-1];
}
}
}
if (debugLocal==1) alert('Cpt = ' +document.getElementById('cpt').value );
// on veut afficher les 3 prochaines vignettes, si 6 on revient à 1
for(z=0; z<3; z++){
indice = cpt - z;
if (indice < 1 ){
if (cpt==1 ) { indice=6-z; } ; // serie 561
if (cpt==2 ) { indice=6-z; } ; // serie 612
if (cpt==3 ) { indice=5; } ; // serie 123
}
if (debugLocal==1) alert('indice = ' +indice );
//Le tableau legende commence a zero
if(liste[indice]!='' && liste[indice]!="-"){
document.getElementById('vignette'+z).style.display="block";
}
else {
document.getElementById('vignette'+z).style.display="none";
}
document.getElementById('vignette'+z).value = document.getElementById(liste[indice-1]).value;
if (debugLocal==1) alert ('vignette'+z+' = '+document.getElementById(liste[indice-1]).value);
} //for+
if (debugLocal==1) alert('Fin descendre');
document.formProduit.submit();
}