integ/js/iri-creation-cinecard.js
changeset 25 cc54acb734fb
parent 23 3c2416e4daf6
child 26 12d37f113973
--- a/integ/js/iri-creation-cinecard.js	Wed Apr 10 12:51:35 2013 +0200
+++ b/integ/js/iri-creation-cinecard.js	Wed Apr 10 13:01:46 2013 +0200
@@ -123,26 +123,7 @@
 			'</li>';
 		$('#images-more').append(itemImagess);
 	});
-	//redimensionnement images
-	$("#images-more 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
-	        });
-	    });
-	});
+	resizeImg('#images-more');
 });//get
 
 //-- trailer
@@ -162,29 +143,33 @@
 				'</a>'+
 			'</li>';
 		$('#videos-more').append(itemVideo);
-		//redimensionnement images
-		$("#videos-more 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
-		        });
-		    });
-		});
+		resizeImg('#videos-more');
 	});
 });
 
+
+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
+	        });
+	    });
+	});
+}
+
 //TOOLTIP
 var show_tooltip_info_iri = function(elem){
 	var tooltip = $('.rate_tooltip'),