//= 750 && largeur < 750){ // ordi -> mobile changementTailleDevice = true; } if(largeur_fenetre < 750 && largeur >= 750){ // ordi <- mobile changementTailleDevice = true; } if(largeur_fenetre != largeur){ largeur_fenetre = largeur; changing = true; } var hauteur = 0; if(window.innerWidth!= undefined){ hauteur = window.innerHeight; }else{ var B= document.body, D= document.documentElement, A= document.activeElement; // hauteur = Math.max(D.clientHeight, B.clientHeight, A.clientHeight); hauteur = D.clientHeight; } if(hauteur_fenetre != hauteur){ hauteur_fenetre = hauteur; changing = true; } if(changing){ // s'il y a des changements de taille, ca peut influencer sur le reste checkDim(); } return true; } /*! * checkDim * fonction qui change des elements de la page en fonction de l'affichage responsive * * @argument : none * @returns : true * @requires : none */ function checkDim(){ changementTailleDevice = false; function isMobileSize(){ if(largeur_fenetre < 750){ return true; } return false; } if(isElementByClass("liste_albums")){ var nombre_colonnes_actuel = $(".liste_albums>.colonne").length; var nombre_colonnes_voulues; if(largeur_fenetre >= 750){ nombre_colonnes_voulues = 3; }else if(largeur_fenetre >= 400){ nombre_colonnes_voulues = 2; }else{ nombre_colonnes_voulues = 1; } if(nombre_colonnes_actuel != nombre_colonnes_voulues){ // on a un changement du nombre de colonnes // on extrait et retrie les albums dans l'ordre if($(".liste_albums .liste_albums_item").length > 0){ var liste_albums = $(".liste_albums .liste_albums_item"); liste_albums.sort(function(a, b) { return +a.getAttribute('data-order') - +b.getAttribute('data-order'); }); // on doit afficher les albums de haut en bas, en fonction de leur hauteur de la miniature var cumul_hauteur_ligne = []; // cumul des hauteurs des images de chaque colonne var colonnes = []; // contenu des colonnes (les albums) for(var i = 0; i < nombre_colonnes_voulues; i++) { cumul_hauteur_ligne.push(0); colonnes.push([]); } // fonction qui retourne la somme des margin/padding/border vertical d'un element function getMPB(e){ return e.outerWidth() - e.innerWidth() + e.innerWidth() - e.width() + e.outerWidth(true) - e.outerWidth(); } // on parcours tous les albums et on les place au fur et a mesure dans la colonne la moins "remplie" jQuery.each(liste_albums, function( i ) { // on calcule une hauteur theorique de l'image pour la largeur donnee; var widthColum = $(".liste_albums").width() / nombre_colonnes_voulues; var h_img = Math.round($(this).data("height") * widthColum / $(this).data("width")); // on ne neglige pas les marges, textes et autre qui prennent de la place var extra_h = getMPB($(this)) + $(this).find("p.title").height() + $(this).find("p.description").height(); // on recupere l'indice de la colonne ou on place l'element : var key_lowest_val = cumul_hauteur_ligne.indexOf(Math.min.apply(window,cumul_hauteur_ligne)); cumul_hauteur_ligne[key_lowest_val] += (h_img+extra_h); colonnes[key_lowest_val].push($(this)); }); // on insert le nouveau tris dans le html var updated_order = ""; jQuery.each(colonnes, function( i ) { updated_order+='\n
\n'; jQuery.each(colonnes[i], function( j, album ) { updated_order+=$(album).get(0).outerHTML; }); updated_order+='
'; }); $(".liste_albums").html(updated_order); }else{ // vide } } } } /*! * waitForWebfonts * fonction qui attend que les font externes soients chargees, * * @argument : fonts {array, liste des noms de fonts} * callback { null/optional } * @returns : true * @requires : #visualisation_out {div, singleton image du menu} */ function waitForWebfonts(fonts, callback) { var loadedFonts = 0; for(var i = 0, l = fonts.length; i < l; ++i) { (function(font) { var node = document.createElement('span'); // Characters that vary significantly among different fonts node.innerHTML = 'giItT1WQy@!-/#'; // Visible - so we can measure it - but not on the screen node.style.position = 'absolute'; node.style.left = '-10000px'; node.style.top = '-10000px'; // Large font size makes even subtle changes obvious node.style.fontSize = '300px'; // Reset any font properties node.style.fontFamily = 'sans-serif'; node.style.fontVariant = 'normal'; node.style.fontStyle = 'normal'; node.style.fontWeight = 'normal'; node.style.letterSpacing = '0'; document.body.appendChild(node); // Remember width with no applied web font var width = node.offsetWidth; node.style.fontFamily = font + ', sans-serif'; var interval; function checkFont() { // Compare current width with original width if(node && node.offsetWidth != width) { ++loadedFonts; node.parentNode.removeChild(node); node = null; } // If all fonts have been loaded if(loadedFonts >= fonts.length) { if(interval) { clearInterval(interval); } if(loadedFonts == fonts.length) { callback(); return true; } } }; if(!checkFont()) { interval = setInterval(checkFont, 50); } })(fonts[i]); } }; function loadImages(photos,is_big){ if(is_big){ var lien = "http://www.guillaumemalheiro.com/photos/"; // var lien = "http://www.guillaumemalheiro.com/photos/med/"; }else{ var lien = "http://www.guillaumemalheiro.com/photos/min/"; } $("").attr("src", "http://www.guillaumemalheiro.com/img/loading.gif").on("load", function() { var img_loaded = 0; jQuery.each( photos, function( i, photo ) { var div; if(isElementById("liste_albums_item_"+photo.id+"")) div = $("#liste_albums_item_"+photo.id+""); if(isElementById("liste_photos_photo_"+photo.id+"")) div = $("#liste_photos_photo_"+photo.id+""); if (typeof div !== 'undefined') { if(!is_big){ div.find(".img_container").append('
'); div.find(".img_container>img").attr("src", lien+photo.filename); } $("").attr("src", lien+photo.filename).on("load", function() { $(this).remove(); div.find(".img_container>img").attr("src", lien+photo.filename); if(!is_big){ img_loaded ++ ; if(photos.length == img_loaded){ loadImages(photos,true); } }else{ div.find(".not_loaded").removeClass("not_loaded"); div.find(".img_container>.loading").fadeOut("fast",function(){ $(this).remove(); }); } }); } }); }); } // function on the index.php, called when all scripts are loaded $(document).ready(function(){ if (typeof allScriptLoaded === "function") { allScriptLoaded(); } }); // ]]>