Aevann 2023-04-29 15:02:01 +02:00
parent a059606fc6
commit 0b887043fa
3 changed files with 7 additions and 13 deletions

View File

@ -144,7 +144,7 @@ function register_new_elements(e) {
const onclick = e.querySelectorAll('[data-onclick]'); const onclick = e.querySelectorAll('[data-onclick]');
for (const element of onclick) { for (const element of onclick) {
element.onclick = () => {execute(element, 'onclick')}; element.addEventListener("click", () => {execute(element, 'onclick')});
} }
const textareas = e.getElementsByTagName('textarea') const textareas = e.getElementsByTagName('textarea')
@ -169,7 +169,9 @@ bs_trigger(document);
document.addEventListener("click", function(e){ document.addEventListener("click", function(e){
const element = e.target let element = e.target
if (element.tagName == "I")
element = element.parentElement
if (element instanceof HTMLImageElement && (element.alt.startsWith('![](')) || element.classList.contains('in-comment-image') || element.classList.contains('img')) { if (element instanceof HTMLImageElement && (element.alt.startsWith('![](')) || element.classList.contains('in-comment-image') || element.classList.contains('img')) {
expandImage() expandImage()

View File

@ -1,12 +1,4 @@
function expandText(id) { function changeIcon(id) {
document.querySelectorAll(".toggled-visible").forEach(i => {
i.classList.add("d-none")
i.classList.remove("toggled-visible")
});
const toggling = document.getElementById('post-text-'+id)
toggling.classList.toggle('d-none');
toggling.classList.add("toggled-visible")
for (const e of document.getElementsByClassName('text-expand-icon-p_'+id)) for (const e of document.getElementsByClassName('text-expand-icon-p_'+id))
{ {
e.classList.toggle('fa-expand-alt'); e.classList.toggle('fa-expand-alt');

View File

@ -116,7 +116,7 @@
<div class="d-flex" style="flex-basis:146px"></div> <div class="d-flex" style="flex-basis:146px"></div>
<ul class="list-inline text-right d-flex"> <ul class="list-inline text-right d-flex">
{% if p.realbody(v, listing=True) %} {% if p.realbody(v, listing=True) %}
<button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.fullname}}"></i></button> <button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="changeIcon('{{p.id}}')" data-toggleelement="#post-text-{{p.id}}" data-toggleattr="d-none"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.fullname}}"></i></button>
{% endif %} {% endif %}
<a class="list-inline-item" {% if v and v.newtab %}data-target="t" target="_blank"{% endif %} href="{{p.permalink}}"> <a class="list-inline-item" {% if v and v.newtab %}data-target="t" target="_blank"{% endif %} href="{{p.permalink}}">
<i class="fas fa-comment-dots mr-2"></i>{{p.comment_count}} <i class="fas fa-comment-dots mr-2"></i>{{p.comment_count}}
@ -144,7 +144,7 @@
</li> </li>
{% if p.realbody(v, listing=True) %} {% if p.realbody(v, listing=True) %}
<button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="expandText('{{p.id}}')"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.fullname}}"></i></button> <button type="button" class="list-inline-item ml-2" data-nonce="{{g.nonce}}" data-onclick="changeIcon('{{p.id}}')" data-toggleelement="#post-text-{{p.id}}" data-toggleattr="d-none"><i class="fas fa-expand-alt mx-0 text-expand-icon-{{p.fullname}}"></i></button>
{% endif %} {% endif %}
{% if v %} {% if v %}