From 2f08e86335f028eb411c35072e948eb72059baab Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Thu, 26 Nov 2026 15:13:45 +0100 Subject: [PATCH] feat(options): Default background color as 2nd choice; label 'Menu item color in header'; per-option default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 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 --- config.xml | 27 +++++++++++++++++---------- options/options.js | 18 +++++++++++++----- options/options.twig | 2 +- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/config.xml b/config.xml index d2b87e6..d3689e8 100644 --- a/config.xml +++ b/config.xml @@ -207,25 +207,32 @@ 2026-11-26, row 115): they are mostly NOT one of the default colors, default white #ffffff. --> #ffffff - - 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". --> + default + - - #444444 + #444444 #5e1c64 #eeeeee #5e1c64 diff --git a/options/options.js b/options/options.js index 70b9cdf..9aaf446 100644 --- a/options/options.js +++ b/options/options.js @@ -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 , 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(); } diff --git a/options/options.twig b/options/options.twig index fbeedc8..6d936a1 100644 --- a/options/options.twig +++ b/options/options.twig @@ -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') }}