vanilla_respondage/views/subviews/header/custom_header.twig
Tammo ter Hark 8370a945d5 feat(options): row 197 — help/border font color choosers, box-only radii, aligned chooser columns, 'Font color for ...' labels
- questionhelpfontcolor + questionbordercolor are now 6-way color choosers
  (+custom children), both default mode 'default' (Default font color);
  resolved via cmm.cm() in custom_header.twig (legacy hex passthrough)
- border radii show only for questionborder=box (per-key show-values in
  options.twig aShowIfValuesByKey); options.js cascades hiding to nested
  conditional wrappers (questionbordercolorcustom); radii stay two
  subcolumns (border-start on TR/BR)
- chooser columns aligned with the font color: title section = one column
  (title-0: font, font color, size/options, legacy picker, title bg, body
  bg), answers-0 += checkbox chooser, help-0 = font + font color + bg
  chooser, help-1 = text position
- all font-color labels follow 'Font color for ...' / 'Custom font color
  for ...' (21 labels renamed, incl. 'Font color for question titles' and
  'Font color for answers and subquestions')
- chooser key lists synced in options.twig/options.js/build.php (+2)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-29 16:31:52 +01:00

382 lines
21 KiB
Twig

{#
LimeSurvey
Copyright (C) 2007-2017 The LimeSurvey Project Team / Louis Gac
All rights reserved.
License: GNU/GPL License v2 or later, see LICENSE.php
LimeSurvey is free software. This version may have been modified pursuant
to the GNU General Public License, and as distributed it includes or
is derivative of works licensed under the GNU General Public License or
other free or open source software licenses.
See COPYRIGHT.php for copyright notices and details.
(¯`·._.·(¯`·._.· Custom Header ·._.·´¯)·._.·´¯)
If you extend a template, and want to add custom headers (js, css, scripts, meta etc), you'd rather do it here.
#}
{# Custom logo option #}
{# Custom backgroud option #}
{# 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. Row 180 / plan P2: legacy modes "primary"/"secondary" of the
old 4-way <el>textcolor dropdowns map to color1/color2 as well. #}
{% macro cm(mode, custom, opts) -%}
{%- set m = mode|default('') -%}
{{- m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' or m == 'primary' ? opts.primarycolor|default('') : (m == 'color2' or m == 'secondary' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : opts.fontcolor|default('')))))) -}}
{%- endmacro %}
{# Row 191 / row 178 plan P6: like cm(), but for BACKGROUND choosers — mode
"default" means "no override" (empty string), so the Bootstrap button default
(btn-primary / btn-outline-secondary) stays; all other modes resolve the same
way as cm(). Used for the per-button background colors of the navigator. #}
{% macro cmbg(mode, custom, opts) -%}
{%- set m = mode|default('') -%}
{{- m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' or m == 'primary' ? opts.primarycolor|default('') : (m == 'color2' or m == 'secondary' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : ''))))) -}}
{%- endmacro %}
{% import _self as cmm %}
<style>
html, body {
font-size: {{ aSurveyInfo.options.fontsize }} !important;
}
{% if (aSurveyInfo.options.backgroundimage == "on" and imageSrc(aSurveyInfo.options.backgroundimagefile )) %}
body {
background-image: url({{ imageSrc(aSurveyInfo.options.backgroundimagefile ) }});
background-attachment: {{ aSurveyInfo.options.backgroundimagefixed }};
background-size: {{ aSurveyInfo.options.backgroundimagedisplay }};
}
body .top-container {
background-color: rgba(236, 240, 241, 0.2);
}
{% endif %}
body {
padding-bottom: 10px;
/*padding-top: 60px;!* now is redefine in JS to fit any title length *!*/
background-color:{{ cmm.cm(aSurveyInfo.options.bodybackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.bodybackgroundcolorcustom|default(''), aSurveyInfo.options) }} ;
color: {{ aSurveyInfo.options.fontcolor }};
}
.table {
color: {{ aSurveyInfo.options.fontcolor }};
}
{# Row 180 / plan P2: the question title now uses the color-chooser scheme —
questiontitletextcolor + questiontitletextcolorcustom (text) and
questiontitlebackgroundcolor + questiontitlebackgroundcolorcustom
(background), resolved via cm() (default modes: text "other" per row 178,
background "color1"; legacy stored hex passes through). The CHOOSER wins
when the mode key exists in the stored options; a row from before P2 (no
questiontitletextcolor key) falls back to the legacy plain picker
questiontitlefontcolor. questiontitlefontoptions (normal|bold|italic|
bolditalic) replaces questiontitlefontweight (400|700) — a legacy stored
weight is mapped like the group title/description (row 157). #}
{% set sQTitleFontOptions = aSurveyInfo.options.questiontitlefontoptions|default(aSurveyInfo.options.questiontitlefontweight|default('700') == '700' ? 'bold' : 'normal') %}
{% set sQTitleBackgroundColor = cmm.cm(aSurveyInfo.options.questiontitlebackgroundcolor|default('color1'), aSurveyInfo.options.questiontitlebackgroundcolorcustom|default(''), aSurveyInfo.options) %}
{% set sQTitleTextColor = aSurveyInfo.options.questiontitletextcolor is defined ? cmm.cm(aSurveyInfo.options.questiontitletextcolor, aSurveyInfo.options.questiontitletextcolorcustom|default(''), aSurveyInfo.options) : aSurveyInfo.options.questiontitlefontcolor|default('') %}
.question-title-container {
font-size: {{ aSurveyInfo.options.questiontitlefontsize }};
font-weight: {{ sQTitleFontOptions == 'bold' or sQTitleFontOptions == 'bolditalic' ? '700' : '400' }};
font-style: {{ sQTitleFontOptions == 'italic' or sQTitleFontOptions == 'bolditalic' ? 'italic' : 'normal' }};
background: {{ sQTitleBackgroundColor }};
color: {{ sQTitleTextColor }};
}
{# Row 157: group title/description font OPTIONS (config.xml <el>fontoptions:
normal|bold|italic|bolditalic) mapped to font-weight + font-style. Until the
theme is reset, a legacy stored <el>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: {{ 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: {{ sGroupDescFontOptions == 'bold' or sGroupDescFontOptions == 'bolditalic' ? '700' : '400' }};
font-style: {{ sGroupDescFontOptions == 'italic' or sGroupDescFontOptions == 'bolditalic' ? 'italic' : 'normal' }};
}
.privacy-block, .privacy .form-check {
background-color: {{ aSurveyInfo.options.privacybackgroundcolor }};
}
{% if ( aSurveyInfo.options.brandlogofile|default('off') not in ['off', '', 'inherit'] and aSurveyInfo.options.brandlogo|default('on') != 'off' ) %}
body .top-container {
margin-top: 0;
}
{% endif %}
{# Row 179 / plan P1: distances in the Questions tab ("Overall question" section).
Free text in px or rem (default 30px); only emitted when the value matches
^<number>(px|rem)$ — anything else falls back to 30px. questiondistance is
the margin-bottom between two question containers (parent theme.css uses
2em), questiondistancebottom the margin-top of the bottom navigator with
the Previous/Next/Submit buttons. #}
{% set sQuestionDistance = aSurveyInfo.options.questiondistance|default('30px') %}
{% set sQuestionDistanceBottom = aSurveyInfo.options.questiondistancebottom|default('30px') %}
.question-container {
margin-bottom: {{ sQuestionDistance matches '/^\\d+(\\.\\d+)?(px|rem)$/' ? sQuestionDistance : '30px' }};
}
#navigator-container {
margin-top: {{ sQuestionDistanceBottom matches '/^\\d+(\\.\\d+)?(px|rem)$/' ? sQuestionDistanceBottom : '30px' }};
}
{% if (aSurveyInfo.options.questionborder == "box" ) %}
.question-container,
#welcome-container,
.save-form,
#surveys-list-container,
.privacy {
border: 1px {{ aSurveyInfo.options.questionborderstyle }} {{ cmm.cm(aSurveyInfo.options.questionbordercolor|default('default'), aSurveyInfo.options.questionbordercolorcustom|default('#cccccc'), aSurveyInfo.options) }};
}
{% endif %}
{% if (aSurveyInfo.options.questionborder == "top" ) %}
.question-container,
#welcome-container,
.save-form,
#surveys-list-container,
.privacy {
border-top: 1px {{ aSurveyInfo.options.questionborderstyle }} {{ cmm.cm(aSurveyInfo.options.questionbordercolor|default('default'), aSurveyInfo.options.questionbordercolorcustom|default('#cccccc'), aSurveyInfo.options) }};
}
{% endif %}
{% if (aSurveyInfo.options.questionborder == "none" ) %}
.question-container,
#welcome-container,
.save-form,
#surveys-list-container,
.privacy {
border: none;
}
{% endif %}
.question-container,
#welcome-container,
.save-form,
#surveys-list-container,
.privacy {
border-radius: {{ aSurveyInfo.options.questionborderradiusTL }}px {{ aSurveyInfo.options.questionborderradiusTR }}px {{ aSurveyInfo.options.questionborderradiusBR }}px {{ aSurveyInfo.options.questionborderradiusBL }}px;
}
.question-title-container{
border-radius: {{ aSurveyInfo.options.questionborderradiusTL }}px {{ aSurveyInfo.options.questionborderradiusTR }}px 0 0;
}
{% if (aSurveyInfo.options.questiondropdown == "on" ) %}
.question-container,
#welcome-container,
.privacy-block,
.save-form,
#surveys-list-container {
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4);
}
.privacy{
margin-top:30px;
}
{% endif %}
{% if (aSurveyInfo.options.questiondropdown == "hover" ) %}
.question-container:hover,
#welcome-container:hover,
.save-form:hover,
#surveys-list-container:hover,
.privacy:hover {
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.4);
}
.privacy{
margin-top:30px;
}
{% endif %}
{# Row 135: headerbackgroundcolor is a MODE dropdown now (see navbarfontcolor
below) — resolve the effective color via the shared partial. Default mode
"defaultbackgroundcolor"; a legacy stored hex passes through. #}
{% set sHeaderBackgroundColor = cmm.cm(aSurveyInfo.options.headerbackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.headerbackgroundcolorcustom|default(''), aSurveyInfo.options) %}
.navbar-light{
background-color: {{ sHeaderBackgroundColor }};
}
{# THEME ADDITION: sticky header per screen size (options
headersticky{computer,tablet,mobile}; Prompt L — the master key
"headersticky" no longer gates this). Breakpoints are Bootstrap's
defaults: phone < md (768px), tablet = md..lg (768-991px),
computer >= lg (992px). The rules are the same as Bootstrap's
.fixed-top, but only inside the selected range(s). Only emitted when
the checkbox options exist (after a theme reset); before that nav_bar.twig
keeps the fixed-top class (old behaviour). Defaults when a checkbox is
undefined: computer on, tablet on, mobile off. #}
{% if aSurveyInfo.options.headerstickycomputer is defined %}
{% if aSurveyInfo.options.headerstickycomputer|default('on') == 'on' %}
@media (min-width: 992px) { #survey-nav { position: fixed; top: 0; right: 0; left: 0; z-index: 1030; } }
{% endif %}
{% if aSurveyInfo.options.headerstickytablet|default('on') == 'on' %}
@media (min-width: 768px) and (max-width: 991.98px) { #survey-nav { position: fixed; top: 0; right: 0; left: 0; z-index: 1030; } }
{% endif %}
{% if aSurveyInfo.options.headerstickymobile|default('off') == 'on' %}
@media (max-width: 767.98px) { #survey-nav { position: fixed; top: 0; right: 0; left: 0; z-index: 1030; } }
{% endif %}
{% endif %}
{# Prompt M: per-logo top margin (options <pos>logotopmargin hold a plain px
number 0-100; the "px" unit is added here. |replace({'px':''}) guards
against a legacy stored value that still carries the unit. Row 138
default: 30 px. Emitted as margin-top on the logo container: together with
the padding-top:0 on .logo-container / .logo-container > img and the
top-aligned header in css/plain.css (sass/plain.sass), the value is the
EXACT distance from the top of the header to the top of the logo —
0 px means the logo touches the top of the page. #}
#survey-nav .logo-left.logo-container {
margin-top: {{ aSurveyInfo.options.brandlogotopmargin|default('30')|replace({'px': ''}) }}px;
}
#survey-nav .logo-center.logo-container {
margin-top: {{ aSurveyInfo.options.centerlogotopmargin|default('30')|replace({'px': ''}) }}px;
}
#survey-nav .logo-right.logo-container {
margin-top: {{ aSurveyInfo.options.rightlogotopmargin|default('30')|replace({'px': ''}) }}px;
}
{# Row 138: header bar height (option headerheight, plain px number; the "px"
unit is added here, |replace guards a legacy value with the unit). Applied
as min-height so taller logos can still grow the bar — the sticky body
padding in scripts/custom.js follows the real nav height. #}
#survey-nav {
min-height: {{ aSurveyInfo.options.headerheight|default('90')|replace({'px': ''}) }}px;
}
{# Row 115 working example: navbarfontcolor is now a MODE dropdown
(default|color1|color2|color3|other). Resolve the effective color:
default -> fontcolor, color1/2/3 -> primarycolor/secondarycolor/tertiarycolor,
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 == '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 }};
}
#survey-nav .navbar-nav > li > a:hover,
#survey-nav .navbar-nav > li > a:focus,
#survey-nav .navbar-nav .nav-link:hover,
#survey-nav .navbar-nav .nav-link:focus {
color: {{ sNavbarFontColor }};
opacity: 0.75;
}
{# Row 135: the progress bar colors are MODE dropdowns now — resolve via the
shared partial. Defaults: background = Default background color, bar = Color 1,
font = Default font color; legacy stored hex passes through. #}
{% set sProgressBarBackgroundColor = cmm.cm(aSurveyInfo.options.progressbarbackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.progressbarbackgroundcolorcustom|default(''), aSurveyInfo.options) %}
{% set sProgressBarColor = cmm.cm(aSurveyInfo.options.progressbarcolor|default('color1'), aSurveyInfo.options.progressbarcolorcustom|default(''), aSurveyInfo.options) %}
{% set sProgressBarFontColor = cmm.cm(aSurveyInfo.options.progressbarfontcolor|default('default'), aSurveyInfo.options.progressbarfontcolorcustom|default(''), aSurveyInfo.options) %}
.progress {
background: {{ sProgressBarBackgroundColor }};
}
label::after,
.radio-item label::after{
background-color: {{ cmm.cm(aSurveyInfo.options.checkboxcolor|default('other'), aSurveyInfo.options.checkboxcolorcustom|default('#ff005f'), aSurveyInfo.options) }};
}
.progress-bar {
background: {{ sProgressBarColor }};
color: {{ sProgressBarFontColor }};
}
{# Row 180 / plan P2: the question body background is a color chooser now
(questionbackgroundcolor, default mode "defaultbackgroundcolor", +
questionbackgroundcolorcustom for "other"); a legacy stored hex passes
through cm() directly. #}
.question-container, #welcome-container {
background: {{ cmm.cm(aSurveyInfo.options.questionbackgroundcolor|default('defaultbackgroundcolor'), aSurveyInfo.options.questionbackgroundcolorcustom|default(''), aSurveyInfo.options) }};
}
{# Row 186 / plan P4, revised row 196/197: the question help background is a
color chooser (questionhelpbackgroundcolor, default mode "color3" since row
196; a legacy stored hex passes through cm()) AND the help font color is a
chooser too (questionhelpfontcolor, 6-way + questionhelpfontcolorcustom,
default mode "default" = the default font color; legacy hex passes through
cm() as well). #}
.question-help-container, .question-valid-container {
background: {{ cmm.cm(aSurveyInfo.options.questionhelpbackgroundcolor|default('color3'), aSurveyInfo.options.questionhelpbackgroundcolorcustom|default('#fff3cd'), aSurveyInfo.options) }};
color: {{ cmm.cm(aSurveyInfo.options.questionhelpfontcolor|default('default'), aSurveyInfo.options.questionhelpfontcolorcustom|default('#444444'), aSurveyInfo.options) }};
}
.slider-handle {
background: {{ aSurveyInfo.options.sliderhandlecolor }};
}
.btn-primary {
background: {{ aSurveyInfo.options.primarycolor }};
}
.bg-primary{
background-color: {{ sQTitleBackgroundColor }};
color: {{ sQTitleTextColor }};
}
.btn-primary:hover, .btn-primary:focus {
background: {{ aSurveyInfo.options.primarycolor }};
}
.btn-check:active+.btn-primary,
.btn-check:checked+.btn-primary,
.btn-primary.active,
.btn-primary:active,
.show>.btn-primary.dropdown-toggle,
.show > .btn-primary.dropdown-toggle,
.btn-primary:focus {
background: {{ aSurveyInfo.options.primarycolor }};
}
{# Row 191 / row 178 plan P6: per-button colors for the navigator buttons
(classes respondage-btn-prev/-next/-submit from navigator.twig).
Backgrounds resolve via cmbg() (mode "default" = no rule = Bootstrap
default button background), text colors via cm() (mode "default" = the
default font color). Row-178 decision 7 defaults: Next/Submit background =
Color 1, text = Other ... #ffffff; Previous background = Other ... #ffffff,
text = Default font color. Legacy stored hex values pass through both
macros. The :hover/:focus/:active variants keep the same specificity as
Bootstrap's .btn-primary:hover rules above and win because this style
block is emitted later. #}
{% set sPrevBtnBg = cmm.cmbg(aSurveyInfo.options.previousbuttonbackgroundcolor|default('other'), aSurveyInfo.options.previousbuttonbackgroundcolorcustom|default('#ffffff'), aSurveyInfo.options) %}
{% set sPrevBtnColor = cmm.cm(aSurveyInfo.options.previousbuttontextcolor|default('default'), aSurveyInfo.options.previousbuttontextcolorcustom|default(''), aSurveyInfo.options) %}
{% set sNextBtnBg = cmm.cmbg(aSurveyInfo.options.nextbuttonbackgroundcolor|default('color1'), aSurveyInfo.options.nextbuttonbackgroundcolorcustom|default('#ffffff'), aSurveyInfo.options) %}
{% set sNextBtnColor = cmm.cm(aSurveyInfo.options.nextbuttontextcolor|default('other'), aSurveyInfo.options.nextbuttontextcolorcustom|default('#ffffff'), aSurveyInfo.options) %}
{% set sSubmitBtnBg = cmm.cmbg(aSurveyInfo.options.submitbuttonbackgroundcolor|default('color1'), aSurveyInfo.options.submitbuttonbackgroundcolorcustom|default('#ffffff'), aSurveyInfo.options) %}
{% set sSubmitBtnColor = cmm.cm(aSurveyInfo.options.submitbuttontextcolor|default('other'), aSurveyInfo.options.submitbuttontextcolorcustom|default('#ffffff'), aSurveyInfo.options) %}
{% if sPrevBtnBg != '' or sPrevBtnColor != '' %}
.respondage-btn-prev, .respondage-btn-prev:hover, .respondage-btn-prev:focus, .respondage-btn-prev:active {
{% if sPrevBtnBg != '' %}background: {{ sPrevBtnBg }}; border-color: {{ sPrevBtnBg }};{% endif %}
{% if sPrevBtnColor != '' %}color: {{ sPrevBtnColor }};{% endif %}
}
{% endif %}
{% if sNextBtnBg != '' or sNextBtnColor != '' %}
.respondage-btn-next, .respondage-btn-next:hover, .respondage-btn-next:focus, .respondage-btn-next:active {
{% if sNextBtnBg != '' %}background: {{ sNextBtnBg }}; border-color: {{ sNextBtnBg }};{% endif %}
{% if sNextBtnColor != '' %}color: {{ sNextBtnColor }};{% endif %}
}
{% endif %}
{% if sSubmitBtnBg != '' or sSubmitBtnColor != '' %}
.respondage-btn-submit, .respondage-btn-submit:hover, .respondage-btn-submit:focus, .respondage-btn-submit:active {
{% if sSubmitBtnBg != '' %}background: {{ sSubmitBtnBg }}; border-color: {{ sSubmitBtnBg }};{% endif %}
{% if sSubmitBtnColor != '' %}color: {{ sSubmitBtnColor }};{% endif %}
}
{% endif %}
{% set checkicon = '"\\' ~ aSurveyInfo.options.checkicon ~ '"' %}
.checkbox-item input[type="checkbox"]:checked + label::after, .checkbox-item input[type="radio"]:checked + label::after {
content: {{ checkicon }};
}
</style>