feat(options): row 221 — align Questions-tab color columns + move slider handle color into the answers section

Request 1: options.js generalizes the Header-tab column alignment
(alignHeaderColumns, measured padding-top) to the Questions tab via
alignQuestionColumns(): in the 'Question title and body' section columns 2
and 3 are top-aligned with the title text-color chooser in column 1; in
'Answer options and subquestions' column 2 (checkbox color) aligns with the
answers text color; in 'Question help' column 2 (help background) aligns with
the help font color. Runs on run(), on any shown.bs.tab and on resize (hidden
panes measure 0 and no-op).

Request 2: the orphaned full-width 'Slider handle color' picker at the bottom
of the Questions tab becomes a 6-way color chooser (default color2) with a
sliderhandlecolorcustom child, placed in the THIRD column of 'Answer options
and subquestions' (aQSlots answers:2). custom_header.twig resolves it via
cm() (legacy stored hex passes through). variants/build.php maps legacy hex
json values of variants to mode 'other' + custom child; all variants rebuilt
(defensie, erasmus) + example config synced.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
Tammo ter Hark 2026-11-30 10:01:49 +01:00
commit e9c0ac5c14

View file

@ -926,16 +926,47 @@ var ThemeOptions = function () {
if (diff > 0) { bgCol[0].style.paddingTop = diff + 'px'; }
};
// THEME ADDITION (row 142): re-measure the header column alignment when the
// Top-of-page tab is (re)shown or the window resizes — at page load that pane
// is usually hidden (display:none), where getBoundingClientRect returns 0 and
// no offset would be applied, so the one-shot run() call alone is not enough.
var bindHeaderAlignTriggers = function () {
document.addEventListener('shown.bs.tab', function (e) {
var t = e.target && e.target.getAttribute ? e.target.getAttribute('data-bs-target') : null;
if (t === '#top-of-page') { setTimeout(alignHeaderColumns, 0); }
// THEME ADDITION (row 221): the same measured top-alignment as the Header tab,
// applied to the Questions tab sections — the color chooser column(s) listed in
// targets get a padding-top so their first control aligns with the font-color
// chooser (ref) in the first column of the same section:
// title section: cols 2+3 (title bg, body bg) align with the title text color
// answers section: col 2 (checkbox color) aligns with the answers text color
// help section: col 2 (help bg) aligns with the help font color
var aQuestionColumnAlign = [
{ sec: 'title', ref: 'questiontitletextcolor', targets: ['questiontitlebackgroundcolor', 'questionbackgroundcolor'] },
{ sec: 'answers', ref: 'answerstextcolor', targets: ['checkboxcolor'] },
{ sec: 'help', ref: 'questionhelpfontcolor', targets: ['questionhelpbackgroundcolor'] }
];
var alignQuestionColumns = function () {
$.each(aQuestionColumnAlign, function (i, cfg) {
var row = globalForm.find('.questions-section-' + cfg.sec).first();
var refField = globalForm.find('#simple_edit_options_' + cfg.ref);
if (!row.length || !refField.length) { return; }
var refWrap = refField.closest('.mb-3');
if (!refWrap.length || !refWrap[0].getBoundingClientRect) { return; }
var refTop = refWrap[0].getBoundingClientRect().top;
$.each(cfg.targets, function (j, tkey) {
var tField = globalForm.find('#simple_edit_options_' + tkey);
if (!tField.length) { return; }
var tCol = tField.closest('.questions-section-' + cfg.sec + ' .col-md-4');
if (!tCol.length || !tCol[0].getBoundingClientRect) { return; }
var diff = refTop - tCol[0].getBoundingClientRect().top;
if (diff > 0) { tCol[0].style.paddingTop = diff + 'px'; }
});
});
window.addEventListener('resize', function () { alignHeaderColumns(); });
};
var alignAllColumns = function () { alignHeaderColumns(); alignQuestionColumns(); };
// THEME ADDITION (row 142, generalized row 221): re-measure the column
// alignment when a tab is (re)shown or the window resizes — at page load the
// non-active panes are hidden (display:none), where getBoundingClientRect
// returns 0 and no offset would be applied, so the one-shot run() call alone
// is not enough. Running on ANY shown tab is safe: hidden panes measure 0 and
// the aligners no-op (diff > 0 guard).
var bindHeaderAlignTriggers = function () {
document.addEventListener('shown.bs.tab', function () { setTimeout(alignAllColumns, 0); });
window.addEventListener('resize', function () { alignAllColumns(); });
};
// Shared delegated handlers for ALL chooser dropdowns (row 122/135): a REAL user
@ -1021,8 +1052,10 @@ var ThemeOptions = function () {
safeStep('bindColorModeDelegates', bindColorModeDelegates);
// THEME ADDITION (row 136/142): align the header background color (col 2) with
// the text color option (col 1) in the Top-of-the-page tab
// the text color option (col 1) in the Top-of-the-page tab; row 221: the same
// for the Questions tab sections (title cols 2+3, answers col 2, help col 2)
safeStep('alignHeaderColumns', alignHeaderColumns);
safeStep('alignQuestionColumns', alignQuestionColumns);
safeStep('bindHeaderAlignTriggers', bindHeaderAlignTriggers);
// THEME ADDITION (row 133): restore the options tab the user was on before
@ -1070,9 +1103,9 @@ var ThemeOptions = function () {
var id = sessionStorage.getItem(tabStorageKey());
if (id) {
activateTab(id);
// row 142: if the restored tab is Top-of-page, re-measure the header
// column alignment now that the pane is visible
if (id === 'tab-top-of-page') { setTimeout(alignHeaderColumns, 0); }
// row 142 / row 221: re-measure the column alignment(s) now that the
// restored pane is visible
setTimeout(alignAllColumns, 0);
}
} catch (e) { /* storage unavailable — keep the first tab */ }
};