feat(options): roll the color-chooser scheme out to 4 more options (row 135)

The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
  underneath: "Make this font color the same color as the color of the progress
  bar when you do not want to see the progress in %."

Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-26 19:14:47 +01:00
commit cfbb4c983b
5 changed files with 184 additions and 63 deletions

View file

@ -205,8 +205,27 @@
<!-- Various colors -->
<!-- Backgrounds of navbar/page stay plain colorpickers (owner decision
2026-11-26, row 115): they are mostly NOT one of the default colors,
default white #ffffff. -->
<headerbackgroundcolor type="colorpicker" category="Colors" width="12" title="Header background color" options="on|off" optionlabels="Yes|No">#ffffff</headerbackgroundcolor>
default white #ffffff. EXCEPTION (row 135): the HEADER background color
is part of the color-chooser scheme below — default "Default background
color". -->
<!-- Row 135: the color-chooser scheme (mode dropdown + swatch chips + custom
picker; see navbarfontcolor) rolled out to four more options. Defaults per
owner (row 135): header background = Default background color, progress
bar color = Color 1, progress background = Default background color,
progress font color = Default font color. The <option data-default="1">
carries the [ ] marker of that option's own default. A legacy stored HEX
value migrates client-side to mode "other" + hex into the <key>custom
child (options.js colorModeUI), and the views accept a raw hex directly. -->
<headerbackgroundcolor type="dropdown" category="Colors" width="12" title="Header background color" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Default font color|Default background color|Color 1|Color 2|Color 3|Other ...">defaultbackgroundcolor
<dropdownoptions>
<option value="default">Default font color</option>
<option value="defaultbackgroundcolor" data-default="1">[Default background color]</option>
<option value="color1">Color 1</option>
<option value="color2">Color 2</option>
<option value="color3">Color 3</option>
<option value="other">Other ...</option>
</dropdownoptions></headerbackgroundcolor>
<headerbackgroundcolorcustom type="colorpicker" category="Colors" width="12" title="Custom header background color (used when 'Other ...' is chosen)" parent="headerbackgroundcolor">#ffffff</headerbackgroundcolorcustom>
<!-- Working example (row 115, reordered + relabelled row 125): menu item color
as a preset dropdown. The KEY navbarfontcolor is kept (stored DB values
stay attached); the type changes colorpicker -> dropdown with modes
@ -242,9 +261,41 @@
</dropdownoptions></navbarfontcolor>
<navbarfontcolorcustom type="colorpicker" category="Colors" width="12" title="Custom menu item color (used when 'Other ...' is chosen)" parent="navbarfontcolor">#444444</navbarfontcolorcustom>
<sliderhandlecolor type="colorpicker" category="Colors" width="12" title="Slider handle color" options="on|off" optionlabels="Yes|No">#5e1c64</sliderhandlecolor>
<progressbarbackgroundcolor type="colorpicker" category="Colors" width="12" title="Progress bar background color" options="on|off" optionlabels="Yes|No">#eeeeee</progressbarbackgroundcolor>
<progressbarcolor type="colorpicker" category="Colors" width="12" title="Progress bar color" options="on|off" optionlabels="Yes|No">#5e1c64</progressbarcolor>
<progressbarfontcolor type="colorpicker" category="Colors" width="12" title="Progress bar font color" options="on|off" optionlabels="Yes|No">#ffffff</progressbarfontcolor>
<!-- Row 135: progress bar colors as color-choosers. Layout in the "Top of the
page" tab (options.twig slots): progress bar color = COLUMN 1, progress
background = COLUMN 2, progress font color = COLUMN 3 (with an extra tip
underneath). Defaults: progress bar color = Color 1, progress background =
Default background color, progress font color = Default font color. -->
<progressbarcolor type="dropdown" category="Colors" width="12" title="Progress bar color" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Default font color|Default background color|Color 1|Color 2|Color 3|Other ...">color1
<dropdownoptions>
<option value="default">Default font color</option>
<option value="defaultbackgroundcolor">Default background color</option>
<option value="color1" data-default="1">[Color 1]</option>
<option value="color2">Color 2</option>
<option value="color3">Color 3</option>
<option value="other">Other ...</option>
</dropdownoptions></progressbarcolor>
<progressbarcolorcustom type="colorpicker" category="Colors" width="12" title="Custom progress bar color (used when 'Other ...' is chosen)" parent="progressbarcolor">#5e1c64</progressbarcolorcustom>
<progressbarbackgroundcolor type="dropdown" category="Colors" width="12" title="Progress bar background color" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Default font color|Default background color|Color 1|Color 2|Color 3|Other ...">defaultbackgroundcolor
<dropdownoptions>
<option value="default">Default font color</option>
<option value="defaultbackgroundcolor" data-default="1">[Default background color]</option>
<option value="color1">Color 1</option>
<option value="color2">Color 2</option>
<option value="color3">Color 3</option>
<option value="other">Other ...</option>
</dropdownoptions></progressbarbackgroundcolor>
<progressbarbackgroundcolorcustom type="colorpicker" category="Colors" width="12" title="Custom progress bar background color (used when 'Other ...' is chosen)" parent="progressbarbackgroundcolor">#eeeeee</progressbarbackgroundcolorcustom>
<progressbarfontcolor type="dropdown" category="Colors" width="12" title="Progress bar font color" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Default font color|Default background color|Color 1|Color 2|Color 3|Other ...">default
<dropdownoptions>
<option value="default" data-default="1">[Default font color]</option>
<option value="defaultbackgroundcolor">Default background color</option>
<option value="color1">Color 1</option>
<option value="color2">Color 2</option>
<option value="color3">Color 3</option>
<option value="other">Other ...</option>
</dropdownoptions></progressbarfontcolor>
<progressbarfontcolorcustom type="colorpicker" category="Colors" width="12" title="Custom progress bar font color (used when 'Other ...' is chosen)" parent="progressbarfontcolor">#ffffff</progressbarfontcolorcustom>
<privacybackgroundcolor type="colorpicker" category="Colors" width="12" title="Privacy background color" options="on|off" optionlabels="Yes|No">lightyellow</privacybackgroundcolor>
<!-- fonts
HOUSE-STYLE: the whole Fonts section (font choice, fontsize and all

View file

@ -19,11 +19,21 @@ var ThemeOptions = function () {
"general_inherit": 1
}
// THEME ADDITION (row 115): legacy hex value of navbarfontcolor, captured right
// after parseOptionObject — later startup steps (prepareSelectField val() with a
// non-matching value, then updateFieldSettings) can clobber optionObject, so the
// migration in navbarColorModeUI must use this snapshot.
var legacyNavbarFontColor = null;
// THEME ADDITION (row 115, generalized row 135): legacy hex values of the
// color-chooser options, captured right after parseOptionObject — later startup
// steps (prepareSelectField val() with a non-matching value, then
// updateFieldSettings) can clobber optionObject, so the migration in colorModeUI
// must use this snapshot.
var legacyColorValues = {};
// row 135: all options that use the color-chooser scheme (mode dropdown with
// class selector_color_mode + swatch chips + a <key>custom colorpicker child)
var aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor'];
// the 5 presets, in the SAME order as the dropdown options in config.xml
// (object key order = swatch chip order) — row 125: "Default background color"
// is the SECOND choice, right after "Default font color".
var colorPresets = { 'default': 'fontcolor', 'defaultbackgroundcolor': 'defaultbackgroundcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor' };
// one refreshAll per chooser, called by the shared delegated handlers
var colorModeRefreshers = [];
// THEME FIX: on the GLOBAL theme-options page the hidden #optionCssFiles can
// hold the literal string "inherit" (not JSON) — an unguarded JSON.parse then
@ -735,25 +745,21 @@ var ThemeOptions = function () {
});
};
// THEME ADDITION (row 115, working example on navbarfontcolor only): preset-dropdown
// UI for the "Menu item color in header" option.
// - option labels of the navbarfontcolor dropdown get the LIVE hex of the preset
// they point at ("Color 1 [#5e1c64]" — values read from the stored options JSON /
// THEME ADDITION (row 115 on navbarfontcolor, generalized row 135 to every key in
// aColorChooserKeys): preset-dropdown UI for a color-chooser option.
// - option labels of the dropdown get the LIVE hex of the preset they point at
// ("Color 1 [#5e1c64]" — values read from the stored options JSON /
// the fields' data-inheritvalue, so they also work at survey level with inherit)
// - clickable swatch chips next to the dropdown (one per preset; click = choose it)
// - an "effective color" swatch appended to the custom picker's input group, showing
// the color that is actually applied for the current mode (overwritable by picking
// another color when mode is "other")
// - legacy migration: a stored HEX value of navbarfontcolor (from before the option
// became a dropdown) selects mode "other" and moves the hex into navbarfontcolorcustom
var navbarColorModeUI = function () {
var sel = globalForm.find('select[name="navbarfontcolor"]');
// - legacy migration: a stored HEX value (from before the option became a
// dropdown) selects mode "other" and moves the hex into the <key>custom child
var colorModeUI = function (key) {
var sel = globalForm.find('select[name="' + key + '"]');
if (!sel.length) { return; }
// row 124/125: 5 presets, in the SAME order as the dropdown options in
// config.xml (object key order = swatch chip order) — row 125: the
// "Default background color" is the SECOND choice, right after "Same as
// default font color".
var presets = { 'default': 'fontcolor', 'defaultbackgroundcolor': 'defaultbackgroundcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor' };
var presets = colorPresets;
// row 126/134: the option's DEFAULT choice — the config.xml <option data-default="1">
// (same value as the <default> element text). In the dropdown LIST it is
// enclosed in [ ] (bolding <option> is not rendered by every browser — row 134);
@ -764,9 +770,10 @@ var ThemeOptions = function () {
|| sel.data('inheritvalue')
|| sel.find('option').not('[value="inherit"]').first().attr('value')
|| '');
var customInput = globalForm.find('input[name="navbarfontcolorcustom"]');
var currentColor = function (key) {
var f = globalForm.find('#simple_edit_options_' + key);
var customInput = globalForm.find('input[name="' + key + 'custom"]');
var rowLabel = String(sel.closest('.mb-3').find('.form-label').first().text() || key);
var currentColor = function (ckey) {
var f = globalForm.find('#simple_edit_options_' + ckey);
var v = f.val();
if (!v) { v = f.data('inheritvalue'); }
return v ? String(v) : '';
@ -850,11 +857,12 @@ var ThemeOptions = function () {
}
var c = effectiveColor();
sw.css('background', c || 'transparent');
sw.attr('title', c ? 'Effective menu item color: ' + c : 'Effective menu item color: (none)');
sw.attr('title', c ? 'Effective color (' + rowLabel + '): ' + c : 'Effective color (' + rowLabel + '): (none)');
};
var refreshAll = function () { refreshLabels(); refreshChips(); refreshEffective(); };
colorModeRefreshers.push(refreshAll);
// legacy migration: stored hex (pre-dropdown value) -> mode "other" + hex into the custom field
var stored = legacyNavbarFontColor;
var stored = legacyColorValues[key];
if (typeof stored === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(stored)) {
sel.val('other');
if (customInput.length && !/^#[0-9a-fA-F]{3,8}$/.test(String(customInput.val() || ''))) {
@ -876,13 +884,22 @@ var ThemeOptions = function () {
}
refreshAll();
sel.on('change', refreshAll);
// Delegated backup: a REAL user change event bubbles natively to document even
// when an earlier direct handler threw (jQuery only aborts synthetic triggers),
// so the active outline still moves on the chosen swatch (row 122).
$(document).on('change', 'select[name="navbarfontcolor"]', refreshAll);
if (customInput.length) { customInput.on('input change', refreshAll); }
$.each(['fontcolor', 'primarycolor', 'secondarycolor', 'tertiarycolor', 'defaultbackgroundcolor'], function (i, key) {
globalForm.find('#simple_edit_options_' + key).on('input change', refreshAll);
};
// Shared delegated handlers for ALL chooser dropdowns (row 122/135): a REAL user
// change event bubbles natively to document even when an earlier direct handler
// threw (jQuery only aborts synthetic triggers), so the active outline still moves
// on the chosen swatch. Bound once, calling every chooser's refreshAll.
var bindColorModeDelegates = function () {
$(document).on('change', 'select.selector_color_mode', function () {
$.each(colorModeRefreshers, function (i, fn) { try { fn(); } catch (e) { /* keep the others running */ } });
});
// live hex labels/chips update when one of the shared color fields changes
$.each(['fontcolor', 'primarycolor', 'secondarycolor', 'tertiarycolor', 'defaultbackgroundcolor'], function (i, ckey) {
globalForm.find('#simple_edit_options_' + ckey).on('input change', function () {
$.each(colorModeRefreshers, function (j, fn) { try { fn(); } catch (e) { /* ignore */ } });
});
});
};
@ -906,14 +923,17 @@ var ThemeOptions = function () {
var run = function () {
safeStep('parseOptionObject', parseOptionObject);
// THEME ADDITION (row 115): snapshot a legacy hex navbarfontcolor before other
// startup steps can clobber optionObject (prepareSelectField + updateFieldSettings)
safeStep('captureNavbarLegacy', function () {
var v = optionObject['navbarfontcolor'];
// THEME ADDITION (row 115, generalized row 135): snapshot a legacy hex value of
// every color-chooser option before other startup steps can clobber
// optionObject (prepareSelectField + updateFieldSettings)
safeStep('captureLegacyColorValues', function () {
$.each(aColorChooserKeys, function (i, k) {
var v = optionObject[k];
if (typeof v === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(v)) {
legacyNavbarFontColor = v;
legacyColorValues[k] = v;
}
});
});
safeStep('startupGeneralInherit', startupGeneralInherit);
@ -937,11 +957,15 @@ var ThemeOptions = function () {
// THEME ADDITION: set initial visibility of conditional fields
safeStep('updateVisibilityByParent', updateVisibilityByParent);
// THEME ADDITION (row 115): preset-dropdown UI for navbarfontcolor (labels,
// swatch chips, effective-color swatch, legacy hex migration) — AFTER
// parseOptionObject (needs the stored optionObject) and AFTER
// updateAllChildren/updateVisibilityByParent (mode "other" enables the child)
safeStep('navbarColorModeUI', navbarColorModeUI);
// THEME ADDITION (row 115, generalized row 135): preset-dropdown UI for every
// color-chooser option (labels with live hex, swatch chips, effective-color
// swatch, legacy hex migration) — AFTER parseOptionObject (needs the stored
// optionObject) and AFTER updateAllChildren/updateVisibilityByParent
// (mode "other" enables the child)
$.each(aColorChooserKeys, function (i, k) {
safeStep('colorModeUI:' + k, function () { colorModeUI(k); });
});
safeStep('bindColorModeDelegates', bindColorModeDelegates);
// THEME ADDITION (row 133): restore the options tab the user was on before
// Save (after a save the page reloads on the first tab)

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 = '20261126.13' %}
{% set OPTIONS_JS_TOKEN = '20261126.14' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
@ -224,12 +224,13 @@
Values are stored per option key, so moving them here does not change any stored
value. The order of this list is the order shown in the tab. #}
{% set aTopOfPageKeys = [
'headerbackgroundcolor', 'headerfont', 'navbarfontcolor', 'navbarfontcolorcustom',
'headerbackgroundcolor', 'headerbackgroundcolorcustom', 'headerfont', 'navbarfontcolor', 'navbarfontcolorcustom',
'headersticky', 'headerstickycomputer', 'headerstickytablet', 'headerstickymobile',
'brandlogofile', 'brandlogotopmargin', 'brandshowoncomputer', 'brandshowontablet', 'brandshowonmobile',
'centerlogofile', 'centerlogotopmargin', 'centershowoncomputer', 'centershowontablet', 'centershowonmobile',
'rightlogofile', 'rightlogotopmargin', 'rightshowoncomputer', 'rightshowontablet', 'rightshowonmobile',
'progressbarposition', 'progressbarfont', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor'
'progressbarposition', 'progressbarfont', 'progressbarcolor', 'progressbarcolorcustom',
'progressbarbackgroundcolor', 'progressbarbackgroundcolorcustom', 'progressbarfontcolor', 'progressbarfontcolorcustom'
] %}
{% set aLogoKeys = [
'brandlogofile', 'brandlogotopmargin', 'brandshowoncomputer', 'brandshowontablet', 'brandshowonmobile',
@ -244,8 +245,11 @@
{% set aFontElements = ['questiontitle', 'answers', 'grouptitle', 'groupdescription', 'buttons'] %}
{% set aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor'] %}
{% set aShowIfValues = { 'questionborder': 'box|top', 'navbarfontcolor': 'other' } %}
{% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %}
{% for ck in aColorChooserKeys %}{% set aShowIfValues = aShowIfValues|merge({ (ck): 'other' }) %}{% endfor %}
{# How a parented option behaves when the parent's value is NOT in the show-values:
default 'hide' = wrapper gets d-none; 'disable' = wrapper STAYS VISIBLE but the
@ -253,6 +257,7 @@
options.js keeps its stored value across saves. Working example: navbarfontcolor
(row 115) — the custom color picker stays visible next to the mode dropdown. #}
{% set aShowIfMode = { 'navbarfontcolor': 'disable' } %}
{% for ck in aColorChooserKeys %}{% set aShowIfMode = aShowIfMode|merge({ (ck): 'disable' }) %}{% endfor %}
{% set aFontsRow1 = ['font', 'fontcolor', 'fontsize'] %}
{% set aFontsRow2 = ['primarycolor', 'secondarycolor', 'tertiarycolor'] %}
@ -366,15 +371,22 @@
{% elseif bTopPane %}
{% if key in aLogoKeys %}{% set fSlot = 'logo' %}
{% elseif key == 'headerbackgroundcolor' %}{% set fSlot = 'h1' %}
{% elseif key == 'headerbackgroundcolorcustom' %}{% set fSlot = 'h1' %}
{% elseif key == 'headerfont' %}{% set fSlot = 'hf' %}
{% elseif key == 'navbarfontcolor' %}{% set fSlot = 'h2' %}
{% elseif key == 'navbarfontcolorcustom' %}{% set fSlot = 'h2' %}
{% elseif key in aTopStickyKeys %}{% set fSlot = 'h3' %}
{% elseif key == 'progressbarposition' %}{% set fSlot = 'ppos' %}
{% elseif key == 'progressbarfont' %}{% set fSlot = 'pfont' %}
{% elseif key == 'progressbarbackgroundcolor' %}{% set fSlot = 'pcol1' %}
{% elseif key == 'progressbarcolor' %}{% set fSlot = 'pcol2' %}
{# row 135: progress bar colors row — col 1 = progress bar color,
col 2 = progress background, col 3 = progress font color
(custom children share their parent's column) #}
{% elseif key == 'progressbarcolor' %}{% set fSlot = 'pcol1' %}
{% elseif key == 'progressbarcolorcustom' %}{% set fSlot = 'pcol1' %}
{% elseif key == 'progressbarbackgroundcolor' %}{% set fSlot = 'pcol2' %}
{% elseif key == 'progressbarbackgroundcolorcustom' %}{% set fSlot = 'pcol2' %}
{% elseif key == 'progressbarfontcolor' %}{% set fSlot = 'pcol3' %}
{% elseif key == 'progressbarfontcolorcustom' %}{% set fSlot = 'pcol3' %}
{% endif %}
{% endif %}
{% if fSlot != fLastSlot and (bFontsPane or bTopPane) %}
@ -559,6 +571,7 @@
{% if attr.parent != '' %}{% set ddClasses = ddClasses ~ ' selector_radio_childfield' %}{% endif %}
{% if tab.category == 'Images' %}{% set ddClasses = ddClasses ~ ' selector_image_selector' %}{% endif %}
{% if key == 'font' %}{% set ddClasses = ddClasses ~ ' selector_fontselect' %}{% endif %}
{% if key in aColorChooserKeys %}{% set ddClasses = ddClasses ~ ' selector_color_mode' %}{% endif %}
<select class="{{ ddClasses }}"
{% if attr.parent != '' %}data-parent="{{ attr.parent }}"{% endif %}
data-inheritvalue="{{ oParentOptions[key] }}"
@ -642,6 +655,12 @@
id="simple_edit_options_{{ key }}" name="{{ key }}"
title="{{ gT("Inherited value:") }} {{ oParentOptions[key] }}"/>
{% endif %}
{# row 135: extra tip underneath the whole "Progress bar font color"
option (attached to its custom child, which renders last in the
same column, so the tip sits at the bottom of the option) #}
{% if key == 'progressbarfontcolorcustom' %}
<div class="form-text mt-1">{{ gT("Make this font color the same color as the color of the progress bar when you do not want to see the progress in %.") }}</div>
{% endif %}
</div>
</div>

View file

@ -268,15 +268,20 @@ foreach ($logoPositions as $pos) {
}
}
// --- Row 115 migration: navbarfontcolor became a mode dropdown (default|color1|
// color2|color3|other) with a navbarfontcolorcustom colorpicker child. A legacy HEX
// --- Row 115/135 migration: the color-chooser options (navbarfontcolor,
// headerbackgroundcolor, progressbarcolor, progressbarbackgroundcolor,
// progressbarfontcolor) became mode dropdowns (default|defaultbackgroundcolor|
// color1|color2|color3|other) with a <key>custom colorpicker child. A legacy HEX
// value in the json means "custom color": map it to mode "other" and move the hex
// into navbarfontcolorcustom, so the variant default stays valid for the dropdown.
if (isset($definition['options']['navbarfontcolor'])
&& is_string($definition['options']['navbarfontcolor'])
&& preg_match('/^#[0-9a-fA-F]{3,8}$/', $definition['options']['navbarfontcolor'])) {
$definition['options']['navbarfontcolorcustom'] = $definition['options']['navbarfontcolor'];
$definition['options']['navbarfontcolor'] = 'other';
// into the <key>custom child, so the variant default stays valid for the dropdown.
$colorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor'];
foreach ($colorChooserKeys as $ck) {
if (isset($definition['options'][$ck])
&& is_string($definition['options'][$ck])
&& preg_match('/^#[0-9a-fA-F]{3,8}$/', $definition['options'][$ck])) {
$definition['options'][$ck . 'custom'] = $definition['options'][$ck];
$definition['options'][$ck] = 'other';
}
}
$optionsNode = $xpath->query('//options')->item(0);

View file

@ -16,6 +16,18 @@
{# Custom logo option #}
{# Custom backgroud option #}
{# Row 135: resolve a color-chooser MODE value to the effective color — used for
headerbackgroundcolor and the progress bar colors below (navbarfontcolor keeps
its own inline expression further down). Modes: default|defaultbackgroundcolor|
color1|color2|color3|other, or a raw hex (legacy stored value) which passes
through directly. #}
{% macro cm(mode, custom, opts) -%}
{%- set m = mode|default('') -%}
{{- m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' ? opts.primarycolor|default('') : (m == 'color2' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : opts.fontcolor|default('')))))) -}}
{%- endmacro %}
{% import _self as cmm %}
<style>
html, body {
font-size: {{ aSurveyInfo.options.fontsize }} !important;
@ -141,8 +153,12 @@
}
{% endif %}
{# Row 135: headerbackgroundcolor is a MODE dropdown now (see navbarfontcolor
below) — resolve the effective color via the shared partial. Default mode
"defaultbackgroundcolor"; a legacy stored hex passes through. #}
{% set sHeaderBackgroundColor = cmm.cm(aSurveyInfo.options.headerbackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.headerbackgroundcolorcustom|default(''), aSurveyInfo.options) %}
.navbar-light{
background-color: {{ aSurveyInfo.options.headerbackgroundcolor }};
background-color: {{ sHeaderBackgroundColor }};
}
{# THEME ADDITION: sticky header per screen size (options
@ -199,8 +215,14 @@
opacity: 0.75;
}
{# Row 135: the progress bar colors are MODE dropdowns now — resolve via the
shared partial. Defaults: background = Default background color, bar = Color 1,
font = Default font color; legacy stored hex passes through. #}
{% set sProgressBarBackgroundColor = cmm.cm(aSurveyInfo.options.progressbarbackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.progressbarbackgroundcolorcustom|default(''), aSurveyInfo.options) %}
{% set sProgressBarColor = cmm.cm(aSurveyInfo.options.progressbarcolor|default('color1'), aSurveyInfo.options.progressbarcolorcustom|default(''), aSurveyInfo.options) %}
{% set sProgressBarFontColor = cmm.cm(aSurveyInfo.options.progressbarfontcolor|default('default'), aSurveyInfo.options.progressbarfontcolorcustom|default(''), aSurveyInfo.options) %}
.progress {
background: {{ aSurveyInfo.options.progressbarbackgroundcolor }};
background: {{ sProgressBarBackgroundColor }};
}
label::after,
@ -209,8 +231,8 @@
}
.progress-bar {
background: {{ aSurveyInfo.options.progressbarcolor }};
color: {{ aSurveyInfo.options.progressbarfontcolor }};
background: {{ sProgressBarColor }};
color: {{ sProgressBarFontColor }};
}
.question-container, #welcome-container {