integ/js/iri-buzz.js
changeset 29 6917b55f901f
parent 28 84719280c84d
child 30 a96fd5fdc4b9
--- a/integ/js/iri-buzz.js	Fri Apr 12 15:08:00 2013 +0200
+++ b/integ/js/iri-buzz.js	Fri Apr 12 17:31:27 2013 +0200
@@ -1,5 +1,27 @@
 $(function(){
 
+function resizeImg(parentId){
+	$(parentId+" img").each(function() {
+	    var img = $(this),
+	        div = $(this).parent();
+	    img.load(function() {
+	        var iw = img.width(),
+	            ih = img.height(),
+	            dw = div.width(),
+	            dh = div.height(),
+	            scale = Math.max(dw/iw, dh/ih),
+	            niw = iw * scale,
+	            nih = ih * scale;
+	        img.css({
+	            width: niw,
+	            height: nih,
+	            "margin-left": (dw - niw) / 2,
+	            "margin-top": (dh - nih) / 3
+	        });
+	    });
+	});
+}
+
 var CONFIG = {
 	wChart : 100,
 	now : new Date(),
@@ -12,7 +34,7 @@
 	width : 960,
 	height : 400,
 	chart : {
-		spacer : 0
+		spacer : 5
 	},
 	data : {
 		model :[],
@@ -38,7 +60,7 @@
 	
 	var movies = data.feed.movie;
 	nbMovies = movies.length;
-	bcSettings.width = nbMovies * CONFIG.wChart;
+	bcSettings.width = nbMovies * CONFIG.wChart + 10 * nbMovies;
 	$('.posters').css('width', bcSettings.width);
 	//var wItem = bcSettings.width / nbMovies;
 
@@ -77,6 +99,7 @@
 */
 	});
 
+	resizeImg('.posters');
 	barChart = $("#data-viz").vs(bcSettings).data('visualSedimentation');
 
 });