diff --git a/config.xml b/config.xml index bb076b7..d09eced 100644 --- a/config.xml +++ b/config.xml @@ -440,24 +440,40 @@ #444444 + base - default + default - - - + + + + + - #444444 - base - default + #444444 + base + default - - - + + + + + - #444444 + #444444 base default @@ -470,9 +486,9 @@ 1.2rem 700 2.0rem - 700 + bold 1.2rem - 400 + normal diff --git a/options/options.js b/options/options.js index 656c7c8..511b929 100644 --- a/options/options.js +++ b/options/options.js @@ -25,9 +25,14 @@ var ThemeOptions = function () { // updateFieldSettings) can clobber optionObject, so the migration in colorModeUI // must use this snapshot. var legacyColorValues = {}; + // row 157: legacy non-hex MODE values of the chooser options (e.g. "primary"/ + // "secondary" stored by the old 4-way grouptitle/groupdescription textcolor + // dropdowns) — mapped to color1/color2 in colorModeUI + var legacyModeValues = {}; // 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', 'bodybackgroundcolor']; + // class selector_color_mode + swatch chips + a custom colorpicker child); + // row 157: the group title/description text colors joined the scheme + var aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor', 'grouptitletextcolor', 'groupdescriptiontextcolor']; // 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". @@ -847,6 +852,7 @@ var ThemeOptions = function () { colorModeRefreshers.push(refreshAll); // legacy migration: stored hex (pre-dropdown value) -> mode "other" + hex into the custom field var stored = legacyColorValues[key]; + var storedMode = legacyModeValues[key]; if (typeof stored === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(stored)) { sel.val('other'); if (customInput.length && !/^#[0-9a-fA-F]{3,8}$/.test(String(customInput.val() || ''))) { @@ -855,6 +861,18 @@ var ThemeOptions = function () { // re-evaluate the child's disabled state for the migrated mode updateAllChildren(); updateVisibilityByParent(); + } else if (typeof storedMode === 'string' && storedMode !== '' && !sel.find('option[value="' + storedMode + '"]').length) { + // row 157: legacy mode of the old 4-way textcolor dropdowns + // (primary|secondary) has no option in the 6-mode chooser -> map it + // (primary -> color1, secondary -> color2); "default"/"other" still + // exist as options and need no mapping + var legacyModeMap = { 'primary': 'color1', 'secondary': 'color2' }; + var mapped = legacyModeMap[storedMode]; + if (mapped && sel.find('option[value="' + mapped + '"]').length) { + sel.val(mapped); + updateAllChildren(); + updateVisibilityByParent(); + } } else if (!sel.val()) { // no (matching) stored value: fall back to the option's configured // default (row 125: every color-chooser option can pick its own default @@ -946,6 +964,8 @@ var ThemeOptions = function () { var v = optionObject[k]; if (typeof v === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(v)) { legacyColorValues[k] = v; + } else if (typeof v === 'string' && v !== '' && v !== 'inherit') { + legacyModeValues[k] = v; } }); }); diff --git a/options/options.twig b/options/options.twig index d57fe37..ecae971 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.19' %} +{% set OPTIONS_JS_TOKEN = '20261127.1' %} {{ 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', 'bodybackgroundcolor'] %} +{% set aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor', 'grouptitletextcolor', 'groupdescriptiontextcolor'] %} {% set aShowIfValues = { 'questionborder': 'box|top', 'navbarfontcolor': 'other' } %} {% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %} @@ -285,13 +285,15 @@ {# row 147: all group-related options of the "Questions" category — they are pulled out of the Questions tab into a dedicated "Groups" tab (aGroupsTab below). - Values are stored per option key, so moving them does not change stored values. #} + Values are stored per option key, so moving them does not change stored values. + Row 157: the Groups pane is laid out in TWO columns (slots g1/g2 below): + col 1 = group title options, col 2 = group description options. #} {% set aGroupKeys = [ - 'grouptitlefont', 'grouptitletextcolor', 'grouptitletextcolorcustom', - 'groupdescriptionfont', 'groupdescriptiontextcolor', 'groupdescriptiontextcolorcustom', - 'grouptitlefontsize', 'grouptitlefontweight', - 'groupdescriptionfontsize', 'groupdescriptionfontweight' + 'grouptitlefont', 'grouptitletextcolor', 'grouptitletextcolorcustom', 'grouptitlefontsize', 'grouptitlefontoptions', + 'groupdescriptionfont', 'groupdescriptiontextcolor', 'groupdescriptiontextcolorcustom', 'groupdescriptionfontsize', 'groupdescriptionfontoptions' ] %} +{% set aGroupCol1 = ['grouptitlefont', 'grouptitletextcolor', 'grouptitletextcolorcustom', 'grouptitlefontsize', 'grouptitlefontoptions'] %} +{% set aGroupCol2 = ['groupdescriptionfont', 'groupdescriptiontextcolor', 'groupdescriptiontextcolorcustom', 'groupdescriptionfontsize', 'groupdescriptionfontoptions'] %} {# Tab list: FIRST the "Fonts" tab (where the default/base font is chosen and the per-element font overrides live), then the "Top of the page" tab (keys = @@ -319,9 +321,9 @@ {% if aImagesKeys is not empty %} {% 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). +{# row 147/157: dedicated "Groups" tab with all group-related options (aGroupKeys). category 'Groups' (no config.xml category of that name) so the pane renders the - normal width-based grid instead of the Questions 3-column layout. #} + slot layout below instead of the Questions 3-column grid. #} {% set aTabs = aTabs|merge([{ 'id': 'groups', 'label': 'Groups', 'category': 'Groups', 'keys': aGroupKeys }]) %} {% for category in aOptionAttributes.categories %} {% if category != 'Fonts' and category != 'Top of the page' and category != 'Colors' and category != 'Images' and category != 'Simple options' %} @@ -414,6 +416,13 @@

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

