From 12ec2820da002fffc3f7a0211614ee5200d0ed00 Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Thu, 26 Nov 2026 14:57:25 +0100 Subject: [PATCH] feat(options): 'Default background color' as 4th column of the colors row + 5th swatch preset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New colorpicker option defaultbackgroundcolor (category Fonts, default #ffffff), rendered as column 1 of the second row of the 'Default fonts and colors' tab — that colors row is now 4 columns (col-md-3 each; the top row stays 3 x col-md-4). The experimental color chooser (navbarfontcolor dropdown + swatch chips) gains this color as a 5th preset: dropdown option 'defaultbackgroundcolor', 5 swatch chips with live hex labels, presets map in options.js extended, and custom_header.twig maps the mode to the option value. OPTIONS_JS_TOKEN -> 20261126.6. Verified: render tc=558 (colors row = defaultbackgroundcolor|primarycolor|secondarycolor|tertiarycolor in 4 col-md-3, top row unchanged, divs balanced, dropdown has 6 options), jsdom suite 6/6 (5 chips pinned), live survey 282267 with mode defaultbackgroundcolor -> #aabbcc (DB row restored), export 0. Variants not rebuilt (deferred). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- config.xml | 8 +++++++- options/options.js | 5 +++-- options/options.twig | 8 +++++--- views/subviews/header/custom_header.twig | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/config.xml b/config.xml index a4b4bff..d2b87e6 100644 --- a/config.xml +++ b/config.xml @@ -216,12 +216,13 @@ 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). --> - default + default + #444444 @@ -308,6 +309,11 @@ secondarycolor are set per variant via variants/.json. --> #444444 16px + + #ffffff #5e1c64 #888888 #dddddd diff --git a/options/options.js b/options/options.js index d444bac..70b9cdf 100644 --- a/options/options.js +++ b/options/options.js @@ -749,7 +749,8 @@ var ThemeOptions = function () { var navbarColorModeUI = function () { var sel = globalForm.find('select[name="navbarfontcolor"]'); if (!sel.length) { return; } - var presets = { 'default': 'fontcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor' }; + // 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' }; var customInput = globalForm.find('input[name="navbarfontcolorcustom"]'); var currentColor = function (key) { var f = globalForm.find('#simple_edit_options_' + key); @@ -849,7 +850,7 @@ var ThemeOptions = function () { // 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'], function (i, key) { + $.each(['fontcolor', 'primarycolor', 'secondarycolor', 'tertiarycolor', 'defaultbackgroundcolor'], function (i, key) { globalForm.find('#simple_edit_options_' + key).on('input change', refreshAll); }); }; diff --git a/options/options.twig b/options/options.twig index ec201db..fbeedc8 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.5' %} +{% set OPTIONS_JS_TOKEN = '20261126.6' %} {{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} @@ -336,6 +336,7 @@ {% if key == 'font' %}{% set fSlot = 'f1' %} {% elseif key == 'fontcolor' %}{% set fSlot = 'f2' %} {% elseif key == 'fontsize' %}{% set fSlot = 'f3' %} + {% elseif key == 'defaultbackgroundcolor' %}{% set fSlot = 'c0' %} {% elseif key == 'primarycolor' %}{% set fSlot = 'c1' %} {% elseif key == 'secondarycolor' %}{% set fSlot = 'c2' %} {% elseif key == 'tertiarycolor' %}{% set fSlot = 'c3' %} @@ -356,8 +357,9 @@ {% endif %} {% if fSlot != fLastSlot and (bFontsPane or bTopPane) %} {% if bFontsPane %} - {% if fLastSlot == 'f3' %}

{{ gT("Default colors") }}

{{ gT("The default colors are your most used colors.") }}

- {% elseif fLastSlot == 'f1' or fLastSlot == 'f2' or fLastSlot == 'c1' or fLastSlot == 'c2' %}
+ {% if fLastSlot == 'f3' %}

{{ gT("Default colors") }}

{{ gT("The default colors are your most used colors.") }}

+ {% elseif fLastSlot == 'f1' or fLastSlot == 'f2' %}
+ {% elseif fLastSlot == 'c0' or fLastSlot == 'c1' or fLastSlot == 'c2' %}
{% endif %} {% if fSlot == 'f1' %}
{% endif %} diff --git a/views/subviews/header/custom_header.twig b/views/subviews/header/custom_header.twig index 4c831eb..8b29122 100644 --- a/views/subviews/header/custom_header.twig +++ b/views/subviews/header/custom_header.twig @@ -185,7 +185,7 @@ other -> navbarfontcolorcustom. A raw hex value (legacy stored value from before the dropdown existed, or a hand-set one) is used directly. #} {% set sNavbarFontColorMode = aSurveyInfo.options.navbarfontcolor|default('default') %} - {% set sNavbarFontColor = sNavbarFontColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sNavbarFontColorMode : (sNavbarFontColorMode == 'color1' ? aSurveyInfo.options.primarycolor|default('') : (sNavbarFontColorMode == 'color2' ? aSurveyInfo.options.secondarycolor|default('') : (sNavbarFontColorMode == 'color3' ? aSurveyInfo.options.tertiarycolor|default('') : (sNavbarFontColorMode == 'other' ? aSurveyInfo.options.navbarfontcolorcustom|default('') : aSurveyInfo.options.fontcolor|default(''))))) %} + {% set sNavbarFontColor = sNavbarFontColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sNavbarFontColorMode : (sNavbarFontColorMode == 'color1' ? aSurveyInfo.options.primarycolor|default('') : (sNavbarFontColorMode == 'color2' ? aSurveyInfo.options.secondarycolor|default('') : (sNavbarFontColorMode == 'color3' ? aSurveyInfo.options.tertiarycolor|default('') : (sNavbarFontColorMode == 'defaultbackgroundcolor' ? aSurveyInfo.options.defaultbackgroundcolor|default('') : (sNavbarFontColorMode == 'other' ? aSurveyInfo.options.navbarfontcolorcustom|default('') : aSurveyInfo.options.fontcolor|default('')))))) %} #survey-nav .navbar-nav > li > a, #survey-nav .navbar-nav .nav-link { color: {{ sNavbarFontColor }};