diff --git a/main/_front/src/html/elems/stepper.html b/main/_front/src/html/elems/stepper.html index 5f9fa11..9cb6de5 100644 --- a/main/_front/src/html/elems/stepper.html +++ b/main/_front/src/html/elems/stepper.html @@ -14,7 +14,7 @@
Минимальное значение везде 1. Максимальное значение задается в data-max
Минимальное значение: 1; максимальное: 10
-
+
+
\ No newline at end of file diff --git a/main/_front/src/js/elems/stepper.js b/main/_front/src/js/elems/stepper.js index 49ef2ec..cb4cb14 100644 --- a/main/_front/src/js/elems/stepper.js +++ b/main/_front/src/js/elems/stepper.js @@ -55,4 +55,32 @@ steppers.forEach(stepper => { } } }) -}) \ No newline at end of file +}) + +const stepperChange = (item, value) => { + const minus_btn = item.querySelector('.stepper__minus'); + const plus_btn = item.querySelector('.stepper__plus'); + const stepper_value = item.querySelector('.stepper__value'); + + const max = item.dataset.max; + stepper_value.textContent = value; + + if (checkMinDisabled(stepper_value)){ + minus_btn.disabled = true; + stepper_value.textContent = "1"; + }else { + minus_btn.disabled = false; + } + if (checkMaxDisabled(stepper_value, max)){ + plus_btn.disabled = true; + stepper_value.textContent = max; + }else { + plus_btn.disabled = false; + } +} + +const change_parameter = document.querySelector("#change_parameter"); +console.log(change_parameter); +change_parameter.addEventListener("click", (e) => { + stepperChange(document.querySelector("#type"), 10); +})