From 368929c1cf88c5ae296dad00189b29c6155c1648 Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Mon, 30 Nov 2026 08:57:23 +0100 Subject: [PATCH] =?UTF-8?q?feat(slider):=20row=20214=20=E2=80=94=20grey=20?= =?UTF-8?q?handle=20for=20untouched=20sliders,=20theme=20color=20when=20to?= =?UTF-8?q?uched?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Core's slider-untouched/slider-touched classes on the .slider element are not a reliable state signal (with slider_default_set an untouched slider keeps slider-touched), so the theme now derives the state itself: scripts/custom.js syncs a slider-is-untouched class onto li.slider-item from the real answer input (#answer, empty = untouched) on load and on every change/keyup that core fires on it; css/custom.css greys .slider-handle and makes .slider-selection transparent while that class is set (specificity 0,3,0 beats the .slider-handle rule in custom_header.twig, which still colors touched handles with sliderhandlecolor). Works for horizontal and vertical sliders; inherited by all variants via extends, no config.xml change. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- css/custom.css | 16 ++++++++++++++++ scripts/custom.js | 27 +++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/css/custom.css b/css/custom.css index 97ef28f..c1ece71 100644 --- a/css/custom.css +++ b/css/custom.css @@ -23,4 +23,20 @@ height: 25px; width: auto; vertical-align: middle; +} + +/* row 214: untouched slider = grey handle + transparent selection; touched = + sliderhandlecolor (the .slider-handle rule in custom_header.twig). + The slider-is-untouched class is synced onto li.slider-item by + scripts/custom.js from the answer input's value — core's own + slider-untouched class on the .slider element is unreliable when + "slider_default_set" is on. Specificity (0,3,0) beats the .slider-handle + rule (0,1,0) from custom_header.twig regardless of style-block order. */ +.slider-item.slider-is-untouched .slider-handle { + background-color: grey; +} + +.slider-item.slider-is-untouched .slider-selection { + background: transparent; + box-shadow: none; } \ No newline at end of file diff --git a/scripts/custom.js b/scripts/custom.js index 5c9694c..9ced8af 100644 --- a/scripts/custom.js +++ b/scripts/custom.js @@ -65,4 +65,31 @@ $(document).on('ready pjax:scriptcomplete',function(){ // namespaced so re-running on pjax:scriptcomplete never stacks duplicate handlers $(window).off('resize.stickyheader').on('resize.stickyheader', fixBodyPaddingSticky); fixBodyPaddingSticky(); + + /** + * THEME ADDITION: untouched vs touched slider (grey handle when untouched, + * sliderhandlecolor when touched — styled in css/custom.css). + * Core toggles slider-untouched/slider-touched on the .slider element, but + * that class is NOT a reliable state signal (with "slider_default_set" an + * untouched slider keeps slider-touched). The reliable signal is the real + * answer input inside .slider-container (#answer, the .ls-js-hidden + * one — NOT the #answerslid bootstrap-slider element): it is empty + * until the slider is used. Sync a theme class slider-is-untouched onto + * the li.slider-item row; core fires change+keyup on that input on every + * slider action (slideStart/slideStop/reset via triggerChanges). + */ + var syncSliderItems = function () { + $('.slider-item').each(function () { + var item = $(this); + var container = item.find('.slider-container').first(); + var rootId = (container.attr('id') || '').replace(/slid-container$/, ''); + var root = rootId ? $('#' + rootId) : $(); + if (!root.length) { return; } + item.toggleClass('slider-is-untouched', String(root.val()) === ''); + }); + }; + syncSliderItems(); + // namespaced + rebound so re-running on pjax:scriptcomplete never stacks duplicates + $(document).off('change.sliderstate keyup.sliderstate input.sliderstate'); + $(document).on('change.sliderstate keyup.sliderstate input.sliderstate', '.slider-container input', syncSliderItems); });