persist post reply fieldset state

This commit is contained in:
rimu 2025-01-04 10:32:00 +13:00
parent 92dffa8535
commit 5a6a013afd
4 changed files with 10 additions and 8 deletions

View file

@ -18,6 +18,7 @@
if (!options.animation) { if (!options.animation) {
fieldset.dispatchEvent(new Event('update')); fieldset.dispatchEvent(new Event('update'));
} }
setCookie(`fieldset_${fieldset.id}_state`, 'collapsed', 365);
} }
function showFieldsetContent(fieldset, options) { function showFieldsetContent(fieldset, options) {
@ -39,6 +40,7 @@
if (!options.animation) { if (!options.animation) {
fieldset.dispatchEvent(new Event('update')); fieldset.dispatchEvent(new Event('update'));
} }
setCookie(`fieldset_${fieldset.id}_state`, 'expanded', 365);
} }
function doToggle(fieldset, setting) { function doToggle(fieldset, setting) {

View file

@ -6,14 +6,14 @@
{% from 'bootstrap/form.html' import render_form %} {% from 'bootstrap/form.html' import render_form %}
{% block app_content %} {% block app_content %}
<script src="/static/js/coolfieldset.js?v=2"></script> <script src="/static/js/coolfieldset.js?v=3"></script>
<div class="row"> <div class="row">
<div class="col-12 col-md-8 position-relative add_reply main_pane"> <div class="col-12 col-md-8 position-relative add_reply main_pane">
<fieldset class="coolfieldset mt-4"><legend class="w-auto">Original post</legend> <fieldset id="post_reply_op" class="coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_reply_op_state', 'collapsed') == 'collapsed' }} mt-3"><legend class="w-auto">Original post</legend>
<h3>{{ post.title }}</h3> <h3>{{ post.title }}</h3>
{{ post.body_html | safe if post.body_html else '' }} {{ post.body_html | safe if post.body_html else '' }}
</fieldset> </fieldset>
<fieldset class="coolfieldset mt-4"><legend class="w-auto">Comment you are replying to</legend> <fieldset id="post_reply_comment" class="coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_reply_comment_state', 'collapsed') == 'collapsed' }} mt-4 mb-4"><legend class="w-auto">Comment you are replying to</legend>
{{ comment.body_html | safe}} {{ comment.body_html | safe}}
</fieldset> </fieldset>
<div class="position-relative"> <div class="position-relative">

View file

@ -6,7 +6,7 @@
{% from 'bootstrap/form.html' import render_form, render_field %} {% from 'bootstrap/form.html' import render_form, render_field %}
{% block app_content %} {% block app_content %}
<script src="/static/js/coolfieldset.js?v=2"></script> <script src="/static/js/coolfieldset.js?v=3"></script>
<div class="row"> <div class="row">
<div class="col-12 col-md-8 position-relative main_pane"> <div class="col-12 col-md-8 position-relative main_pane">
{% block title %}<h1>{{ _('Edit post') }}</h1>{% endblock %} {% block title %}<h1>{{ _('Edit post') }}</h1>{% endblock %}
@ -116,7 +116,7 @@
{{ render_field(form.tags) }} {{ render_field(form.tags) }}
<small class="field_hint">{{ _('Separate each tag with a comma.') }}</small> <small class="field_hint">{{ _('Separate each tag with a comma.') }}</small>
<fieldset id="post_more_options" class="mt-4 mb-4 coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_more_options_state') == 'collapsed' }}"> <fieldset id="post_more_options" class="mt-4 mb-4 coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_more_options_state', 'collapsed') == 'collapsed' }}">
<legend class="w-auto">{{ _('More options') }}</legend> <legend class="w-auto">{{ _('More options') }}</legend>
{{ render_field(form.notify_author) }} {{ render_field(form.notify_author) }}
{{ render_field(form.sticky) }} {{ render_field(form.sticky) }}

View file

@ -6,15 +6,15 @@
{% from 'bootstrap/form.html' import render_form %} {% from 'bootstrap/form.html' import render_form %}
{% block app_content %} {% block app_content %}
<script src="/static/js/coolfieldset.js?v=2"></script> <script src="/static/js/coolfieldset.js?v=3"></script>
<div class="row"> <div class="row">
<div class="col-12 col-md-8 position-relative add_reply main_pane"> <div class="col-12 col-md-8 position-relative add_reply main_pane">
<fieldset class="coolfieldset mt-4"><legend class="w-auto">Original post</legend> <fieldset id="post_reply_op" class="coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_reply_op_state', 'collapsed') == 'collapsed' }} mt-3"><legend class="w-auto">Original post</legend>
<h3>{{ post.title }}</h3> <h3>{{ post.title }}</h3>
{{ post.body_html|safe if post.body_html }} {{ post.body_html|safe if post.body_html }}
</fieldset> </fieldset>
{% if comment %} {% if comment %}
<fieldset class="coolfieldset mt-4"><legend class="w-auto">Comment you are replying to</legend> <fieldset id="post_reply_comment" class="coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_reply_comment_state', 'collapsed') == 'collapsed' }} mt-4 mb-4"><legend class="w-auto">Comment you are replying to</legend>
{{ comment.body_html|safe }} {{ comment.body_html|safe }}
</fieldset> </fieldset>
{% endif %} {% endif %}