$(function(){
	//Slider 1 Point
	$(".custom-personality-scale-table .slider-range-1point" ).each(function(){
		var slider = $(this);
		slider.slider({
			orientation: "horizontal",
			range: "min",
			max: 100,
			value: slider.data("slider-value")
		})
		.slider("pips", {
			labels: {
				"first": slider.data("slider-firstpip"),
				"last": slider.data("slider-lastpip")
			},
			step: 10,
			rest: "label"
		})
		.slider("float");
	});
	
	//Slider 2 Point
	$(".custom-personality-scale-table .slider-range-2point" ).slider({
		range: true,
		orientation: "horizontal",
		min: 0,
		max: 100,
		values: [30, 70]
	})
	.slider("pips", {
		labels: {
			"first": "Socially distant",
			"last": "High need to be liked"
		},
		step: 10,
		rest: "label"
	})
	.slider("float");

	//Slider 3 Point
	/* https://refreshless.com/nouislider/ */
	var slider3Point = $(".custom-personality-scale-table .slider-range-3point" ); 
	slider3Point.each(function(){
		var slider = $(this);
		noUiSlider.create(this, {
			start: [50,70, 80],
			step: 1,
			connect: [true, true, true, true],
			range: {
				'min': [ 0 ],
				'max': [ 100 ]
			},
			tooltips: true,
			format: wNumb({
				decimals: 0
			}),
			pips: { // Show a scale with the slider
				mode: 'positions',
				values: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
				density: 10
//				filter: function(value, type){
//					return value % 10 ? 1 : 0;
//				}
			}
		});
	});
	slider3Point.find(".noUi-handle").on({
		mouseenter: function () {
	        $(this).find('.noUi-tooltip').show();
	    },
	    click: function () {
	    	$(this).find('.noUi-tooltip').show();
	    },
	    mouseleave: function () {
	        $(this).find('.noUi-tooltip').hide();
	    },
	}).find('.noUi-tooltip').hide();
	
	slider3Point.find(".noUi-connect").each(function(index){
		var item = $(this);
		if(index == 0){
			item.addClass('veryLowColor');
		}else if(index == 1){
			item.addClass('lowColor');			
		}else if(index == 2){
			item.addClass('perfectColor');			
		}else if(index == 3){
			item.addClass('overColor');			
		}
	});
	
	slider3Point.find(".noUi-pips > div:nth-child(2)").text('Unwilling to take responsibility');
	slider3Point.find(".noUi-pips > div:nth-child(2)").css('width','14%');
	slider3Point.find(".noUi-pips > div:nth-child(22)").text('Over responsible');
	slider3Point.find(".noUi-pips > div:nth-child(22)").css('width','14%');
//	slider3Point.find(".noUi-pips > div.noUi-marker:nth-child(11)").text('Over resposible');
	
	
	
});