integration/js/main.js
changeset 20 c86141a8570d
parent 11 95df5542a1ce
child 21 c2dd00471b2d
--- a/integration/js/main.js	Tue Oct 30 18:04:28 2012 +0100
+++ b/integration/js/main.js	Tue Nov 27 18:08:06 2012 +0100
@@ -5,56 +5,71 @@
 	$('.cluster').width( clusterWidth );
 	var clusterVisibleWidth = $(".cluster-visible").width();
 	var clusterVisibleLeft = 20;
+	$(".arrow-left").addClass('bute');
 	if (clusterWidth>clusterVisibleWidth) {
 		$(".cluster-containment").css({
 			"left": -(clusterWidth-clusterVisibleWidth),
 			"width":clusterWidth+(clusterWidth-clusterVisibleWidth+clusterVisibleLeft)
 		});
 		$(".cluster-visible").css({"left": (clusterWidth-912+clusterVisibleLeft)});
+		
 		$("a.cluster-arrow").bind("click",function(e){
-		
 			e.preventDefault();
+			$(".cluster").stop();
+			moveCluster(this, 5);
+		});
+
+
+		$("a.cluster-arrow").hover(
+			function(){
+				moveCluster(this, 20);
+			},
+			function(){
+				$(".cluster").stop();
+			}
+		);
+
+		function moveCluster(arrow, speed){
 			var clusterContainmentLeft = parseInt($(".cluster-containment").css("left"));
 			var clusterContainmentRight = parseInt($(".cluster-containment").css("left")) + $(".cluster-containment").width();
 			var clusterLeft = parseInt($(".cluster").css("left"));
 			var clusterRight = parseInt($(".cluster").css("left"))+$(".cluster").width();
-			if ($(this).hasClass("arrow-right")) {
-				if (clusterLeft-40>clusterContainmentLeft) {
-					$(".cluster").css({
-						"left":"-="+40	
-					});
-				}else{
-					$(".cluster").css({
-						"left":clusterContainmentLeft
-					});
-				}
-		
-			}else if($(this).hasClass("arrow-left")){
-			
-				if (clusterRight+40<clusterContainmentRight) {
-					$(".cluster").css({
-						"left":"+="+40	
-					});
-				}else{
-					$(".cluster").css({
-						"left":0
-					});
-				}
+
+			if ($(arrow).hasClass("arrow-right")) {
+				$(".arrow-left").removeClass('bute');
+				vitesse = (clusterLeft-clusterContainmentLeft)*speed;
+				$(".cluster").animate({
+					"left":clusterContainmentLeft
+				},vitesse,'linear',function(){
+					$(arrow).addClass('bute');
+				});
+			}else{
+				$(".arrow-right").removeClass('bute');
+				vitesse = (clusterContainmentRight-clusterRight)*speed;
+				$(".cluster").animate({
+					"left":0
+				},vitesse,'linear',function(){
+					$(arrow).addClass('bute');
+				});
 			}
-		});
-	
+		}
+
 		//DRAGGABLE
 		$(".cluster").draggable({ axis: "x",containment: ".cluster-containment"  });
 	};
 //WIDGET
 	//HEIGHT
-	var contentRightHeight = $(".content-right").height();
-	var contentLeftHeight = $(".content-left").height();
-	if(contentRightHeight>contentLeftHeight){
-		$(".content-left .widget-wrap").css({
-			"height":"+="+(contentRightHeight-contentLeftHeight)
-		});
+	function resizeWidgetSidebar(){
+		var contentRightHeight = $(".content-right").height();
+		var contentLeftHeight = $(".content-left").height();
+		if(contentRightHeight>contentLeftHeight){
+			$(".content-left .widget-wrap").css({
+				"height":"+="+(contentRightHeight-contentLeftHeight)
+			});
+		}
 	}
+	resizeWidgetSidebar();
+
 	//VOLET
 	//Tout fermer par défaut
 	//$("div.content-left div.widget-wrap div.widget div.widget-inner").hide().removeClass("open");
@@ -78,10 +93,13 @@
 		if ($(this).hasClass("treemap") && !$(this).hasClass("active")) {
 			$('.widget.affichage li a.liste').removeClass("active");
 			$(this).addClass('active');
+			$('#liste').hide();$('#treemap').show();
 		}else if($(this).hasClass("liste") && !$(this).hasClass("active")){
 			$('.widget.affichage li a.treemap').removeClass("active");
 			$(this).addClass('active');
+			$('#liste').show();$('#treemap').hide();
 		}
+		resizeWidgetSidebar();
 	});
 	//DATE PICKER
 	$(".dateBegin").datepicker({
@@ -107,8 +125,8 @@
 		}
 	});
 */
-	$("div.header a.dossier-button").bind("click",function(e){e.preventDefault();});
-	$("div.header a.dossier-button, div.header div.dossier-documentaire").hover(
+	$(".header .dossier-button").bind("click",function(e){e.preventDefault();});
+	$(".header .dossier-button, .header .dossier-documentaire").hover(
 		function(){
 			$("div.dossier-documentaire").stop().slideDown();
 		},
@@ -121,6 +139,18 @@
 		var contentHeight = $(this).parents(".article-content").height();
 		//$(this).height(contentHeight);
 	});
+	$(".article-annotations a").hover(
+		function(){
+			var x = $(this).offset().left + $(this).width()/2;
+			var y = $(this).offset().top;
+			var text = $(this).attr('title');
+			showTooltip(x,y,text);
+		},
+		function(){
+			var tip = $(".tooltip");
+			tip.hide();
+		}
+	);
 //FRISE
 	//valeurs init du slider à définir
 	var valSlider1 = 75;
@@ -146,6 +176,26 @@
 		}
 	});
 
+//TOOLTIP
+	function showTooltip(x,y, text) {
+		//white_arrow_long.png
+		var tip = $(".tooltip");
+		tip.show();
+	    tip.css({
+	        "left" : Math.floor(x - tip.outerWidth() / 2) + "px",
+	        "top" : Math.floor(y - tip.outerHeight()) + "px"
+	    }).text(text);
+	}
 
-	
+//HOME TREEMAP
+	var lastActuBind = false;
+	$('#treemap').on('mouseover', '.actu', function(){
+		if(this == lastActuBind) return;
+		lastActuBind = this;
+
+		console.log('mouseover', $(this));
+
+	});
+
+
 });//jQuery