integration/js/main.js
author Anthony Ly <anthonyly.com@gmail.com>
Mon, 08 Oct 2012 17:31:29 +0200
changeset 2 6e47ed0c413c
parent 1 43d9dff6758a
child 3 b5b13ce6935f
permissions -rwxr-xr-x
maj periplus front
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
43d9dff6758a premiers ajout front périples
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
     1
$(function(){
2
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     2
	//CLUSTER
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     3
	var clusterWidth=0;
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     4
	$('.cluster li').each( function(){ clusterWidth += $(this).width() + 10; });
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     5
	$('.cluster').width( clusterWidth );
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     6
	var clusterVisibleWidth = $(".cluster-visible").width();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     7
	var clusterVisibleLeft = 20;
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     8
	if (clusterWidth>clusterVisibleWidth) {
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
     9
		$(".cluster-containment").css({
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    10
			"left": -(clusterWidth-clusterVisibleWidth),
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    11
			"width":clusterWidth+(clusterWidth-clusterVisibleWidth+clusterVisibleLeft)
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    12
		});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    13
		$(".cluster-visible").css({"left": (clusterWidth-912+clusterVisibleLeft)});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    14
		$("a.cluster-arrow").bind("click",function(e){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    15
			console.log("click")
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    16
			e.preventDefault();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    17
			var clusterContainmentLeft = parseInt($(".cluster-containment").css("left"));
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    18
			var clusterContainmentRight = parseInt($(".cluster-containment").css("left")) + $(".cluster-containment").width();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    19
			var clusterLeft = parseInt($(".cluster").css("left"));
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    20
			var clusterRight = parseInt($(".cluster").css("left"))+$(".cluster").width();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    21
			if ($(this).hasClass("arrow-left")) {
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    22
				if (clusterLeft-40>clusterContainmentLeft) {
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    23
					$(".cluster").css({
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    24
						"left":"-="+40	
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    25
					});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    26
				}else{
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    27
					$(".cluster").css({
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    28
						"left":clusterContainmentLeft
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    29
					});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    30
				}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    31
		
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    32
			}else if($(this).hasClass("arrow-right")){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    33
			
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    34
				if (clusterRight+40<clusterContainmentRight) {
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    35
					$(".cluster").css({
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    36
						"left":"+="+40	
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    37
					});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    38
				}else{
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    39
					$(".cluster").css({
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    40
						"left":0
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    41
					});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    42
				}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    43
			}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    44
			
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    45
		});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    46
	
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    47
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    48
		//DRAGGABLE
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    49
		$(".cluster").draggable({ axis: "x",containment: ".cluster-containment"  });
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    50
	};
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    51
	//WIDGET
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    52
	//$("div.content-left div.widget-wrap div.widget div.widget-inner").hide();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    53
	$("div.content-left div.widget-wrap div.widget h3 a").bind("click",function(e){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    54
		e.preventDefault();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    55
		var widgetInner = $(this).parents("h3").siblings("div.widget-inner");
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    56
		widgetInner.stop();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    57
		if ($(this).hasClass("open")) {
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    58
			widgetInner.slideUp();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    59
			$(this).removeClass("open");
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    60
		}else{
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    61
			widgetInner.slideDown();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    62
			$(this).addClass("open");
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    63
		}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    64
	});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    65
	//DOCUMENTAIRE
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    66
	$("div.dossier-documentaire").hide();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    67
	$("div.header a.dossier-button").bind("click",function(e){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    68
		e.preventDefault();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    69
		$("div.dossier-documentaire").stop()
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    70
		if($("div.dossier-documentaire").is(":visible")){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    71
			$("div.dossier-documentaire").slideUp();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    72
		}else{
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    73
			$("div.dossier-documentaire").slideDown();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    74
		}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    75
	});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    76
	//ARTICLES
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    77
	$(".article-visuel-wrap").each(function(){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    78
		var contentHeight = $(this).parents(".article-content").height();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    79
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    80
		//$(this).height(contentHeight);
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    81
	});
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    82
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    83
	
1
43d9dff6758a premiers ajout front périples
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    84
43d9dff6758a premiers ajout front périples
Anthony Ly <anthonyly.com@gmail.com>
parents:
diff changeset
    85
});