function updateProgressValue() { return { // + 1 т.к. шаги начинаются с 1 counterCurrentStep: getActiveStepIndex() + 1, counterAllSteps: visibleStepsCount, progressCurrentStep: getActiveStepIndex(), progressAllSteps: hasCaptureForm ? visibleStepsCount : visibleStepsCount - 1, }; } function checkLastStep() { return getActiveStepIndex() === visibleStepsCount - 1; } function checkFirstStep() { return getActiveStepIndex() === 0; } function checkNextToLast() { return getActiveStepIndex() === visibleStepsCount - 2; } function showOrHideButtons() { if (!hasCaptureForm) { // нет формы захвата и шаг предпоследний if (checkNextToLast()) { nextBtn.style.display = 'none'; resultBtn.style.display = 'block'; submitBtnWrapper.style.display = 'none'; return; } if (checkLastStep()) { // если шаг последний и отсутствует форма захвата - показываем кнопку отправки формы nextBtn.style.display = 'none'; resultBtn.style.display = 'none'; submitBtnWrapper.style.display = 'block'; return; } } if (checkLastStep()) { // шаг последний и есть форма захвата – показываем кнопку открытия формы захвата nextBtn.style.display = 'none'; resultBtn.style.display = 'block'; submitBtnWrapper.style.display = 'none'; return; } nextBtn.style.display = 'block'; resultBtn.style.display = 'none'; submitBtnWrapper.style.display = 'none'; } function showStep(newStepIndex) { var currentStep = form.querySelector('.t-step-form__step_active'); var newStep = steps[newStepIndex]; if (currentStep) { animateStepSwitch(currentStep, newStep, { onNewStepAnimationStart: function () { t835_runLazyLoad(); checkIfShouldSubmitForm(); showOrHideButtons(); enableButtons(rec); var range = rec.querySelector('.t-range'); if (range) t_triggerEvent(range, 'displayChanged'); stepChangeInProgress = false; t835_adjustStepToHeight(rec); }, onAnimationStart: function () { stepChangeInProgress = true; disableButtons(rec); }, }); return; } if (newStep) newStep.classList.add('t-step-form__step_active'); t835_runLazyLoad(); checkIfShouldSubmitForm(); showOrHideButtons(); var range = rec.querySelector('.t-range'); if (range) t_triggerEvent(range, 'displayChanged'); setTimeout(function () { t835_adjustStepToHeight(rec); }, 100);