mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
Don't create expandCWs button multiple times
This commit is contained in:
parent
d9cb4b36e5
commit
3407aa8086
@ -67,31 +67,35 @@ function menuPrepare() {
|
|||||||
|
|
||||||
function expandCWButtonPrepare()
|
function expandCWButtonPrepare()
|
||||||
{
|
{
|
||||||
var theButton = document.createElement('p');
|
var theButton = document.querySelector('#expandCWs');
|
||||||
theButton.textContent = "Expand CWs";
|
if (!theButton) {
|
||||||
theButton.classList.toggle('button');
|
theButton = document.createElement('p');
|
||||||
document.querySelector('#title').insertAdjacentElement('afterend', theButton);
|
theButton.id = "expandCWs";
|
||||||
var details = document.querySelectorAll('details');
|
theButton.textContent = "Expand CWs";
|
||||||
var openState = false;
|
theButton.classList.toggle('button');
|
||||||
|
document.querySelector('#title').insertAdjacentElement('afterend', theButton);
|
||||||
|
var details = document.querySelectorAll('details');
|
||||||
|
var openState = false;
|
||||||
|
|
||||||
if (details != null) {
|
if (details != null) {
|
||||||
theButton.addEventListener('click', function() {
|
theButton.addEventListener('click', function() {
|
||||||
openState = details.item(0).hasAttribute('open');
|
openState = details.item(0).hasAttribute('open');
|
||||||
details.forEach(function ($el) {
|
details.forEach(function ($el) {
|
||||||
if (openState)
|
if (openState)
|
||||||
{
|
{
|
||||||
$el.removeAttribute('open');
|
$el.removeAttribute('open');
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
$el.setAttribute('open', '');
|
$el.setAttribute('open', '');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
openState = !openState;
|
||||||
|
if (openState) { theButton.textContent = 'Collapse CWs'; }
|
||||||
|
else { theButton.textContent = "Expand CWs"; };
|
||||||
|
theButton.classList.toggle('is-active');
|
||||||
});
|
});
|
||||||
openState = !openState;
|
};
|
||||||
if (openState) { theButton.textContent = 'Collapse CWs'; }
|
}
|
||||||
else { theButton.textContent = "Expand CWs"; };
|
|
||||||
theButton.classList.toggle('is-active');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fileButtonUpdaters()
|
function fileButtonUpdaters()
|
||||||
|
@ -36,8 +36,3 @@ mastodon.status_context(<numerical id>)
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block page_scripts_inline %}
|
|
||||||
<script type="application/javascript">
|
|
||||||
document.addEventListener('DOMContentLoaded', expandCWButtonPrepare);
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user