{% endif %} + {% if tab.id == 'groups' %} + {# row 157: full-width intro of the Groups tab, above the two columns #} +
+

{{ gT("Groups") }}

+

{{ gT("Groups are more or less the same as pages. In the survey settings you can decide to show or hide the group title and the group description. Here you choose how they look when shown.") }}

+
+ {% endif %}
{% set qLastCol = 0 %} {% set fLastSlot = 0 %} @@ -428,6 +437,7 @@ {% set bFontsPane = tab.category == 'Fonts' %} {% set bTopPane = tab.id == 'top-of-page' %} {% set bImagesPane = tab.category == 'Images' %} + {% set bGroupsPane = tab.id == 'groups' %} {% set fSlot = 'rest' %} {% if bFontsPane %} {% if key == 'font' %}{% set fSlot = 'f1' %} @@ -472,8 +482,14 @@ {% if key in ['bodybackgroundcolor', 'bodybackgroundcolorcustom', 'backgroundimage'] %}{% set fSlot = 'bg1' %} {% elseif key in ['backgroundimagefile', 'backgroundimagefixed', 'backgroundimagedisplay'] %}{% set fSlot = 'bg2' %} {% endif %} + {% elseif bGroupsPane %} + {# row 157: Groups pane — TWO columns: col 1 (g1) = group title + options, col 2 (g2) = group description options #} + {% if key in aGroupCol1 %}{% set fSlot = 'g1' %} + {% elseif key in aGroupCol2 %}{% set fSlot = 'g2' %} + {% endif %} {% endif %} - {% if fSlot != fLastSlot and (bFontsPane or bTopPane or bImagesPane) %} + {% if fSlot != fLastSlot and (bFontsPane or bTopPane or bImagesPane or bGroupsPane) %} {% if bFontsPane %} {% if fLastSlot == 'f3' %}

{{ gT("Default colors") }}

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

{% elseif fLastSlot == 'f1' or fLastSlot == 'f2' %}
@@ -504,6 +520,11 @@ bg1 key opens col 1 #} {% if fLastSlot == 'bg1' %}
{% endif %} {% if fSlot == 'bg1' %}
{% endif %} + {% elseif bGroupsPane %} + {# row 157: Groups transitions — g1 -> g2 closes col 1 and opens + col 2 (border-start); the first g1 key opens col 1 #} + {% if fLastSlot == 'g1' %}
{% endif %} + {% if fSlot == 'g1' %}
{% endif %} {% endif %} {% set fLastSlot = fSlot %} {% endif %} @@ -620,7 +641,7 @@ {% set qLastCol = qCol %} {% endif %} {% endif %} - {% if bQuestionsPane or bTopPane or (bFontsPane and fSlot != 'rest') %}{% set wrapClass = 'col-12' %}{% else %}{% set wrapClass = 'col-12 col-md-' ~ attr.width|default(2) %}{% endif %} + {% if bQuestionsPane or bTopPane or bGroupsPane or (bFontsPane and fSlot != 'rest') %}{% set wrapClass = 'col-12' %}{% else %}{% set wrapClass = 'col-12 col-md-' ~ attr.width|default(2) %}{% endif %} {# server-side current value for this option (checked/selected/value) #} {% set currentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[key] is defined ? aCurrentOptions[key] : (oParentOptions[key] is defined ? oParentOptions[key] : '')) %} {# parent != '': this field is only visible when the parent option's value @@ -855,6 +876,9 @@ {% endif %} {% endif %} {% if tab.category == 'Questions' and qLastCol > 0 %}
{% endif %} + {# row 157: close the open Groups column (each groups slot opens exactly + one div: the col-md-6) #} + {% if tab.id == 'groups' and fLastSlot in ['g1', 'g2'] %}
{% 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) #} {% if (tab.category == 'Fonts' or tab.id == 'top-of-page') and fLastSlot != 0 and fLastSlot != 'rest' and fLastSlot != 'logo' %}
{% endif %} diff --git a/variants/build.php b/variants/build.php index 4b26108..831c40e 100644 --- a/variants/build.php +++ b/variants/build.php @@ -268,19 +268,40 @@ foreach ($logoPositions as $pos) { } } -// --- Row 115/135/149 migration: the color-chooser options (navbarfontcolor, +// --- Row 115/135/149/157 migration: the color-chooser options (navbarfontcolor, // headerbackgroundcolor, progressbarcolor, progressbarbackgroundcolor, -// progressbarfontcolor, bodybackgroundcolor) became mode dropdowns (default|defaultbackgroundcolor| +// progressbarfontcolor, bodybackgroundcolor, grouptitletextcolor, +// groupdescriptiontextcolor) became mode dropdowns (default|defaultbackgroundcolor| // color1|color2|color3|other) with a custom colorpicker child. A legacy HEX // value in the json means "custom color": map it to mode "other" and move the hex // into the custom child, so the variant default stays valid for the dropdown. -$colorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor']; +// A legacy mode "primary"/"secondary" (old 4-way group textcolor dropdown) maps to +// "color1"/"color2". +$colorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor', 'grouptitletextcolor', 'groupdescriptiontextcolor']; +$colorChooserLegacyModes = ['primary' => 'color1', 'secondary' => 'color2']; foreach ($colorChooserKeys as $ck) { if (isset($definition['options'][$ck]) && is_string($definition['options'][$ck]) && preg_match('/^#[0-9a-fA-F]{3,8}$/', $definition['options'][$ck])) { $definition['options'][$ck . 'custom'] = $definition['options'][$ck]; $definition['options'][$ck] = 'other'; + } elseif (isset($definition['options'][$ck]) + && is_string($definition['options'][$ck]) + && isset($colorChooserLegacyModes[$definition['options'][$ck]])) { + $definition['options'][$ck] = $colorChooserLegacyModes[$definition['options'][$ck]]; + } +} + +// --- Row 157 migration: the old fontweight json keys (400|700) became +// fontoptions (normal|bold|italic|bolditalic); map the old values and remove +// the old keys so the unknown-key check below does not fail on them. +$fontWeightToOptions = ['400' => 'normal', '700' => 'bold']; +foreach (['grouptitle', 'groupdescription'] as $el) { + $oldKey = $el . 'fontweight'; + if (isset($definition['options'][$oldKey])) { + $w = (string) $definition['options'][$oldKey]; + $definition['options'][$el . 'fontoptions'] = $fontWeightToOptions[$w] ?? 'normal'; + unset($definition['options'][$oldKey]); } } diff --git a/views/subviews/header/custom_header.twig b/views/subviews/header/custom_header.twig index 1d973cf..01f1550 100644 --- a/views/subviews/header/custom_header.twig +++ b/views/subviews/header/custom_header.twig @@ -63,14 +63,22 @@ color: {{ aSurveyInfo.options.questiontitlefontcolor }}; } + {# Row 157: group title/description font OPTIONS (config.xml fontoptions: + normal|bold|italic|bolditalic) mapped to font-weight + font-style. Until the + theme is reset, a legacy stored fontweight ("400"/"700") is mapped onto + the new values; the defaults keep the old look (title bold, description normal). #} + {% set sGroupTitleFontOptions = aSurveyInfo.options.grouptitlefontoptions|default(aSurveyInfo.options.grouptitlefontweight|default('700') == '700' ? 'bold' : 'normal') %} + {% set sGroupDescFontOptions = aSurveyInfo.options.groupdescriptionfontoptions|default(aSurveyInfo.options.groupdescriptionfontweight|default('400') == '700' ? 'bold' : 'normal') %} .group-title { font-size: {{ aSurveyInfo.options.grouptitlefontsize }}; - font-weight: {{ aSurveyInfo.options.grouptitlefontweight }}; + font-weight: {{ sGroupTitleFontOptions == 'bold' or sGroupTitleFontOptions == 'bolditalic' ? '700' : '400' }}; + font-style: {{ sGroupTitleFontOptions == 'italic' or sGroupTitleFontOptions == 'bolditalic' ? 'italic' : 'normal' }}; } .group-description { font-size: {{ aSurveyInfo.options.groupdescriptionfontsize }}; - font-weight: {{ aSurveyInfo.options.groupdescriptionfontweight }}; + font-weight: {{ sGroupDescFontOptions == 'bold' or sGroupDescFontOptions == 'bolditalic' ? '700' : '400' }}; + font-style: {{ sGroupDescFontOptions == 'italic' or sGroupDescFontOptions == 'bolditalic' ? 'italic' : 'normal' }}; } .privacy-block, .privacy .form-check { diff --git a/views/subviews/survey/group_subviews/group_desc.twig b/views/subviews/survey/group_subviews/group_desc.twig index 789ce2b..046e1d3 100644 --- a/views/subviews/survey/group_subviews/group_desc.twig +++ b/views/subviews/survey/group_subviews/group_desc.twig @@ -22,11 +22,16 @@ "groupdescriptionfont", type fontselect). "base" = same as the base font: no extra class, inherits body font. #} {% set sGroupDescFont = aSurveyInfo.options.groupdescriptionfont|default('base') %} -{# Prompt U: per-element text color — mode default -> fontcolor, primary -> - primarycolor, secondary -> secondarycolor, other -> groupdescriptiontextcolorcustom. - Emitted as an inline style on the element below. #} +{# Row 157: group description color is a color-chooser now (mode dropdown + default|defaultbackgroundcolor|color1|color2|color3|other, like navbarfontcolor + in custom_header.twig). Resolve the effective color: default -> fontcolor, + defaultbackgroundcolor -> defaultbackgroundcolor, color1/2/3 -> + primary/secondary/tertiarycolor, other -> groupdescriptiontextcolorcustom. A raw + hex (legacy stored value) passes through directly; the legacy modes "primary"/ + "secondary" of the old 4-way dropdown map to color1/color2. Emitted as an inline + style on the element below. #} {% set sGroupDescTextColorMode = aSurveyInfo.options.groupdescriptiontextcolor|default('default') %} -{% set sGroupDescTextColor = sGroupDescTextColorMode == 'primary' ? aSurveyInfo.options.primarycolor|default('') : (sGroupDescTextColorMode == 'secondary' ? aSurveyInfo.options.secondarycolor|default('') : (sGroupDescTextColorMode == 'other' ? aSurveyInfo.options.groupdescriptiontextcolorcustom|default('') : aSurveyInfo.options.fontcolor|default(''))) %} +{% set sGroupDescTextColor = sGroupDescTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sGroupDescTextColorMode : ((sGroupDescTextColorMode == 'color1' or sGroupDescTextColorMode == 'primary') ? aSurveyInfo.options.primarycolor|default('') : ((sGroupDescTextColorMode == 'color2' or sGroupDescTextColorMode == 'secondary') ? aSurveyInfo.options.secondarycolor|default('') : (sGroupDescTextColorMode == 'color3' ? aSurveyInfo.options.tertiarycolor|default('') : (sGroupDescTextColorMode == 'defaultbackgroundcolor' ? aSurveyInfo.options.defaultbackgroundcolor|default('') : (sGroupDescTextColorMode == 'other' ? aSurveyInfo.options.groupdescriptiontextcolorcustom|default('') : aSurveyInfo.options.fontcolor|default('')))))) %} {% if aGroup.showgroupinfo == 'D' or aGroup.showgroupinfo == 'B' %} {% if aGroup.description != '' %} diff --git a/views/subviews/survey/group_subviews/group_name.twig b/views/subviews/survey/group_subviews/group_name.twig index 7e1434c..72279f5 100644 --- a/views/subviews/survey/group_subviews/group_name.twig +++ b/views/subviews/survey/group_subviews/group_name.twig @@ -22,11 +22,16 @@ {# THEME ADDITION: font for the group title (config.xml option "grouptitlefont", type fontselect). "base" = same as the base font: no extra class, inherits body font. #} {% set sGroupTitleFont = aSurveyInfo.options.grouptitlefont|default('base') %} -{# Prompt U: per-element text color — mode default -> fontcolor, primary -> - primarycolor, secondary -> secondarycolor, other -> grouptitletextcolorcustom. - Emitted as an inline style on the element below. #} +{# Row 157: group title color is a color-chooser now (mode dropdown + default|defaultbackgroundcolor|color1|color2|color3|other, like navbarfontcolor + in custom_header.twig). Resolve the effective color: default -> fontcolor, + defaultbackgroundcolor -> defaultbackgroundcolor, color1/2/3 -> + primary/secondary/tertiarycolor, other -> grouptitletextcolorcustom. A raw hex + (legacy stored value) passes through directly; the legacy modes "primary"/ + "secondary" of the old 4-way dropdown map to color1/color2. Emitted as an inline + style on the element below. #} {% set sGroupTitleTextColorMode = aSurveyInfo.options.grouptitletextcolor|default('default') %} -{% set sGroupTitleTextColor = sGroupTitleTextColorMode == 'primary' ? aSurveyInfo.options.primarycolor|default('') : (sGroupTitleTextColorMode == 'secondary' ? aSurveyInfo.options.secondarycolor|default('') : (sGroupTitleTextColorMode == 'other' ? aSurveyInfo.options.grouptitletextcolorcustom|default('') : aSurveyInfo.options.fontcolor|default(''))) %} +{% set sGroupTitleTextColor = sGroupTitleTextColorMode matches '/^#[0-9a-fA-F]{3,8}$/' ? sGroupTitleTextColorMode : ((sGroupTitleTextColorMode == 'color1' or sGroupTitleTextColorMode == 'primary') ? aSurveyInfo.options.primarycolor|default('') : ((sGroupTitleTextColorMode == 'color2' or sGroupTitleTextColorMode == 'secondary') ? aSurveyInfo.options.secondarycolor|default('') : (sGroupTitleTextColorMode == 'color3' ? aSurveyInfo.options.tertiarycolor|default('') : (sGroupTitleTextColorMode == 'defaultbackgroundcolor' ? aSurveyInfo.options.defaultbackgroundcolor|default('') : (sGroupTitleTextColorMode == 'other' ? aSurveyInfo.options.grouptitletextcolorcustom|default('') : aSurveyInfo.options.fontcolor|default('')))))) %} {% if aGroup.showgroupinfo == 'N' or aGroup.showgroupinfo == 'B' %}
{{ processString(aGroup.name, false, 3, {'GID': aGroup.gid}) }}