integ/js/iri.js
changeset 9 b58988e19096
parent 7 84f000d09bd4
child 10 bdfc6ff39081
--- a/integ/js/iri.js	Thu Apr 04 18:19:28 2013 +0200
+++ b/integ/js/iri.js	Fri Apr 05 17:28:05 2013 +0200
@@ -32,7 +32,7 @@
 //-- API allocine
 
 //-- movie
-var urlMovie = 'http://api.allocine.fr/rest/v3/movie?partner=B00015838755&code='+ idMovie;
+var urlMovie = 'http://api.allocine.fr/rest/v3/movie?partner='+partnerCode+'&code='+ idMovie;
 $.getJSON(urlMovie, function(data) {
 	var movie = data.movie;
 
@@ -54,9 +54,12 @@
 		}	
 		var urlFichePersonne = 'http://www.allocine.fr/personne/fichepersonne_gen_cpersonne='+codeActor+'.html';
 		var itemStar = 
-			'<li><a target="_blank" href="'+ urlFichePersonne +'" title="'+ name +'">'+
-				'<img src="'+ urlPicture +'" alt="'+ name +'" />'+
-			'</a></li>';
+			'<li>'+
+
+				'<a class="tool-info" target="_blank" href="'+ urlFichePersonne +'" title="'+ name +'">'+
+					'<img src="'+ urlPicture +'" alt="'+ name +'" />'+
+				'</a>'+
+			'</li>';
 		$('#stars-more').append(itemStar);
 	});	
 
@@ -72,17 +75,91 @@
 });
 
 //-- picture
-var urlPicture = 'http://api.allocine.fr/rest/v3/picturelist?partner=B00015838755&subject=movie:135082';
+var urlPicture = 'http://api.allocine.fr/rest/v3/picturelist?partner='+partnerCode+'&subject=movie:'+ idMovie;
 $.getJSON(urlPicture, function(data) {
 	var media = data.feed.media;
 	$.each(media, function(k, v){
 		var urlThumb = v.thumbnail.href;
+		var rcode = v.rcode;
+		var title = v.title;
+		var urlAllocine = 'http://www.allocine.fr/film/fichefilm-'+ idMovie +'/photos/detail/?cmediafile='+ rcode;
 		var itemImagess = 
 			'<li>'+
-				'<img src="'+ urlThumb +'" alt="" />'+
+				'<a target="_blank" href="'+ urlAllocine +'">'+
+					'<img src="'+ urlThumb +'" alt="'+title+'" />'+
+				'</a>'+
 			'</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
+	        });
+	    });
+	});
+});//get
+
+//-- trailer
+var urlTrailers = 'http://api.allocine.fr/rest/v3/videolist?partner='+partnerCode+'&mediafmt=flv&subject=movie:'+ idMovie;
+$.getJSON(urlTrailers, function(data) {
+	var media = data.feed.media;
+	$.each(media, function(k, v){
+		console.log(v)
+		var urlThumbnail = v.thumbnail.href;
+		var title = v.title;
+		var code = v.code;
+		var url = 'http://www.allocine.fr/video/player_gen_cmedia='+code+'&cfilm='+idMovie+'.html';
+		var itemVideo = 
+			'<li>'+
+				'<a target="_blank" href="'+ url +'">'+
+					'<img src="'+ urlThumbnail +'" alt="'+title+'" />'+
+				'</a>'+
+			'</li>';
+		$('#videos-more').append(itemVideo);
+	});
 });
 
+//TOOLTIP
+var show_tooltip_info_iri = function(elem){
+	var tooltip = $('.tooltip-iri'),
+		name = elem.attr('title'),
+		arrow = tooltip.find('.arrow_tooltip'),
+		top = elem.offset().top,
+		right = elem.offset().left + elem.width() + arrow.width();
+	tooltip.find('p').text(name)
+	tooltip.show();
+	tooltip.css({
+		top : top,
+		left : right
+	});
+}
+var hide_tooltip_info_iri = function(elem){
+	var tooltip = $('.tooltip-iri');
+	tooltip.hide();
+}
+$(document).on({
+    mouseenter: function() {
+    	show_tooltip_info_iri($(this));
+	},
+    mouseleave: function() {
+    	hide_tooltip_info_iri($(this));
+    }
+}, 'a.tool-info');
+
+
+
 });
\ No newline at end of file