Collapsable posts
This commit is contained in:
parent
79a1de9968
commit
1ae070a4dd
2 changed files with 28 additions and 1 deletions
|
|
@ -18,11 +18,24 @@
|
|||
{% if g.user['id'] == post['author_id'] %}
|
||||
<a class="action" href="{{ url_for('blog.update', id=post['id']) }}">Edit</a>
|
||||
{% endif %}
|
||||
<button class="toggle-content" onclick="toggleContent(this)">Expand</button>
|
||||
</header>
|
||||
<p class="body">{{ post['body'] }}</p>
|
||||
<p class="body" style="display: none;">{{ post['body'] }}</p>
|
||||
</article>
|
||||
{% if not loop.last %}
|
||||
<hr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<script>
|
||||
function toggleContent(button) {
|
||||
const body = button.parentElement.nextElementSibling;
|
||||
if (body.style.display === "none") {
|
||||
body.style.display = "block";
|
||||
button.textContent = "Collapse";
|
||||
} else {
|
||||
body.style.display = "none";
|
||||
button.textContent = "Expand";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue