thisphoto_resize = false; // La photo n'a pas été resizée, ne rien faire au clic this_old_size = ''; ejs_desactive = 0; ejs_pos = 0; var produit_id = 0; affiche_photo_debug = true; affiche_photo_loading = false; // ON DEFINIT LES CHAMPS // New stockage var photo_html = []; // stocke tous les HTML des photos var photo_src = []; // stocke tous les SRC des photos var photo_ids = []; // Stockes les ID des 15 dernieres photos chargées var photo_max_cache = 5; // Autres variables var cachefleche; var deja_contextmenu = []; var hash_tab = []; var hash_qs = ''; var hash_tab2 = []; window.onpopstate = function(event) { url = location.href; if(affiche_photo_debug) console.log('(onpopstate) '+url); url_decoupe = url.split('/photo-'); url_decoupe2 = url_decoupe[1].split('.'); this_photo_id = url_decoupe2[0]; if(vn(this_photo_id) && photo_loaded != this_photo_id) { affiche_photo(this_photo_id, true); } }; photo_hash_number = 0; photo_count = 0; // Affiche une photo si forcé hash = document.location.hash; if(hash != '') { hash = hash.replace('#', ''); url_type = url_type+'#'+hash; if(affiche_photo_debug) console.log('(hash) '+hash); hash_tab = hash.split(','); for(a=0;a', ''); html_tab[1] = html_tab[1].replace('', ''); html_tab[2] = html_tab[2].replace('', ''); // Précédente / Suivante prec_suiv = html_tab[0].split("-"); precedent = prec_suiv[0]; suivant = prec_suiv[1]; console.log(precedent+'/'+suivant); if(affiche_photo_debug) console.log('(hash) Suiv = '+suivant+' prec = '+precedent); // URL photo img_url = html_tab[1]; // Navibar navibar = html_tab[2]; } // Iphone bloc_description_iphone = $(html).find('.photo_viewer_bouton_info_compteur').html(); $('.photo_viewer_bouton_info_compteur').html(bloc_description_iphone); mob_bouton = $(html).find('#photo_viewer_mob_bouton').html(); $('#photo_viewer_mob_bouton').html(mob_bouton); // On place tout (ouhou, ca fait peur) $('#albumphoto_boutons_2').html(bloc_bouton); $('h1').html(h1); $('#albumphoto_description_zone').html(bloc_description); $('#image_'+photo_id).load(function() { affichephoto_resize(photo_id) }); }) } } /* FONCTION AFFICHAGE DE LA PHOTOS */ function photo_last_15(photo_id) { // On parse et on met a jour le tableau photo_ids pour stocker les 15 dernieres photos, et on met a jour photo_html et photo_src, pour le garder que les 15 dernieres photo if(affiche_photo_debug) console.log('(photo_last_15) On efface les vieilles photo en ajoutant '+photo_id); if(affiche_photo_debug) console.log(photo_ids); var new_array = [photo_id]; var b = 1; for(a=0;a On affiche'); // ON AFFICHE //loadPageRes(photo_html[photo_id], 'albumphoto_cur'); //alert(photo_html[photo_id]); $('#albumphoto_cur').html(photo_html[photo_id]); //$('#albumphoto_cur').css('border', 'red 1px solid'); // On force la taille maxi screen_width = ecran_larg-60; screen_height = ecran_hauteur-160; $('#albumphoto_cur img').css('max-width', screen_width); $('#albumphoto_cur img').css('max-height', screen_height); // On met a jour l'url if(!nopushstate) { history.pushState({ "photo_id":photo_id }, "Photo 1", url_type.replace('##PID##', photo_id)); if(affiche_photo_debug) console.log('(affiche_photo) Push de '+photo_id); } // On resize la photo (en fait, on affiche les tags) $('#image_'+photo_id).load(function() { affichephoto_resize(photo_id, 0) }); // ON CHOPPE LES PREV ET NEXT ET NAVIBAR html = new Array(); //alert(html); html = photo_html[photo_id].split("\n"); txt_navibar = html[2]; html = html[0].split("-"); precedent = html[2]; suivant = html[3]; txt_navibar = txt_navibar.split("--"); if(gebi('navibar_links')) gebi('navibar_links').innerHTML = txt_navibar[1]; // ON PLACE PREV DANS PREV if(precedent != 0) { preload_photo(precedent, 'prev', function() { }); } // ON PLACE NEXT DANS NEXT if(suivant != 0) { preload_photo(suivant, 'suiv', function() { }); } // ON RESET LA FLECHE DU BAS ejs_pos = 0; } else { if(affiche_photo_debug) console.log('(affiche_photo) Photo '+photo_id+' non trouvée dans le cache -> Merde, on fait quoi ?'); } affiche_photo_loading = false; }); // ON SCROLL photo_affiche_popup(); } function affichephoto_resize(photo_id) { // Cette fonction sert a resizer la photo pour être affichée entierement a l'ecran // En fait, ca ne sert plus qu'a afficher les tags shopping if(affiche_photo_debug) console.log('(affichephoto_resize) On regle la taille maxi'); // On force la taille maxi screen_width = ecran_larg-60; screen_height = ecran_hauteur-230; $('#albumphoto_cur img').css('max-width', screen_width); $('#albumphoto_cur img').css('max-height', screen_height); // ON CENTRE L'IMAGE // scroll if(photo_id != photo_loaded_first) { if($('#albumphoto_boutons').length>0) { scrollto_pos = $('#albumphoto_boutons').offset(); scrollto_pos = scrollto_pos.top; window.scrollTo(0, scrollto_pos); } else if($('#albumphoto_boutons_2').length>0) { position = $('#albumphoto_boutons_2').offset(); scrollto_pos = position.top-50; console.log('sp :'+scrollto_pos+' /sp :'+position.left); window.scrollTo(0, scrollto_pos); } else window.scrollTo(0, 370); if(affiche_photo_debug) console.log('(affichephoto_resize) Scroll automatique de la photo'); } // On place les tags if($('#albumphoto_boutons_2').length>0) { photo_get_tag(photo_id, '32', produit_id, false, ''); } if(affiche_photo_debug) console.log('Photo '+photo_id+' resizee'); } function affichephoto_affichemenu(etat) { if(etat) { // On affiche le bloc $('#albumphoto_conteneurphoto_info_mob').css('height', ecran_hauteur-10); $('#albumphoto_conteneurphoto_info_mob').css('top', ecran_hauteur); $('#albumphoto_conteneurphoto_info_mob').animate({ top: 5 }, 500, function() { // Animation complete. }); } else { // On retire le bloc $('#albumphoto_conteneurphoto_info_mob').animate({ top: ecran_hauteur+50 }, 500, function() { // Animation complete. }); } } /* POPUP */ // Pub ML popup_ml = ScanCookie('photo_popup'); popup_passage = 0; popup_apres_page = 3; function photo_affiche_popup() { // Nombre de passage popup_passage++; // On regarde le cookie if(popup_ml != '1') { // On peut afficher if(popup_passage == popup_apres_page) { afficheBoxCentered(file('//www.forumconstruire.com/photos/ajax.php?content=7'), 500, 300, true, false); CreationCookie('photo_popup', 1, true); _paq.push(['trackGoal', 2]); } } } // Touche clavier $(document).ready(function() { afficheBoxCentered('
Utilisez les touches du clavier pour naviguer
', 320, 220, true, false); } ) /* NAVIGATION */ function ejs_code_clavier(code, large_fenetre) { url_suiv = ""; url_prec = ""; //url_index = "voir-pid_"+projet_id+".php"; // 37 -> PRECENDENTE // 38 -> HAUT // 39 -> SUIVANTE // 40 -> BAS //alert(ejs_code_eventChooser); if(!ejs_desactive) { if(code == 37) { if(precedent != 0) { affiche_photo(precedent, false); //document.location.href='#photo_'+precedent; } else { if(affiche_photo_debug) console.log('(ejs_code_clavier) '+url_fin); document.location.href=url_fin; } } else if(code == 39) { if(suivant != 0) { affiche_photo(suivant, false); //document.location.href='#photo_'+suivant; } else { document.location.href=url_fin; } } else if(code == 77) { txt = file2('//www.forumconstruire.com/ajax/getcontent.php?content=49&photo_id='+photo_loaded+'&more=1', function() { txt = html; if(txt == 'user') { txt_notif = ' Vous devez être membre pour voter pour une photo. Cliquez ici.'; } else { gebi('love_box').innerHTML = txt; txt_notif = ' Votre vote a bien été pris en compte !'; } if(large_fenetre) { afficheBoxCentered('
Information
'+txt_notif+'
', 320, 220, true, false); } else { notification(txt_notif, 2000); } }); } } return(false); } /* ZOOM PHOTO */ function affichelarge_photo(url, photo_id) { divname = "viewer_large"; if(!document.getElementById(divname)) { obj = document.createElement("div"); obj.id = divname; var b = document.getElementsByTagName("body")[0]; if (b.firstChild != null) b.insertBefore(obj, b.firstChild); else b.appendChild(div); } // Z index zindex = 2000; gebi(divname).style.zIndex = zindex; // Style gebi(divname).style.position='absolute'; gebi(divname).style.border='7px solid #707070'; gebi(divname).style.display='block'; obj.innerHTML = ''; gebi('viewer_large_image').onload = affichelarge_deplace; } function affichelarge_deplace() { divname = "viewer_large"; if(!gebi(divname)) return(''); // taille cadre largeur = gebi(divname).offsetWidth; hauteur = gebi(divname).offsetHeight; // On deplace posleft = (document.documentElement.offsetWidth-largeur)/2; if(posleft < 5) posleft = 5; gebi(divname).style.left=posleft+'px'; if($('#albumphoto_boutons').length>0) { position = $('#albumphoto_boutons').offset(); postop = position.top; } else if($('#albumphoto_boutons_2').length>0) { position = $('#albumphoto_boutons_2').offset(); postop = position.top; } else postop = 370; $('#'+divname).css('top', postop); } /* EVENEMENTS */ // Clavier $(document).keydown(function( event ) { if ((event.which == 37 || event.which == 39 || event.which == 77) && !affiche_box_state) { ejs_code_clavier(event.which, false); } }); // On force le bloc $('#albumphoto_cur').css('display', 'block'); // Au chargement de l'image, on resize la photo $('#image_'+photo_loaded).load(function() { affichephoto_resize(photo_loaded) }); // Changement de taille ? D'orientation ? On resize $(window).resize(function(event) { affichephoto_resize(photo_loaded); }); $( window ).on( "orientationchange", function( event ) { affichephoto_resize(photo_loaded) }); $(document).ready(function() { // Lien avec le hashtag qui indiqueque le mec like la photo if(document.location.hash == '#love') { ejs_code_clavier(77, true); } // ON debloque la largeur de la photo $('#content.extens').css('max-width', 'none'); $('#content.extens').css('margin', '0px 10px'); if(vn(suivant)) this_photo_suivante = suivant; if(vn(this_photo_suivante)) preload_photo(this_photo_suivante, 'suiv', function() { }); } ) // On resize l'image $(window).load(function() { if(vn(photo_id)) affichephoto_resize(photo_id); }); var photo_detect_doubleclick_timer = 0; function photo_detect_doubleclick(url) { time = (new Date().getTime()/1000); if(photo_detect_doubleclick_timer > time-1) { if(confirm('La photo va s\'ouvrir en grand format dans un nouvel onglet.\nContinuer ?')) { window.open(url, '_blank'); } } photo_detect_doubleclick_timer = time; } $('textarea input').focus(function() { ejs_desactive = true; if(affiche_photo_debug) console.log('input / false'); }); $('textarea input').blur(function() { ejs_desactive = false; if(affiche_photo_debug) console.log('input / false'); });