2026-11-24 22:04:11 +01:00
|
|
|
|
// Custom options-page JavaScript for this theme (used because config.xml sets
|
|
|
|
|
|
// <optionspage>custom</optionspage>). This is a copy of the core package
|
|
|
|
|
|
// assets/packages/themeoptions-core/themeoptions-core.js, patched so that
|
|
|
|
|
|
// .action_hide_on_inherit rows are also hidden when "Inherit everything" is on
|
|
|
|
|
|
// (the custom page has no per-category tabs to disable).
|
|
|
|
|
|
// When updating, diff against the core file and re-apply that patch.
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
var ThemeOptions = function () {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
"use strict";
|
2026-11-16 19:36:04 +01:00
|
|
|
|
//////////////////
|
|
|
|
|
|
// Define necessary globals
|
|
|
|
|
|
|
|
|
|
|
|
// general_inherit_active is not present at global level
|
|
|
|
|
|
// see: https://github.com/LimeSurvey/LimeSurvey/blob/1cbfa11b081f54763b28364472926b155efea5dc/themes/survey/vanilla/options/options.twig#L71
|
|
|
|
|
|
var inheritPossible = ($('#general_inherit_active').length > 0);
|
|
|
|
|
|
|
|
|
|
|
|
//get option Object from Template configuration options
|
2026-11-24 22:04:11 +01:00
|
|
|
|
var optionObject = {
|
|
|
|
|
|
"general_inherit": 1
|
|
|
|
|
|
}
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// THEME ADDITION (row 115, generalized row 135): legacy hex values of the
|
|
|
|
|
|
// color-chooser options, captured right after parseOptionObject — later startup
|
|
|
|
|
|
// steps (prepareSelectField val() with a non-matching value, then
|
|
|
|
|
|
// updateFieldSettings) can clobber optionObject, so the migration in colorModeUI
|
|
|
|
|
|
// must use this snapshot.
|
|
|
|
|
|
var legacyColorValues = {};
|
2026-11-27 02:50:06 +01:00
|
|
|
|
// row 157: legacy non-hex MODE values of the chooser options (e.g. "primary"/
|
|
|
|
|
|
// "secondary" stored by the old 4-way grouptitle/groupdescription textcolor
|
|
|
|
|
|
// dropdowns) — mapped to color1/color2 in colorModeUI
|
|
|
|
|
|
var legacyModeValues = {};
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// row 135: all options that use the color-chooser scheme (mode dropdown with
|
2026-11-27 02:50:06 +01:00
|
|
|
|
// class selector_color_mode + swatch chips + a <key>custom colorpicker child);
|
2026-11-29 14:45:57 +01:00
|
|
|
|
// row 157: the group title/description text colors joined the scheme;
|
|
|
|
|
|
// row 180 / plan P2: the Questions "title" section keys as well
|
2026-11-29 15:08:49 +01:00
|
|
|
|
// (questiontitletextcolor, questiontitlebackgroundcolor, questionbackgroundcolor);
|
2026-11-29 15:17:56 +01:00
|
|
|
|
// row 184 / plan P3: answerstextcolor as well; row 186 / plan P4:
|
2026-11-29 15:48:26 +01:00
|
|
|
|
// questionhelpbackgroundcolor as well; row 191 / plan P6: the six per-button
|
2026-11-29 16:05:39 +01:00
|
|
|
|
// choosers (previous/next/submit button background + text color); row 195:
|
feat(options): row 197 — help/border font color choosers, box-only radii, aligned chooser columns, 'Font color for ...' labels
- questionhelpfontcolor + questionbordercolor are now 6-way color choosers
(+custom children), both default mode 'default' (Default font color);
resolved via cmm.cm() in custom_header.twig (legacy hex passthrough)
- border radii show only for questionborder=box (per-key show-values in
options.twig aShowIfValuesByKey); options.js cascades hiding to nested
conditional wrappers (questionbordercolorcustom); radii stay two
subcolumns (border-start on TR/BR)
- chooser columns aligned with the font color: title section = one column
(title-0: font, font color, size/options, legacy picker, title bg, body
bg), answers-0 += checkbox chooser, help-0 = font + font color + bg
chooser, help-1 = text position
- all font-color labels follow 'Font color for ...' / 'Custom font color
for ...' (21 labels renamed, incl. 'Font color for question titles' and
'Font color for answers and subquestions')
- chooser key lists synced in options.twig/options.js/build.php (+2)
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-29 16:30:39 +01:00
|
|
|
|
// checkboxcolor as well; row 197: questionhelpfontcolor + questionbordercolor.
|
2026-11-29 14:45:57 +01:00
|
|
|
|
// Must stay in sync with aColorChooserKeys in options/options.twig.
|
feat(options): row 197 — help/border font color choosers, box-only radii, aligned chooser columns, 'Font color for ...' labels
- questionhelpfontcolor + questionbordercolor are now 6-way color choosers
(+custom children), both default mode 'default' (Default font color);
resolved via cmm.cm() in custom_header.twig (legacy hex passthrough)
- border radii show only for questionborder=box (per-key show-values in
options.twig aShowIfValuesByKey); options.js cascades hiding to nested
conditional wrappers (questionbordercolorcustom); radii stay two
subcolumns (border-start on TR/BR)
- chooser columns aligned with the font color: title section = one column
(title-0: font, font color, size/options, legacy picker, title bg, body
bg), answers-0 += checkbox chooser, help-0 = font + font color + bg
chooser, help-1 = text position
- all font-color labels follow 'Font color for ...' / 'Custom font color
for ...' (21 labels renamed, incl. 'Font color for question titles' and
'Font color for answers and subquestions')
- chooser key lists synced in options.twig/options.js/build.php (+2)
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-29 16:30:39 +01:00
|
|
|
|
var aColorChooserKeys = ['navbarfontcolor', 'headerbackgroundcolor', 'progressbarcolor', 'progressbarbackgroundcolor', 'progressbarfontcolor', 'bodybackgroundcolor', 'grouptitletextcolor', 'groupdescriptiontextcolor', 'questiontitletextcolor', 'questiontitlebackgroundcolor', 'questionbackgroundcolor', 'answerstextcolor', 'questionhelpbackgroundcolor', 'questionhelpfontcolor', 'questionbordercolor', 'checkboxcolor', 'previousbuttonbackgroundcolor', 'previousbuttontextcolor', 'nextbuttonbackgroundcolor', 'nextbuttontextcolor', 'submitbuttonbackgroundcolor', 'submitbuttontextcolor'];
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// the 5 presets, in the SAME order as the dropdown options in config.xml
|
|
|
|
|
|
// (object key order = swatch chip order) — row 125: "Default background color"
|
|
|
|
|
|
// is the SECOND choice, right after "Default font color".
|
|
|
|
|
|
var colorPresets = { 'default': 'fontcolor', 'defaultbackgroundcolor': 'defaultbackgroundcolor', 'color1': 'primarycolor', 'color2': 'secondarycolor', 'color3': 'tertiarycolor' };
|
|
|
|
|
|
// one refreshAll per chooser, called by the shared delegated handlers
|
|
|
|
|
|
var colorModeRefreshers = [];
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
|
2026-11-25 21:25:07 +01:00
|
|
|
|
// THEME FIX: on the GLOBAL theme-options page the hidden #optionCssFiles can
|
|
|
|
|
|
// hold the literal string "inherit" (not JSON) — an unguarded JSON.parse then
|
|
|
|
|
|
// throws inside this constructor, so run() never executes: no change handlers
|
|
|
|
|
|
// and no save handler get bound, and Save silently posts the stale options
|
|
|
|
|
|
// JSON (nothing changed in the UI is saved). Fall back to an empty file list.
|
|
|
|
|
|
var optionCssFiles;
|
|
|
|
|
|
try {
|
|
|
|
|
|
optionCssFiles = JSON.parse($('#optionCssFiles').val());
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
optionCssFiles = { add: [], replace: [], remove: [] };
|
|
|
|
|
|
}
|
2026-11-16 19:36:04 +01:00
|
|
|
|
//get the global form
|
|
|
|
|
|
var globalForm = $('.action_update_options_string_form');
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
/////////////////
|
|
|
|
|
|
// Define methods run on startup
|
|
|
|
|
|
|
|
|
|
|
|
// #TemplateConfiguration_options is the id of the Options field in advanced option
|
|
|
|
|
|
// getter for generalInherit
|
|
|
|
|
|
var generalInherit = function () {
|
|
|
|
|
|
return $('#TemplateConfiguration_options').val() === 'inherit';
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//parse the options as set in the advanced form
|
|
|
|
|
|
var parseOptionObject = function () {
|
|
|
|
|
|
// If no general inherit, then pass the value of the "Options" field in advanced option to the object optionObject
|
|
|
|
|
|
if ($('#TemplateConfiguration_options').length > 0 && !generalInherit()) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
optionObject = JSON.parse($('#TemplateConfiguration_options').val());
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.ls ? console.ls.error('No valid option field!') : console.log('No valid option field!');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Show/Hide fields on generalInherit
|
|
|
|
|
|
// To hide a simple option on generalInherit: just add the class "action_hide_on_inherit" to the rows continaing it
|
|
|
|
|
|
var startupGeneralInherit = function () {
|
|
|
|
|
|
|
|
|
|
|
|
if (!inheritPossible) return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (generalInherit()) {
|
|
|
|
|
|
$('#general_inherit_on').prop('checked', true).trigger('change').closest('label').addClass('active');
|
|
|
|
|
|
$('.action_hide_on_inherit').addClass('d-none');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('.tab_action_hide_on_inherit').addClass('ls-tab-disabled');
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
} else {
|
|
|
|
|
|
$('#general_inherit_off').prop('checked', true).trigger('change').closest('label').addClass('active');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('.action_hide_on_inherit_wrapper').addClass('d-none');
|
|
|
|
|
|
$('.action_hide_on_inherit').removeClass('d-none');
|
|
|
|
|
|
$('.tab_action_hide_on_inherit').removeClass('ls-tab-disabled');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// So this function find the selectors in the forum, and pass their values to the advanced options
|
|
|
|
|
|
var updateFieldSettings = function () {
|
|
|
|
|
|
|
|
|
|
|
|
if ($('#general_inherit_on').prop('checked')) {
|
|
|
|
|
|
$('#TemplateConfiguration_options').val('inherit');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
globalForm.find('.selector_option_value_field').each(function (i, item) {
|
|
|
|
|
|
//disabled items should be inherit or false
|
|
|
|
|
|
if ($(item).prop('disabled')) {
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
// THEME ADDITION (row 115, navbarfontcolor working example): a child of a
|
|
|
|
|
|
// "disable"-mode parent (data-keep-value) keeps its stored value instead of
|
|
|
|
|
|
// being reset — the grayed-out picker must remember the custom color even
|
|
|
|
|
|
// when another mode is selected and the form is saved.
|
|
|
|
|
|
if ($(item).data('keep-value')) {
|
|
|
|
|
|
if (optionObject[$(item).attr('name')] === undefined) {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = ($(item).data('inheritvalue') !== undefined ? String($(item).data('inheritvalue')) : '');
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$(item).val((inheritPossible ? 'inherit' : false));
|
|
|
|
|
|
optionObject[$(item).attr('name')] = getOptionFieldValue(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = getOptionFieldValue(item);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
}
|
2026-11-24 22:04:11 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
globalForm.find('.selector_image_selector').each(function (i, item) {
|
|
|
|
|
|
|
|
|
|
|
|
// disable the preview image button if the image
|
|
|
|
|
|
// selected could not be mapped to one of the images
|
|
|
|
|
|
// that actually exists within the theme
|
|
|
|
|
|
const src = $(item).find('option:selected').data('lightbox-src');
|
|
|
|
|
|
const missing = src === '';
|
|
|
|
|
|
const itemId = $(item).attr('id');
|
|
|
|
|
|
const button = $(`button[data-bs-target="#${itemId}"]`);
|
|
|
|
|
|
button.prop('disabled', missing);
|
|
|
|
|
|
|
|
|
|
|
|
// add some feedback to the user, mark field invalid
|
|
|
|
|
|
$(item).toggleClass('is-invalid', missing);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
globalForm.find('.selector_option_radio_field ').each(function (i, item) {
|
|
|
|
|
|
//disabled items should be inherit or false
|
|
|
|
|
|
if ($(item).prop('disabled')) {
|
|
|
|
|
|
$(item).val((inheritPossible ? 'inherit' : false));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ($(item).attr('type') == 'radio') {
|
|
|
|
|
|
if ($(item).prop('checked')) {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = $(item).val();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// THEME ADDITION: checkboxes (checked = "on"); an untouched box that was
|
|
|
|
|
|
// "inherit" keeps "inherit" (see prepareCheckboxField)
|
|
|
|
|
|
globalForm.find('.selector_option_checkbox_field').each(function (i, item) {
|
|
|
|
|
|
if ($(item).prop('disabled')) {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = (inheritPossible ? 'inherit' : 'off');
|
|
|
|
|
|
} else if ($(item).data('was-inherit')) {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = 'inherit';
|
|
|
|
|
|
} else {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = $(item).prop('checked') ? 'on' : 'off';
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
globalForm.find('.selector_text_option_value_field').each(function (i, item) {
|
|
|
|
|
|
//disabled items should be inherit or false
|
|
|
|
|
|
if ($(item).prop('disabled')) {
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
// THEME ADDITION (row 115): see the selector_option_value_field loop above —
|
|
|
|
|
|
// data-keep-value children keep their stored value while disabled.
|
|
|
|
|
|
if ($(item).data('keep-value')) {
|
|
|
|
|
|
if (optionObject[$(item).attr('name')] === undefined) {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = ($(item).data('inheritvalue') !== undefined ? String($(item).data('inheritvalue')) : '');
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$(item).val((inheritPossible ? 'inherit' : false));
|
|
|
|
|
|
optionObject[$(item).attr('name')] = $(item).val();
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
optionObject[$(item).attr('name')] = $(item).val();
|
2026-11-24 22:04:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
var newOptionObject = $.extend(true, {}, optionObject);
|
|
|
|
|
|
delete newOptionObject.general_inherit;
|
|
|
|
|
|
|
|
|
|
|
|
$('#TemplateConfiguration_options').val(JSON.stringify(newOptionObject));
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
|
|
// Utility Methods
|
|
|
|
|
|
// -- small utilities i.g. for images or similar, or very specialized functions
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// Color picker text fields are left empty when the value is inherited, so they show the translated placeholder instead of "inherit"
|
|
|
|
|
|
var getOptionFieldValue = function (item) {
|
|
|
|
|
|
if ($(item).hasClass('selector__color-picker') && $(item).val() === '' && inheritPossible) {
|
|
|
|
|
|
return 'inherit';
|
|
|
|
|
|
}
|
|
|
|
|
|
return $(item).val();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var applyColorPickerValue = function (item) {
|
|
|
|
|
|
if ($(item).hasClass('selector__color-picker')) {
|
|
|
|
|
|
console.ls.log($(item).data('inheritvalue'), $(item).val(), item);
|
|
|
|
|
|
if ($(item).val() === 'inherit') {
|
|
|
|
|
|
$(item).val('');
|
|
|
|
|
|
$(item).closest('.input-group').find('.selector__colorpicker-inherit-value').val($(item).data('inheritvalue')).trigger('change');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$(item).closest('.input-group').find('.selector__colorpicker-inherit-value').val($(item).val()).trigger('change');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//Special code for numerical
|
|
|
|
|
|
var parseNumeric = function (item) {
|
|
|
|
|
|
if ($(item).hasClass('selector-numerical-input')) {
|
|
|
|
|
|
if (!(/^((\d+)|(inherit))$/.test($(item).val()))) {
|
|
|
|
|
|
$(item).val((inheritPossible ? 'inherit' : 1000));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// display inherited options as tooltips
|
|
|
|
|
|
var showInheritedValue = function () {
|
|
|
|
|
|
$.each($('#simple_edit_add_css > option'), function (i, option) {
|
|
|
|
|
|
$.each(optionCssFiles.add, function (i, item) {
|
|
|
|
|
|
if (option.value === item && $('#simple_edit_add_css option:first').val() === 'inherit') {
|
|
|
|
|
|
$('#simple_edit_add_css option:first').text($('#simple_edit_add_css option:first').text() + ' ' + option.text + ']');
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
globalForm.find('.selector-numerical-input').each(function (i, item) {
|
|
|
|
|
|
var element = $(item);
|
|
|
|
|
|
//element.attr('title', element.attr('title')+optionObjectInheritedValues[$(item).attr('name')]);
|
|
|
|
|
|
element.tooltip();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
//Parses the option value for an item
|
|
|
|
|
|
var parseOptionValue = function (item, fallbackValue) {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
if (fallbackValue == undefined) fallbackValue = false;
|
2026-11-16 19:36:04 +01:00
|
|
|
|
// If general inherit, then the value of the dropdown is inherit, else it's the value defined in advanced options
|
|
|
|
|
|
var itemValue = generalInherit() ? 'inherit' : optionObject[$(item).attr('name')];
|
|
|
|
|
|
|
|
|
|
|
|
// If anything goes wrong (manual edit or anything else), we make sure it will have a correct value
|
|
|
|
|
|
if (itemValue == null || itemValue == undefined) {
|
|
|
|
|
|
itemValue = inheritPossible ? 'inherit' : fallbackValue;
|
|
|
|
|
|
optionObject[$(item).attr('name')] = itemValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
return itemValue;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//Set value and propagate to bootstrapSwitch
|
|
|
|
|
|
var setAndPropageteToSwitch = function (item) {
|
|
|
|
|
|
$(item).prop('checked', true).trigger('change');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
//$(item).closest('label').addClass('active');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
|
|
// Parser methods
|
|
|
|
|
|
// -- These methods will either parse through existing fields, or set existing fields to their correct values
|
|
|
|
|
|
|
|
|
|
|
|
// Update values in the form to the template options
|
|
|
|
|
|
// selector_option_value_field are the select dropdown (like variations and fonts)
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// TODO: This seems to be designed for select fields only, but it is also used for other input types. Should be reviewed.
|
2026-11-16 19:36:04 +01:00
|
|
|
|
var prepareSelectField = function () {
|
|
|
|
|
|
globalForm.find('.selector_option_value_field').each(function (i, item) {
|
|
|
|
|
|
var itemValue = parseOptionValue(item);
|
|
|
|
|
|
$(item).val(itemValue);
|
2026-11-24 22:04:11 +01:00
|
|
|
|
applyColorPickerValue(item);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: checkbox options (type "checkbox", class
|
|
|
|
|
|
// .selector_option_checkbox_field): checked = "on", unchecked = "off".
|
|
|
|
|
|
// When the saved value is "inherit" (survey-level inherit), the box shows
|
|
|
|
|
|
// the inherited state (data-inheritvalue) and is marked data was-inherit,
|
|
|
|
|
|
// so updateFieldSettings() keeps writing "inherit" until the user actually
|
|
|
|
|
|
// toggles the box (the change handler in hotSwapFields clears the mark).
|
|
|
|
|
|
var prepareCheckboxField = function () {
|
|
|
|
|
|
globalForm.find('.selector_option_checkbox_field').each(function (i, item) {
|
|
|
|
|
|
var itemValue = parseOptionValue(item, 'off');
|
|
|
|
|
|
var effective = (itemValue === 'inherit') ? $(item).data('inheritvalue') : itemValue;
|
|
|
|
|
|
$(item).prop('checked', String(effective) === 'on');
|
|
|
|
|
|
if (itemValue === 'inherit') {
|
|
|
|
|
|
$(item).data('was-inherit', '1');
|
|
|
|
|
|
$(item).attr('title', 'Inherited value: ' + $(item).data('inheritvalue'));
|
|
|
|
|
|
}
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Generate the state of switches (On/Off/Inherit)
|
|
|
|
|
|
var parseParentSwitchFields = function () {
|
|
|
|
|
|
globalForm.find('.selector_option_radio_field').each(function (i, item) {
|
|
|
|
|
|
|
|
|
|
|
|
var itemValue = parseOptionValue(item, 'off');
|
|
|
|
|
|
|
|
|
|
|
|
//if it is a radio selector, check it and propagate the change to bootstrapSwitch
|
|
|
|
|
|
if ($(item).val() == itemValue) {
|
|
|
|
|
|
setAndPropageteToSwitch(item);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var prepareFontField = function () {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
var currentPackageObject = 'inherit';
|
|
|
|
|
|
// THEME CHANGE: fallback is the bundled default font of this theme
|
|
|
|
|
|
// ('noto_sans', self-hosted), never a core package font like roboto/ibm-sans
|
|
|
|
|
|
// (privacy: no external font hosts may ever be requested).
|
|
|
|
|
|
optionObject.font = optionObject.font || (inheritPossible ? 'inherit' : 'noto_sans');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
|
|
|
|
|
if (optionObject.font !== 'inherit') {
|
|
|
|
|
|
$('#simple_edit_options_font').val(optionObject.font);
|
|
|
|
|
|
}
|
|
|
|
|
|
updateFieldSettings();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
var prepareFruityThemeField = function () {
|
|
|
|
|
|
var currentThemeObject = 'inherit';
|
|
|
|
|
|
if ($('#TemplateConfiguration_files_css').val() !== 'inherit' && $('body').hasClass('fruity')) {
|
|
|
|
|
|
currentThemeObject = {
|
|
|
|
|
|
"add": ['css/animate.css', 'css/ajaxify.css', 'css/variations/sea_green.css', 'css/theme.css', 'custom.css']
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
currentThemeObject = JSON.parse($('#TemplateConfiguration_files_css').val());
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
console.error('No valid monochrom theme field!');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (currentThemeObject.add) {
|
|
|
|
|
|
$('#simple_edit_add_css').val(currentThemeObject.add.filter(function (item, i) {
|
|
|
|
|
|
return /^css\/variations\/.*$/.test(item);
|
|
|
|
|
|
}));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Update values of 'text' options in the form
|
|
|
|
|
|
var prepareTextField = function () {
|
|
|
|
|
|
globalForm.find('.selector_text_option_value_field').each(function (i, item) {
|
|
|
|
|
|
var itemValue = parseOptionValue(item, "");
|
|
|
|
|
|
$(item).val(itemValue);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// updates the disabled status of a child field
|
|
|
|
|
|
// based on the parent element
|
|
|
|
|
|
// NOTE:
|
|
|
|
|
|
// for font and variations dropdowns, the childfield
|
|
|
|
|
|
// class is added and the data-parent attr exists,
|
|
|
|
|
|
// but no parent element exists in the markup
|
|
|
|
|
|
// so if we actually have a parent element, enable/disable
|
|
|
|
|
|
// based on that, otherwise we enable by default
|
|
|
|
|
|
const updateChild = function(parentEl, childEl) {
|
|
|
|
|
|
|
|
|
|
|
|
let enabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
if(parentEl.length) {
|
2026-11-25 11:35:18 +01:00
|
|
|
|
const wrapper = $(childEl).closest('.option-visibility');
|
|
|
|
|
|
const showValues = String(wrapper.data('show-if-value') || 'on').split('|');
|
feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)
Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-25 11:51:57 +01:00
|
|
|
|
// THEME ADDITION (Prompt U): the parent may also be a <select> (e.g.
|
|
|
|
|
|
// <el>textcolorcustom has parent <el>textcolor, a dropdown) — read the
|
|
|
|
|
|
// select's current value instead of a checked radio.
|
|
|
|
|
|
const parentSelect = parentEl.filter('select');
|
|
|
|
|
|
if (parentSelect.length) {
|
|
|
|
|
|
enabled = showValues.indexOf(String(parentSelect.val())) !== -1;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// THEME ADDITION (Prompt R): parentEl is a SET of radios — read the
|
|
|
|
|
|
// CHECKED one (not the first element) and accept any of the wrapper's
|
|
|
|
|
|
// show-values (data-show-if-value, pipe-separated). Single-value
|
|
|
|
|
|
// parents ('on') behave exactly as before.
|
|
|
|
|
|
const checked = parentEl.filter(':checked');
|
|
|
|
|
|
enabled = checked.length > 0 && showValues.indexOf(String(checked.val())) !== -1;
|
|
|
|
|
|
}
|
2026-11-24 22:04:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$(childEl).prop('disabled', !enabled);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
// a11y: mirror the disabled state for assistive technology (row 115)
|
|
|
|
|
|
$(childEl).attr('aria-disabled', String(!enabled));
|
2026-11-24 22:04:11 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// grab the parent for a given child field
|
|
|
|
|
|
const getParent = function(childEl) {
|
|
|
|
|
|
const parentName = $(childEl).data('parent');
|
feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)
Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-25 11:51:57 +01:00
|
|
|
|
// THEME ADDITION (Prompt U): match selects too, not only radio inputs
|
|
|
|
|
|
const parentEl = $(`input[name=${parentName}], select[name=${parentName}]`);
|
2026-11-24 22:04:11 +01:00
|
|
|
|
return parentEl;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// go through each child field, grab parent, and update disabled status
|
|
|
|
|
|
const updateAllChildren = function() {
|
|
|
|
|
|
$('.selector_radio_childfield').each(function (i, childEl) {
|
|
|
|
|
|
const parentEl = getParent(childEl);
|
|
|
|
|
|
updateChild(parentEl, childEl);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: show/hide whole option fields based on a parent option's value.
|
|
|
|
|
|
// A wrapper with class "option-visibility" and data-show-if-parent="<parentName>"
|
|
|
|
|
|
// (rendered by options/options.twig for every option that has a parent="..." in
|
|
|
|
|
|
// config.xml) is only visible when the checked radio input[name=<parentName>]
|
|
|
|
|
|
// has value data-show-if-value (default "on"). This makes e.g. the logo file and
|
|
|
|
|
|
// hide-on-small selects disappear when the corresponding logo is set to "No".
|
|
|
|
|
|
const updateVisibilityByParent = function() {
|
|
|
|
|
|
$('.option-visibility[data-show-if-parent]').each(function (i, wrapperEl) {
|
|
|
|
|
|
const parentName = $(wrapperEl).data('show-if-parent');
|
feat(options): row 197 — help/border font color choosers, box-only radii, aligned chooser columns, 'Font color for ...' labels
- questionhelpfontcolor + questionbordercolor are now 6-way color choosers
(+custom children), both default mode 'default' (Default font color);
resolved via cmm.cm() in custom_header.twig (legacy hex passthrough)
- border radii show only for questionborder=box (per-key show-values in
options.twig aShowIfValuesByKey); options.js cascades hiding to nested
conditional wrappers (questionbordercolorcustom); radii stay two
subcolumns (border-start on TR/BR)
- chooser columns aligned with the font color: title section = one column
(title-0: font, font color, size/options, legacy picker, title bg, body
bg), answers-0 += checkbox chooser, help-0 = font + font color + bg
chooser, help-1 = text position
- all font-color labels follow 'Font color for ...' / 'Custom font color
for ...' (21 labels renamed, incl. 'Font color for question titles' and
'Font color for answers and subquestions')
- chooser key lists synced in options.twig/options.js/build.php (+2)
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-29 16:30:39 +01:00
|
|
|
|
// row 197: cascade — when the parent field itself sits inside a hidden
|
|
|
|
|
|
// .option-visibility wrapper (nested conditional, e.g. questionbordercolorcustom
|
|
|
|
|
|
// whose parent questionbordercolor is a child of questionborder=none), this
|
|
|
|
|
|
// wrapper must hide as well, regardless of its own show-if-mode
|
|
|
|
|
|
const anyParent0 = $('input[name="' + parentName + '"]');
|
|
|
|
|
|
const anyParent1 = $('select[name="' + parentName + '"]');
|
|
|
|
|
|
const anyParent = anyParent0.length ? anyParent0 : anyParent1;
|
|
|
|
|
|
if (anyParent.length) {
|
|
|
|
|
|
const pw = anyParent.first().closest('.option-visibility');
|
|
|
|
|
|
if (pw.length && pw.hasClass('d-none')) { $(wrapperEl).addClass('d-none'); return; }
|
|
|
|
|
|
}
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
// THEME ADDITION (row 115, navbarfontcolor working example): parents with
|
|
|
|
|
|
// data-show-if-mode="disable" never hide their children — the wrapper stays
|
|
|
|
|
|
// visible and only the child control is disabled (updateChild/updateAllChildren).
|
|
|
|
|
|
if (String($(wrapperEl).data('show-if-mode') || 'hide') === 'disable') {
|
|
|
|
|
|
$(wrapperEl).removeClass('d-none');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-11-25 11:35:18 +01:00
|
|
|
|
// THEME ADDITION (Prompt R): multi-value — data-show-if-value may be a
|
|
|
|
|
|
// pipe-separated list (e.g. "box|top" for questionborder); a single
|
|
|
|
|
|
// value keeps working unchanged.
|
|
|
|
|
|
const showValues = String($(wrapperEl).data('show-if-value') || 'on').split('|');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
const parentInputs = $('input[name="' + parentName + '"]');
|
feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)
Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-25 11:51:57 +01:00
|
|
|
|
const parentSelects = $('select[name="' + parentName + '"]');
|
|
|
|
|
|
// no parent input in the markup: always visible,
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// same fallback as updateChild() above
|
feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)
Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-25 11:51:57 +01:00
|
|
|
|
if (parentInputs.length === 0 && parentSelects.length === 0) {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$(wrapperEl).removeClass('d-none');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)
Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-25 11:51:57 +01:00
|
|
|
|
// THEME ADDITION (Prompt U): select parent (e.g. <el>textcolor dropdown) —
|
|
|
|
|
|
// visibility follows the select's current value, multi-value aware
|
|
|
|
|
|
if (parentInputs.length === 0 && parentSelects.length > 0) {
|
|
|
|
|
|
const visible = showValues.indexOf(String(parentSelects.val())) !== -1;
|
|
|
|
|
|
$(wrapperEl).toggleClass('d-none', !visible);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-11-24 22:04:11 +01:00
|
|
|
|
const checked = parentInputs.filter(':checked');
|
2026-11-25 11:35:18 +01:00
|
|
|
|
const visible = checked.length > 0 && showValues.indexOf(String(checked.val())) !== -1;
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$(wrapperEl).toggleClass('d-none', !visible);
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
///////////////
|
|
|
|
|
|
// HotSwap methods
|
|
|
|
|
|
// -- These methods connect an input directly to the value in the optionsObject
|
|
|
|
|
|
|
|
|
|
|
|
// Disable dependent inputs when their parents are set to off, or inherit
|
2026-11-24 22:04:11 +01:00
|
|
|
|
const hotSwapParentRadioButtons = function () {
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// for each child field, add a listener for the
|
|
|
|
|
|
// parent's change and update the child's disabled
|
|
|
|
|
|
// status accordingly
|
|
|
|
|
|
// i = element index in list of matches, unused
|
|
|
|
|
|
$('.selector_radio_childfield').each(function (i, childEl) {
|
|
|
|
|
|
const parentEl = getParent(childEl);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
parentEl.on('change', function () {
|
|
|
|
|
|
updateChild(parentEl, childEl);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// hotswapping the fields
|
|
|
|
|
|
var hotSwapFields = function () {
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
globalForm.find('.selector_option_value_field, .selector_text_option_value_field').on('change', function (evt) {
|
2026-11-16 19:36:04 +01:00
|
|
|
|
updateFieldSettings();
|
2026-11-24 22:04:11 +01:00
|
|
|
|
parseNumeric(this);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
globalForm.find('.selector_option_radio_field').on('change', function (evt) {
|
|
|
|
|
|
updateFieldSettings();
|
|
|
|
|
|
parseNumeric(this);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: checkbox change -> drop the was-inherit mark, re-serialize
|
|
|
|
|
|
globalForm.find('.selector_option_checkbox_field').on('change', function (evt) {
|
|
|
|
|
|
$(this).removeData('was-inherit');
|
|
|
|
|
|
updateFieldSettings();
|
|
|
|
|
|
});
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var hotswapGeneralInherit = function () {
|
|
|
|
|
|
//hotswapping the general inherit
|
|
|
|
|
|
$('#general_inherit_on').on('change', function (evt) {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('#TemplateConfiguration_files_css').val('inherit');
|
|
|
|
|
|
$('#TemplateConfiguration_files_js').val('inherit');
|
|
|
|
|
|
$('#TemplateConfiguration_files_print_css').val('inherit');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('#TemplateConfiguration_options').val('inherit');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('#TemplateConfiguration_cssframework_name').val('inherit');
|
|
|
|
|
|
$('#TemplateConfiguration_cssframework_css').val('inherit');
|
|
|
|
|
|
$('#TemplateConfiguration_cssframework_js').val('inherit');
|
|
|
|
|
|
$('#TemplateConfiguration_packages_to_load').val('inherit');
|
|
|
|
|
|
$('.action_hide_on_inherit_wrapper').removeClass('d-none');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('.action_hide_on_inherit').addClass('d-none');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('.tab_action_hide_on_inherit').addClass('ls-tab-disabled');
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
|
|
|
|
|
$('#general_inherit_off').on('change', function (evt) {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('.action_hide_on_inherit_wrapper').addClass('d-none');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('.action_hide_on_inherit').removeClass('d-none');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('.tab_action_hide_on_inherit').removeClass('ls-tab-disabled');
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
updateFieldSettings();
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// THEME ADDITION: manage the font packages of ALL font selects, not just the
|
|
|
|
|
|
// base "font" dropdown. Every per-element font override (type "fontselect",
|
|
|
|
|
|
// class .selector_fontselect) can pick a different font, and each selected
|
|
|
|
|
|
// font needs its package (font-<data-font-package>) in packages_to_load,
|
|
|
|
|
|
// otherwise the survey page does not load that font's css. Values "inherit"
|
|
|
|
|
|
// (survey-level inherit) and "base" (= base font, handled by the font select
|
|
|
|
|
|
// itself) contribute no package of their own.
|
|
|
|
|
|
// PRIVACY HARD RULE: only LOCAL packages may be added. The only allowed
|
|
|
|
|
|
// font package is "websafe" (served from the server's own assets, pure
|
|
|
|
|
|
// system-font stacks). Bundled fonts load via the theme's css/fonts.css and
|
|
|
|
|
|
// need no package. Any other package (font-roboto, font-noto, ...) is skipped
|
|
|
|
|
|
// with a warning, so a survey page can never request a font from Google or
|
|
|
|
|
|
// any other external host.
|
|
|
|
|
|
var ALLOWED_FONT_PACKAGES = ['websafe'];
|
2026-11-16 19:36:04 +01:00
|
|
|
|
var hotswapFontField = function () {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('.selector_fontselect').on('change', function (evt) {
|
|
|
|
|
|
// base font set to "inherit" => inherit the packages as a whole
|
2026-11-16 19:36:04 +01:00
|
|
|
|
if ($('#simple_edit_options_font').val() === 'inherit') {
|
|
|
|
|
|
$('#TemplateConfiguration_packages_to_load').val('inherit');
|
2026-11-24 22:04:11 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var currentPackageObject = $('#TemplateConfiguration_packages_to_load').val() !== 'inherit' ?
|
|
|
|
|
|
JSON.parse($('#TemplateConfiguration_packages_to_load').val()) :
|
|
|
|
|
|
$(this).data('inheritvalue');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
if (currentPackageObject === 'inherit' || !currentPackageObject) {
|
|
|
|
|
|
currentPackageObject = {add: []};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// drop all font-* packages, then re-add the ones of all current font selects
|
|
|
|
|
|
var filteredAdd = (currentPackageObject.add || []).filter(function (value, index) {
|
|
|
|
|
|
return !(/^font-.*$/.test(String(value)));
|
|
|
|
|
|
});
|
|
|
|
|
|
$('.selector_fontselect').each(function (i, item) {
|
|
|
|
|
|
var val = $(item).val();
|
|
|
|
|
|
if (!val || val === 'inherit' || val === 'base') {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
var packageName = $(item).find('option:selected').data('font-package');
|
|
|
|
|
|
if (!packageName) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// privacy: only allow local packages (see ALLOWED_FONT_PACKAGES)
|
|
|
|
|
|
if (ALLOWED_FONT_PACKAGES.indexOf(String(packageName)) === -1) {
|
|
|
|
|
|
if (window.console && console.warn) {
|
|
|
|
|
|
console.warn('Theme privacy rule: font package "font-' + packageName + '" is not allowed (external hosts are never requested); skipped.');
|
|
|
|
|
|
}
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2026-11-16 19:36:04 +01:00
|
|
|
|
var formatedPackageName = 'font-' + packageName;
|
2026-11-24 22:04:11 +01:00
|
|
|
|
if (filteredAdd.indexOf(formatedPackageName) === -1) {
|
|
|
|
|
|
filteredAdd.push(formatedPackageName);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
currentPackageObject.add = filteredAdd;
|
|
|
|
|
|
$('#TemplateConfiguration_packages_to_load').val(JSON.stringify(currentPackageObject));
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
//hotswapping the colorpickers and adding the reset functionality
|
|
|
|
|
|
var hotswapColorPicker = function () {
|
|
|
|
|
|
|
2026-11-25 21:05:01 +01:00
|
|
|
|
// THEME ADDITION: bind 'input' as well as 'change' — browsers fire 'input'
|
|
|
|
|
|
// live while the native color popup is dragged and 'change' only when it
|
|
|
|
|
|
// closes, so without 'input' a color picked but not yet "closed" would be
|
|
|
|
|
|
// lost when Save is clicked; syncing live makes the text field (and thus
|
|
|
|
|
|
// the saved options JSON) always carry the latest picked color.
|
2026-11-24 22:04:11 +01:00
|
|
|
|
globalForm.find('.selector__colorpicker-inherit-value')
|
2026-11-25 21:05:01 +01:00
|
|
|
|
.on('change input', function (e) {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$(this).closest('.input-group').find('.selector_option_value_field').val($(this).val()).trigger('change');
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
globalForm.find('.selector__reset-colorfield-to-inherit').on('click', function (e) {
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
var colorField = $(this).closest('.input-group').find('.selector__color-picker');
|
|
|
|
|
|
console.ls.log(colorField, colorField.data('inheritvalue'));
|
|
|
|
|
|
$(this).closest('.input-group').find('.selector__colorpicker-inherit-value').val(colorField.data('inheritvalue')).trigger('change');
|
|
|
|
|
|
colorField.attr('type', 'text').val('');
|
|
|
|
|
|
optionObject[colorField.attr('name')] = 'inherit';
|
|
|
|
|
|
updateFieldSettings();
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var removeVariationsFromField = function (fieldSelector) {
|
|
|
|
|
|
if ($(fieldSelector).val() === 'inherit') {
|
|
|
|
|
|
fieldSelector = '#optionCssFiles';
|
|
|
|
|
|
}
|
|
|
|
|
|
let currentValue = {};
|
|
|
|
|
|
try {
|
|
|
|
|
|
currentValue = JSON.parse($(fieldSelector).val());
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
currentValue = {};
|
|
|
|
|
|
}
|
|
|
|
|
|
let empty = true;
|
|
|
|
|
|
['add', 'replace', 'remove'].forEach(function (action) {
|
|
|
|
|
|
if (currentValue.hasOwnProperty(action)) {
|
|
|
|
|
|
currentValue[action] = currentValue[action].filter(function (item) {
|
|
|
|
|
|
return !(/^css\/variations\/.*$/.test(item));
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
2026-11-24 22:04:11 +01:00
|
|
|
|
if (currentValue[action].length) {
|
|
|
|
|
|
empty = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
if (!empty) {
|
|
|
|
|
|
$(fieldSelector).val(JSON.stringify(currentValue));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$(fieldSelector).val(inheritPossible ? 'inherit' : JSON.stringify({}));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// update the files_css field to be saved in the database
|
|
|
|
|
|
var addVariationToField = function (selectedVariation, filesCssId, selectedMode) {
|
|
|
|
|
|
let filesCss = [];
|
|
|
|
|
|
try {
|
|
|
|
|
|
filesCss = JSON.parse($(filesCssId).val());
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!filesCss.hasOwnProperty(selectedMode)) {
|
|
|
|
|
|
filesCss[selectedMode] = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
if (selectedMode === 'replace') {
|
|
|
|
|
|
filesCss[selectedMode].push(selectedVariation);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
filesCss[selectedMode].unshift(selectedVariation);
|
|
|
|
|
|
}
|
|
|
|
|
|
$(filesCssId).val(JSON.stringify(filesCss));
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var hotswapTheme = function () {
|
|
|
|
|
|
$('#simple_edit_options_cssframework').on('change', function (evt) {
|
|
|
|
|
|
let newThemeDataValue = $('option:selected', this).attr('data-value') || false;
|
|
|
|
|
|
let selectedVariation = newThemeDataValue || $('#simple_edit_options_cssframework').val();
|
|
|
|
|
|
let selectedMode = $('#simple_edit_options_cssframework').find('option[value=\'' + selectedVariation + '\']').attr('data-mode') || 'add';
|
|
|
|
|
|
let filesCssId = '#TemplateConfiguration_files_css';
|
|
|
|
|
|
let filesCss = {};
|
|
|
|
|
|
try {
|
|
|
|
|
|
filesCss = JSON.parse($(filesCssId).val());
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
filesCss = $(filesCssId).val();
|
|
|
|
|
|
}
|
|
|
|
|
|
// load the parent data if set to inherit, so no data gets lost
|
|
|
|
|
|
if (filesCss.length === 0 || filesCss === 'inherit') {
|
|
|
|
|
|
$(filesCssId).val($('#optionCssFiles').val());
|
|
|
|
|
|
}
|
|
|
|
|
|
removeVariationsFromField(filesCssId);
|
|
|
|
|
|
removeVariationsFromField('#TemplateConfiguration_cssframework_css');
|
|
|
|
|
|
if (selectedVariation !== 'inherit') {
|
|
|
|
|
|
addVariationToField(selectedVariation, filesCssId, selectedMode);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
$(filesCssId).val('inherit');
|
2026-11-16 19:36:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
|
|
// Event methods
|
|
|
|
|
|
// -- These methods are triggered on events. Please see `bind´ method for more information
|
|
|
|
|
|
var onSaveButtonClickAction = function (evt) {
|
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
if ($('#general_inherit_on').prop('checked')) {
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('#TemplateConfiguration_options').val('inherit');
|
|
|
|
|
|
$('#template-options-form').trigger('submit'); // submit the form
|
|
|
|
|
|
} else {
|
2026-11-24 22:04:11 +01:00
|
|
|
|
updateFieldSettings();
|
2026-11-16 19:36:04 +01:00
|
|
|
|
//Create a copy of the inherent optionObject
|
|
|
|
|
|
var newOptionObject = $.extend(true, {}, optionObject);
|
|
|
|
|
|
newOptionObject.generalInherit = null;
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
//now write the newly created object to the correspondent field as a json string
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('#TemplateConfiguration_options').val(JSON.stringify(newOptionObject));
|
2026-11-24 22:04:11 +01:00
|
|
|
|
//and submit the form
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('#template-options-form').trigger('submit');
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////
|
|
|
|
|
|
// Instance methods
|
|
|
|
|
|
var bind = function () {
|
|
|
|
|
|
//if the save button is clicked write everything into the template option field and send the form
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('#theme-options--submit').on('click', onSaveButtonClickAction);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
|
|
|
|
|
//Bind the hotwaps
|
|
|
|
|
|
hotSwapParentRadioButtons();
|
|
|
|
|
|
hotSwapFields();
|
|
|
|
|
|
hotswapGeneralInherit();
|
2026-11-24 22:04:11 +01:00
|
|
|
|
hotswapColorPicker();
|
2026-11-16 19:36:04 +01:00
|
|
|
|
hotswapFontField();
|
2026-11-24 22:04:11 +01:00
|
|
|
|
hotswapTheme();
|
|
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: re-evaluate conditional visibility whenever a radio changes
|
|
|
|
|
|
globalForm.find('.selector_option_radio_field').on('change', updateVisibilityByParent);
|
feat(options): Fonts tab becomes 'Fonts and colors' with per-element font+color combos (Prompt U)
Tab 'Fonts' is renamed to 'Fonts and colors' and gets a dedicated layout:
top row (col 1: font, fontcolor, fontsize; col 2: primarycolor +
new secondarycolor; col 3 empty), an hr, then one combo row per element
(header, progressbar, questiontitle, answers, grouptitle,
groupdescription, buttons) with col 1 = existing <el>font fontselect,
col 2 = new <el>textcolor dropdown (default|primary|secondary|other),
col 3 = new <el>textcolorcustom colorpicker, visible only when mode is
'other' (parent show-value via aShowIfValues, server-side initial d-none,
options.js updateVisibilityByParent/updateChild now handle select parents,
multi-value aware; font's self-parent removed from config.xml).
config.xml: fontcolor/primarycolor moved from Colors to Fonts (retitled
'Default font color (body text)' / 'Primary color'), secondarycolor added
(default #888888), 14 per-element color keys added with dropdownoptions.
Views emit the per-element color as inline style (default->fontcolor,
primary->primarycolor, secondary->secondarycolor, other->custom picker).
Colors tab now only holds sliderhandlecolor + privacybackgroundcolor
(final Colors layout = Prompt T, still open).
Variants rebuilt (defensie, erasmus, example respondage_respondage) —
no unknown-key failures; theme reset in LS-admin still owner action.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-25 11:51:57 +01:00
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION (Prompt U): a changed SELECT may also be a parent of
|
|
|
|
|
|
// conditional fields (e.g. <el>textcolor driving <el>textcolorcustom) —
|
|
|
|
|
|
// bound separately so visibility updates even if updateFieldSettings()
|
|
|
|
|
|
// above throws on the same event
|
|
|
|
|
|
globalForm.find('select').on('change', function () {
|
|
|
|
|
|
updateVisibilityByParent();
|
|
|
|
|
|
updateAllChildren();
|
|
|
|
|
|
});
|
2026-11-24 22:04:11 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: order the font dropdowns' optgroups as:
|
|
|
|
|
|
// Custom (this theme) > Bundled open source fonts > User browser > Local server - core/user (LAST).
|
|
|
|
|
|
// Core package optgroups are recognized structurally (their options carry
|
|
|
|
|
|
// data-font-package equal to their own value; theme/user fonts use "websafe"),
|
|
|
|
|
|
// the rest by label keyword, so translated labels still work.
|
|
|
|
|
|
var reorderFontDropdowns = function () {
|
|
|
|
|
|
var rank = function (label) {
|
|
|
|
|
|
var l = String(label || '').toLowerCase();
|
|
|
|
|
|
if (l.indexOf('custom') !== -1) { return 0; }
|
|
|
|
|
|
if (l.indexOf('bundled') !== -1) { return 1; }
|
|
|
|
|
|
if (l.indexOf('user') !== -1) { return 2; }
|
|
|
|
|
|
return 3;
|
|
|
|
|
|
};
|
|
|
|
|
|
var isServerPackageGroup = function ($og) {
|
|
|
|
|
|
var $first = $og.children('option').first();
|
|
|
|
|
|
return $first.length > 0 && $first.attr('data-font-package') === $first.attr('value');
|
|
|
|
|
|
};
|
|
|
|
|
|
globalForm.find('.selector_fontselect').each(function () {
|
|
|
|
|
|
var $sel = $(this);
|
|
|
|
|
|
// THEME ADDITION: drop empty optgroups (e.g. "Custom (this theme)" when
|
|
|
|
|
|
// the theme ships no own font) — an empty category is not shown.
|
|
|
|
|
|
$sel.children('optgroup').each(function () {
|
|
|
|
|
|
if ($(this).children('option').length === 0) { $(this).remove(); }
|
|
|
|
|
|
});
|
|
|
|
|
|
var groups = $sel.children('optgroup').get();
|
|
|
|
|
|
groups.sort(function (a, b) {
|
|
|
|
|
|
var aSrv = isServerPackageGroup($(a));
|
|
|
|
|
|
var bSrv = isServerPackageGroup($(b));
|
|
|
|
|
|
if (aSrv !== bSrv) { return aSrv ? 1 : -1; } // server packages last
|
|
|
|
|
|
if (aSrv && bSrv) { return 0; } // keep core before user (original order)
|
|
|
|
|
|
return rank($(a).attr('label')) - rank($(b).attr('label'));
|
|
|
|
|
|
});
|
|
|
|
|
|
$.each(groups, function (i, g) { $sel.append(g); });
|
|
|
|
|
|
});
|
2026-11-16 19:36:04 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// THEME ADDITION (row 115 on navbarfontcolor, generalized row 135 to every key in
|
|
|
|
|
|
// aColorChooserKeys): preset-dropdown UI for a color-chooser option.
|
|
|
|
|
|
// - option labels of the dropdown get the LIVE hex of the preset they point at
|
|
|
|
|
|
// ("Color 1 [#5e1c64]" — values read from the stored options JSON /
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
// the fields' data-inheritvalue, so they also work at survey level with inherit)
|
|
|
|
|
|
// - clickable swatch chips next to the dropdown (one per preset; click = choose it)
|
|
|
|
|
|
// - an "effective color" swatch appended to the custom picker's input group, showing
|
|
|
|
|
|
// the color that is actually applied for the current mode (overwritable by picking
|
|
|
|
|
|
// another color when mode is "other")
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// - legacy migration: a stored HEX value (from before the option became a
|
|
|
|
|
|
// dropdown) selects mode "other" and moves the hex into the <key>custom child
|
|
|
|
|
|
var colorModeUI = function (key) {
|
|
|
|
|
|
var sel = globalForm.find('select[name="' + key + '"]');
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
if (!sel.length) { return; }
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
var presets = colorPresets;
|
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>
2026-11-26 18:51:41 +01:00
|
|
|
|
// row 126/134: the option's DEFAULT choice — the config.xml <option data-default="1">
|
|
|
|
|
|
// (same value as the <default> element text). In the dropdown LIST it is
|
|
|
|
|
|
// enclosed in [ ] (bolding <option> is not rendered by every browser — row 134);
|
|
|
|
|
|
// the swatch label below the swatch stays bold via the is-default class.
|
|
|
|
|
|
// Fallback when the marker is missing: the inherited value, else the first
|
|
|
|
|
|
// non-"inherit" entry.
|
fix(options): bold the default color choice through every browser mechanism
Row 132: after cache clear + theme reset + hard refresh the default entry of
the color-chooser dropdown still was not bold in the owner's browser — not
every browser applies font-weight to <option> elements (Safari ignores option
styling entirely; the closed select box often ignores it too), even though
the data-default attribute and <b> were in the DOM. Now stacked:
1. CSS rule select option[data-default="1"] { font-weight: 700 } (existing),
2. a real <b> around the default label (row 129, existing),
3. inline style font-weight:700 on the default <option> (new in options.js),
4. .action_update_options_string_form select:has(option[data-default="1"]:checked)
{ font-weight: 700 } — bolds the CLOSED select box when the default choice
is selected (new in options.twig inline <style>),
5. the swatch chip label of the default stays bold via .is-default (row 126).
Also: the default mode is now read with a fallback chain (data-default option
-> data-inheritvalue -> first non-inherit option) so the swatch label bold
cannot silently disappear. OPTIONS_JS_TOKEN -> 20261126.11. Verified: render
tc=618 (served as options.js?v=20261126.11, :has rule present in HTML), jsdom
6/6 incl. new pins (inline font-weight on the default option only, :has rule
in the inline style), export exit 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 16:59:01 +01:00
|
|
|
|
var defaultMode = String(sel.find('option[data-default="1"]').first().attr('value')
|
|
|
|
|
|
|| sel.data('inheritvalue')
|
|
|
|
|
|
|| sel.find('option').not('[value="inherit"]').first().attr('value')
|
|
|
|
|
|
|| '');
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
var customInput = globalForm.find('input[name="' + key + 'custom"]');
|
|
|
|
|
|
var currentColor = function (ckey) {
|
|
|
|
|
|
var f = globalForm.find('#simple_edit_options_' + ckey);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
var v = f.val();
|
|
|
|
|
|
if (!v) { v = f.data('inheritvalue'); }
|
|
|
|
|
|
return v ? String(v) : '';
|
|
|
|
|
|
};
|
|
|
|
|
|
var refreshLabels = function () {
|
|
|
|
|
|
sel.find('option').each(function () {
|
|
|
|
|
|
var op = $(this);
|
|
|
|
|
|
var mode = String(op.attr('value'));
|
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>
2026-11-26 18:51:41 +01:00
|
|
|
|
if (!op.data('base-label')) {
|
|
|
|
|
|
// strip the [ ] default marker from config.xml so re-wrapping stays idempotent
|
|
|
|
|
|
op.data('base-label', op.text().replace(/^\s*\[(.*)\]\s*$/, '$1'));
|
fix(options): bold the default color choice through every browser mechanism
Row 132: after cache clear + theme reset + hard refresh the default entry of
the color-chooser dropdown still was not bold in the owner's browser — not
every browser applies font-weight to <option> elements (Safari ignores option
styling entirely; the closed select box often ignores it too), even though
the data-default attribute and <b> were in the DOM. Now stacked:
1. CSS rule select option[data-default="1"] { font-weight: 700 } (existing),
2. a real <b> around the default label (row 129, existing),
3. inline style font-weight:700 on the default <option> (new in options.js),
4. .action_update_options_string_form select:has(option[data-default="1"]:checked)
{ font-weight: 700 } — bolds the CLOSED select box when the default choice
is selected (new in options.twig inline <style>),
5. the swatch chip label of the default stays bold via .is-default (row 126).
Also: the default mode is now read with a fallback chain (data-default option
-> data-inheritvalue -> first non-inherit option) so the swatch label bold
cannot silently disappear. OPTIONS_JS_TOKEN -> 20261126.11. Verified: render
tc=618 (served as options.js?v=20261126.11, :has rule present in HTML), jsdom
6/6 incl. new pins (inline font-weight on the default option only, :has rule
in the inline style), export exit 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 16:59:01 +01:00
|
|
|
|
}
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
var base = String(op.data('base-label'));
|
|
|
|
|
|
var pk = presets[mode];
|
feat(options): color-chooser option texts with live hexcodes, default bold
Row 131: the navbarfontcolor dropdown entries now read exactly "Default font
color", "Default background color", "Color 1", "Color 2", "Color 3",
"Other ..." (config.xml options/optionlabels/dropdownoptions renamed from
"Same as default font color" / "Other…"). options.js appends each entry's
chosen hexcode in brackets — presets from their color option fields,
"Other ..." from the custom picker's value (navbarfontcolorcustom) — and the
entry marked data-default="1" stays bold via a real <b> (row 129) plus CSS.
Rendered list example: bold "Default font color [#444444]", "Default
background color [#ffffff]", "Color 1 [#5e1c64]", ..., "Other ... [#444444]".
OPTIONS_JS_TOKEN -> 20261126.10. Verified: render tc=603 (raw option texts
match the list), jsdom 6/6 incl. new pins (exact label texts, hex on
"Other ..." and "Default background color" entries, <b> only on default),
export exit 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 16:49:35 +01:00
|
|
|
|
// row 131: every entry shows its chosen hexcode — the preset colors
|
|
|
|
|
|
// from their option fields, "Other ..." from the custom picker's value
|
|
|
|
|
|
var c = pk ? currentColor(pk)
|
|
|
|
|
|
: (mode === 'other' && customInput.length && /^#[0-9a-fA-F]{3,8}$/.test(String(customInput.val() || '')) ? String(customInput.val()) : '');
|
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>
2026-11-26 18:51:41 +01:00
|
|
|
|
// 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;
|
feat(options): color-chooser option texts with live hexcodes, default bold
Row 131: the navbarfontcolor dropdown entries now read exactly "Default font
color", "Default background color", "Color 1", "Color 2", "Color 3",
"Other ..." (config.xml options/optionlabels/dropdownoptions renamed from
"Same as default font color" / "Other…"). options.js appends each entry's
chosen hexcode in brackets — presets from their color option fields,
"Other ..." from the custom picker's value (navbarfontcolorcustom) — and the
entry marked data-default="1" stays bold via a real <b> (row 129) plus CSS.
Rendered list example: bold "Default font color [#444444]", "Default
background color [#ffffff]", "Color 1 [#5e1c64]", ..., "Other ... [#444444]".
OPTIONS_JS_TOKEN -> 20261126.10. Verified: render tc=603 (raw option texts
match the list), jsdom 6/6 incl. new pins (exact label texts, hex on
"Other ..." and "Default background color" entries, <b> only on default),
export exit 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 16:49:35 +01:00
|
|
|
|
if (pk || mode === 'other') {
|
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>
2026-11-26 18:51:41 +01:00
|
|
|
|
op.text(c ? name + ' [' + c + ']' : name);
|
2026-11-26 15:59:46 +01:00
|
|
|
|
} else if (op.attr('data-default')) {
|
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>
2026-11-26 18:51:41 +01:00
|
|
|
|
op.text(name);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
var refreshChips = function () {
|
|
|
|
|
|
var chips = sel.data('color-chips');
|
|
|
|
|
|
if (!chips) {
|
|
|
|
|
|
chips = $('<span class="color-mode-chips"></span>');
|
|
|
|
|
|
sel.after(chips);
|
|
|
|
|
|
sel.data('color-chips', chips);
|
|
|
|
|
|
$.each(presets, function (mode, key) {
|
2026-11-26 14:15:09 +01:00
|
|
|
|
// per preset: a swatch button with the hex value BELOW it
|
|
|
|
|
|
// (the hex inside the swatch was unreadable and obscured the color)
|
|
|
|
|
|
var item = $('<span class="color-chip-item"></span>');
|
|
|
|
|
|
var chip = $('<button type="button" class="color-chip" data-mode="' + mode + '"></button>');
|
|
|
|
|
|
var lbl = $('<span class="color-chip-label"></span>');
|
2026-11-26 14:46:19 +01:00
|
|
|
|
// row 122: set the value and refresh FIRST, then fire change inside
|
|
|
|
|
|
// try/catch — a throwing handler in the synthetic change chain aborts
|
|
|
|
|
|
// the rest of this click handler, and without this the outline would
|
|
|
|
|
|
// not move when clicking a swatch (while the dropdown works via the
|
|
|
|
|
|
// delegated document handler, because native events still bubble).
|
|
|
|
|
|
chip.on('click', function () {
|
|
|
|
|
|
sel.val(mode);
|
|
|
|
|
|
refreshAll();
|
|
|
|
|
|
try { sel.trigger('change'); } catch (e) { /* save re-serializes anyway */ }
|
|
|
|
|
|
});
|
2026-11-26 14:15:09 +01:00
|
|
|
|
item.append(chip).append(lbl);
|
|
|
|
|
|
chips.append(item);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
chips.find('.color-chip').each(function () {
|
|
|
|
|
|
var chip = $(this);
|
|
|
|
|
|
var mode = String(chip.data('mode'));
|
|
|
|
|
|
var c = currentColor(presets[mode]);
|
|
|
|
|
|
chip.css('background', c || 'transparent');
|
|
|
|
|
|
chip.attr('title', mode + (c ? ' [' + c + ']' : ''));
|
|
|
|
|
|
chip.attr('aria-label', chip.attr('title'));
|
|
|
|
|
|
chip.toggleClass('active', String(sel.val()) === mode);
|
2026-11-26 15:50:28 +01:00
|
|
|
|
chip.siblings('.color-chip-label').first().text(c || '')
|
|
|
|
|
|
.toggleClass('is-default', defaultMode !== '' && mode === defaultMode);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
});
|
|
|
|
|
|
};
|
2026-11-26 20:09:56 +01:00
|
|
|
|
// row 143: NO third part in the input group any more — the "effective color"
|
|
|
|
|
|
// swatch (.color-mode-effective) is removed; the group is just the swatch
|
|
|
|
|
|
// part + the text input, both the same height (CSS in options.twig)
|
|
|
|
|
|
var refreshAll = function () { refreshLabels(); refreshChips(); };
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
colorModeRefreshers.push(refreshAll);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
// legacy migration: stored hex (pre-dropdown value) -> mode "other" + hex into the custom field
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
var stored = legacyColorValues[key];
|
2026-11-27 02:50:06 +01:00
|
|
|
|
var storedMode = legacyModeValues[key];
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
if (typeof stored === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(stored)) {
|
|
|
|
|
|
sel.val('other');
|
|
|
|
|
|
if (customInput.length && !/^#[0-9a-fA-F]{3,8}$/.test(String(customInput.val() || ''))) {
|
|
|
|
|
|
customInput.val(stored);
|
|
|
|
|
|
}
|
|
|
|
|
|
// re-evaluate the child's disabled state for the migrated mode
|
|
|
|
|
|
updateAllChildren();
|
|
|
|
|
|
updateVisibilityByParent();
|
2026-11-27 02:50:06 +01:00
|
|
|
|
} else if (typeof storedMode === 'string' && storedMode !== '' && !sel.find('option[value="' + storedMode + '"]').length) {
|
|
|
|
|
|
// row 157: legacy mode of the old 4-way <el>textcolor dropdowns
|
|
|
|
|
|
// (primary|secondary) has no option in the 6-mode chooser -> map it
|
|
|
|
|
|
// (primary -> color1, secondary -> color2); "default"/"other" still
|
|
|
|
|
|
// exist as options and need no mapping
|
|
|
|
|
|
var legacyModeMap = { 'primary': 'color1', 'secondary': 'color2' };
|
|
|
|
|
|
var mapped = legacyModeMap[storedMode];
|
|
|
|
|
|
if (mapped && sel.find('option[value="' + mapped + '"]').length) {
|
|
|
|
|
|
sel.val(mapped);
|
|
|
|
|
|
updateAllChildren();
|
|
|
|
|
|
updateVisibilityByParent();
|
|
|
|
|
|
}
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
} else if (!sel.val()) {
|
feat(options): Default background color as 2nd choice; label 'Menu item color in header'; per-option default
- navbarfontcolor dropdown reordered to default|defaultbackgroundcolor|
color1|color2|color3|other (options attr, optionlabels, dropdownoptions),
and the swatch chips follow the same order (presets map key order in
options.js) — 'Default background color' is now the second choice.
- Label of navbarfontcolor changed to 'Menu item color in header' (child
navbarfontcolorcustom -> 'Custom menu item color ...').
- Per-option default mechanism made explicit: the config.xml <default> of a
color-chooser dropdown is that option's default choice (stored on theme
reset); navbarfontcolor keeps default 'default' = 'Same as default font
color'. The JS no-value fallback no longer hardcodes 'default' but falls
back to data-inheritvalue / the first non-inherit dropdown entry, so a
future chooser (e.g. questiontitlebackgroundcolor defaulting to color1)
can set its own default. custom_header.twig mapping unchanged.
- OPTIONS_JS_TOKEN -> 20261126.7. Verified: render tc=573 (dropdown order
default,defaultbackgroundcolor,color1,color2,color3,other; label; divs
balanced; served as options.js?v=20261126.7), jsdom 6/6 incl. new pins
(dropdown order + chip order, Default background color 2nd), live survey
282267 with stored mode 'default' renders navbar menu color = fontcolor
#444444, export_public.sh exit 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 15:13:45 +01:00
|
|
|
|
// no (matching) stored value: fall back to the option's configured
|
|
|
|
|
|
// default (row 125: every color-chooser option can pick its own default
|
|
|
|
|
|
// via the config.xml <default>, stored on theme reset; in the DOM the
|
|
|
|
|
|
// inherited value is data-inheritvalue, else the first non-"inherit"
|
|
|
|
|
|
// dropdown entry is the default choice of the pattern)
|
|
|
|
|
|
var fallback = sel.data('inheritvalue') || sel.find('option').not('[value="inherit"]').first().attr('value');
|
|
|
|
|
|
if (fallback) { sel.val(fallback); }
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
updateAllChildren();
|
|
|
|
|
|
updateVisibilityByParent();
|
|
|
|
|
|
}
|
|
|
|
|
|
refreshAll();
|
|
|
|
|
|
sel.on('change', refreshAll);
|
|
|
|
|
|
if (customInput.length) { customInput.on('input change', refreshAll); }
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-27 03:17:57 +01:00
|
|
|
|
// THEME ADDITION (row 136): in the "Header" tab the header row is
|
2026-11-26 20:04:33 +01:00
|
|
|
|
// col 1 = font + text color in header, col 2 = header background color. Lower the
|
2026-11-26 19:25:22 +01:00
|
|
|
|
// background column so its option aligns with the color option in col 1:
|
|
|
|
|
|
// measure the vertical distance between the navbarfontcolor block's top and
|
|
|
|
|
|
// the background column's top and apply it as padding-top (robust against
|
|
|
|
|
|
// font-size/line-height differences — no hardcoded px).
|
|
|
|
|
|
var alignHeaderColumns = function () {
|
|
|
|
|
|
var row = globalForm.find('.top-section-header').first();
|
|
|
|
|
|
if (!row.length) { return; }
|
|
|
|
|
|
var bgField = globalForm.find('#simple_edit_options_headerbackgroundcolor');
|
|
|
|
|
|
var colorField = globalForm.find('#simple_edit_options_navbarfontcolor');
|
|
|
|
|
|
if (!bgField.length || !colorField.length) { return; }
|
|
|
|
|
|
var bgCol = bgField.closest('.top-section-header .col-md-4');
|
|
|
|
|
|
var colorWrap = colorField.closest('.mb-3');
|
|
|
|
|
|
if (!bgCol.length || !colorWrap.length || !bgCol[0].getBoundingClientRect) { return; }
|
|
|
|
|
|
var diff = colorWrap[0].getBoundingClientRect().top - bgCol[0].getBoundingClientRect().top;
|
|
|
|
|
|
if (diff > 0) { bgCol[0].style.paddingTop = diff + 'px'; }
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-26 20:04:33 +01:00
|
|
|
|
// 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); }
|
|
|
|
|
|
});
|
|
|
|
|
|
window.addEventListener('resize', function () { alignHeaderColumns(); });
|
|
|
|
|
|
};
|
|
|
|
|
|
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// Shared delegated handlers for ALL chooser dropdowns (row 122/135): a REAL user
|
|
|
|
|
|
// change event bubbles natively to document even when an earlier direct handler
|
|
|
|
|
|
// threw (jQuery only aborts synthetic triggers), so the active outline still moves
|
|
|
|
|
|
// on the chosen swatch. Bound once, calling every chooser's refreshAll.
|
|
|
|
|
|
var bindColorModeDelegates = function () {
|
|
|
|
|
|
$(document).on('change', 'select.selector_color_mode', function () {
|
|
|
|
|
|
$.each(colorModeRefreshers, function (i, fn) { try { fn(); } catch (e) { /* keep the others running */ } });
|
|
|
|
|
|
});
|
|
|
|
|
|
// live hex labels/chips update when one of the shared color fields changes
|
|
|
|
|
|
$.each(['fontcolor', 'primarycolor', 'secondarycolor', 'tertiarycolor', 'defaultbackgroundcolor'], function (i, ckey) {
|
|
|
|
|
|
globalForm.find('#simple_edit_options_' + ckey).on('input change', function () {
|
|
|
|
|
|
$.each(colorModeRefreshers, function (j, fn) { try { fn(); } catch (e) { /* ignore */ } });
|
|
|
|
|
|
});
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-25 21:28:43 +01:00
|
|
|
|
// THEME HARDENING: run every startup step isolated — one throwing step must
|
|
|
|
|
|
// NEVER prevent bind() (without the save/change handlers, Save silently
|
|
|
|
|
|
// posts the stale options JSON; that is exactly the 2026-11-25 regression
|
|
|
|
|
|
// where JSON.parse($('#optionCssFiles').val()) threw on "inherit" at global
|
|
|
|
|
|
// level and nothing on the page saved anymore).
|
|
|
|
|
|
var safeStep = function (name, fn) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
fn();
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
if (window.console && console.ls && console.ls.error) {
|
|
|
|
|
|
console.ls.error('ThemeOptions step "' + name + '" failed: ' + (e && e.message ? e.message : e));
|
|
|
|
|
|
} else if (window.console && console.error) {
|
|
|
|
|
|
console.error('ThemeOptions step "' + name + '" failed: ' + (e && e.message ? e.message : e));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-16 19:36:04 +01:00
|
|
|
|
var run = function () {
|
2026-11-25 21:28:43 +01:00
|
|
|
|
safeStep('parseOptionObject', parseOptionObject);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// THEME ADDITION (row 115, generalized row 135): snapshot a legacy hex value of
|
|
|
|
|
|
// every color-chooser option before other startup steps can clobber
|
|
|
|
|
|
// optionObject (prepareSelectField + updateFieldSettings)
|
|
|
|
|
|
safeStep('captureLegacyColorValues', function () {
|
|
|
|
|
|
$.each(aColorChooserKeys, function (i, k) {
|
|
|
|
|
|
var v = optionObject[k];
|
|
|
|
|
|
if (typeof v === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(v)) {
|
|
|
|
|
|
legacyColorValues[k] = v;
|
2026-11-27 02:50:06 +01:00
|
|
|
|
} else if (typeof v === 'string' && v !== '' && v !== 'inherit') {
|
|
|
|
|
|
legacyModeValues[k] = v;
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-11-25 21:28:43 +01:00
|
|
|
|
safeStep('startupGeneralInherit', startupGeneralInherit);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-25 21:28:43 +01:00
|
|
|
|
safeStep('prepareSelectField', prepareSelectField);
|
|
|
|
|
|
safeStep('prepareTextField', prepareTextField);
|
|
|
|
|
|
safeStep('parseParentSwitchFields', parseParentSwitchFields);
|
|
|
|
|
|
safeStep('prepareCheckboxField', prepareCheckboxField);
|
|
|
|
|
|
safeStep('prepareFontField', prepareFontField);
|
|
|
|
|
|
safeStep('prepareFruityThemeField', prepareFruityThemeField);
|
|
|
|
|
|
safeStep('showInheritedValue', showInheritedValue);
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: font dropdown optgroup order (see above)
|
2026-11-25 21:28:43 +01:00
|
|
|
|
safeStep('reorderFontDropdowns', reorderFontDropdowns);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-25 21:28:43 +01:00
|
|
|
|
// ALWAYS bind, even if a prepare step above failed
|
|
|
|
|
|
safeStep('bind', bind);
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|
|
|
|
|
|
// set initial disabled status of child fields
|
2026-11-25 21:28:43 +01:00
|
|
|
|
safeStep('updateAllChildren', updateAllChildren);
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION: set initial visibility of conditional fields
|
2026-11-25 21:28:43 +01:00
|
|
|
|
safeStep('updateVisibilityByParent', updateVisibilityByParent);
|
feat(options): menu item color as preset dropdown with persistent custom color (working example)
navbarfontcolor (Top of the page tab, column 2) changes from a plain
colorpicker to a dropdown: Same as default font color | Color 1 | Color 2 |
Color 3 | Other. The new navbarfontcolorcustom colorpicker stays visible but
grayed out (disabled + aria-disabled) unless 'Other' is chosen, and keeps its
value across saves (data-keep-value) so switching back to 'Other' restores the
last picked color. Dropdown option labels show the live hex of each preset and
clickable swatch chips select a preset; an effective-color swatch next to the
picker shows the color actually applied. A legacy stored hex is migrated to
mode 'other' + custom field (options.js) and accepted directly in
custom_header.twig, so nothing is lost before a theme reset. Views map
default->fontcolor, color1/2/3->primary/secondary/tertiarycolor,
other->navbarfontcolorcustom. headerbackgroundcolor/bodybackgroundcolor stay
plain colorpickers, default #ffffff. build.php maps a legacy hex
navbarfontcolor in variant jsons to other+custom for when variants are built.
Verified: jsdom suite 6/6 (new options_navbar_color_mode test: migration,
gray-out, keep-value on save, chips, swatches), live survey render for all 5
modes, export check exit 0.
NOTE (owner 2026-11-26): variant builds are intentionally DEFERRED — no
customer is waiting; the on-disk variant folders were left at their
pre-feature state and no variant theme was reset. Run
variants/build.php per variant only after the open prompts are done.
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 13:51:55 +01:00
|
|
|
|
|
feat(options): roll the color-chooser scheme out to 4 more options (row 135)
The experimental color-chooser (mode dropdown + swatch chips + custom picker,
previously only navbarfontcolor) now also covers, with the owner-specified
defaults:
- headerbackgroundcolor — default "Default background color" (slot h1)
- progressbarcolor — COLUMN 1 of the progress colors row (was col 2), default Color 1
- progressbarbackgroundcolor — COLUMN 2 (was col 1), default Default background color
- progressbarfontcolor — column 3, default Default font color, with an extra tip
underneath: "Make this font color the same color as the color of the progress
bar when you do not want to see the progress in %."
Each option is a dropdown (default|defaultbackgroundcolor|color1|color2|color3|
other) whose own default carries data-default="1" + [ ] in config.xml, plus a
<key>custom colorpicker child (parent, disable-mode, data-keep-value). options.js
generalized navbarColorModeUI to colorModeUI(key) over aColorChooserKeys with
shared presets, one delegated change handler for select.selector_color_mode, and
per-key legacy hex migration (stored hex -> mode "other" + hex into the custom
child). custom_header.twig resolves the modes via a local cm() macro (import
_self, same pattern as nav_bar.twig); raw hex passes through. build.php migrates
legacy hex values in variant jsons for all 5 chooser keys. OPTIONS_JS_TOKEN ->
20261126.14. Verified: render tc=618 (all 5 selects with per-option [ ] default,
progress row col order, tip present, divs balanced, options.js?v=20261126.14),
jsdom 7/7 incl. new options_color_choosers.test.js (5 choosers, legacy migration,
chips, layout, tip) and the navbar test re-scoped to its own chips; live survey
282267 with legacy hex AND with modes (color2 -> #888888, defaultbackgroundcolor
-> #ffffff; DB row restored); export exit 0; build.php lints. Variants not
rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:14:47 +01:00
|
|
|
|
// THEME ADDITION (row 115, generalized row 135): preset-dropdown UI for every
|
|
|
|
|
|
// color-chooser option (labels with live hex, swatch chips, effective-color
|
|
|
|
|
|
// swatch, legacy hex migration) — AFTER parseOptionObject (needs the stored
|
|
|
|
|
|
// optionObject) and AFTER updateAllChildren/updateVisibilityByParent
|
|
|
|
|
|
// (mode "other" enables the child)
|
|
|
|
|
|
$.each(aColorChooserKeys, function (i, k) {
|
|
|
|
|
|
safeStep('colorModeUI:' + k, function () { colorModeUI(k); });
|
|
|
|
|
|
});
|
|
|
|
|
|
safeStep('bindColorModeDelegates', bindColorModeDelegates);
|
2026-11-26 18:45:16 +01:00
|
|
|
|
|
2026-11-26 20:04:33 +01:00
|
|
|
|
// 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
|
2026-11-26 19:25:22 +01:00
|
|
|
|
safeStep('alignHeaderColumns', alignHeaderColumns);
|
2026-11-26 20:04:33 +01:00
|
|
|
|
safeStep('bindHeaderAlignTriggers', bindHeaderAlignTriggers);
|
2026-11-26 19:25:22 +01:00
|
|
|
|
|
2026-11-26 18:45:16 +01:00
|
|
|
|
// THEME ADDITION (row 133): restore the options tab the user was on before
|
|
|
|
|
|
// Save (after a save the page reloads on the first tab)
|
|
|
|
|
|
safeStep('restoreActiveTab', restoreActiveTab);
|
|
|
|
|
|
safeStep('bindTabPersistence', bindTabPersistence);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// THEME ADDITION (row 133): remember the active options tab across Save. The
|
|
|
|
|
|
// active tab button id is stored in sessionStorage, keyed per options-page URL
|
|
|
|
|
|
// (pathname + sid/gsid scope, so global and per-survey pages don't clash and a
|
|
|
|
|
|
// volatile flash param in the redirect URL cannot change the key); on load the
|
|
|
|
|
|
// stored tab is re-activated by class toggling (no Bootstrap API needed).
|
|
|
|
|
|
var tabStorageKey = function () {
|
|
|
|
|
|
var scope = '';
|
|
|
|
|
|
try {
|
|
|
|
|
|
var p = new URLSearchParams(location.search);
|
|
|
|
|
|
scope = p.get('sid') || p.get('gsid') || '';
|
|
|
|
|
|
} catch (e) { /* older browser — scope stays empty */ }
|
|
|
|
|
|
return 'respondage_options_tab:' + location.pathname + '|' + scope;
|
|
|
|
|
|
};
|
|
|
|
|
|
var activateTab = function (btnId) {
|
|
|
|
|
|
var btn = document.getElementById(btnId);
|
|
|
|
|
|
if (!btn || !btn.classList.contains('nav-link')) { return false; }
|
|
|
|
|
|
var nav = btn.closest('.nav-tabs');
|
|
|
|
|
|
var paneSel = btn.getAttribute('data-bs-target') || ('#' + btn.getAttribute('aria-controls'));
|
|
|
|
|
|
var pane = nav && paneSel ? document.querySelector(paneSel) : null;
|
|
|
|
|
|
if (!pane) { return false; }
|
|
|
|
|
|
Array.prototype.forEach.call(nav.querySelectorAll('.nav-link'), function (b) {
|
|
|
|
|
|
var on = b === btn;
|
|
|
|
|
|
b.classList.toggle('active', on);
|
|
|
|
|
|
b.setAttribute('aria-selected', on ? 'true' : 'false');
|
|
|
|
|
|
});
|
|
|
|
|
|
var content = pane.parentElement;
|
|
|
|
|
|
Array.prototype.forEach.call(content.children, function (p) {
|
|
|
|
|
|
if (!p.classList.contains('tab-pane')) { return; }
|
|
|
|
|
|
var on = p === pane;
|
|
|
|
|
|
p.classList.toggle('active', on);
|
|
|
|
|
|
p.classList.toggle('show', on);
|
|
|
|
|
|
});
|
|
|
|
|
|
return true;
|
|
|
|
|
|
};
|
|
|
|
|
|
var restoreActiveTab = function () {
|
|
|
|
|
|
try {
|
|
|
|
|
|
var id = sessionStorage.getItem(tabStorageKey());
|
2026-11-26 20:04:33 +01:00
|
|
|
|
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); }
|
|
|
|
|
|
}
|
2026-11-26 18:45:16 +01:00
|
|
|
|
} catch (e) { /* storage unavailable — keep the first tab */ }
|
|
|
|
|
|
};
|
|
|
|
|
|
var bindTabPersistence = function () {
|
|
|
|
|
|
// plain delegated click listener: works whether or not Bootstrap's tab
|
|
|
|
|
|
// plugin fires its events (shown.bs.tab)
|
|
|
|
|
|
document.addEventListener('click', function (e) {
|
|
|
|
|
|
var t = e.target && e.target.closest ? e.target.closest('.nav-tabs .nav-link') : null;
|
|
|
|
|
|
if (!t || !t.id) { return; }
|
|
|
|
|
|
try { sessionStorage.setItem(tabStorageKey(), t.id); } catch (err) { /* ignore */ }
|
|
|
|
|
|
}, false);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return run;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$(function () {
|
|
|
|
|
|
var prepare = function () {
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
var deferred = $.Deferred();
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
var themeOptionStarter = new ThemeOptions();
|
|
|
|
|
|
themeOptionStarter();
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
deferred.resolve();
|
|
|
|
|
|
}, 650);
|
|
|
|
|
|
return deferred.promise();
|
|
|
|
|
|
};
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
2026-11-24 22:33:11 +01:00
|
|
|
|
// THEME CHANGE (Prompt I): the spinner is NOT shown on page load — nothing
|
|
|
|
|
|
// asynchronous is awaited here (the 650ms timeout existed only to flash it).
|
|
|
|
|
|
// It is still shown during a real upload (onBeforeSend/onSuccess in BindUpload
|
|
|
|
|
|
// below); the element keeps its display:none default in options.twig.
|
|
|
|
|
|
prepare();
|
2026-11-16 19:36:04 +01:00
|
|
|
|
|
|
|
|
|
|
$('.selector__open_lightbox').on('click', function (e) {
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
var imgSrc = $($(this).data('bs-target')).find('option:selected').data('lightbox-src');
|
|
|
|
|
|
var imgTitle = $($(this).data('bs-target')).val();
|
|
|
|
|
|
imgTitle = imgTitle.split('/').pop();
|
|
|
|
|
|
$('#lightbox-modal').find('.selector__title').text(imgTitle);
|
2026-11-24 22:04:11 +01:00
|
|
|
|
$('#lightbox-modal').find('.selector__image').attr({
|
|
|
|
|
|
'src': imgSrc,
|
|
|
|
|
|
'alt': imgTitle
|
|
|
|
|
|
});
|
2026-11-16 19:36:04 +01:00
|
|
|
|
$('#lightbox-modal').modal('show');
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2026-11-24 22:04:11 +01:00
|
|
|
|
// Icon values are hexadecimal code points, show them as text so other values can't add markup
|
|
|
|
|
|
var iconCharacter = function (hexCode) {
|
|
|
|
|
|
hexCode = String(hexCode);
|
|
|
|
|
|
var codePoint = parseInt(hexCode, 16);
|
|
|
|
|
|
return /^[0-9a-f]{1,6}$/i.test(hexCode) && codePoint <= 0x10FFFF ? String.fromCodePoint(codePoint) : '';
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$('.simple_edit_options_checkicon').on('change', function () {
|
|
|
|
|
|
var preview = $(this).siblings('.selector__checkicon-preview').find('i');
|
|
|
|
|
|
var hexCode = $(this).val() == 'inherit' ? preview.attr('data-inheritvalue') : $(this).val();
|
|
|
|
|
|
preview.text(iconCharacter(hexCode));
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
$(function () {
|
|
|
|
|
|
let selectedTabHash = window.location.hash;
|
|
|
|
|
|
let selectedTabElement = document.querySelector('[data-bs-target="' + selectedTabHash + '"]');
|
|
|
|
|
|
if (selectedTabElement !== null) {
|
|
|
|
|
|
let tab = new bootstrap.Tab(selectedTabElement);
|
|
|
|
|
|
tab.show();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var BindUpload = function (options) {
|
|
|
|
|
|
var $activeForm = $(options.form);
|
|
|
|
|
|
var $activeInput = $(options.input);
|
|
|
|
|
|
var $progressBar = $(options.progress);
|
|
|
|
|
|
|
|
|
|
|
|
var onSuccess = options.onSuccess || function () {
|
|
|
|
|
|
};
|
|
|
|
|
|
var onBeforeSend = options.onBeforeSend || function () {
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var progressHandling = function (event) {
|
|
|
|
|
|
var percent = 0;
|
|
|
|
|
|
var position = event.loaded || event.position;
|
|
|
|
|
|
var total = event.total;
|
|
|
|
|
|
if (event.lengthComputable) {
|
|
|
|
|
|
percent = Math.ceil(position / total * 100);
|
|
|
|
|
|
}
|
|
|
|
|
|
// update progressbars classes so it fits your code
|
|
|
|
|
|
$progressBar.css('width', String(percent) + '%');
|
|
|
|
|
|
$progressBar.find('span.visually-hidden').text(percent + '%');
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
$activeInput.on('change', function (e) {
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
var formData = new FormData($activeForm[0]);
|
|
|
|
|
|
console.log(JSON.stringify(formData));
|
|
|
|
|
|
// add assoc key values, this will be posts values
|
|
|
|
|
|
formData.append('file', $activeInput.prop('files')[0]);
|
|
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
|
type: 'POST',
|
|
|
|
|
|
url: $activeForm.attr('action'),
|
|
|
|
|
|
xhr: function () {
|
|
|
|
|
|
var myXhr = $.ajaxSettings.xhr();
|
|
|
|
|
|
if (myXhr.upload) {
|
|
|
|
|
|
myXhr.upload.addEventListener('progress', progressHandling, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
return myXhr;
|
|
|
|
|
|
},
|
|
|
|
|
|
beforeSend: onBeforeSend,
|
|
|
|
|
|
success: function (data) {
|
|
|
|
|
|
console.log(data);
|
|
|
|
|
|
if (data.success === true) {
|
|
|
|
|
|
LS.LsGlobalNotifier.createAlert(data.message, 'success', {showCloseButton: true});
|
|
|
|
|
|
$progressBar.css('width', '0%');
|
|
|
|
|
|
$progressBar.find('span.visually-hidden').text('0%');
|
|
|
|
|
|
onSuccess(options.input, data);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
LS.LsGlobalNotifier.createAlert(data.message, 'danger', {showCloseButton: true});
|
|
|
|
|
|
$progressBar.css('width', '0%');
|
|
|
|
|
|
$progressBar.find('span.visually-hidden').text('0%');
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
error: function (error) {
|
|
|
|
|
|
$progressBar.css('width', '0%');
|
|
|
|
|
|
$progressBar.find('span.visually-hidden').text('0%');
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
},
|
|
|
|
|
|
async: true,
|
|
|
|
|
|
data: formData,
|
|
|
|
|
|
cache: false,
|
|
|
|
|
|
contentType: false,
|
|
|
|
|
|
processData: false,
|
|
|
|
|
|
timeout: 60000
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
return this;
|
|
|
|
|
|
};
|
|
|
|
|
|
new BindUpload({
|
|
|
|
|
|
form: '#upload_frontend',
|
|
|
|
|
|
input: '#upload_image',
|
|
|
|
|
|
progress: '#upload_progress',
|
|
|
|
|
|
onSuccess: function (inputId, data) {
|
|
|
|
|
|
addUploadedImageToSelectors(data && data.file);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
new BindUpload({
|
2026-11-16 19:36:04 +01:00
|
|
|
|
form: '#upload_frontend',
|
|
|
|
|
|
input: '#upload_image_frontend',
|
|
|
|
|
|
progress: '#upload_progress_frontend',
|
|
|
|
|
|
onBeforeSend: function () {
|
|
|
|
|
|
$('.simple-template-edit-loading').css('display', 'block');
|
|
|
|
|
|
},
|
2026-11-24 22:04:11 +01:00
|
|
|
|
onSuccess: function (inputId, data) {
|
|
|
|
|
|
$('.simple-template-edit-loading').css('display', 'none');
|
|
|
|
|
|
addUploadedImageToSelectors(data && data.file);
|
2026-11-16 19:36:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-11-27 03:17:57 +01:00
|
|
|
|
// row 139: second upload widget in the "Header" tab (under the logos
|
feat(options): upload-a-file facility also under the logos row of Top of the page
Row 139: the "Upload an image" widget is no longer tied to the Images tab —
a new row with a single element (the upload control + progress bar) is
rendered directly under the logos row of the "Top of the page" tab, with its
own ids (#upload_image_frontend_top / #upload_progress_frontend_top).
options.js binds a second BindUpload instance on the same shared
#upload_frontend form for those ids, so both widgets upload and both feed
addUploadedImageToSelectors (a fresh upload becomes selectable in the image
dropdowns immediately). The original Images-tab widget is unchanged.
OPTIONS_JS_TOKEN -> 20261126.16. Verified: render tc=648 (new ids exactly
once, original id once, widget sits after logo-columns-hr, divs 324/324,
options.js?v=20261126.16), jsdom 7/7 incl. new pins (id uniqueness, position
under the logos row, change handler bound on BOTH file inputs), export
exit 0. Variants not rebuilt (deferred).
Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-26 19:46:18 +01:00
|
|
|
|
// row) — own input/progress ids, same shared upload form; uploads land in the
|
|
|
|
|
|
// same image selectors via addUploadedImageToSelectors
|
|
|
|
|
|
new BindUpload({
|
|
|
|
|
|
form: '#upload_frontend',
|
|
|
|
|
|
input: '#upload_image_frontend_top',
|
|
|
|
|
|
progress: '#upload_progress_frontend_top',
|
|
|
|
|
|
onBeforeSend: function () {
|
|
|
|
|
|
$('.simple-template-edit-loading').css('display', 'block');
|
|
|
|
|
|
},
|
|
|
|
|
|
onSuccess: function (inputId, data) {
|
|
|
|
|
|
$('.simple-template-edit-loading').css('display', 'none');
|
|
|
|
|
|
addUploadedImageToSelectors(data && data.file);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|
|
|
|
|
|
// Adds a freshly uploaded image to the theme options image selectors so it becomes
|
|
|
|
|
|
// selectable immediately, without a full page reload. Falls back to a reload if the
|
|
|
|
|
|
// server didn't return the file info.
|
|
|
|
|
|
function addUploadedImageToSelectors(file) {
|
|
|
|
|
|
if (!file || !file.filepath) {
|
|
|
|
|
|
let url = new URL(window.location.href);
|
|
|
|
|
|
let activeTab = document.querySelector('.CoreThemeOptions--settingsTab.active');
|
|
|
|
|
|
url.hash = activeTab !== null ? activeTab.id : '';
|
|
|
|
|
|
$(document).trigger('pjax:load', { url: url.href });
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// Group options by their virtual path prefix (e.g. "image::generalfiles::").
|
|
|
|
|
|
let prefixMatch = String(file.filepath).match(/^(image::\w+::)/);
|
|
|
|
|
|
let prefix = prefixMatch ? prefixMatch[1] : null;
|
|
|
|
|
|
$('.selector_image_selector').each(function () {
|
|
|
|
|
|
let select = this;
|
|
|
|
|
|
// Skip if the image is already listed (e.g. an existing file was overwritten).
|
|
|
|
|
|
let exists = Array.prototype.some.call(select.options, function (opt) {
|
|
|
|
|
|
return opt.value === file.filepath;
|
|
|
|
|
|
});
|
|
|
|
|
|
if (exists) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
let option = new Option(file.filename, file.filepath);
|
|
|
|
|
|
option.setAttribute('data-lightbox-src', file.preview || '');
|
|
|
|
|
|
// Insert after the last option of the same group, otherwise append.
|
|
|
|
|
|
let insertAfter = null;
|
|
|
|
|
|
if (prefix) {
|
|
|
|
|
|
Array.prototype.forEach.call(select.options, function (opt) {
|
|
|
|
|
|
if (opt.value.indexOf(prefix) === 0) {
|
|
|
|
|
|
insertAfter = opt;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if (insertAfter && insertAfter.nextSibling) {
|
|
|
|
|
|
insertAfter.parentNode.insertBefore(option, insertAfter.nextSibling);
|
|
|
|
|
|
} else if (insertAfter) {
|
|
|
|
|
|
insertAfter.parentNode.appendChild(option);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
select.appendChild(option);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2026-11-16 19:36:04 +01:00
|
|
|
|
});
|
2026-11-24 22:04:11 +01:00
|
|
|
|
|