feat(options): rebuild Page background tab layout; overall background color becomes a color chooser

Page background tab (config.xml "Images" category), new layout:
- full-width h2 "Page background (behind the body of the page)" + intro text
  "Set the page background here. Either just a solid color or an image."
- three columns: col 1 = Overall background color + custom picker, an in-column
  hr, then Background image on/off; col 2 = background image file / fixed-or-scroll /
  display, hidden as a whole column when the image is off (the column itself carries
  option-visibility on backgroundimage); col 3 empty
- full-width hr, then the image upload facility full width with the same
  scope-dependent help text as in the Top of the page tab

bodybackgroundcolor is now a color-chooser dropdown (modes default|
defaultbackgroundcolor|color1|color2|color3|other) with a bodybackgroundcolorcustom
child; its default is "Default background color". Added to aColorChooserKeys in
options.twig/options.js and to the legacy-hex migration in variants/build.php;
custom_header.twig resolves the mode via the cm() macro (raw hex still passes through).
OPTIONS_JS_TOKEN -> 20261126.19.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-26 20:57:07 +01:00
commit 7bf5437596
4 changed files with 78 additions and 16 deletions

View file

@ -131,10 +131,28 @@
(always relevant), then the three image-detail options which are only (always relevant), then the three image-detail options which are only
relevant when a background image is shown (parent="backgroundimage", relevant when a background image is shown (parent="backgroundimage",
shown/hidden via .option-visibility in options.twig/options.js). shown/hidden via .option-visibility in options.twig/options.js).
Prompt P: all five width=12 — the Images pane renders them stacked in Row 149: the "Page background" pane lays these out in three columns —
column 1 of a three-column grid (only that column is used). --> col 1 = overall background color (chooser) + background image on/off,
col 2 = the three image-detail options (hidden as a whole when the
image is off), col 3 empty. -->
<backgroundimage type="buttons" category="Images" width="12" title="Background image (behind body of page)" options="on|off" optionlabels="Yes|No">on</backgroundimage> <backgroundimage type="buttons" category="Images" width="12" title="Background image (behind body of page)" options="on|off" optionlabels="Yes|No">on</backgroundimage>
<bodybackgroundcolor type="colorpicker" category="Images" width="12" title="Overall background color (when there is no picture in the background)" options="on|off" optionlabels="Yes|No">#ffffff</bodybackgroundcolor> <!-- Row 149: the overall background color is a color-chooser dropdown like the
other chooser options (default|defaultbackgroundcolor|color1|color2|color3|
other) with a <key>custom colorpicker child; its DEFAULT is the Default
background color. A legacy stored hex is migrated client-side to mode
"other" + hex into bodybackgroundcolorcustom (options.js), and
custom_header.twig resolves the mode via the cm() macro (a raw hex still
passes through directly). -->
<bodybackgroundcolor type="dropdown" category="Images" width="12" title="Overall 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></bodybackgroundcolor>
<bodybackgroundcolorcustom type="colorpicker" category="Images" width="12" title="Custom overall background color (for 'Other ...')" parent="bodybackgroundcolor">#ffffff</bodybackgroundcolorcustom>
<backgroundimagefixed type="buttons" category="Images" width="12" title="Background image fixed or scroll" options="fixed|scroll" optionlabels="Fixed|Scroll" parent="backgroundimage">scroll</backgroundimagefixed> <backgroundimagefixed type="buttons" category="Images" width="12" title="Background image fixed or scroll" options="fixed|scroll" optionlabels="Fixed|Scroll" parent="backgroundimage">scroll</backgroundimagefixed>
<backgroundimagedisplay type="buttons" category="Images" width="12" title="Background image display" options="tile|cover" optionlabels="Tile|Cover" parent="backgroundimage">tile</backgroundimagedisplay> <backgroundimagedisplay type="buttons" category="Images" width="12" title="Background image display" options="tile|cover" optionlabels="Tile|Cover" parent="backgroundimage">tile</backgroundimagedisplay>
<backgroundimagefile type="imagefile" category="Images" width="12" title="Background image file" parent="backgroundimage">./files/tiledtexture.png</backgroundimagefile> <backgroundimagefile type="imagefile" category="Images" width="12" title="Background image file" parent="backgroundimage">./files/tiledtexture.png</backgroundimagefile>

View file

@ -27,7 +27,7 @@ var ThemeOptions = function () {
var legacyColorValues = {}; var legacyColorValues = {};
// row 135: all options that use the color-chooser scheme (mode dropdown with // row 135: all options that use the color-chooser scheme (mode dropdown with
// class selector_color_mode + swatch chips + a <key>custom colorpicker child) // class selector_color_mode + swatch chips + a <key>custom colorpicker child)
var aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor']; var aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor'];
// the 5 presets, in the SAME order as the dropdown options in config.xml // 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" // (object key order = swatch chip order) — row 125: "Default background color"
// is the SECOND choice, right after "Default font color". // is the SECOND choice, right after "Default font color".

View file

@ -46,7 +46,7 @@
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). 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 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. #} options/options.js changes, so every browser fetches the new file once. #}
{% set OPTIONS_JS_TOKEN = '20261126.18' %} {% set OPTIONS_JS_TOKEN = '20261126.19' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
@ -262,7 +262,7 @@
{% set aFontElements = ['questiontitle', 'answers', 'grouptitle', 'groupdescription', 'buttons'] %} {% set aFontElements = ['questiontitle', 'answers', 'grouptitle', 'groupdescription', 'buttons'] %}
{% set aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor'] %} {% set aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor'] %}
{% set aShowIfValues = { 'questionborder': 'box|top', 'navbarfontcolor': 'other' } %} {% set aShowIfValues = { 'questionborder': 'box|top', 'navbarfontcolor': 'other' } %}
{% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %} {% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %}
@ -312,8 +312,12 @@
{% set aImagesKeys = aImagesKeys|merge([key]) %} {% set aImagesKeys = aImagesKeys|merge([key]) %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{# row 149: the Page background pane has an explicit key order (slot layout below):
col 1 = overall background color (chooser + custom) + in-column hr + background
image on/off; col 2 = the three image-detail options; col 3 stays empty #}
{% set aImagesPaneKeys = ['bodybackgroundcolor', 'bodybackgroundcolorcustom', 'backgroundimage', 'backgroundimagefile', 'backgroundimagefixed', 'backgroundimagedisplay'] %}
{% if aImagesKeys is not empty %} {% if aImagesKeys is not empty %}
{% set aTabs = aTabs|merge([{ 'id': 'category-images', 'label': 'Page background', 'category': 'Images', 'keys': null }]) %} {% set aTabs = aTabs|merge([{ 'id': 'category-images', 'label': 'Page background', 'category': 'Images', 'keys': aImagesPaneKeys }]) %}
{% endif %} {% endif %}
{# row 147: dedicated "Groups" tab with all group-related options (aGroupKeys). {# row 147: dedicated "Groups" tab with all group-related options (aGroupKeys).
category 'Groups' (no config.xml category of that name) so the pane renders the category 'Groups' (no config.xml category of that name) so the pane renders the
@ -401,8 +405,16 @@
<p>{{ gT("Here you choose the default font, the font that is used on most places in your version of the theme.") }}</p> <p>{{ gT("Here you choose the default font, the font that is used on most places in your version of the theme.") }}</p>
</div></div> </div></div>
{% endif %} {% endif %}
{% if tab.category == 'Images' %}
{# row 149: full-width intro of the Page background tab; bgImgVal is the current
value of the backgroundimage on/off switch (drives the col-2 visibility) #}
{% set bgImgVal = bGeneralInherit ? 'inherit' : (aCurrentOptions['backgroundimage'] is defined ? aCurrentOptions['backgroundimage'] : (oParentOptions['backgroundimage'] is defined ? oParentOptions['backgroundimage'] : '')) %}
<div class="row action_hide_on_inherit images-intro"><div class="col-12">
<h2>{{ gT("Page background (behind the body of the page)") }}</h2>
<p>{{ gT("Set the page background here. Either just a solid color or an image.") }}</p>
</div></div>
{% endif %}
<div class="row action_hide_on_inherit"> <div class="row action_hide_on_inherit">
{% if tab.category == 'Images' %}<div class="col-md-4 images-options-column">{% endif %}
{% set qLastCol = 0 %} {% set qLastCol = 0 %}
{% set fLastSlot = 0 %} {% set fLastSlot = 0 %}
{% for key in aTabKeys %} {% for key in aTabKeys %}
@ -415,6 +427,7 @@
the transition into the logo slot also fires. #} the transition into the logo slot also fires. #}
{% set bFontsPane = tab.category == 'Fonts' %} {% set bFontsPane = tab.category == 'Fonts' %}
{% set bTopPane = tab.id == 'top-of-page' %} {% set bTopPane = tab.id == 'top-of-page' %}
{% set bImagesPane = tab.category == 'Images' %}
{% set fSlot = 'rest' %} {% set fSlot = 'rest' %}
{% if bFontsPane %} {% if bFontsPane %}
{% if key == 'font' %}{% set fSlot = 'f1' %} {% if key == 'font' %}{% set fSlot = 'f1' %}
@ -452,8 +465,15 @@
{% elseif key == 'progressbarfontcolor' %}{% set fSlot = 'pcol3' %} {% elseif key == 'progressbarfontcolor' %}{% set fSlot = 'pcol3' %}
{% elseif key == 'progressbarfontcolorcustom' %}{% set fSlot = 'pcol3' %} {% elseif key == 'progressbarfontcolorcustom' %}{% set fSlot = 'pcol3' %}
{% endif %} {% endif %}
{% elseif bImagesPane %}
{# row 149: Page background pane — col 1 = overall background color
(chooser + custom child) + background image on/off; col 2 = the
three image-detail options #}
{% if key in ['bodybackgroundcolor', 'bodybackgroundcolorcustom', 'backgroundimage'] %}{% set fSlot = 'bg1' %}
{% elseif key in ['backgroundimagefile', 'backgroundimagefixed', 'backgroundimagedisplay'] %}{% set fSlot = 'bg2' %}
{% endif %}
{% endif %} {% endif %}
{% if fSlot != fLastSlot and (bFontsPane or bTopPane) %} {% if fSlot != fLastSlot and (bFontsPane or bTopPane or bImagesPane) %}
{% if bFontsPane %} {% if bFontsPane %}
{% if fLastSlot == 'f3' %}</div></div><div class="row action_hide_on_inherit"><div class="col-12"><hr class="fonts-hr"></div></div><div class="row action_hide_on_inherit fonts-section-intro"><div class="col-12"><h2>{{ gT("Default colors") }}</h2><p>{{ gT("The default colors are your most used colors.") }}</p></div></div><div class="row action_hide_on_inherit fonts-colors-row"><div class="col-md-3"> {% if fLastSlot == 'f3' %}</div></div><div class="row action_hide_on_inherit"><div class="col-12"><hr class="fonts-hr"></div></div><div class="row action_hide_on_inherit fonts-section-intro"><div class="col-12"><h2>{{ gT("Default colors") }}</h2><p>{{ gT("The default colors are your most used colors.") }}</p></div></div><div class="row action_hide_on_inherit fonts-colors-row"><div class="col-md-3">
{% elseif fLastSlot == 'f1' or fLastSlot == 'f2' %}</div><div class="col-md-4"> {% elseif fLastSlot == 'f1' or fLastSlot == 'f2' %}</div><div class="col-md-4">
@ -461,7 +481,7 @@
{% endif %} {% endif %}
{% if fSlot == 'f1' %}<div class="row action_hide_on_inherit fonts-top-row"><div class="col-md-4"> {% if fSlot == 'f1' %}<div class="row action_hide_on_inherit fonts-top-row"><div class="col-md-4">
{% endif %} {% endif %}
{% else %} {% elseif bTopPane %}
{# top-of-page transitions: close previous slot, open new slot. {# top-of-page transitions: close previous slot, open new slot.
Header (row 136): col 1 = h1 slot (headerfont + navbarfontcolor Header (row 136): col 1 = h1 slot (headerfont + navbarfontcolor
stacked), col 2 = h2 slot (header background color), col 3 = h3 stacked), col 2 = h2 slot (header background color), col 3 = h3
@ -477,6 +497,13 @@
{% if fSlot == 'h1' %}<div class="row action_hide_on_inherit top-section-header"><div class="col-md-4"> {% if fSlot == 'h1' %}<div class="row action_hide_on_inherit top-section-header"><div class="col-md-4">
{% elseif fSlot == 'ppos' %}<div class="row action_hide_on_inherit progress-block"><div class="col-md-4"> {% elseif fSlot == 'ppos' %}<div class="row action_hide_on_inherit progress-block"><div class="col-md-4">
{% endif %} {% endif %}
{% elseif bImagesPane %}
{# row 149: Page background transitions — bg1 -> bg2 closes col 1
and opens col 2 (the whole column carries option-visibility,
so it is hidden when the background image is off); the first
bg1 key opens col 1 #}
{% if fLastSlot == 'bg1' %}</div><div class="col-md-4 border-start images-col-2 option-visibility{% if bgImgVal != 'on' %} d-none{% endif %}" data-show-if-parent="backgroundimage" data-show-if-value="on">{% endif %}
{% if fSlot == 'bg1' %}<div class="col-md-4 images-col-1">{% endif %}
{% endif %} {% endif %}
{% set fLastSlot = fSlot %} {% set fLastSlot = fSlot %}
{% endif %} {% endif %}
@ -623,6 +650,9 @@
keep the stored child value instead of resetting it to inherit/false #} keep the stored child value instead of resetting it to inherit/false #}
{% set bDisableMode = attr.parent != '' and (aShowIfMode[attr.parent] ?? 'hide') == 'disable' %} {% set bDisableMode = attr.parent != '' and (aShowIfMode[attr.parent] ?? 'hide') == 'disable' %}
{% set bChildDisabled = bParentHidden and bDisableMode %} {% set bChildDisabled = bParentHidden and bDisableMode %}
{# row 149: horizontal line inside column 1 of the Page background pane,
between the overall background color and the background image switch #}
{% if bImagesPane and key == 'backgroundimage' %}<div class="col-12"><hr class="images-col1-hr"></div>{% endif %}
<div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden and not bDisableMode %} d-none{% endif %}{% endif %}" <div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden and not bDisableMode %} d-none{% endif %}{% endif %}"
{% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="{{ showIfValues }}"{% if bDisableMode %} data-show-if-mode="disable"{% endif %}{% endif %}> {% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="{{ showIfValues }}"{% if bDisableMode %} data-show-if-mode="disable"{% endif %}{% endif %}>
<div class="mb-3"> <div class="mb-3">
@ -779,7 +809,11 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% if tab.category == 'Images' %}</div>{% endif %} {% if tab.category == 'Images' %}
{# row 149: close the open Page background column; after col 2 append the empty col 3 #}
{% if fLastSlot == 'bg1' or fLastSlot == 'bg2' %}</div>{% endif %}
{% if fLastSlot == 'bg2' %}<div class="col-md-4 images-col-3"></div>{% endif %}
{% endif %}
{% if tab.category == 'Questions' and qLastCol > 0 %}</div>{% endif %} {% if tab.category == 'Questions' and qLastCol > 0 %}</div>{% endif %}
{# close an open slot container at the end of a Fonts/Top-of-page pane {# close an open slot container at the end of a Fonts/Top-of-page pane
(every non-logo, non-rest slot has exactly two open divs: row + col) #} (every non-logo, non-rest slot has exactly two open divs: row + col) #}
@ -787,8 +821,11 @@
</div> </div>
{% if tab.category == 'Images' %} {% if tab.category == 'Images' %}
{# row 149: full-width horizontal line, then the upload facility full width
with the same scope-dependent help text as in the Top of the page tab #}
<div class="row action_hide_on_inherit"><div class="col-12"><hr class="images-upload-hr"></div></div>
{# Upload an image; the actual upload form (#upload_frontend) is rendered by themeOptions/update.php #} {# Upload an image; the actual upload form (#upload_frontend) is rendered by themeOptions/update.php #}
<div class="row action_hide_on_inherit"> <div class="row action_hide_on_inherit upload-file-row">
<div class="ls-space margin bottom-15 top-15"> <div class="ls-space margin bottom-15 top-15">
<div class="row ls-space margin bottom-15"> <div class="row ls-space margin bottom-15">
<div class="col-12 mb-1"> <div class="col-12 mb-1">
@ -813,6 +850,13 @@
</div> </div>
</div> </div>
</div> </div>
{# row 149: same translatable, scope-dependent help text as under the
upload widget in the Top of the page tab (rows 140/141) #}
<div class="row">
<div class="col-12">
<div class="form-text mt-1">{% if bInherit %}{{ gT("Upload here the files for logos and background. You are in the settings for your specific survey now, so files that you upload here are available for this survey only. If you want a file to be available for all surveys, upload it at the global theme settings options page.") }}{% else %}{{ gT("Upload here the files for logos and background. You are in global settings now, so files that you upload here are available for all surveys. If you want a file to be available only for your specific survey, upload it at the theme settings options page for that specific survey.") }}{% endif %}</div>
</div>
</div>
</div> </div>
</div> </div>
{% endif %} {% endif %}

View file

@ -17,9 +17,9 @@
{# Custom logo option #} {# Custom logo option #}
{# Custom backgroud option #} {# Custom backgroud option #}
{# Row 135: resolve a color-chooser MODE value to the effective color — used for {# Row 135/149: resolve a color-chooser MODE value to the effective color — used for
headerbackgroundcolor and the progress bar colors below (navbarfontcolor keeps headerbackgroundcolor, the progress bar colors and bodybackgroundcolor below
its own inline expression further down). Modes: default|defaultbackgroundcolor| (navbarfontcolor keeps its own inline expression further down). Modes: default|defaultbackgroundcolor|
color1|color2|color3|other, or a raw hex (legacy stored value) which passes color1|color2|color3|other, or a raw hex (legacy stored value) which passes
through directly. #} through directly. #}
{% macro cm(mode, custom, opts) -%} {% macro cm(mode, custom, opts) -%}
@ -48,7 +48,7 @@
body { body {
padding-bottom: 10px; padding-bottom: 10px;
/*padding-top: 60px;!* now is redefine in JS to fit any title length *!*/ /*padding-top: 60px;!* now is redefine in JS to fit any title length *!*/
background-color:{{ aSurveyInfo.options.bodybackgroundcolor }} ; background-color:{{ cmm.cm(aSurveyInfo.options.bodybackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.bodybackgroundcolorcustom|default(''), aSurveyInfo.options) }} ;
color: {{ aSurveyInfo.options.fontcolor }}; color: {{ aSurveyInfo.options.fontcolor }};
} }