update image resize
authorAnthony Ly <anthonyly.com@gmail.com>
Wed, 10 Apr 2013 13:01:46 +0200
changeset 25 cc54acb734fb
parent 24 feb0342a166f
child 26 12d37f113973
update image resize
integ/css/iri.css
integ/js/iri-creation-cinecard.js
--- a/integ/css/iri.css	Wed Apr 10 12:51:35 2013 +0200
+++ b/integ/css/iri.css	Wed Apr 10 13:01:46 2013 +0200
@@ -36,8 +36,8 @@
 
 .videos.less{height: 76px; overflow: hidden;}
 .videos li:nth-child(3n+3) { margin-right: 0;}
-.videos li a{width: 80px; height: 80px;}
-.videos li{overflow: hidden;margin: 0 8px 10px 0;width: 80px; height: 64px;border: 1px solid #767676; float: left;}
+.videos li a{width: 80px; height: 64px;}
+.videos li{overflow: hidden;margin: 0 8px 10px 0;border: 1px solid #767676; float: left;}
 
 .renkan{ position: relative;display: table-cell; padding-top:60px; vertical-align: top;  background-color: #eee; width:100%; background: url(../img/bg-renkan.png) 0 0; min-width: 400px;}
 .renkan .wrap-top{width: 100%; height: 56px; background-color:rgba(0,0,0,.4);}
--- 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'),