mirror of
https://gitlab.com/brutaldon/brutaldon
synced 2025-06-05 21:49:32 +02:00
Ensure that CW-expander is present when threads page is AJAX-loaded
This commit is contained in:
@@ -64,3 +64,32 @@ function menuPrepare() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expandCWButtonPrepare()
|
||||||
|
{
|
||||||
|
var theButton = document.createElement('p');
|
||||||
|
theButton.textContent = "Expand CWs";
|
||||||
|
theButton.classList.toggle('button');
|
||||||
|
document.querySelector('#title').insertAdjacentElement('afterend', theButton);
|
||||||
|
var details = document.querySelectorAll('details');
|
||||||
|
var openState = false;
|
||||||
|
|
||||||
|
if (details != null) {
|
||||||
|
theButton.addEventListener('click', function() {
|
||||||
|
openState = details.item(0).hasAttribute('open');
|
||||||
|
details.forEach(function ($el) {
|
||||||
|
if (openState)
|
||||||
|
{
|
||||||
|
$el.removeAttribute('open');
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$el.setAttribute('open', '');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
openState = !openState;
|
||||||
|
if (openState) { theButton.textContent = 'Collapse CWs'; }
|
||||||
|
else { theButton.textContent = "Expand CWs"; };
|
||||||
|
theButton.classList.toggle('is-active');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@@ -29,37 +29,15 @@ mastodon.status_context(<numerical id>)
|
|||||||
<hr class="is-hidden">
|
<hr class="is-hidden">
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if not preferences.theme.is_brutalist %}
|
||||||
|
<script type="application/javascript">
|
||||||
|
Intercooler.ready(expandCWButtonPrepare);
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block page_scripts_inline %}
|
{% block page_scripts_inline %}
|
||||||
<script type="application/javascript">
|
<script type="application/javascript">
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', expandCWButtonPrepare);
|
||||||
var theButton = document.createElement('p');
|
|
||||||
theButton.textContent = "Expand CWs";
|
|
||||||
theButton.classList.toggle('button');
|
|
||||||
document.querySelector('#title').insertAdjacentElement('afterend', theButton);
|
|
||||||
var details = document.querySelectorAll('details');
|
|
||||||
var openState = false;
|
|
||||||
|
|
||||||
if (details != null) {
|
|
||||||
theButton.addEventListener('click', function() {
|
|
||||||
openState = details.item(0).hasAttribute('open');
|
|
||||||
details.forEach(function ($el) {
|
|
||||||
if (openState)
|
|
||||||
{
|
|
||||||
$el.removeAttribute('open');
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
$el.setAttribute('open', '');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
openState = !openState;
|
|
||||||
if (openState) { theButton.textContent = 'Collapse CWs'; }
|
|
||||||
else { theButton.textContent = "Expand CWs"; };
|
|
||||||
theButton.classList.toggle('is-active');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@@ -144,7 +144,7 @@
|
|||||||
ic-target="#main"
|
ic-target="#main"
|
||||||
ic-select-from-response="#main"
|
ic-select-from-response="#main"
|
||||||
ic-push-url="true"
|
ic-push-url="true"
|
||||||
ic-on-success="afterPage('{{ own_acct.username }}', 'thread');"
|
ic-on-success="afterPage('{{ own_acct.username }}', 'thread')"
|
||||||
ic-indicator="#page-load-indicator"">
|
ic-indicator="#page-load-indicator"">
|
||||||
thread
|
thread
|
||||||
</a>
|
</a>
|
||||||
|
Reference in New Issue
Block a user