feat(options): Default background color as 2nd choice; label 'Menu item color in header'; per-option default

- navbarfontcolor dropdown reordered to default|defaultbackgroundcolor|
  color1|color2|color3|other (options attr, optionlabels, dropdownoptions),
  and the swatch chips follow the same order (presets map key order in
  options.js) — 'Default background color' is now the second choice.
- Label of navbarfontcolor changed to 'Menu item color in header' (child
  navbarfontcolorcustom -> 'Custom menu item color ...').
- Per-option default mechanism made explicit: the config.xml <default> of a
  color-chooser dropdown is that option's default choice (stored on theme
  reset); navbarfontcolor keeps default 'default' = 'Same as default font
  color'. The JS no-value fallback no longer hardcodes 'default' but falls
  back to data-inheritvalue / the first non-inherit dropdown entry, so a
  future chooser (e.g. questiontitlebackgroundcolor defaulting to color1)
  can set its own default. custom_header.twig mapping unchanged.
- OPTIONS_JS_TOKEN -> 20261126.7. Verified: render tc=573 (dropdown order
  default,defaultbackgroundcolor,color1,color2,color3,other; label; divs
  balanced; served as options.js?v=20261126.7), jsdom 6/6 incl. new pins
  (dropdown order + chip order, Default background color 2nd), live survey
  282267 with stored mode 'default' renders navbar menu color = fontcolor
  #444444, export_public.sh exit 0. 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 15:13:45 +01:00
commit 2f08e86335
3 changed files with 31 additions and 16 deletions

View file

@ -207,25 +207,32 @@
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>
<!-- Working example (row 115): menu item text color as a preset dropdown.
The KEY navbarfontcolor is kept (stored DB values stay attached); the
type changes colorpicker -> dropdown with modes default|color1|color2|
color3|other. A legacy stored hex value is migrated client-side to mode
"other" + hex into navbarfontcolorcustom (options.js navbarColorModeUI),
and custom_header.twig accepts a raw hex directly. The child
<!-- 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
default|defaultbackgroundcolor|color1|color2|color3|other — the "Default
background color" is the SECOND choice (row 125). A legacy stored hex
value is migrated client-side to mode "other" + hex into
navbarfontcolorcustom (options.js navbarColorModeUI), and
custom_header.twig accepts a raw hex directly. The child
navbarfontcolorcustom is rendered VISIBLE but grayed out (disabled)
unless mode "other" (data-show-if-mode="disable" in options.twig) and
keeps its value across saves (data-keep-value in options.js). -->
<navbarfontcolor type="dropdown" category="Colors" width="12" title="Menu item text color in the top bar" options="default|color1|color2|color3|defaultbackgroundcolor|other" optionlabels="Same as default font color|Color 1|Color 2|Color 3|Default background color|Other…">default
keeps its value across saves (data-keep-value in options.js).
PER-OPTION DEFAULT (row 125): every color-chooser dropdown can pick its
own default value — the element text below IS that default (LimeSurvey
stores it in the DB on theme reset). Here the default is "default"
("Same as default font color"); e.g. when questiontitlebackgroundcolor
is later converted to this pattern, its default can be set to "color1". -->
<navbarfontcolor type="dropdown" category="Colors" width="12" title="Menu item color in header" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Same as default font color|Default background color|Color 1|Color 2|Color 3|Other…">default
<dropdownoptions>
<option value="default">Same as 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="defaultbackgroundcolor">Default background color</option>
<option value="other">Other…</option>
</dropdownoptions></navbarfontcolor>
<navbarfontcolorcustom type="colorpicker" category="Colors" width="12" title="Custom menu item text color (used when 'Other…' is chosen)" parent="navbarfontcolor">#444444</navbarfontcolorcustom>
<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>

View file

@ -736,7 +736,7 @@ var ThemeOptions = function () {
};
// THEME ADDITION (row 115, working example on navbarfontcolor only): preset-dropdown
// UI for the "Menu item text color" option.
// 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 /
// the fields' data-inheritvalue, so they also work at survey level with inherit)
@ -749,8 +749,11 @@ var ThemeOptions = function () {
var navbarColorModeUI = function () {
var sel = globalForm.find('select[name="navbarfontcolor"]');
if (!sel.length) { return; }
// row 124: 5 presets — the 4th named color is now the "Default background color"
var presets = { 'default': 'fontcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor', 'defaultbackgroundcolor': 'defaultbackgroundcolor' };
// 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 customInput = globalForm.find('input[name="navbarfontcolorcustom"]');
var currentColor = function (key) {
var f = globalForm.find('#simple_edit_options_' + key);
@ -838,8 +841,13 @@ var ThemeOptions = function () {
updateAllChildren();
updateVisibilityByParent();
} else if (!sel.val()) {
// no (matching) stored value: fall back to the first option
sel.val('default');
// no (matching) stored value: fall back to the option's configured
// default (row 125: every color-chooser option can pick its own default
// via the config.xml <default>, stored on theme reset; in the DOM the
// inherited value is data-inheritvalue, else the first non-"inherit"
// dropdown entry is the default choice of the pattern)
var fallback = sel.data('inheritvalue') || sel.find('option').not('[value="inherit"]').first().attr('value');
if (fallback) { sel.val(fallback); }
updateAllChildren();
updateVisibilityByParent();
}

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.6' %}
{% set OPTIONS_JS_TOKEN = '20261126.7' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}