fix: step navigation back-click bug and add shortcode lang attribute
Track highestStep so navigating backward preserves completed dots and allows clicking forward to any previously visited step. Add [umzugsliste lang="de|en"] shortcode attribute that switches locale via switch_to_locale() for per-page language control. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
var l10n = typeof umzugslisteL10n !== 'undefined' ? umzugslisteL10n : {};
|
||||
var TOTAL_STEPS = 9;
|
||||
var currentStep = 1;
|
||||
var highestStep = 1;
|
||||
|
||||
// ===== Utility Helpers =====
|
||||
|
||||
@@ -57,6 +58,7 @@
|
||||
if (target) target.classList.add('active');
|
||||
|
||||
currentStep = n;
|
||||
if (n > highestStep) highestStep = n;
|
||||
updateProgressBar();
|
||||
updateNavButtons();
|
||||
updateRunningTotalsVisibility();
|
||||
@@ -90,7 +92,7 @@
|
||||
dot.classList.remove('active', 'completed');
|
||||
if (step === currentStep) {
|
||||
dot.classList.add('active');
|
||||
} else if (step < currentStep) {
|
||||
} else if (step <= highestStep) {
|
||||
dot.classList.add('completed');
|
||||
}
|
||||
});
|
||||
@@ -98,7 +100,7 @@
|
||||
// Update progress fill
|
||||
var fill = qs('#progress-fill');
|
||||
if (fill) {
|
||||
var pct = ((currentStep - 1) / (TOTAL_STEPS - 1)) * 100;
|
||||
var pct = ((highestStep - 1) / (TOTAL_STEPS - 1)) * 100;
|
||||
fill.style.width = pct + '%';
|
||||
}
|
||||
}
|
||||
@@ -510,11 +512,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
// Progress dot click (backward navigation only)
|
||||
// Progress dot click (navigate to any visited step)
|
||||
qsa('.progress-dot').forEach(function(dot) {
|
||||
dot.addEventListener('click', function() {
|
||||
var step = parseInt(this.getAttribute('data-step'), 10);
|
||||
if (step < currentStep) {
|
||||
if (step <= highestStep && step !== currentStep) {
|
||||
showStep(step);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user