feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)

Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-25 11:51:57 +01:00
commit 9716aac4ee

View file

@ -43,7 +43,7 @@
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
options/options.js changes, so every browser fetches the new file once. #}
{% set OPTIONS_JS_TOKEN = '20261125.1' %}
{% set OPTIONS_JS_TOKEN = '20261125.2' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
@ -163,12 +163,31 @@
next to it stays empty) directly below the logo hr, in this fixed order. #}
{% set aProgressKeys = ['progressbarposition', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor'] %}
{# Prompt U: the elements that get a font+color combo row in the "Fonts and
colors" pane. Per element <el> the keys are <el>font (fontselect),
<el>textcolor (dropdown default|primary|secondary|other) and
<el>textcolorcustom (colorpicker, visible only when <el>textcolor = "other"). #}
{% set aFontElements = ['header', 'progressbar', 'questiontitle', 'answers', 'grouptitle', 'groupdescription', 'buttons'] %}
{# Prompt R: multi-value show lists per parent key, rendered as
data-show-if-value (e.g. "box|top" for questionborder). Core passes only the
`parent` attribute through to the option attributes, so this list lives here
in the theme. Default 'on'. Used both for the wrapper attribute and for the
server-side initial d-none (Prompt Q). #}
server-side initial d-none (Prompt Q). Prompt U adds 'other' for every
<el>textcolor dropdown (parent of <el>textcolorcustom). #}
{% set aShowIfValues = { 'questionborder': 'box|top' } %}
{% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %}
{# Prompt U: the Fonts pane is rendered as "Fonts and colors" with a special
layout: a TOP ROW (col 1: font/fontcolor/fontsize; col 2: primarycolor/
secondarycolor; col 3 empty), an hr, then one combo row per element in
aFontElements (col 1: <el>font, col 2: <el>textcolor, col 3:
<el>textcolorcustom), then the remaining Fonts options (sizes/weights)
stacked as usual ("rest"). config.xml lists the Fonts options in exactly
this order, so the generic loop meets them slot by slot and opens/closes
the containers on slot change (fLastSlot). #}
{% set aFontsTop1 = ['font', 'fontcolor', 'fontsize'] %}
{% set aFontsTop2 = ['primarycolor', 'secondarycolor'] %}
{# Prompt R: the Questions pane renders as THREE columns (col-md-4, border-start
between them) with explicit key lists. config.xml lists the Questions options
@ -187,7 +206,7 @@
stay stable regardless of the tab order. #}
{% set aTabs = [] %}
{% if 'Fonts' in aOptionAttributes.categories %}
{% set aTabs = [{ 'id': 'category-fonts', 'label': 'Fonts', 'category': 'Fonts', 'keys': null }] %}
{% set aTabs = [{ 'id': 'category-fonts', 'label': 'Fonts and colors', 'category': 'Fonts', 'keys': null }] %}
{% endif %}
{% set aTabs = aTabs|merge([{ 'id': 'top-of-page', 'label': 'Top of the page', 'category': 'Top of the page', 'keys': aTopOfPageKeys }]) %}
{% for category in aOptionAttributes.categories %}
@ -249,6 +268,7 @@
below stays full width. #}
{% if tab.category == 'Images' %}<div class="col-md-4 images-options-column">{% endif %}
{% set qLastCol = 0 %}
{% set fLastSlot = 0 %}
{% for key in aTabKeys %}
{% set attr = aOptionAttributes.optionAttributes[key] ?? null %}
{% if attr is not null %}
@ -339,7 +359,36 @@
{% set qLastCol = qCol %}
{% endif %}
{% endif %}
{% if bQuestionsPane %}{% set wrapClass = 'col-12' %}{% elseif bProgressKey %}{% set wrapClass = 'col-12' %}{% else %}{% set wrapClass = 'col-12 col-md-' ~ attr.width|default(2) %}{% endif %}
{# Prompt U: Fonts pane ("Fonts and colors") — slot-based layout. Slots:
top1 (top row col 1), top2 (top row col 2), combo1/2/3 (per-element
combo row cols 1-3), rest (sizes/weights, normal grid). On slot
change close the previous container(s) and open the new one. All
slots except rest have exactly two open divs (row + col). #}
{% set bFontsPane = tab.category == 'Fonts' %}
{% set fSlot = 'rest' %}
{% if bFontsPane %}
{% if key in aFontsTop1 %}{% set fSlot = 'top1' %}
{% elseif key in aFontsTop2 %}{% set fSlot = 'top2' %}
{% else %}
{% for el in aFontElements %}
{% if key == el ~ 'font' %}{% set fSlot = 'combo1' %}
{% elseif key == el ~ 'textcolor' %}{% set fSlot = 'combo2' %}
{% elseif key == el ~ 'textcolorcustom' %}{% set fSlot = 'combo3' %}{% endif %}
{% endfor %}
{% endif %}
{% if fSlot != fLastSlot %}
{% if fLastSlot == 'top2' %}</div><div class="col-md-4"></div></div><div class="row action_hide_on_inherit"><div class="col-12"><hr class="fonts-hr"></div></div>{% endif %}
{% if fLastSlot == 'combo3' %}</div></div>{% endif %}
{% if fSlot == 'top1' %}<div class="row fonts-top-row"><div class="col-md-4">
{% elseif fSlot == 'top2' %}</div><div class="col-md-4">
{% elseif fSlot == 'combo1' %}<div class="row font-combo-row"><div class="col-md-4">
{% elseif fSlot == 'combo2' %}</div><div class="col-md-4">
{% elseif fSlot == 'combo3' %}</div><div class="col-md-4">
{% endif %}
{% set fLastSlot = fSlot %}
{% endif %}
{% endif %}
{% if bQuestionsPane or bProgressKey or (bFontsPane and fSlot != 'rest') %}{% set wrapClass = 'col-12' %}{% else %}{% set wrapClass = 'col-12 col-md-' ~ attr.width|default(2) %}{% endif %}
{# server-side current value for this option (checked/selected/value) #}
{% set currentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[key] is defined ? aCurrentOptions[key] : (oParentOptions[key] is defined ? oParentOptions[key] : '')) %}
{# parent != '': this field is only visible when the parent option's value
@ -347,20 +396,20 @@
questionborder, see aShowIfValues). options.js toggles
.option-visibility via data-show-if-parent/data-show-if-value;
the field itself is additionally disabled via data-parent/selector_radio_childfield #}
{# Prompt Q (multi-value since Prompt R): server-side INITIAL visibility —
when the parent is a buttons group, add d-none at render time unless the
parent's current value is IN the show-value list. Same source of truth
as currentValue (stored options JSON, fallback oParentOptions). options.js
{# Prompt Q (multi-value since Prompt R, dropdown parents since Prompt U):
server-side INITIAL visibility — when the parent is a buttons group
or a dropdown (e.g. <el>textcolorcustom with parent <el>textcolor,
show-value "other"), add d-none at render time unless the parent's
current value is IN the show-value list. Same source of truth as
currentValue (stored options JSON, fallback oParentOptions). options.js
updateVisibilityByParent() toggles the same class on change (idempotent
with this initial state). Non-buttons parents (e.g. font's self-parent
dropdown) have no radio inputs -> options.js always shows them, so no
d-none here. #}
with this initial state). #}
{% set bParentHidden = false %}
{% set showIfValues = 'on' %}
{% if attr.parent != '' %}
{% if attr.parent != '' and attr.parent != key %}
{% set parentAttr = aOptionAttributes.optionAttributes[attr.parent] ?? null %}
{% set showIfValues = aShowIfValues[attr.parent] ?? 'on' %}
{% if parentAttr is not null and parentAttr.type == 'buttons' %}
{% if parentAttr is not null and (parentAttr.type == 'buttons' or parentAttr.type == 'dropdown') %}
{% set parentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[attr.parent] is defined ? aCurrentOptions[attr.parent] : (oParentOptions[attr.parent] is defined ? oParentOptions[attr.parent] : '')) %}
{% if parentValue not in showIfValues|split('|') %}{% set bParentHidden = true %}{% endif %}
{% endif %}
@ -505,6 +554,9 @@
{% endfor %}
{% if tab.category == 'Images' %}</div>{% endif %}
{% if tab.category == 'Questions' and qLastCol > 0 %}</div>{% endif %}
{# Prompt U: close the Fonts pane's open slot container (every non-rest
slot has exactly two open divs: row + col) #}
{% if tab.category == 'Fonts' and fLastSlot != 0 and fLastSlot != 'rest' %}</div></div>{% endif %}
</div>
{% if tab.category == 'Images' %}