vanilla_respondage/views/subviews/header/custom_header.twig
Tammo ter Hark 956324775b feat(options): Groups tab with intro and two columns; group colors become color choosers; font options Normal|Bold|Italic|Bold italic
Row 157. Groups pane gets a full-width h2 'Groups' + explanatory text and a
two-column slot layout: col 1 = group title options (font, color, custom,
size, font options), col 2 = same for the group description (singular wording).
grouptitletextcolor/groupdescriptiontextcolor switch from the old 4-way
dropdown to the row-135 color chooser (6 modes, default 'Default font color',
swatch chips, grayed-out custom picker unless 'other'); legacy stored modes
primary/secondary and raw hex migrate client-side (options.js) and in the views.
The old *fontweight keys (400|700) become *fontoptions (normal|bold|italic|
bolditalic), mapped to font-weight/font-style in custom_header.twig with a
legacy 400/700 fallback until theme reset. build.php migrates variant jsons
(chooser hex/modes + fontweight keys). OPTIONS_JS_TOKEN 20261127.1.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-27 02:50:06 +01:00

295 lines
14 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. #}
{% macro cm(mode, custom, opts) -%}
{%- set m = mode|default('') -%}
{{- m matches '/^#[0-9a-fA-F]{3,8}$/' ? m : (m == 'color1' ? opts.primarycolor|default('') : (m == 'color2' ? opts.secondarycolor|default('') : (m == 'color3' ? opts.tertiarycolor|default('') : (m == 'defaultbackgroundcolor' ? opts.defaultbackgroundcolor|default('') : (m == 'other' ? custom|default('') : opts.fontcolor|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 }};
}
.question-title-container {
font-size: {{ aSurveyInfo.options.questiontitlefontsize }};
font-weight: {{ aSurveyInfo.options.questiontitlefontweight }};
background: {{ aSurveyInfo.options.questiontitlebackgroundcolor }};
color: {{ aSurveyInfo.options.questiontitlefontcolor }};
}
{# 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 %}
{% if (aSurveyInfo.options.questionborder == "box" ) %}
.question-container,
#welcome-container,
.save-form,
#surveys-list-container,
.privacy {
border: 1px {{ aSurveyInfo.options.questionborderstyle }} {{ aSurveyInfo.options.questionbordercolor }};
}
{% endif %}
{% if (aSurveyInfo.options.questionborder == "top" ) %}
.question-container,
#welcome-container,
.save-form,
#surveys-list-container,
.privacy {
border-top: 1px {{ aSurveyInfo.options.questionborderstyle }} {{ aSurveyInfo.options.questionbordercolor }};
}
{% 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. #}
#survey-nav .logo-left > img {
padding-top: {{ aSurveyInfo.options.brandlogotopmargin|default('30')|replace({'px': ''}) }}px;
}
#survey-nav .logo-center > img {
padding-top: {{ aSurveyInfo.options.centerlogotopmargin|default('30')|replace({'px': ''}) }}px;
}
#survey-nav .logo-right > img {
padding-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: {{ aSurveyInfo.options.checkboxcolor }};
}
.progress-bar {
background: {{ sProgressBarColor }};
color: {{ sProgressBarFontColor }};
}
.question-container, #welcome-container {
background: {{ aSurveyInfo.options.questionbackgroundcolor }};
}
.question-help-container, .question-valid-container {
background: {{ aSurveyInfo.options.questionhelpbackgroundcolor }};
color: {{ aSurveyInfo.options.questionhelpfontcolor|default('') }};
}
.slider-handle {
background: {{ aSurveyInfo.options.sliderhandlecolor }};
}
.btn-primary {
background: {{ aSurveyInfo.options.primarycolor }};
}
.bg-primary{
background-color: {{ aSurveyInfo.options.questiontitlebackgroundcolor }};
color: {{ aSurveyInfo.options.questiontitlefontcolor }};
}
.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 }};
}
{% set checkicon = '"\\' ~ aSurveyInfo.options.checkicon ~ '"' %}
.checkbox-item input[type="checkbox"]:checked + label::after, .checkbox-item input[type="radio"]:checked + label::after {
content: {{ checkicon }};
}
</style>