vanilla_respondage/views/subviews/header/nav_bar.twig
Tammo ter Hark b44d120d7d feat(options): sticky header as label + 3 standalone checkboxes (Prompt L)
config.xml: the three headersticky* checkboxes lose parent="headersticky"
and get width=12 (stacked as a vertical list); the master key headersticky
stays in config.xml/DB for backward compatibility but is rendered as a
static label only (special case in options.twig — no input). Views:
custom_header.twig emits the per-breakpoint fixed-top media queries based
on the three checkboxes alone (master gate dropped; defaults on/on/off
when undefined); nav_bar.twig fallback now keys off headerstickycomputer
being defined. Migration note: an old row with headersticky=off no longer
disables sticky — only the checkboxes govern it.

Verified: CLI render row 270 — top-of-page pane shows the label + 3
checkboxes (col-md-12, no parent, checked on/on/off, no option-visibility);
survey 282267 renders media queries for computer+tablet but not mobile and
no hardcoded fixed-top; jsdom toggle/serialize + radio idempotency PASS;
run_all PASS; export green. Variants NOT rebuilt yet (config.xml batch —
rebuild+reset once after Prompt U per standing rule).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-24 23:03:57 +01:00

102 lines
6.2 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.
(¯`·._.·(¯`·._.· Bootstrap Navigation Bar ·._.·´¯)·._.·´¯)
This file renders a typical bootstrap navigation bar.
See: https://getbootstrap.com/components/#navbar
For the survey navigator ("Next", "Back", etc.), see: navigation/navigator.twig
#}
{% if not aSurveyInfo.popupPreview %}
{% set navClass = "navbar-light bg-light" %}
{% if( aSurveyInfo.template == "bootswatch") %}
{% set navClass = "navbar-default bg-primary" %}
{% endif %}
<!-- Bootstrap Navigation Bar -->
{# ShowMenu used for navbar-toggler and navbar-collapse #}
{% set ShowMenu = (aSurveyInfo.aNavigator.load.show == "Y" or aSurveyInfo.aNavigator.save.show == "Y")
or ((aSurveyInfo.bShowClearAll == true or aSurveyInfo.bShowClearAll == null) and aSurveyInfo.options.showclearall == 'on')
or (aSurveyInfo.aQuestionIndex.bShow == true and aSurveyInfo.format != 'A')
or (aSurveyInfo.alanguageChanger.show)
%}
{% set showRightLogo = (aSurveyInfo.options.rightlogo == "on" and imageSrc(aSurveyInfo.options.rightlogofile)) %}
{# THEME ADDITION: font for the header / top menu (config.xml option "headerfont",
type fontselect). "base" = same as the base font: no extra class, the navbar
inherits the body font (body gets font-<base font>). Applied on #survey-nav,
so it covers the menu items and the survey name as well. #}
{% set sHeaderFont = aSurveyInfo.options.headerfont|default('base') %}
{# THEME ADDITION: sticky header per screen size (options
headersticky{computer,tablet,mobile}; Prompt L — the master key no longer
counts). When the checkbox options exist (theme was reset after adding
them), fixed-top is NOT hardcoded here anymore — custom_header.twig emits
the media queries instead. Before a reset the old behaviour (always
fixed-top) is kept as fallback. #}
{% set bStickyConfigured = aSurveyInfo.options.headerstickycomputer is defined %}
{# Per-logo "hide on small screens" (Bootstrap classes d-none d-md-block).
Default (option missing or "on") keeps the logo hidden below the md breakpoint. #}
{% set hideSmallLeft = (aSurveyInfo.options.brandlogohideonsmall != "off") %}
{% set hideSmallCenter = (aSurveyInfo.options.centerlogohideonsmall != "off") %}
{% set hideSmallRight = (aSurveyInfo.options.rightlogohideonsmall != "off") %}
<div id="survey-nav" class="navbar {{ navClass }} navbar-expand-md {% if not bStickyConfigured %}fixed-top{% endif %} border-bottom pt-0 pb-0 {% if sHeaderFont != 'base' %}font-{{ sHeaderFont }}{% endif %}">
<div class="container-fluid d-flex align-items-center">
{% if ShowMenu %}
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar"
aria-controls="small-screens-menus" aria-expanded="false">
<span class="visually-hidden-focusable">{{ gT("Tools") }}</span>
<span class="navbar-toggler-icon" aria-hidden="true"></span>
</button>
{% endif %}
{# Left logo #}
{% if( aSurveyInfo.options.brandlogo == "on" and imageSrc(aSurveyInfo.options.brandlogofile)) %}
<div class="navbar-brand logo-container logo-left {{ hideSmallLeft ? 'd-none d-md-block' : '' }}">
{{ image(aSurveyInfo.options.brandlogofile, aSurveyInfo.name, {"class": "logo img-fluid"}) }}
</div>
{% else %}
<div class="navbar-brand logo-left">
{{ aSurveyInfo.name }}
</div>
{% endif %}
{# Center logo (absolutely centered via CSS, see sass/plain.sass) #}
{% if( aSurveyInfo.options.centerlogo == "on" and imageSrc(aSurveyInfo.options.centerlogofile)) %}
<div class="navbar-brand logo-container logo-center {{ hideSmallCenter ? 'd-none d-md-block' : '' }}">
{{ image(aSurveyInfo.options.centerlogofile, aSurveyInfo.name, {"class": "logo img-fluid"}) }}
</div>
{% endif %}
{# RIGHT zone — always pushed to the far right (ms-auto on the wrapper).
Layout rules (see sass/plain.sass):
- left logo always far left, right logo always far right;
- center logo always exactly centered (absolute), independent of the
other logos;
- when a right logo is present, the right-side menu texts (language
changer, save/clear all, question index) still appear at the right,
but BELOW the logo (flex-column wrapper). #}
<div class="survey-nav-right ms-auto d-flex flex-column align-items-end">
{# Right logo #}
{% if showRightLogo %}
<div class="navbar-brand logo-container logo-right {{ hideSmallRight ? 'd-none d-md-block' : '' }}">
{{ image(aSurveyInfo.options.rightlogofile, aSurveyInfo.name, {"class": "logo img-fluid"}) }}
</div>
{% endif %}
{% if ShowMenu %}
<div id="navbar" class="collapse navbar-collapse navbar-nav-scroll pt-2">
<ul class="nav navbar-nav navbar-action-link navbar-right">
{{ include('./subviews/navigation/save_links.twig') }}
{{ include('./subviews/navigation/clearall_links.twig') }}
{{ include('./subviews/navigation/question_index_menu.twig') }}
{{ include('./subviews/navigation/language_changer_top_menu.twig') }}
</ul>
</div>
{% endif %}
</div>
</div>
</div>
{% endif %}