From 7bf54375965aca5e1147cb0acf7ed97bc50ff922 Mon Sep 17 00:00:00 2001 From: Tammo ter Hark Date: Thu, 26 Nov 2026 20:57:07 +0100 Subject: [PATCH] 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 --- config.xml | 24 ++++++++-- options/options.js | 2 +- options/options.twig | 60 ++++++++++++++++++++---- views/subviews/header/custom_header.twig | 8 ++-- 4 files changed, 78 insertions(+), 16 deletions(-) diff --git a/config.xml b/config.xml index 6a3edc2..bb076b7 100644 --- a/config.xml +++ b/config.xml @@ -131,10 +131,28 @@ (always relevant), then the three image-detail options which are only relevant when a background image is shown (parent="backgroundimage", shown/hidden via .option-visibility in options.twig/options.js). - Prompt P: all five width=12 — the Images pane renders them stacked in - column 1 of a three-column grid (only that column is used). --> + Row 149: the "Page background" pane lays these out in three columns — + 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. --> on - #ffffff + + defaultbackgroundcolor + + + + + + + + + #ffffff scroll tile ./files/tiledtexture.png diff --git a/options/options.js b/options/options.js index 9847988..656c7c8 100644 --- a/options/options.js +++ b/options/options.js @@ -27,7 +27,7 @@ var ThemeOptions = function () { var legacyColorValues = {}; // row 135: all options that use the color-chooser scheme (mode dropdown with // class selector_color_mode + swatch chips + a 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 // (object key order = swatch chip order) — row 125: "Default background color" // is the SECOND choice, right after "Default font color". diff --git a/options/options.twig b/options/options.twig index d8cb251..c037317 100644 --- a/options/options.twig +++ b/options/options.twig @@ -46,7 +46,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.18' %} +{% set OPTIONS_JS_TOKEN = '20261126.19' %} {{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} @@ -262,7 +262,7 @@ {% 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' } %} {% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %} @@ -312,8 +312,12 @@ {% set aImagesKeys = aImagesKeys|merge([key]) %} {% endif %} {% 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 %} - {% 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 %} {# 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 @@ -401,8 +405,16 @@

{{ gT("Here you choose the default font, the font that is used on most places in your version of the theme.") }}

{% 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'] : '')) %} +
+

{{ gT("Page background (behind the body of the page)") }}

+

{{ gT("Set the page background here. Either just a solid color or an image.") }}

+
+ {% endif %}
- {% if tab.category == 'Images' %}
{% endif %} {% set qLastCol = 0 %} {% set fLastSlot = 0 %} {% for key in aTabKeys %} @@ -415,6 +427,7 @@ the transition into the logo slot also fires. #} {% set bFontsPane = tab.category == 'Fonts' %} {% set bTopPane = tab.id == 'top-of-page' %} + {% set bImagesPane = tab.category == 'Images' %} {% set fSlot = 'rest' %} {% if bFontsPane %} {% if key == 'font' %}{% set fSlot = 'f1' %} @@ -452,8 +465,15 @@ {% elseif key == 'progressbarfontcolor' %}{% set fSlot = 'pcol3' %} {% elseif key == 'progressbarfontcolorcustom' %}{% set fSlot = 'pcol3' %} {% 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 %} - {% if fSlot != fLastSlot and (bFontsPane or bTopPane) %} + {% if fSlot != fLastSlot and (bFontsPane or bTopPane or bImagesPane) %} {% if bFontsPane %} {% if fLastSlot == 'f3' %}

{{ gT("Default colors") }}

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

{% elseif fLastSlot == 'f1' or fLastSlot == 'f2' %}
@@ -461,7 +481,7 @@ {% endif %} {% if fSlot == 'f1' %}
{% endif %} - {% else %} + {% elseif bTopPane %} {# top-of-page transitions: close previous slot, open new slot. Header (row 136): col 1 = h1 slot (headerfont + navbarfontcolor stacked), col 2 = h2 slot (header background color), col 3 = h3 @@ -477,6 +497,13 @@ {% if fSlot == 'h1' %}
{% elseif fSlot == 'ppos' %}
{% 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' %}
{% endif %} + {% if fSlot == 'bg1' %}
{% endif %} {% endif %} {% set fLastSlot = fSlot %} {% endif %} @@ -623,6 +650,9 @@ keep the stored child value instead of resetting it to inherit/false #} {% set bDisableMode = attr.parent != '' and (aShowIfMode[attr.parent] ?? 'hide') == 'disable' %} {% 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' %}

{% endif %}
@@ -779,7 +809,11 @@ {% endif %} {% endif %} {% endfor %} - {% if tab.category == 'Images' %}
{% 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' %}
{% endif %} + {% if fLastSlot == 'bg2' %}
{% endif %} + {% endif %} {% if tab.category == 'Questions' and qLastCol > 0 %}
{% endif %} {# 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) #} @@ -787,8 +821,11 @@
{% 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 #} +

{# Upload an image; the actual upload form (#upload_frontend) is rendered by themeOptions/update.php #} -
+
@@ -813,6 +850,13 @@
+ {# row 149: same translatable, scope-dependent help text as under the + upload widget in the Top of the page tab (rows 140/141) #} +
+
+
{% 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 %}
+
+
{% endif %} diff --git a/views/subviews/header/custom_header.twig b/views/subviews/header/custom_header.twig index 03b7838..1d973cf 100644 --- a/views/subviews/header/custom_header.twig +++ b/views/subviews/header/custom_header.twig @@ -17,9 +17,9 @@ {# 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| +{# Row 135/149: resolve a color-chooser MODE value to the effective color — used for + headerbackgroundcolor, the progress bar colors and bodybackgroundcolor 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) -%} @@ -48,7 +48,7 @@ body { padding-bottom: 10px; /*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 }}; }