jQuery(function($){$(".range").each(function(){var parent=$(this);var track=parent.find(".track")[0];var labelMin=parent.find(".label-min")[0];var labelMax=parent.find(".label-max")[0];var left=parent.find('input[type="range"]').eq(0)[0];var right=parent.find('input[type="range"]').eq(1)[0];var fake=parent.find('input[type="hidden"]')[0];var min=+(left.min||0);var max=+(left.max||100);var value=fake.value===null?[min,max]:fake.value.split(",");left.value=value[0];right.value=value[1];function update(){value[0]=parseFloat(left.value);value[1]=parseFloat(right.value);if(value[1]<=value[0]){value[1]=value[0]+1}else if(value[0]>=value[1]){value[1]=value[0]+1} var low=100*((value[0]-min)/(max-min))+0.001;var high=100*((value[1]-min)/(max-min))-0.001;track.style.setProperty("--low",low+"%");track.style.setProperty("--high",high+"%");labelMin.style.setProperty("--low",low+"%");labelMin.innerText=labelMin.dataset.text.replace("{value}",value[0]);labelMax.style.setProperty("--high",100-high+"%");labelMax.innerText=labelMax.dataset.text.replace("{value}",value[1]);fake.value=value.join(",");left.value=value[0];right.value=value[1]} function passClick(event){var offsetX=event.offsetX;if(!offsetX){var rect=event.target.getBoundingClientRect();offsetX=event.targetTouches[0].pageX-rect.left} var clickPoint=offsetX/track.offsetWidth;var clickValue=(max-min)*clickPoint+min;var realClick=clickValue-min;var realLeft=value[0]-min;var realRight=value[1]-min;var lowDiff=Math.abs(realLeft-realClick);var highDiff=Math.abs(realRight-realClick);if(highDiff>lowDiff){if(event.currentTarget==left){return} event.stopPropagation();event.preventDefault();right.style.zIndex=2;left.style.zIndex=3;left.value=Math.round(clickValue);update()}else{if(event.currentTarget==right){return} event.stopPropagation();event.preventDefault();left.style.zIndex=2;right.style.zIndex=3;right.value=Math.round(clickValue);update()} return!1} left.addEventListener("input",update);right.addEventListener("input",update);update();left.addEventListener("mousedown",passClick);right.addEventListener("mousedown",passClick);left.addEventListener("touchstart",passClick);right.addEventListener("touchstart",passClick)})}) ;