feat(slider): row 214 — grey handle for untouched sliders, theme color when touched
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<fname>, 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 <vibe@mistral.ai>
This commit is contained in:
parent
61d0aa2709
commit
368929c1cf
1 changed files with 43 additions and 0 deletions
|
|
@ -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<fname>, the .ls-js-hidden
|
||||
* one — NOT the #answer<fname>slid 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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue