Pantela,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css"> .slider {
margin: 17px 0;
position: relative;
}
.slider.priceSlider {
margin-top: 22px;
}
.sliderTooltip {
position: absolute;
padding: 5px 0;
margin-top: -3px;
margin-left: 2px;
top: -28px;
z-index: 90;
}
.stLabel {
background-color: #0eaaa6;
font-size: 11px;
line-height: 12px;
color: #fff;
padding: 4px 6px;
border-radius: 2px;
text-align: center;
white-space: nowrap;
}
.stArrow {
border-color: transparent;
bottom: 0;
left: 50%;
margin-left: -5px;
border-width: 5px 5px 0;
border-style: solid;
position: absolute;
width: 0;
height: 0;
border-top-color: #0eaaa6;
}
.ui-slider-horizontal .ui-slider-handle{
background-color: #0eaaa6;
border: 6px solid #fff;
}
.ui-slider .ui-slider-range {
background-color: #0eaaa6;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
</head>
<body>
<div class="form-group">
<label class="control-label">Records</label>
<div class="slider priceSlider" id="records">
<div class="sliderTooltip">
<div class="stArrow"></div>
<div class="stLabel"></div>
</div>
</div>
<input name="min_records" id="min_records" data-min="0" value="10" type="hidden" />
<input name="max_records" id="max_records" data-max="200" value="50" type="hidden" />
</div>
<div class="form-group">
<label class="control-label">Records</label>
<div class="slider priceSlider" id="records">
<div class="sliderTooltip">
<div class="stArrow"></div>
<div class="stLabel"></div>
</div>
</div>
<input name="min_records" id="min_records" data-min="0" value="100" type="hidden" />
<input name="max_records" id="max_records" data-max="1000" value="500" type="hidden" />
</div>
<script>
(function($) {
$(".form-group").each(function(indx, el){
// priceSlider
var val_min = $("input[name=min_records]",el).val();
var val_max = $("input[name=max_records]",el).val();
// priceSlider
var opt_min = $("input[name=min_records]",el).data('min');
var opt_max = $("input[name=max_records]",el).data('max');
var symbol = "$";
var step = 1;
$('.priceSlider',el).slider({
range: true,
min: opt_min,
max: opt_max,
values: [val_min, val_max],
step: step,
slide: function(event, ui) {
$('.priceSlider .sliderTooltip .stLabel',el).html(
ui.values[0].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") +symbol+
' <span class="fa fa-arrows-h"></span> ' +
ui.values[1].toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") +symbol
);
var priceSliderRangeLeft = parseInt($('.priceSlider .ui-slider-range',el).css('left'));
var priceSliderRangeWidth = $('.priceSlider .ui-slider-range',el).width();
var priceSliderLeft = priceSliderRangeLeft + ( priceSliderRangeWidth / 2 ) - ( $('.priceSlider .sliderTooltip',el).width() / 2 );
$('.priceSlider .sliderTooltip',el).css('left', priceSliderLeft);
// Set val
// console.log(ui.values[0]);
// console.log(ui.values[1]);
$("input[name=min_records]",el).val(ui.values[0]);
$("input[name=max_records]",el).val(ui.values[1]);
}
});
$('.priceSlider .sliderTooltip .stLabel',el).html(
$('.priceSlider',el).slider('values', 0).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") +symbol+
' <span class="fa fa-arrows-h"></span> ' +
$('.priceSlider',el).slider('values', 1).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") +symbol
);
var priceSliderRangeLeft = parseInt($('.priceSlider .ui-slider-range',el).css('left'));
var priceSliderRangeWidth = $('.priceSlider .ui-slider-range',el).width();
var priceSliderLeft = priceSliderRangeLeft + ( priceSliderRangeWidth / 2 ) - ( $('.priceSlider .sliderTooltip').width() / 2 );
$('.priceSlider .sliderTooltip',el).css('left', priceSliderLeft);
});
// Orders
})(jQuery);
</script>
</body>
</html>