PageSourceSearch

https://www.gites-de-france-var.fr/lib_2/js/foncs/photos.js

js gites-de-france-var.fr collected 2026-10-02 20:52:18 UTC 20,881 bytes, 515 lines download raw bytes

1// Adrien 10/05/23 : Attention, ce fichier n'est plus utilisé sur la majorité des sites web excepté sur le compte client et le script de résa
2
3var NB_PHOTOS_MAX = 150;
4
5function initAlbumPhoto(qsForVisu){
6		if($("div_fiche_album")){
7		var tabObj=new Array();
8		var photoPrinc=document.getElementById("img_fiche_photoPrincipale");
9		var fenetre=0;
10		var largTotal=0;xFinTotal=0;
11		var maxLarg=0;
12		var maxHaut=0;
13
14		var nomPhotoRef="img_fiche_photoAlbum1";
15		var nomPhotoRefFngf="img_fiche_photoAlbumFngf1";
16
17		var legendePhoto = document.getElementById("fiche_legendePhotos");
18
19		//jslog(qsForVisu);
20		if (!qsForVisu)qsForVisu="";
21
22		if (!document.getElementById(nomPhotoRef) && document.getElementById(nomPhotoRefFngf))var fngf=true;
23		else fngf=false;
24
25		for (var i=1;i<=NB_PHOTOS_MAX;i++){
26			if (fngf)var objPhoto=document.getElementById("img_fiche_photoAlbumFngf"+i);
27			else var objPhoto=document.getElementById("img_fiche_photoAlbum"+i);
28			if (objPhoto){
29				tabObj.push($(objPhoto));
30				/*if (objPhoto.width>maxLarg)maxLarg=objPhoto.naturalWidth;
31				if (objPhoto.height>
31maxHaut)maxHaut=objPhoto.naturalHeight;	*/
32				if (getLargeurReelleImage(objPhoto)>maxLarg)maxLarg=getLargeurReelleImage(objPhoto);
33				if (getHauteurReelleImage(objPhoto)>maxHaut)maxHaut=getHauteurReelleImage(objPhoto);
34				//jslog("max_w:"+maxLarg+" max_h"+maxHaut);
35			}
36		}
37		for (var i=0;i<tabObj.length;i++){
38			new Effect.Opacity(tabObj[i], {from: 1, to: 0.9});
39			tabObj[i].onmouseover=function(evt){
40				if (photoPrinc)photoPrinc.src2=photoPrinc.src;
41				if (photoPrinc && this.src)photoPrinc.src=this.src;
42				this.parentNode.parentNode.addClassName("photo_active");
43				if($("fiche_legendePhotos")){
44					$("fiche_legendePhotos").innerHTML2=legendePhoto.innerHTML;
45					$("fiche_legendePhotos").innerHTML=this.getAttribute("data-txt");
46                    
47				}
48				new Effect.Opacity(this, {from: 0.9, to: 1});
49
50			}
51			tabObj[i].onmouseout=function(evt){
52				new Effect.Opacity(this, {from: 1, to: 0.9});
53				if (photoPrinc && photoPrinc.src2)photoPrinc.src=photoPrinc.src2;
54				if(this.parentNode.parentNode.hasClassName("photo_active"))this.parentNode.parentNode.removeClassName("photo_active");
55				if ($("fiche_legendePhotos")) $("fiche_legendePhotos").innerHTML=legendePhoto.innerHTML2;
56			}
57
58			tabObj[i].num=i;
59			/*if(($("div_fiche_photoSuppl"))){
60				if (!fngf){
61					tabObj[i].onclick=function(evt){
62						afficheDiaporama(qsForVisu,this.num,maxLarg,maxHaut);
63					}
64				}
65			}*/
66			var larg=parseInt(tabObj[i].offsetWidth);
67			if (larg>fenetre)fenetre=larg;
68			largTotal+=larg;
69
70			if (tabObj[i] && tabObj[i].offsetLeft){
71				var xFin=(parseInt(tabObj[i].offsetLeft)+larg);
72				if (xFinTotal<xFin)xFinTotal=xFin;
73
74			}
75			if (xFinTotal<largTotal)xFinTotal=largTotal;
76		}
77
78		var divPrinc=$(document.getElementById("div_fiche_album"));
79		if (!divPrinc)return;
80
81		var btPrec=$(document.getElementById("spanFiche_album_prev"));
82		var btSuiv=$(document.getElementById("spanFiche_album_next"));
83		var ulPrinc=$(document.getElementById("lst_fiche_photos_suppl"));
84
85		btSuiv.style.visibility="hidden";
86		btPrec.style.visibility="hidden";
87
88		//alert(xFinTotal+">"+parseInt(divPrinc.offsetWidth));
89		if (xFinTotal>parseInt(divPrinc.offsetWidth)){
90			btSuiv.style.visibility="visible";
91		}
92
93
94		ulPrinc.style.position="absolute";
95		var pas=fenetre*2;
96
97		btSuiv.onmousedown=function(){
98			$(document.getElementById("spanFiche_album_prev")).style.visibility="visible";
99			var decal=pas*-1;
100
101
102			if(btSuiv.hasClassName("span_verticale")){
103				var xFinPrinc=parseInt(ulPrinc.offsetTop)+parseInt(divPrinc.offsetTop)+xFinTotal;
104				var xFinVisu=parseInt(divPrinc.offsetTop)+parseInt(divPrinc.offsetWidth);
105			}
106			else {
107				var xFinPrinc=parseInt(ulPrinc.offsetLeft)+parseInt(divPrinc.offsetLeft)+xFinTotal;
108				var xFinVisu=parseInt(divPrinc.offsetLeft)+parseInt(divPrinc.offsetWidth);
109			}
110			var xFinApresPrinc=xFinPrinc+decal-50;
111
112			if (xFinApresPrinc<xFinVisu){
113				decal=((xFinPrinc-xFinVisu)*-1);
114				decal=decal-10;
115				this.style.visibility="hidden";
116			}
117			if(btSuiv.hasClassName("span_verticale")) new Effect.Move(ulPrinc, {y: decal, mode: 'relative'});
118			else new Effect.Move(ulPrinc, {x: decal, mode: 'relative'});
119		}
120		btPrec.onmousedown=function(){
121			$(document.getElementById("spanFiche_album_next")).style.visibility="visible";
122			var decal=pas+50;
123			if(btSuiv.hasClassName("span_verticale")) var xDebPrinc=parseInt(ulPrinc.offsetTop);
124			else var xDebPrinc=parseInt(ulPrinc.offsetLeft);
125			var xDebApresPrinc=xDebPrinc+decal;
126			if (xDebApresPrinc>0){
127				decal=xDebPrinc*-1;
128				this.style.visibility="hidden";
129			}
130			if(btPrec.hasClassName("span_verticale")) new Effect.Move(ulPrinc, {y: decal, mode: 'relative'});
131			else new Effect.Move(ulPrinc, {x: decal, mode: 'relative'});
132		}
133	}
134
135}
136
137function initAlbumPhotoJquery(){
138	if(jQuery("#div_fiche_albumJquery").length>0){
139        var nbParNav = jQuery("#div_fiche_albumJquery").attr("data-nbparslide");
140        var nbPhotos = jQuery("#div_fiche_albumJquery").attr("data-nbPhotos");
141        
142        var continuous = false;
143        if(jQuery("#div_fiche_albumJquery").attr("data-continuous")=="true" && (parseInt(nbPhotos) > parseInt(nbParNav))){
144            continuous = true;   
145        }		
146		var sudoSlider1 = jQuery("#div_fiche_albumJquery").sudoSlider({
147			autowidth:false,
148			slideCount:nbParNav,
149			moveCount:nbParNav,
150			speed:400,
151            continuous:continuous
152		});
153        var i=1;
154        var tabSudoSlider1 = new Array();
155        while(jQuery("#div_fiche_albumJquery"+i).length>0){
156            nbParNav = jQuery("#div_fiche_albumJquery"+i).attr("data-nbparslide");
157            var nbPhotos = jQuery("#div_fiche_albumJquery"+i).attr("data-nbPhotos");
158            
159            var continuous = false;
160            if(jQuery("#div_fiche_albumJquery"+i).attr("data-continuous")=="true"  && (parseInt(nbPhotos) > parseInt(nbParNav))){
161                continuous = true;   
162            }
163            tabSudoSlider1[i] = jQuery("#div_fiche_albumJquery"+i).sudoSlider({
164                autowidth:false,
165                slideCount:nbParNav,
166                moveCount:nbParNav,
167                speed:400,
168                continuous:continuous
169            });
170        
171            i++;
172        }
173	}
174    
175	if(jQuery("#div_fiche_sliderJquery").length>0){
176		var sudoSlider2 = jQuery("#div_fiche_sliderJquery").sudoSlider({
177			autowidth:false,
178			speed:400,
179			numeric:true,
180			prevNext:false
181		});
182	}
183	if(jQuery("#div_fiche_sliderJquery_prevnext").length>0){
184		var sudoSlider3 = jQuery("#div_fiche_sliderJquery_prevnext").sudoSlider({
185			autowidth:false,
186			speed:400,
187			prevNext:true
188		});
189	}
190	if(jQuery("#div_diaporamaInterne").length>0){
191		var tabImages = new Array();
192
193		jQuery("#div_diaporamaInterneListePhotos img").each(function(){
194			tabImages.push(jQuery(this).attr("src"));
195		});
196
197		var sudoSlider4 = jQuery("#div_diaporamaInterneContent").sudoSlider({
198			ajax: tabImages,
199			numeric:true,
200			preloadAjax:true,
201			fade:true,
202			ajaxLoadFunction: function(t){
203				var url = jQuery(this).children().attr('src');
204				jQuery('.controls li a span').eq(t-1).html('<img src="'+url+'" />');
205				jQuery("#div_diaporamaInterneContent img").bind("click",function(){
206					var tabPhotosDiapo = new Array();
207					tabPhotosDiapo.push(jQuery(this).attr("src"));
208					jQuery(this).parent().nextAll().children("img").each(function(){
209						tabPhotosDiapo.push(jQuery(this).attr("src"));
210					});
211					jQuery(this).parent().prevAll().children("img").each(function(){
212						tabPhotosDiapo.push(jQuery(this).attr("src"));
213					});
214					jQuery.fancybox(tabPhotosDiapo,{prevEffect : 'fade',nextEffect : 'fade'});
215				});
216			}
217		});
218		
219	}
220        
221    if(jQuery(".lance_fancybox").length>0){
222		jQuery(".lance_fancybox").bind("click",function(){
223			jQuery(".itea_fancyboxPrincipale").trigger('click');
224		});
225	}
226    
227    if(jQuery("#lst_fiche_photos_supplJqueryAvecSurvol").length>0 && jQuery("#img_fiche_photoPrincipale").length>0){        
228		jQuery("#lst_fiche_photos_supplJqueryAvecSurvol img").mouseover(function(){
229            var imgHover = jQuery(this).attr("data-hover");            
230			jQuery("#img_fiche_photoPrincipale").attr("src",imgHover);
231            jQuery("#img_fiche_photoPrincipale").parent("a").attr("href",imgHover.split("?")[0]);
232            jQuery("#img_fiche_photoPrincipale").parent("a").attr("title",jQuery(this).parent("a").attr("title"));
233            jQuery("#img_fiche_photoPrincipale").attr("title",jQuery(this).parent("a").attr("title"));
234		});
235        setTimeout(function(){
236            var tabImg = new Array();
237            jQuery("#lst_fiche_photos_supplJqueryAvecSurvol img").each(function(){
238                tabImg.push(jQuery(this).attr("data-hover"));
239            });
240            jQuery.preLoadImages(tabImg);
241        }, 5000);
242	}
243    
244    if (jQuery("#lst_fiche_photos_supplJqueryAvecSurvol").length > 0 && jQuery(".div_sliderMobileContent").length > 0) {
245        var changeOnClick = false;
246        if(jQuery("#lst_fiche_photos_supplJqueryAvecSurvol").attr("data-dataChangeOnclick")=="true"){
247            changeOnClick = true; 
248        }
249        if(changeOnClick){
250            jQuery("#lst_fiche_photos_supplJqueryAvecSurvol img").click(function () {
251                var imgHover = jQuery(this).attr("data-hover");
252                var imgPos = jQuery(this).attr("data-pos");
253                jQuery(".div_sliderMobileContent img").hide();
254                jQuery(".div_sliderMobileContent img[data-pos=" + imgPos + "]").attr('src', imgHover).show();                
255                setHtmlLegendePhotoSlider(jQuery(this).data('ident'),jQuery(this).data('txt'));
256                var listeUlDefilement = jQuery('ul.infosSlide');
257                listeUlDefilement.find('li.active').removeClass("active");
258                listeUlDefilement.find('li[data-pos="'+imgPos+'"]').addClass("active");
259            });
260        }
261        else{
262            jQuery("#lst_fiche_photos_supplJqueryAvecSurvol img").mouseover(function () {
263                var imgHover = jQuery(this).attr("data-hover");
264                var imgPos = jQuery(this).attr("data-pos");
265                jQuery(".div_sliderMobileContent img").hide();
266                jQuery(".div_sliderMobileContent img[data-pos=" + imgPos + "]").attr('src', imgHover).show();
267            });
268        }
269    }    
270    
271    initClicPhotoChambreHotes();
272}
273
274function initAlbumPhoto_owlCarousel(){
275    (function($){
276        if($('#div_fiche_albumJqueryOwlCarousel').length>0){
277            var nbPhoto = parseInt($('#div_fiche_albumJqueryOwlCarousel').data('nbphotos'));
278            var nbParSlide = parseInt($('#div_fiche_albumJqueryOwlCarousel').data('nbparslide'));
279            var nbAffiche = parseInt($('#div_fiche_albumJqueryOwlCarousel').data('nbaffiche'));
280            var continuous = $('#div_fiche_albumJqueryOwlCarousel').data('continuous');
281            var margin = parseInt($('#div_fiche_albumJqueryOwlCarousel').data('margin'));
282            
283            var loop = false;
284            if(nbPhoto > nbAffiche && continuous==true){
285                loop = true;
286            }
287            
288            $('.div_diapoFicheOwlCarousel').owlCarousel({
289                loop:loop,
290                margin:margin,
291                nav:true,
292                responsive:{
293                    0:{
294                        items:nbAffiche,
295                        slideBy:nbParSlide
296                    }
297                }
298            });
299            
300            var changeOnClick = false;
301            if(jQuery("#div_fiche_albumJqueryOwlCarouselContent_avecSurvol").attr("data-dataChangeOnclick")=="true"){
302                changeOnClick = true; 
303            }
304            
305            if(changeOnClick){
306                jQuery("#div_fiche_albumJqueryOwlCarouselContent_avecSurvol img").click(function () {
307                    var imgHover = jQuery(this).attr("data-hover");
308                    var imgPos = jQuery(this).attr("data-pos");
309                    jQuery(".div_sliderMobileContent img").hide();
310                    jQuery(".div_sliderMobileContent img[data-pos=" + imgPos + "]").attr('src', imgHover).show();                
311                    setHtmlLegendePhotoSlider(jQuery(this).data('ident'),jQuery(this).data('txt'));
312                    var listeUlDefilement = jQuery('ul.infosSlide');
313                    listeUlDefilement.find('li.active').removeClass("active");
314                    listeUlDefilement.find('li[data-pos="'+imgPos+'"]').addClass("active");
315                });
316            }
317            else{
318                jQuery("#div_fiche_albumJqueryOwlCarouselContent_avecSurvol img").mouseover(function () {
319                    var imgHover = jQuery(this).attr("data-hover");
320                    var imgPos = jQuery(this).attr("data-pos");
321                    jQuery(".div_sliderMobileContent img").hide();
322                    jQuery(".div_sliderMobileContent img[data-pos=" + imgPos + "]").attr('src', imgHover).show();
323                });
324            }
325            
326        }
327    })(jQuery);
328}
329
330function initFancyBoxDeBase(){
331	if(jQuery(".itea_fancybox").length>0){
332		jQuery(".itea_fancybox").bind('click', function() {
333				var photos = [];
334				var actual = jQuery(this).attr('href');
335				actual = actual.replace(/\//g,'\\\/')
336				Expression = new RegExp(actual)
337				var postion = 0;
338
339				//je génère en live mon tableau de photo en fonction de l'attribut rel=
340				jQuery.each(jQuery(".itea_fancybox[rel="+jQuery(this).attr('rel')+"]"), function(key, value) {
341					photos.push(value);
342					if (Expression.test(value)) postion = key
343				});
344				//Si je n'ai pas de suites de photos (si rel est absent), ma lightbox n'e sou'ouvrira rien
345				if(photos.length==0) photos = jQuery(this)
346				//je lance ma fancybox avec la bonne image de départ
347                                var paramsFancyBox = {
348                                    openEffect	: 'none',
349                                    closeEffect	: 'none',
350                                    prevEffect : 'fade',
351                                    nextEffect : 'fade',
352                                    index : postion, 
353                                    titlePosition :'over'
354				};
355				jQuery.fancybox.open(photos,paramsFancyBox);
356				// au hover des éléments suivants/précedans dans la fancybox, je hack le CSS pour ie7 et ie8
357				if(jQuery.browser.msie && jQuery.browser.version<9){
358					jQuery(".fancybox-nav").live("mouseover",function(){jQuery(this).children("span").css("visibility","visible")});
359					jQuery(".fancybox-nav").live("mouseout",function(){jQuery(this).children("span").css("visibility","hidden")});
360				}
361				// j'interdit l'ouverture dans un nouvel onglet (merci ie9)
362				return false;
363
364		});
365	}
366	if(jQuery(".lancerFancyboxDesVignettes").length>0){
367		jQuery(".lancerFancyboxDesVignettes").bind('click', function() {
368            var idListe = jQuery(this).attr('data-id');
369            if(jQuery('#'+idListe).length > 0){
370                jQuery('#'+idListe+' a.itea_fancybox  img[data-hover="'+jQuery(this).children('img').attr('src')+'"]').trigger('click');
371            }
372            return false;
373		});
374	}
375}
376
377function init_sliderMobile(){
378    jQuery('body').delegate('.div_sliderMobile ul.infosSlide li','click', function () {
379        jQuery(this).parent().children('li').removeClass('active');
380        jQuery(this).addClass('active');
381
382        var pos = jQuery(this).attr('data-pos');
383        jQuery(this).closest('.div_sliderMobile').children('.div_sliderMobileContent').find('img').hide();
384        var photoAmontrer = jQuery(this).closest('.div_sliderMobile').children('.div_sliderMobileContent').find('img[data-pos=' + pos + ']');
385        photoAmontrer.attr('src', photoAmontrer.attr('data-original'));
386        photoAmontrer.show();
387        setHtmlLegendePhotoSlider(photoAmontrer.data("ident"), photoAmontrer.attr("title"));
388        if (photoAmontrer.next().length > 0) {
389            photoAmontrer.next().attr('src', photoAmontrer.next().attr('data-original'));
390        }
391    });
392    jQuery('body').delegate('.div_sliderMobile .divInfosSlideNextPrev .suivant', 'click', function () {
393        init_sliderMobile_defiler(this);
394    });
395    jQuery('body').delegate('.div_sliderMobile .divInfosSlideNextPrev .precedent', 'click', function () {
396        init_sliderMobile_defiler(this, 'prev');
397    });
398    //fiche 251411
399    jQuery('body').delegate('.div_sliderMobile .divInfosSlideNextPrev', 'click', function () {
400        var $elem = jQuery(this);
401        setTimeout(function () {
402            $elem.removeClass('iteaStatMe_ALBUM_PHOTO');
403        }, 300);
404    });
405    if(jQuery(".div_sliderMobile").length>0){
406        if(jQuery('.div_sliderMobile ul.infosSlide').length > 0){
407
408            // ne marche pas sur les listes lorsqu'il y a un <a> autour de l'image.
409            // Pour forcer le swipe (mais le click sur l'image n'ouvre plus la fiche hébergement, voici l'option à ajouter après le threshold : 
410            // excludedElements:'button,input' /*redéfinir les éléments exclus, sinon <a> est dans la liste par défaut*/
411            // J'ai trouvé un autre système en natif qui marche bien.
412            
413            var x1 = 0;
414            var x2 = 0;
415            
416            jQuery('.div_sliderMobile .div_sliderMobileContent img').bind('touchstart', function (e) {
417                x1 = getCoord(e, 'X');
418            });
419
420            jQuery('.div_sliderMobile .div_sliderMobileContent img').bind('touchend', function (e) {
421                x2 = getCoord(e, 'X');
422                var diff = x2 - x1;
423                if (diff < -60) {
424                    init_sliderMobile_defiler(this);
425                }
426                else if (diff > 60) {
427                    init_sliderMobile_defiler(this,'prev');
428                }
429            });
430            
431        }
432        
433        if(jQuery(".a_sliderMobileZoom").length>0){            
434            jQuery(".a_sliderMobileZoom").click(function(){              
435                tabTout = new Array();
436                jQuery("img[rel='sliderMobile']").each(function(){
437                    var obj = {href:jQuery(this).attr("data-zoom"), title:jQuery(this).attr("title")};
438                    tabTout.push(obj);
439                });
440
441                window.indexPhotoAffiche = 0;
442                jQuery(".div_sliderMobileContent img").each(function(){
443                    if(jQuery(this).is(":visible")){
444                        window.indexPhotoAffiche = parseInt(jQuery(this).attr("data-pos")) - 1;
445                    }
446                })
447
448                jQuery.fancybox.open(tabTout,{
449                    prevEffect : 'fade',
450                    nextEffect : 'fade',
451                    index : window.indexPhotoAffiche
452                });
453                
454            })
455        }
456        
457        setTimeout(function(){
458            jQuery(".div_sliderMobile").find('img[data-pos="2"]').each(function(){
459                jQuery(this).attr("src",jQuery(this).attr("data-original"));
460             });
461        }, 3000);        
462    }
463}
464
465function init_sliderMobile_defiler(element,direction){
466    var dataPosition;
467    var divParente = jQuery(element).parents('.div_sliderMobile');
468    var listeUlDefilement = jQuery('ul.infosSlide[data-ident="'+jQuery(element).data("ident")+'"]',divParente);
469    if(direction==undefined){
470        var direction='next';
471    }
472    if(direction == 'prev' ){
473        dataPosition  = jQuery(listeUlDefilement).find('li.active').prev().attr('data-pos');
474    }else{
475        dataPosition  = jQuery(listeUlDefilement).find('li.active').next().attr('data-pos');
476    }
477    if(jQuery(listeUlDefilement).children('[data-pos='+dataPosition+']').length == 0){
478        if(direction == 'prev' ){
479            dataPosition = jQuery(listeUlDefilement).children().length;
480        }else{
481            dataPosition = 1;
482        }
483    }
484    jQuery(listeUlDefilement).children('[data-pos='+dataPosition+']').trigger('click');
485    
486    addEventGa("navig_sliderMobile",direction,jQuery(element).data('labelevent'));
487}
488
489function setHtmlLegendePhotoSlider(ident,txt){
490    if(txt==undefined){
491        txt='';
492    }    
493    if(jQuery('.div_sliderMobileLegende[data-ident="'+ident+'"]').length>0){
494        if(txt.length>0){
495            jQuery('.div_sliderMobileLegende[data-ident="'+ident+'"]').html('<div class="div_sliderMobileLegendeContent">'+txt+'</div>');
496        }
497        else{
498            jQuery('.div_sliderMobileLegende[data-ident="'+ident+'"]').html('');
499        }
500    }
501}
502
503function initClicPhotoChambreHotes(){
504    if(jQuery(".div_imgChambreNbPhoto").length>0){
505        jQuery(".div_imgChambreNbPhoto").click(function(){
506            jQuery(this).parent().find('img:first-child').trigger('click');
507        })
508    }
509}
510
511function getCoord(e, c) {  // pour touchstart et touchend
512    
513    return /touch/.test(e.type) ? (e.originalEvent || e).changedTouches[0]['page' + c] : e['page' + c];
514    
515}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.