fix(options): mark the default color choice with [ ] in the dropdown, not bold

Row 134: bolding <option> text is not rendered by every browser (native
dropdown popups ignore it), so the default entry of a color-chooser dropdown
is now enclosed in square brackets instead — e.g. "[Default font color]
[#444444]". The brackets live in config.xml on the <option data-default="1">
(navbarfontcolor + the five <el>textcolor dropdowns), so they show even before
JS runs; options.js strips and re-adds them idempotently while appending the
live hexcode. Removed from the dropdown list: the <b> wrap (row 129), the
inline font-weight (row 132), the CSS option[data-default] rule and the
:has() closed-select rule. The bold REMAINS only on the swatch label below the
swatch (.color-chip-label.is-default), where it renders reliably.
OPTIONS_JS_TOKEN -> 20261126.13. Verified: render tc=618 (raw option
"[Default font color]", served options.js?v=20261126.13), jsdom 6/6 incl.
pins (label "[Default font color] [#444444]", no <b>/inline bold/stale CSS
rules, non-default not bracketed, swatch label still bold), export exit 0.
Variants not rebuilt (deferred).

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-26 18:51:41 +01:00
commit 57c7009ec2
3 changed files with 35 additions and 46 deletions

View file

@ -218,20 +218,22 @@
navbarfontcolorcustom is rendered VISIBLE but grayed out (disabled) navbarfontcolorcustom is rendered VISIBLE but grayed out (disabled)
unless mode "other" (data-show-if-mode="disable" in options.twig) and unless mode "other" (data-show-if-mode="disable" in options.twig) and
keeps its value across saves (data-keep-value in options.js). keeps its value across saves (data-keep-value in options.js).
PER-OPTION DEFAULT (row 125/126): every color-chooser dropdown can pick its PER-OPTION DEFAULT (row 125/126/134): every color-chooser dropdown can pick
own default value — the element text below IS that default (LimeSurvey its own default value — the element text below IS that default (LimeSurvey
stores it in the DB on theme reset), and the <option data-default="1"> stores it in the DB on theme reset), and the <option data-default="1">
marks it so the options page can show it in BOLD (options.twig CSS + marks it. The default entry is enclosed in [ ] in the dropdown list
options.js swatch label). Here the default is "default" ("Default font (bolding <option> text is not rendered by every browser — row 134), and
color"); e.g. when questiontitlebackgroundcolor is later converted to its swatch label below the swatch stays bold (options.js is-default).
this pattern, its default can be set to "color1". Here the default is "default" ("Default font color"); e.g. when
questiontitlebackgroundcolor is later converted to this pattern, its
default can be set to "color1".
ROW 131: the option TEXTS are exactly "Default font color", ROW 131: the option TEXTS are exactly "Default font color",
"Default background color", "Color 1", "Color 2", "Color 3", "Default background color", "Color 1", "Color 2", "Color 3",
"Other ..." — options.js appends each entry's live hexcode in brackets "Other ..." — options.js appends each entry's live hexcode in brackets
(for "Other ..." the custom color's hex) and bolds the default. --> (for "Other ..." the custom color's hex) and bolds the default. -->
<navbarfontcolor type="dropdown" category="Colors" width="12" title="Menu item color in header" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Default font color|Default background color|Color 1|Color 2|Color 3|Other ...">default <navbarfontcolor type="dropdown" category="Colors" width="12" title="Menu item color in header" options="default|defaultbackgroundcolor|color1|color2|color3|other" optionlabels="Default font color|Default background color|Color 1|Color 2|Color 3|Other ...">default
<dropdownoptions> <dropdownoptions>
<option value="default" data-default="1">Default font color</option> <option value="default" data-default="1">[Default font color]</option>
<option value="defaultbackgroundcolor">Default background color</option> <option value="defaultbackgroundcolor">Default background color</option>
<option value="color1">Color 1</option> <option value="color1">Color 1</option>
<option value="color2">Color 2</option> <option value="color2">Color 2</option>
@ -347,7 +349,7 @@
<questiontitlefont type="fontselect" category="Questions" width="4" title="Font for question titles">base</questiontitlefont> <questiontitlefont type="fontselect" category="Questions" width="4" title="Font for question titles">base</questiontitlefont>
<questiontitletextcolor type="dropdown" category="Questions" width="12" title="Text color for question titles" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default <questiontitletextcolor type="dropdown" category="Questions" width="12" title="Text color for question titles" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default
<dropdownoptions> <dropdownoptions>
<option value="default" data-default="1">Default font color</option> <option value="default" data-default="1">[Default font color]</option>
<option value="primary">Primary color</option> <option value="primary">Primary color</option>
<option value="secondary">Secondary color</option> <option value="secondary">Secondary color</option>
<option value="other">Other…</option> <option value="other">Other…</option>
@ -356,7 +358,7 @@
<answersfont type="fontselect" category="Questions" width="4" title="Font for answers and help texts">base</answersfont> <answersfont type="fontselect" category="Questions" width="4" title="Font for answers and help texts">base</answersfont>
<answerstextcolor type="dropdown" category="Questions" width="12" title="Text color for answers and help texts" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default <answerstextcolor type="dropdown" category="Questions" width="12" title="Text color for answers and help texts" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default
<dropdownoptions> <dropdownoptions>
<option value="default" data-default="1">Default font color</option> <option value="default" data-default="1">[Default font color]</option>
<option value="primary">Primary color</option> <option value="primary">Primary color</option>
<option value="secondary">Secondary color</option> <option value="secondary">Secondary color</option>
<option value="other">Other…</option> <option value="other">Other…</option>
@ -365,7 +367,7 @@
<grouptitlefont type="fontselect" category="Questions" width="4" title="Font for group titles">base</grouptitlefont> <grouptitlefont type="fontselect" category="Questions" width="4" title="Font for group titles">base</grouptitlefont>
<grouptitletextcolor type="dropdown" category="Questions" width="12" title="Text color for group titles" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default <grouptitletextcolor type="dropdown" category="Questions" width="12" title="Text color for group titles" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default
<dropdownoptions> <dropdownoptions>
<option value="default" data-default="1">Default font color</option> <option value="default" data-default="1">[Default font color]</option>
<option value="primary">Primary color</option> <option value="primary">Primary color</option>
<option value="secondary">Secondary color</option> <option value="secondary">Secondary color</option>
<option value="other">Other…</option> <option value="other">Other…</option>
@ -374,7 +376,7 @@
<groupdescriptionfont type="fontselect" category="Questions" width="4" title="Font for group descriptions">base</groupdescriptionfont> <groupdescriptionfont type="fontselect" category="Questions" width="4" title="Font for group descriptions">base</groupdescriptionfont>
<groupdescriptiontextcolor type="dropdown" category="Questions" width="12" title="Text color for group descriptions" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default <groupdescriptiontextcolor type="dropdown" category="Questions" width="12" title="Text color for group descriptions" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default
<dropdownoptions> <dropdownoptions>
<option value="default" data-default="1">Default font color</option> <option value="default" data-default="1">[Default font color]</option>
<option value="primary">Primary color</option> <option value="primary">Primary color</option>
<option value="secondary">Secondary color</option> <option value="secondary">Secondary color</option>
<option value="other">Other…</option> <option value="other">Other…</option>
@ -383,7 +385,7 @@
<buttonsfont type="fontselect" category="Questions" width="4" title="Font for the buttons (Previous/Next/Submit)">base</buttonsfont> <buttonsfont type="fontselect" category="Questions" width="4" title="Font for the buttons (Previous/Next/Submit)">base</buttonsfont>
<buttonstextcolor type="dropdown" category="Questions" width="12" title="Text color for the buttons (Previous/Next/Submit)" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default <buttonstextcolor type="dropdown" category="Questions" width="12" title="Text color for the buttons (Previous/Next/Submit)" options="default|primary|secondary|other" optionlabels="Default font color|Primary color|Secondary color|Other…">default
<dropdownoptions> <dropdownoptions>
<option value="default" data-default="1">Default font color</option> <option value="default" data-default="1">[Default font color]</option>
<option value="primary">Primary color</option> <option value="primary">Primary color</option>
<option value="secondary">Secondary color</option> <option value="secondary">Secondary color</option>
<option value="other">Other…</option> <option value="other">Other…</option>

View file

@ -754,12 +754,12 @@ var ThemeOptions = function () {
// "Default background color" is the SECOND choice, right after "Same as // "Default background color" is the SECOND choice, right after "Same as
// default font color". // default font color".
var presets = { 'default': 'fontcolor', 'defaultbackgroundcolor': 'defaultbackgroundcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor' }; var presets = { 'default': 'fontcolor', 'defaultbackgroundcolor': 'defaultbackgroundcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor' };
// row 126/132: the option's DEFAULT choice — the config.xml <option data-default="1"> // row 126/134: the option's DEFAULT choice — the config.xml <option data-default="1">
// (same value as the <default> element text). Shown bold via every mechanism // (same value as the <default> element text). In the dropdown LIST it is
// available, because browsers differ: CSS on the option + a real <b> + inline // enclosed in [ ] (bolding <option> is not rendered by every browser — row 134);
// style (row 132) for the popup, :has() rule for the CLOSED select box, and the // the swatch label below the swatch stays bold via the is-default class.
// is-default class on the swatch label. Fallback when the marker is missing: // Fallback when the marker is missing: the inherited value, else the first
// the inherited value, else the first non-"inherit" entry. // non-"inherit" entry.
var defaultMode = String(sel.find('option[data-default="1"]').first().attr('value') var defaultMode = String(sel.find('option[data-default="1"]').first().attr('value')
|| sel.data('inheritvalue') || sel.data('inheritvalue')
|| sel.find('option').not('[value="inherit"]').first().attr('value') || sel.find('option').not('[value="inherit"]').first().attr('value')
@ -781,30 +781,24 @@ var ThemeOptions = function () {
sel.find('option').each(function () { sel.find('option').each(function () {
var op = $(this); var op = $(this);
var mode = String(op.attr('value')); var mode = String(op.attr('value'));
if (op.attr('data-default')) { if (!op.data('base-label')) {
// row 132: inline style as well — some browsers only honour the // strip the [ ] default marker from config.xml so re-wrapping stays idempotent
// inline style on <option>, not the stylesheet rule op.data('base-label', op.text().replace(/^\s*\[(.*)\]\s*$/, '$1'));
op.css('font-weight', '700');
} }
if (!op.data('base-label')) { op.data('base-label', op.text()); }
var base = String(op.data('base-label')); var base = String(op.data('base-label'));
var pk = presets[mode]; var pk = presets[mode];
// row 131: every entry shows its chosen hexcode — the preset colors // row 131: every entry shows its chosen hexcode — the preset colors
// from their option fields, "Other ..." from the custom picker's value // from their option fields, "Other ..." from the custom picker's value
var c = pk ? currentColor(pk) var c = pk ? currentColor(pk)
: (mode === 'other' && customInput.length && /^#[0-9a-fA-F]{3,8}$/.test(String(customInput.val() || '')) ? String(customInput.val()) : ''); : (mode === 'other' && customInput.length && /^#[0-9a-fA-F]{3,8}$/.test(String(customInput.val() || '')) ? String(customInput.val()) : '');
// row 134: the DEFAULT choice is enclosed in [ ] in the dropdown list —
// bolding <option> text is not rendered by every browser, so brackets
// are the marker in the list (the swatch label below the swatch stays bold)
var name = op.attr('data-default') ? '[' + base + ']' : base;
if (pk || mode === 'other') { if (pk || mode === 'other') {
var label = c ? base + ' [' + c + ']' : base; op.text(c ? name + ' [' + c + ']' : name);
if (op.attr('data-default')) {
// row 129: the DEFAULT choice is bold — via a real <b> element
// (not every browser applies font-weight CSS to <option>),
// on top of the select option[data-default="1"] CSS rule
op.empty().append($('<b>').text(label));
} else {
op.text(label);
}
} else if (op.attr('data-default')) { } else if (op.attr('data-default')) {
op.empty().append($('<b>').text(base)); op.text(name);
} }
}); });
}; };

View file

@ -43,7 +43,7 @@
heuristically cached copy (the file has only Last-Modified/ETag, no Cache-Control). 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 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. #} options/options.js changes, so every browser fetches the new file once. #}
{% set OPTIONS_JS_TOKEN = '20261126.12' %} {% set OPTIONS_JS_TOKEN = '20261126.13' %}
{{ unregisterScriptFile(optionsPath ~ '/options.js') }} {{ unregisterScriptFile(optionsPath ~ '/options.js') }}
{{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }} {{ registerScriptFile(optionsPath ~ '/options.js?v=' ~ OPTIONS_JS_TOKEN, 'POS_END') }}
@ -154,18 +154,11 @@
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
/* row 126: the DEFAULT choice of a color-chooser option (the config.xml /* row 126/134: the DEFAULT choice of a color-chooser option (the config.xml
<option data-default="1">) is shown in bold — in the dropdown (CSS below) <option data-default="1">) is enclosed in [ ] in the dropdown list — bolding
and on its swatch label (is-default class set by options.js) */ <option> text is not rendered by every browser, so brackets are used there
select option[data-default="1"] { instead. The bold remains ONLY on the swatch label below the swatch
font-weight: 700; (is-default class set by options.js). */
}
/* row 132: also bold the CLOSED select box when the default choice is the
selected one (the popup alone is not enough — some browsers ignore option
styling in the closed box) */
.action_update_options_string_form select:has(option[data-default="1"]:checked) {
font-weight: 700;
}
.color-chip-label.is-default { .color-chip-label.is-default {
font-weight: 700; font-weight: 700;
color: #212529; color: #212529;