mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
Ensure that CW-expander is present when threads page is AJAX-loaded
This commit is contained in:
parent
6e087eb45f
commit
4f8bba7765
@ -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">
|
||||
{% endfor %}
|
||||
|
||||
|
||||
{% if not preferences.theme.is_brutalist %}
|
||||
<script type="application/javascript">
|
||||
Intercooler.ready(expandCWButtonPrepare);
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block page_scripts_inline %}
|
||||
<script type="application/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
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');
|
||||
});
|
||||
};
|
||||
});
|
||||
document.addEventListener('DOMContentLoaded', expandCWButtonPrepare);
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
@ -144,7 +144,7 @@
|
||||
ic-target="#main"
|
||||
ic-select-from-response="#main"
|
||||
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"">
|
||||
thread
|
||||
</a>
|
||||
|
Loading…
Reference in New Issue
Block a user