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:
parent
671fba4aff
commit
9716aac4ee
2 changed files with 386 additions and 110 deletions
|
|
@ -311,14 +311,22 @@ var ThemeOptions = function () {
|
|||
let enabled = true;
|
||||
|
||||
if(parentEl.length) {
|
||||
// THEME ADDITION (Prompt R): parentEl is a SET of radios — read the
|
||||
// CHECKED one (not the first element) and accept any of the wrapper's
|
||||
// show-values (data-show-if-value, pipe-separated). Single-value
|
||||
// parents ('on') behave exactly as before.
|
||||
const checked = parentEl.filter(':checked');
|
||||
const wrapper = $(childEl).closest('.option-visibility');
|
||||
const showValues = String(wrapper.data('show-if-value') || 'on').split('|');
|
||||
enabled = checked.length > 0 && showValues.indexOf(String(checked.val())) !== -1;
|
||||
// THEME ADDITION (Prompt U): the parent may also be a <select> (e.g.
|
||||
// <el>textcolorcustom has parent <el>textcolor, a dropdown) — read the
|
||||
// select's current value instead of a checked radio.
|
||||
const parentSelect = parentEl.filter('select');
|
||||
if (parentSelect.length) {
|
||||
enabled = showValues.indexOf(String(parentSelect.val())) !== -1;
|
||||
} else {
|
||||
// THEME ADDITION (Prompt R): parentEl is a SET of radios — read the
|
||||
// CHECKED one (not the first element) and accept any of the wrapper's
|
||||
// show-values (data-show-if-value, pipe-separated). Single-value
|
||||
// parents ('on') behave exactly as before.
|
||||
const checked = parentEl.filter(':checked');
|
||||
enabled = checked.length > 0 && showValues.indexOf(String(checked.val())) !== -1;
|
||||
}
|
||||
}
|
||||
|
||||
$(childEl).prop('disabled', !enabled);
|
||||
|
|
@ -327,7 +335,8 @@ var ThemeOptions = function () {
|
|||
// grab the parent for a given child field
|
||||
const getParent = function(childEl) {
|
||||
const parentName = $(childEl).data('parent');
|
||||
const parentEl = $(`input[name=${parentName}]`);
|
||||
// THEME ADDITION (Prompt U): match selects too, not only radio inputs
|
||||
const parentEl = $(`input[name=${parentName}], select[name=${parentName}]`);
|
||||
return parentEl;
|
||||
};
|
||||
|
||||
|
|
@ -353,12 +362,20 @@ var ThemeOptions = function () {
|
|||
// value keeps working unchanged.
|
||||
const showValues = String($(wrapperEl).data('show-if-value') || 'on').split('|');
|
||||
const parentInputs = $('input[name="' + parentName + '"]');
|
||||
// no parent input in the markup (e.g. font's self-parent): always visible,
|
||||
const parentSelects = $('select[name="' + parentName + '"]');
|
||||
// no parent input in the markup: always visible,
|
||||
// same fallback as updateChild() above
|
||||
if (parentInputs.length === 0) {
|
||||
if (parentInputs.length === 0 && parentSelects.length === 0) {
|
||||
$(wrapperEl).removeClass('d-none');
|
||||
return;
|
||||
}
|
||||
// THEME ADDITION (Prompt U): select parent (e.g. <el>textcolor dropdown) —
|
||||
// visibility follows the select's current value, multi-value aware
|
||||
if (parentInputs.length === 0 && parentSelects.length > 0) {
|
||||
const visible = showValues.indexOf(String(parentSelects.val())) !== -1;
|
||||
$(wrapperEl).toggleClass('d-none', !visible);
|
||||
return;
|
||||
}
|
||||
const checked = parentInputs.filter(':checked');
|
||||
const visible = checked.length > 0 && showValues.indexOf(String(checked.val())) !== -1;
|
||||
$(wrapperEl).toggleClass('d-none', !visible);
|
||||
|
|
@ -621,6 +638,15 @@ var ThemeOptions = function () {
|
|||
|
||||
// THEME ADDITION: re-evaluate conditional visibility whenever a radio changes
|
||||
globalForm.find('.selector_option_radio_field').on('change', updateVisibilityByParent);
|
||||
|
||||
// THEME ADDITION (Prompt U): a changed SELECT may also be a parent of
|
||||
// conditional fields (e.g. <el>textcolor driving <el>textcolorcustom) —
|
||||
// bound separately so visibility updates even if updateFieldSettings()
|
||||
// above throws on the same event
|
||||
globalForm.find('select').on('change', function () {
|
||||
updateVisibilityByParent();
|
||||
updateAllChildren();
|
||||
});
|
||||
};
|
||||
|
||||
// THEME ADDITION: order the font dropdowns' optgroups as:
|
||||
|
|
|
|||
|
|
@ -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' %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue