mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
persist post options fieldset state
This commit is contained in:
parent
956229c7da
commit
92dffa8535
5 changed files with 25 additions and 5 deletions
|
@ -44,8 +44,10 @@
|
||||||
function doToggle(fieldset, setting) {
|
function doToggle(fieldset, setting) {
|
||||||
if (fieldset.classList.contains('collapsed')) {
|
if (fieldset.classList.contains('collapsed')) {
|
||||||
showFieldsetContent(fieldset, setting);
|
showFieldsetContent(fieldset, setting);
|
||||||
|
setCookie(`fieldset_${fieldset.id}_state`, 'expanded', 365);
|
||||||
} else if (fieldset.classList.contains('expanded')) {
|
} else if (fieldset.classList.contains('expanded')) {
|
||||||
hideFieldsetContent(fieldset, setting);
|
hideFieldsetContent(fieldset, setting);
|
||||||
|
setCookie(`fieldset_${fieldset.id}_state`, 'collapsed', 365);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,5 +75,6 @@
|
||||||
// coolfieldset('.coolfieldset', { collapsed: true, animation: true, speed: 'slow' });
|
// coolfieldset('.coolfieldset', { collapsed: true, animation: true, speed: 'slow' });
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
coolfieldset('.coolfieldset', { collapsed: true, animation: true, speed: 'slow' });
|
coolfieldset('.coolfieldset.collapsed', { collapsed: true, animation: true, speed: 'slow' });
|
||||||
|
coolfieldset('.coolfieldset:not(.collapsed)', { collapsed: false, animation: true, speed: 'slow' });
|
||||||
});
|
});
|
||||||
|
|
|
@ -806,6 +806,23 @@ function getCookie(name) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCookie(name, value, days) {
|
||||||
|
var expires;
|
||||||
|
|
||||||
|
if (days) {
|
||||||
|
var date = new Date();
|
||||||
|
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||||
|
expires = "; expires=" + date.toGMTString();
|
||||||
|
} else {
|
||||||
|
expires = "";
|
||||||
|
}
|
||||||
|
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||||
|
}
|
||||||
|
|
||||||
|
function eraseCookie(name) {
|
||||||
|
setCookie(name, "", -1);
|
||||||
|
}
|
||||||
|
|
||||||
/* register a service worker */
|
/* register a service worker */
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
window.addEventListener('load', function() {
|
window.addEventListener('load', function() {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% 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"></script>
|
<script src="/static/js/coolfieldset.js?v=2"></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 class="coolfieldset mt-4"><legend class="w-auto">Original post</legend>
|
||||||
|
|
|
@ -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"></script>
|
<script src="/static/js/coolfieldset.js?v=2"></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 class="mt-4 mb-4 coolfieldset collapsed">
|
<fieldset id="post_more_options" class="mt-4 mb-4 coolfieldset {{ 'collapsed' if request.cookies.get('fieldset_post_more_options_state') == '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) }}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% 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"></script>
|
<script src="/static/js/coolfieldset.js?v=2"></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 class="coolfieldset mt-4"><legend class="w-auto">Original post</legend>
|
||||||
|
|
Loading…
Reference in a new issue