{#
Custom options page of this theme. Activated by custom
in config.xml: LimeSurvey then renders THIS file inside the "Simple options" tab
of themeOptions/update (instead of the core options_core.php partial) and
auto-registers options/options.js next to it.
All options are rendered GENERICALLY from config.xml via aOptionAttributes (the
same structure the core renderer uses, see TemplateManifest::getOptionAttributes()),
grouped by category. Adding an ' %}{% endif %}
{% set imageOptions = imageOptions ~ '' %}{% endif %}
{# If this is a survey-specific (or survey-group) settings page, offer full inheritance of the parent template #}
{% if bInherit %}
{% endif %}
{# Every tab pane ends with the Respondage footer. The logo uses a dedicated file
name (not logo.png) on purpose: variants may ship their own files/logo.png as
client logo, and imageSrc() resolves './files/...' in the variant first — with
this name it falls through to the mother theme, so the footer always shows the
Respondage logo. #}
{% set respondageLogo = imageSrc('./files/respondage-logo.png') %}
{# Options that make up the TOP OF THE PAGE (everything in the header, plus the
progress bar which sits in/just under the header): the menu (navbar text color),
the left/center/right logos, the header background color, and the progress bar
position + colors. These keys are pulled out of their original config.xml
categories (Colors / Images / Progress) into a dedicated FIRST tab below.
Values are stored per option key, so moving them here does not change any stored
value. The order of this list is the order shown in the tab. #}
{% set aTopOfPageKeys = [
'headerbackgroundcolor', 'navbarfontcolor',
'headersticky', 'headerstickycomputer', 'headerstickytablet', 'headerstickymobile',
'brandlogofile', 'brandlogotopmargin', 'brandshowoncomputer', 'brandshowontablet', 'brandshowonmobile',
'centerlogofile', 'centerlogotopmargin', 'centershowoncomputer', 'centershowontablet', 'centershowonmobile',
'rightlogofile', 'rightlogotopmargin', 'rightshowoncomputer', 'rightshowontablet', 'rightshowonmobile',
'progressbarposition', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor'
] %}
{# Prompt M: the logo keys are rendered as ONE dedicated 3-column block (triggered at
the first logo key, 'brandlogofile') and skipped in the generic per-key loop. #}
{% set aLogoKeys = [
'brandlogofile', 'brandlogotopmargin', 'brandshowoncomputer', 'brandshowontablet', 'brandshowonmobile',
'centerlogofile', 'centerlogotopmargin', 'centershowoncomputer', 'centershowontablet', 'centershowonmobile',
'rightlogofile', 'rightlogotopmargin', 'rightshowoncomputer', 'rightshowontablet', 'rightshowonmobile'
] %}
{% set aLogoPositions = ['brand', 'center', 'right'] %}
{# Prompt N: the progress-bar keys render as ONE column (col-md-4; the col-md-8
next to it stays empty) directly below the logo hr, in this fixed order. #}
{% set aProgressKeys = ['progressbarposition', 'progressbarbackgroundcolor', 'progressbarcolor', 'progressbarfontcolor'] %}
{# Prompt U: the elements that get a font+color combo row in the "Fonts and
colors" pane. Per element the keys are font (fontselect),
textcolor (dropdown default|primary|secondary|other) and
textcolorcustom (colorpicker, visible only when textcolor = "other"). #}
{% set aFontElements = ['header', 'progressbar', 'questiontitle', 'answers', 'grouptitle', 'groupdescription', 'buttons'] %}
{# Prompt R: multi-value show lists per parent key, rendered as
data-show-if-value (e.g. "box|top" for questionborder). Core passes only the
`parent` attribute through to the option attributes, so this list lives here
in the theme. Default 'on'. Used both for the wrapper attribute and for the
server-side initial d-none (Prompt Q). Prompt U adds 'other' for every
textcolor dropdown (parent of textcolorcustom). #}
{% set aShowIfValues = { 'questionborder': 'box|top' } %}
{% for el in aFontElements %}{% set aShowIfValues = aShowIfValues|merge({ (el ~ 'textcolor'): 'other' }) %}{% endfor %}
{# Prompt U: the Fonts pane is rendered as "Fonts and colors" with a special
layout: a TOP ROW (col 1: font/fontcolor/fontsize; col 2: primarycolor/
secondarycolor; col 3 empty), an hr, then one combo row per element in
aFontElements (col 1: font, col 2: textcolor, col 3:
textcolorcustom), then the remaining Fonts options (sizes/weights)
stacked as usual ("rest"). config.xml lists the Fonts options in exactly
this order, so the generic loop meets them slot by slot and opens/closes
the containers on slot change (fLastSlot). #}
{% set aFontsTop1 = ['font', 'fontcolor', 'fontsize'] %}
{% set aFontsTop2 = ['primarycolor', 'secondarycolor'] %}
{# Prompt R: the Questions pane renders as THREE columns (col-md-4, border-start
between them) with explicit key lists. config.xml lists the Questions options
in exactly this column order, so the generic loop meets them column by column
and opens/closes the columns on column change (qLastCol). Column 2's
conditional children use aShowIfValues['questionborder'] = 'box|top'. #}
{% set aQuestionsCol1 = ['questiontitlebackgroundcolor', 'questiontitlefontcolor', 'questionbackgroundcolor', 'questionhelpbackgroundcolor', 'questionhelpfontcolor', 'questionhelptextposition'] %}
{% set aQuestionsCol2 = ['questionborder', 'questionbordercolor', 'questionborderstyle', 'questiondropdown', 'questionborderradiusTL', 'questionborderradiusTR', 'questionborderradiusBL', 'questionborderradiusBR'] %}
{% set aQuestionsCol3 = ['checkboxcolor'] %}
{# 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 =
aTopOfPageKeys), then one tab per remaining category from config.xml like the
core options page (keys = null: all options of that category, except the
top-of-page keys). Category tab ids are slugs of the category name, so they
stay stable regardless of the tab order. #}
{% set aTabs = [] %}
{% if 'Fonts' in aOptionAttributes.categories %}
{% set aTabs = [{ 'id': 'category-fonts', 'label': 'Fonts and colors', 'category': 'Fonts', 'keys': null }] %}
{% endif %}
{% set aTabs = aTabs|merge([{ 'id': 'top-of-page', 'label': 'Top of the page', 'category': 'Top of the page', 'keys': aTopOfPageKeys }]) %}
{% for category in aOptionAttributes.categories %}
{% if category != 'Fonts' and category != 'Top of the page' %}
{# Resolve this category's keys once and skip the tab entirely when none
remain (Prompt S): e.g. "Progress" — its only option (progressbarposition)
moved to the Top-of-page tab, so an empty tab must not be rendered. #}
{% set catKeys = [] %}
{% for key, attr in aOptionAttributes.optionAttributes %}
{% if key != 'ajaxmode' and attr.category == category and key not in aTopOfPageKeys %}
{% set catKeys = catKeys|merge([key]) %}
{% endif %}
{% endfor %}
{% if catKeys is not empty %}
{% set aTabs = aTabs|merge([{ 'id': 'category-' ~ category|lower|replace({' ': '-'}), 'label': category, 'category': category, 'keys': null }]) %}
{% endif %}
{% endif %}
{% endfor %}
{% for tab in aTabs %}
{% endfor %}
{% for tab in aTabs %}
{# Resolve which option keys this tab shows: the top-of-page tab uses the fixed
order of aTopOfPageKeys; a category tab shows its config.xml options (in
config.xml order) minus the top-of-page keys. #}
{% set aTabKeys = tab.keys %}
{% if aTabKeys is null %}
{% set aTabKeys = [] %}
{% for key, attr in aOptionAttributes.optionAttributes %}
{% if key != 'ajaxmode' and attr.category == tab.category and key not in aTopOfPageKeys %}
{% set aTabKeys = aTabKeys|merge([key]) %}
{% endif %}
{% endfor %}
{% else %}
{# the top-of-page tab also picks up options that literally carry the
category "Top of the page" (so config.xml may use it after a reset) #}
{% for key, attr in aOptionAttributes.optionAttributes %}
{% if key != 'ajaxmode' and attr.category == 'Top of the page' and key not in aTabKeys %}
{% set aTabKeys = aTabKeys|merge([key]) %}
{% endif %}
{% endfor %}
{% endif %}
{# Prompt P: in the Images pane use the three-column grid like the logo
block (Prompt M), but fill ONLY column 1 — all Images options stack
vertically in this single col-md-4 (their width=12 makes each wrapper
full width of the column). Columns 2-3 stay empty. The upload block
below stays full width. #}
{% if tab.category == 'Images' %}
{% endif %}
{% set qLastCol = 0 %}
{% set fLastSlot = 0 %}
{% for key in aTabKeys %}
{% set attr = aOptionAttributes.optionAttributes[key] ?? null %}
{% if attr is not null %}
{% if tab.id == 'top-of-page' and key == 'brandlogofile' %}
{# PROMPT M: dedicated 3-column logo block (left/center/right), vertical
borders between columns, hr below. Per column, top to bottom:
file dropdown ("No logo" first), margin 0-100px, "Show logo on"
with 3 device checkboxes. Labels above controls (Prompt G),
server-side checked/selected/value like the generic renderer. #}
{% for pos in aLogoPositions %}
{% set fkey = pos ~ 'logofile' %}
{% set mkey = pos ~ 'logotopmargin' %}
{% set fattr = aOptionAttributes.optionAttributes[fkey] %}
{% set mattr = aOptionAttributes.optionAttributes[mkey] %}
{% set fcv = bGeneralInherit ? 'inherit' : (aCurrentOptions[fkey] is defined ? aCurrentOptions[fkey] : (oParentOptions[fkey] is defined ? oParentOptions[fkey] : '')) %}
{% set mcv = bGeneralInherit ? 'inherit' : (aCurrentOptions[mkey] is defined ? aCurrentOptions[mkey] : (oParentOptions[mkey] is defined ? oParentOptions[mkey] : '')) %}
{# 1. logo file dropdown, "No logo" (value off) first #}
{# 2. margin between logo and top of screen, 0-100 px #}
{# 3. "Show logo on" per device #}
{{ gT("Show logo on") }}
{% for dev in ['computer', 'tablet', 'mobile'] %}
{% set ckey = pos ~ 'showon' ~ dev %}
{% set cattr = aOptionAttributes.optionAttributes[ckey] %}
{% set ccv = bGeneralInherit ? 'inherit' : (aCurrentOptions[ckey] is defined ? aCurrentOptions[ckey] : (oParentOptions[ckey] is defined ? oParentOptions[ckey] : '')) %}
{% endfor %}
{% endfor %}
{% elseif key not in aLogoKeys %}
{# Prompt N: in the Top-of-page tab the progress keys form ONE column below
the logo hr — open a row + col-md-4 at the first progress key and close
it (with an empty col-md-8) at the last; inside the column the wrapper
is plain col-12 so the options stack vertically. #}
{% set bProgressKey = (tab.id == 'top-of-page' and key in aProgressKeys) %}
{% if bProgressKey and key == 'progressbarposition' %}
{% endif %}
{# Prompt R: Questions pane — three columns; open a col-md-4 at the
first key and switch column (border-start) whenever the key's
column changes. All options in this pane stack as col-12. #}
{% set bQuestionsPane = tab.category == 'Questions' %}
{% if bQuestionsPane %}
{% set qCol = key in aQuestionsCol1 ? 1 : (key in aQuestionsCol2 ? 2 : 3) %}
{% if qCol != qLastCol %}
{% if qLastCol > 0 %}
{% endif %}
{% set qLastCol = qCol %}
{% endif %}
{% endif %}
{# Prompt U: Fonts pane ("Fonts and colors") — slot-based layout. Slots:
top1 (top row col 1), top2 (top row col 2), combo1/2/3 (per-element
combo row cols 1-3), rest (sizes/weights, normal grid). On slot
change close the previous container(s) and open the new one. All
slots except rest have exactly two open divs (row + col). #}
{% set bFontsPane = tab.category == 'Fonts' %}
{% set fSlot = 'rest' %}
{% if bFontsPane %}
{% if key in aFontsTop1 %}{% set fSlot = 'top1' %}
{% elseif key in aFontsTop2 %}{% set fSlot = 'top2' %}
{% else %}
{% for el in aFontElements %}
{% if key == el ~ 'font' %}{% set fSlot = 'combo1' %}
{% elseif key == el ~ 'textcolor' %}{% set fSlot = 'combo2' %}
{% elseif key == el ~ 'textcolorcustom' %}{% set fSlot = 'combo3' %}{% endif %}
{% endfor %}
{% endif %}
{% if fSlot != fLastSlot %}
{% if fLastSlot == 'top2' %}
{% endif %}
{% if fLastSlot == 'combo3' %}
{% endif %}
{% if fSlot == 'top1' %}
{% elseif fSlot == 'top2' %}
{% elseif fSlot == 'combo1' %}
{% elseif fSlot == 'combo2' %}
{% elseif fSlot == 'combo3' %}
{% endif %}
{% set fLastSlot = fSlot %}
{% endif %}
{% endif %}
{% if bQuestionsPane or bProgressKey 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
is one of the show-values (default "on"; Prompt R: e.g. "box|top" for
questionborder, see aShowIfValues). options.js toggles
.option-visibility via data-show-if-parent/data-show-if-value;
the field itself is additionally disabled via data-parent/selector_radio_childfield #}
{# Prompt Q (multi-value since Prompt R, dropdown parents since Prompt U):
server-side INITIAL visibility — when the parent is a buttons group
or a dropdown (e.g. textcolorcustom with parent textcolor,
show-value "other"), add d-none at render time unless the parent's
current value is IN the show-value list. Same source of truth as
currentValue (stored options JSON, fallback oParentOptions). options.js
updateVisibilityByParent() toggles the same class on change (idempotent
with this initial state). #}
{% set bParentHidden = false %}
{% set showIfValues = 'on' %}
{% if attr.parent != '' and attr.parent != key %}
{% set parentAttr = aOptionAttributes.optionAttributes[attr.parent] ?? null %}
{% set showIfValues = aShowIfValues[attr.parent] ?? 'on' %}
{% if parentAttr is not null and (parentAttr.type == 'buttons' or parentAttr.type == 'dropdown') %}
{% set parentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[attr.parent] is defined ? aCurrentOptions[attr.parent] : (oParentOptions[attr.parent] is defined ? oParentOptions[attr.parent] : '')) %}
{% if parentValue not in showIfValues|split('|') %}{% set bParentHidden = true %}{% endif %}
{% endif %}
{% endif %}
{# label ALWAYS above the control, for every type incl. checkbox (Prompt G) #}
{% if key == 'headersticky' %}
{# Prompt L: the master switch is rendered as a STATIC LABEL only
(the generic form-label above); no input. The key stays in
config.xml/DB for compat, but sticky behaviour is governed
solely by the three headersticky* checkboxes below. #}
{% elseif attr.type == 'buttons' %}
{# buttons type: one radio per value of options="a|b", labels from optionlabels="A|B" #}
{% set optValues = attr.options|split('|') %}
{% set optLabels = attr.optionlabels|split('|') %}
{% for optValue in optValues %}
{% endfor %}
{% if bInherit %}
{% endif %}
{% elseif attr.type == 'checkbox' %}
{# checkbox: checked = "on", unchecked = "off". The label is rendered
above like every other type (generic form-label at the top of this
block, Prompt G); only the box itself is wrapped in .form-check.
With survey-level inherit, an untouched box keeps the value
"inherit" (options.js: data was-inherit). Children of a parent
switch get selector_radio_childfield + data-parent like the rest. #}
{% elseif attr.type == 'dropdown' %}
{% set ddClasses = 'form-select selector_option_value_field' %}
{% if attr.parent != '' %}{% set ddClasses = ddClasses ~ ' selector_radio_childfield' %}{% endif %}
{% if tab.category == 'Images' %}{% set ddClasses = ddClasses ~ ' selector_image_selector' %}{% endif %}
{% if key == 'font' %}{% set ddClasses = ddClasses ~ ' selector_fontselect' %}{% endif %}
{% elseif attr.type == 'fontselect' %}
{# fontselect (per-element font override): the SAME font choices as the
base "font" dropdown — the optgroups are shared, so bundled and
variant-custom fonts appear here automatically — plus a first option
"Same as base font" (value "base": the views then put no extra class
on the element, it inherits the body font). options.js collects the
packages of ALL .selector_fontselect selects into packages_to_load. #}
{% set fontAttr = aOptionAttributes.optionAttributes['font'] ?? null %}
{% elseif attr.type == 'imagefile' %}
{% elseif attr.type == 'colorpicker' %}
{% endif %}
{% if tab.category == 'Questions' and qLastCol > 0 %}
{% endif %}
{# Prompt U: close the Fonts pane's open slot container (every non-rest
slot has exactly two open divs: row + col) #}
{% if tab.category == 'Fonts' and fLastSlot != 0 and fLastSlot != 'rest' %}
{% endif %}
{% if tab.category == 'Images' %}
{# Upload an image; the actual upload form (#upload_frontend) is rendered by themeOptions/update.php #}
0%
{% endif %}
{# Footer at the bottom of every tab: "Proudly developed by [Respondage logo]",
linking to https://www.respondage.nl #}
{% if respondageLogo %}
{% endif %}
{% endfor %}
{# HOIST TABS (Prompt D): with optionspage=custom, core renders this whole page inside
one outer "Simple options" tab (ul#theme-options-tabs > li > #simple). Move our tab
buttons into the outer tab bar, our panes into the outer .tab-content and everything
else (spinner, inherit row, hr) above the outer tab bar, then drop the #simple
wrapper — so our category tabs sit at the SAME level as the outer bar.
Inline (rendered into the page HTML, so it runs on every fresh page load even with a
heuristically cached options.js; idempotent). Bootstrap 5 tabs use delegated click
handlers on document, so the moved buttons keep working without re-init. #}
{{ registerScript('respondage-hoist-tabs', "(function(){function hoist(){var outer=document.getElementById('theme-options-tabs');var simple=document.getElementById('simple');if(!outer||!simple){return;}var innerNav=null,innerContent=null,i;var kids=Array.prototype.slice.call(simple.children);for(i=0;i