integration/js/main.js
author Anthony Ly <anthonyly.com@gmail.com>
Wed, 10 Oct 2012 15:16:59 +0200
changeset 5 16413123bc8c
parent 4 b00fdbef41d4
child 6 a3e60d7addb3
permissions -rwxr-xr-x
ajout date picker / avancement
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(){
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
     2
//CLUSTER
2
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
		//DRAGGABLE
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    47
		$(".cluster").draggable({ axis: "x",containment: ".cluster-containment"  });
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    48
	};
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    49
//WIDGET
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    50
	//VOLET
4
b00fdbef41d4 ajout du header sur pages articles
Anthony Ly <anthonyly.com@gmail.com>
parents: 3
diff changeset
    51
	//Tout fermer par défaut
b00fdbef41d4 ajout du header sur pages articles
Anthony Ly <anthonyly.com@gmail.com>
parents: 3
diff changeset
    52
	//$("div.content-left div.widget-wrap div.widget div.widget-inner").hide().removeClass("open");
b00fdbef41d4 ajout du header sur pages articles
Anthony Ly <anthonyly.com@gmail.com>
parents: 3
diff changeset
    53
	//$("div.dossier-similaire div.widget div.widget-inner").hide().removeClass("open");
b00fdbef41d4 ajout du header sur pages articles
Anthony Ly <anthonyly.com@gmail.com>
parents: 3
diff changeset
    54
b00fdbef41d4 ajout du header sur pages articles
Anthony Ly <anthonyly.com@gmail.com>
parents: 3
diff changeset
    55
	$("div.content-left div.widget-wrap div.widget h3 a, div.dossier-similaire div.widget h3 a").bind("click",function(e){
2
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    56
		e.preventDefault();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    57
		var widgetInner = $(this).parents("h3").siblings("div.widget-inner");
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    58
		widgetInner.stop();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    59
		if ($(this).hasClass("open")) {
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    60
			widgetInner.slideUp();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    61
			$(this).removeClass("open");
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    62
		}else{
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    63
			widgetInner.slideDown();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    64
			$(this).addClass("open");
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    65
		}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    66
	});
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    67
	//AFFICHAGE
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    68
	$('.widget.affichage li a').bind('click',function(e){
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    69
		e.preventDefault();
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    70
		if ($(this).hasClass("treemap") && !$(this).hasClass("active")) {
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    71
			$('.widget.affichage li a.liste').removeClass("active");
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    72
			$(this).addClass('active');
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    73
		}else if($(this).hasClass("liste") && !$(this).hasClass("active")){
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    74
			$('.widget.affichage li a.treemap').removeClass("active");
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    75
			$(this).addClass('active');
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    76
		}
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    77
	});
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    78
	//DATE PICKER
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    79
	$(".dateBegin").datepicker({
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    80
		onSelect: function( selectedDate ) {
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    81
        	$( ".dateEnd" ).datepicker( "option", "minDate", selectedDate );
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    82
        }
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    83
	});
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    84
	$(".dateEnd").datepicker({
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    85
		onSelect: function( selectedDate ) {
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    86
        	$( ".dateBegin" ).datepicker( "option", "maxDate", selectedDate );
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    87
        }
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
    88
	});
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
    89
//VOLET DOCUMENTAIRE
2
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    90
	$("div.dossier-documentaire").hide();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    91
	$("div.header a.dossier-button").bind("click",function(e){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    92
		e.preventDefault();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    93
		$("div.dossier-documentaire").stop()
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    94
		if($("div.dossier-documentaire").is(":visible")){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    95
			$("div.dossier-documentaire").slideUp();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    96
		}else{
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    97
			$("div.dossier-documentaire").slideDown();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    98
		}
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
    99
	});
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   100
//ARTICLES
2
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
   101
	$(".article-visuel-wrap").each(function(){
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
   102
		var contentHeight = $(this).parents(".article-content").height();
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
   103
		//$(this).height(contentHeight);
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
   104
	});
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   105
//FRISE
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   106
	//valeurs init du slider à définir
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   107
	var valSlider1 = 75;
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   108
	var valSlider2 = 300;
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   109
	var diffSlide = valSlider2-valSlider1;
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   110
	var widthFrise = $('.frise').width();
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   111
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   112
	$( "#slider-range" ).dragslider({
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   113
		range: true,
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   114
		rangeDrag: true,
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   115
		min: 0,
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   116
		max: widthFrise,
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   117
		values: [ valSlider1, valSlider2 ],
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   118
		create: function(event, ui){
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   119
			$(".voile-left").width(valSlider1);
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   120
			$(".voile-right").width(widthFrise-valSlider2); 
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   121
		},
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   122
		slide: function( event, ui ) {
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   123
			//if(ui.values[1]-ui.values[ 0 ]!= diffSlide){
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   124
			//	return false;
2
6e47ed0c413c maj periplus front
Anthony Ly <anthonyly.com@gmail.com>
parents: 1
diff changeset
   125
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   126
			//}
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   127
			$(".voile-left").width(ui.values[ 0 ]);
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   128
			$(".voile-right").width(widthFrise-ui.values[ 1 ]);
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   129
		},
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   130
		change: function( event, ui ){
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   131
			//console.log("change")
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   132
		}
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   133
	});
5
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   134
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   135
16413123bc8c ajout date picker / avancement
Anthony Ly <anthonyly.com@gmail.com>
parents: 4
diff changeset
   136
	
3
b5b13ce6935f ajout de jquery ui
Anthony Ly <anthonyly.com@gmail.com>
parents: 2
diff changeset
   137
});//jQuery