feat(options): Images tab conditional background-image options with server-side initial visibility (Prompt Q)
config.xml: Images background block reordered to backgroundimage, bodybackgroundcolor, then the three image-detail children (backgroundimagefixed/display/file, all parent="backgroundimage") — the color stays directly below the Yes/No choice, the details only matter when an image is shown. options.twig: the .option-visibility wrapper now gets a server-side d-none at render time when the parent buttons group's current value is not the show-value, so the initial state matches the stored value even before/without options.js; options.js updateVisibilityByParent() keeps toggling on change (idempotent, verified by jsdom test). Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
parent
2039cbcd48
commit
365b60a9b4
2 changed files with 23 additions and 4 deletions
10
config.xml
10
config.xml
|
|
@ -126,11 +126,15 @@
|
|||
<rightshowoncomputer type="checkbox" category="Images" width="12" title="Computer screen">on</rightshowoncomputer>
|
||||
<rightshowontablet type="checkbox" category="Images" width="12" title="Tablet">on</rightshowontablet>
|
||||
<rightshowonmobile type="checkbox" category="Images" width="12" title="Mobile phone">off</rightshowonmobile>
|
||||
<!-- Prompt Q: order fixed — Background image, then Overall background color
|
||||
(always relevant), then the three image-detail options which are only
|
||||
relevant when a background image is shown (parent="backgroundimage",
|
||||
shown/hidden via .option-visibility in options.twig/options.js). -->
|
||||
<backgroundimage type="buttons" category="Images" width="4" title="Background image (behind body of page)" options="on|off" optionlabels="Yes|No">on</backgroundimage>
|
||||
<backgroundimagefixed type="buttons" category="Images" width="4" title="Background image fixed or scroll" options="fixed|scroll" optionlabels="Fixed|Scroll">scroll</backgroundimagefixed>
|
||||
<backgroundimagedisplay type="buttons" category="Images" width="4" title="Background image display" options="tile|cover" optionlabels="Tile|Cover">tile</backgroundimagedisplay>
|
||||
<backgroundimagefile type="imagefile" category="Images" width="12" title="Background image file" parent="backgroundimage">./files/tiledtexture.png</backgroundimagefile>
|
||||
<bodybackgroundcolor type="colorpicker" category="Images" width="8" title="Overall background color (when there is no picture in the background)" options="on|off" optionlabels="Yes|No">#dddddd</bodybackgroundcolor>
|
||||
<backgroundimagefixed type="buttons" category="Images" width="4" title="Background image fixed or scroll" options="fixed|scroll" optionlabels="Fixed|Scroll" parent="backgroundimage">scroll</backgroundimagefixed>
|
||||
<backgroundimagedisplay type="buttons" category="Images" width="4" title="Background image display" options="tile|cover" optionlabels="Tile|Cover" parent="backgroundimage">tile</backgroundimagedisplay>
|
||||
<backgroundimagefile type="imagefile" category="Images" width="12" title="Background image file" parent="backgroundimage">./files/tiledtexture.png</backgroundimagefile>
|
||||
|
||||
<!-- Questions
|
||||
HOUSE-STYLE: the colorpicker options in this section (question
|
||||
|
|
|
|||
|
|
@ -310,7 +310,22 @@
|
|||
{# parent != '': this field is only visible when the parent option is "on"
|
||||
(options.js toggles .option-visibility via data-show-if-parent);
|
||||
the field itself is additionally disabled via data-parent/selector_radio_childfield #}
|
||||
<div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% endif %}"
|
||||
{# Prompt Q: server-side INITIAL visibility — when the parent is a buttons
|
||||
group, add d-none at render time unless the parent's current value is
|
||||
the show-value ("on"). Same source of truth as currentValue (stored
|
||||
options JSON, fallback oParentOptions). options.js updateVisibilityByParent()
|
||||
toggles the same class on change (idempotent with this initial state).
|
||||
Non-buttons parents (e.g. font's self-parent dropdown) have no radio
|
||||
inputs -> options.js always shows them, so no d-none here. #}
|
||||
{% set bParentHidden = false %}
|
||||
{% if attr.parent != '' %}
|
||||
{% set parentAttr = aOptionAttributes.optionAttributes[attr.parent] ?? null %}
|
||||
{% if parentAttr is not null and parentAttr.type == 'buttons' %}
|
||||
{% set parentValue = bGeneralInherit ? 'inherit' : (aCurrentOptions[attr.parent] is defined ? aCurrentOptions[attr.parent] : (oParentOptions[attr.parent] is defined ? oParentOptions[attr.parent] : '')) %}
|
||||
{% if parentValue != 'on' %}{% set bParentHidden = true %}{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<div class="{{ wrapClass }} {% if attr.parent != '' %}option-visibility{% if bParentHidden %} d-none{% endif %}{% endif %}"
|
||||
{% if attr.parent != '' %}data-show-if-parent="{{ attr.parent }}" data-show-if-value="on"{% endif %}>
|
||||
<div class="mb-3">
|
||||
{# label ALWAYS above the control, for every type incl. checkbox (Prompt G) #}
|
||||
|
|
|
|||
Loading…
Reference in a new issue