fix(options): checkbox box before label, labels above controls, live color-swatch sync

- checkboxes (incl. the 9 logo show-on boxes): back to classic .form-check
  with the input BEFORE the label (label right of the box); label keeps id
  lbl_simple_edit_options_<key> so JS/test anchors are unchanged
- all other option types: label gets d-block so it sits above the control
  even next to an inline-flex btn-group (Simple options / Questions tabs)
- options.js: color swatch syncs on 'input' as well as 'change', so a color
  picked in the native popup is already in the saved JSON when Save is
  clicked (browsers fire 'change' only when the popup closes);
  OPTIONS_JS_TOKEN bumped to 20261125.3

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-25 21:05:01 +01:00
commit 588199086a
2 changed files with 31 additions and 18 deletions

View file

@ -511,8 +511,13 @@ var ThemeOptions = function () {
//hotswapping the colorpickers and adding the reset functionality //hotswapping the colorpickers and adding the reset functionality
var hotswapColorPicker = function () { var hotswapColorPicker = function () {
// THEME ADDITION: bind 'input' as well as 'change' — browsers fire 'input'
// live while the native color popup is dragged and 'change' only when it
// closes, so without 'input' a color picked but not yet "closed" would be
// lost when Save is clicked; syncing live makes the text field (and thus
// the saved options JSON) always carry the latest picked color.
globalForm.find('.selector__colorpicker-inherit-value') globalForm.find('.selector__colorpicker-inherit-value')
.on('change', function (e) { .on('change input', function (e) {
$(this).closest('.input-group').find('.selector_option_value_field').val($(this).val()).trigger('change'); $(this).closest('.input-group').find('.selector_option_value_field').val($(this).val()).trigger('change');
}); });

View file

@ -43,7 +43,7 @@
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control).
Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever Re-register it with a version token: bump OPTIONS_JS_TOKEN below whenever
options/options.js changes, so every browser fetches the new file once. #} options/options.js changes, so every browser fetches the new file once. #}
{% set OPTIONS_JS_TOKEN = '20261125.2' %} {% set OPTIONS_JS_TOKEN = '20261125.3' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
@ -355,13 +355,13 @@
{% set ckey = pos ~ 'showon' ~ dev %} {% set ckey = pos ~ 'showon' ~ dev %}
{% set cattr = aOptionAttributes.optionAttributes[ckey] %} {% set cattr = aOptionAttributes.optionAttributes[ckey] %}
{% set ccv = bGeneralInherit ? 'inherit' : (aCurrentOptions[ckey] is defined ? aCurrentOptions[ckey] : (oParentOptions[ckey] is defined ? oParentOptions[ckey] : '')) %} {% set ccv = bGeneralInherit ? 'inherit' : (aCurrentOptions[ckey] is defined ? aCurrentOptions[ckey] : (oParentOptions[ckey] is defined ? oParentOptions[ckey] : '')) %}
<div class="mb-1"> <div class="form-check mb-1">
<label for="simple_edit_options_{{ ckey }}" id="lbl_simple_edit_options_{{ ckey }}" class="form-label">{{ gT(cattr.title) }}</label>
<input type="checkbox" value="on" <input type="checkbox" value="on"
{% if ccv == 'on' %}checked{% endif %} {% if ccv == 'on' %}checked{% endif %}
class="form-check-input selector_option_checkbox_field" class="form-check-input selector_option_checkbox_field"
data-inheritvalue="{{ oParentOptions[ckey] }}" data-inheritvalue="{{ oParentOptions[ckey] }}"
id="simple_edit_options_{{ ckey }}" name="{{ ckey }}"> id="simple_edit_options_{{ ckey }}" name="{{ ckey }}">
<label for="simple_edit_options_{{ ckey }}" id="lbl_simple_edit_options_{{ ckey }}" class="form-check-label">{{ gT(cattr.title) }}</label>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
@ -409,8 +409,13 @@
<div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden %} d-none{% endif %}{% endif %}" <div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden %} d-none{% endif %}{% endif %}"
{% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="{{ showIfValues }}"{% endif %}> {% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="{{ showIfValues }}"{% endif %}>
<div class="mb-3"> <div class="mb-3">
{# label ALWAYS above the control, for every option type #} {# label ALWAYS above the control, for every option type EXCEPT checkbox
<label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-label">{{ gT(attr.title) }}</label> (checkboxes carry their label to the RIGHT of the box, rendered in
the checkbox branch below). d-block so the label gets its own line
even next to an inline-flex control (btn-group buttons). #}
{% if attr.type != 'checkbox' %}
<label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-label d-block">{{ gT(attr.title) }}</label>
{% endif %}
{% if key == 'headersticky' %} {% if key == 'headersticky' %}
{% elseif attr.type == 'buttons' %} {% elseif attr.type == 'buttons' %}
@ -435,18 +440,21 @@
</div> </div>
{% elseif attr.type == 'checkbox' %} {% elseif attr.type == 'checkbox' %}
{# checkbox: checked = "on", unchecked = "off". The label sits above {# checkbox: checked = "on", unchecked = "off". The box comes BEFORE
the box via the generic form-label at the top of this block (same its label (classic .form-check, label to the right of the box); the
id lbl_simple_edit_options_<key>, so tests/JS anchors keep working). label keeps the same id (lbl_simple_edit_options_<key>) so tests/JS
With survey-level inherit, an untouched box keeps the value anchors keep working. With survey-level inherit, an untouched box
"inherit" (options.js: data was-inherit). Children of a parent keeps the value "inherit" (options.js: data was-inherit). Children
switch get selector_radio_childfield + data-parent. #} of a parent switch get selector_radio_childfield + data-parent. #}
<input type="checkbox" value="on" <div class="form-check">
{% if currentValue == 'on' %}checked{% endif %} <input type="checkbox" value="on"
class="form-check-input selector_option_checkbox_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}" {% if currentValue == 'on' %}checked{% endif %}
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %} class="form-check-input selector_option_checkbox_field {% if attr.parent != '' %}selector_radio_childfield{% endif %}"
data-inheritvalue="{{ oParentOptions[key] }}" {% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
id="simple_edit_options_{{ key }}" name="{{ key }}"> data-inheritvalue="{{ oParentOptions[key] }}"
id="simple_edit_options_{{ key }}" name="{{ key }}">
<label for="simple_edit_options_{{ key }}" id="lbl_simple_edit_options_{{ key }}" class="form-check-label">{{ gT(attr.title) }}</label>
</div>
{% elseif attr.type == 'dropdown' %} {% elseif attr.type == 'dropdown' %}
{% set ddClasses = 'form-select selector_option_value_field' %} {% set ddClasses = 'form-select selector_option_value_field' %}