diff --git a/static/js/user_profile.js b/static/js/user_profile.js index 59f496a..d29f8b3 100644 --- a/static/js/user_profile.js +++ b/static/js/user_profile.js @@ -229,16 +229,48 @@ function onblurInputField(event,el){ // } function sliderInit() { - $('#id_weight').ionRangeSlider({ - skin: "round", - type: "single", - min: 0, - max: 1000, - from: 0, - step: 1, - grid: true, - grid_num: 5, - }); + + let $range = $("#id_weight"), + $input = $(".js-input"), + instance, + min = 0, + max = 1000, + start_value = document.querySelector(".range-slider") + + $range.ionRangeSlider({ + skin: "round", + type: "single", + min: min, + max: max, + from: start_value, + step: 1, + grid: true, + grid_num: 5, + onStart: function(data) { + $input.prop("value", data.from); + }, + onChange: function(data) { + $input.prop("value", data.from); + } + }); + + instance = $range.data("ionRangeSlider"); + + $input.on("change keyup", function() { + let val = $(this).prop("value"); + + // validate + if (val < min) { + val = min; + } else if (val > max) { + val = max; + } + + instance.update({ + from: val + }); + }); + } diff --git a/templates/blocks/profile/b_new_route.html b/templates/blocks/profile/b_new_route.html index 06bb809..5b5bc8d 100644 --- a/templates/blocks/profile/b_new_route.html +++ b/templates/blocks/profile/b_new_route.html @@ -208,6 +208,10 @@
+
+ +
+
{% if not errors_off and form.errors and form.errors.weight %} {{ form.errors.weight }}