Ramzes94,
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>slider demo</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/le-frog/jquery-ui.css">
<style>
#slider{
margin:20px;
width:500px;
height:5px;
}
.ui-slider-handle{
border-radius:50%;
position:relative;
font-size:14px;
display:block;
}
.ui-slider-horizontal .ui-slider-handle{
top:0.5em;
background:transparent;
border-radius:0%;
width:0;
height:0;
border-top:none;
text-decoration:none;
border-left:7px solid transparent;
border-right:7px solid transparent;
border-bottom:14px solid red;
}
#slider:focus{
outline:0;
border:0;
}
.ui-slider-horizontal .ui-slider-handle:last-of-type{
background:transparent;
border-bottom:none;
border-top:14px solid red;
top:-1.2em;
}
.option{
cursor: pointer;
border-radius: 3px;
border: 2px solid rgb(0, 0, 255);
margin: 5px;
width: 120px;
}
</style>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<body>
<input type="hidden" name="minCostCat" value="990">
<input type="hidden" name="maxCostCat" value="70000">
<div class="box">
<div class="box-heading">Диапазон цен</div>
<form class="fromtofilter" action="#" method="GET">
<div class="formCost">
<label for="minCost">от</label><input type="text" id="minCost" />
<label for="maxCost">до</label><input type="text" id="maxCost" />
</div>
<div class="sliderCont">
<div id="slider"></div>
</div>
<div class="option" data-val='[1200,5000]'><span class="val" >Текст1 1200,5000</span></div>
<div class="option" data-val='[3000,80000]'><span class="val" >Текст2 3000,80000</span></div>
<div class="option" data-val='[4000,95000]'><span class="val" >Текст3 4000,95000</span></div>
</form>
</div>
<script>
jQuery(document).ready(function(){
var min_max = [+jQuery("[name='minCostCat']").val(),+jQuery("[name='maxCostCat']").val()]
/* слайдер цен */
jQuery("#slider").slider({
min: min_max[0],
max: min_max[1],
values: min_max,
range: true,
change: function(event, ui) {
jQuery("input#minCost").val(ui.values[0]);
jQuery("input#maxCost").val(ui.values[1]);
},
slide: function(event, ui){
jQuery("input#minCost").val(ui.values[0]);
jQuery("input#maxCost").val(ui.values[1]);
}
});
$("#slider").slider( "option", "values", min_max );
jQuery("input#minCost").change(function(){
var value1=+jQuery("input#minCost").val()||min_max[0];
var value2=+jQuery("input#maxCost").val()||min_max[1];
if(value1 > value2){value1 = value2};
if(value1 < min_max[0]){value1 = min_max[0]};
jQuery("input#minCost").val(value1);
jQuery("#slider").slider("values",0,value1);
});
jQuery("input#maxCost").change(function(){
var value1=+jQuery("input#minCost").val()||min_max[0];
var value2=+jQuery("input#maxCost").val()||min_max[1];
if (value2 > min_max[1]) { value2 = min_max[1]};
if(value1 > value2){value2 = value1;}
jQuery("input#maxCost").val(value2);
jQuery("#slider").slider("values",1,value2);
});
jQuery(".option").click(function() {
var val = jQuery(this).data("val");
min_max = [val[0],val[1]];
jQuery("#slider").slider("option", {"min":val[0],"max":val[1],"values" : min_max})
})
});
</script>
</body>
</html>
|