Fix captcha theming

This commit is contained in:
Jannis Portmann 2023-07-29 12:16:00 +02:00
parent 8d8e1b69d7
commit a5fca29239
2 changed files with 18 additions and 3 deletions

View file

@ -20,8 +20,10 @@
const setTheme = function(theme) {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark')
set_captcha_theme('dark', 0)
} else {
document.documentElement.setAttribute('data-bs-theme', theme)
set_captcha_theme(theme, 0)
}
}
@ -59,4 +61,17 @@
})
})
})
})()
})()
function set_captcha_theme(theme, set_try) {
var captchaDiv = document.getElementById("id_captcha");
if (captchaDiv) {
console.log("Set the theme on try" + set_try)
if (theme == 'dark') {
captchaDiv.classList.add("dark");
} else {
captchaDiv.classList.remove("dark");
}
}
};

View file

@ -46,7 +46,6 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
crossorigin="anonymous"></script>
<script src="{% static 'bootstrap-color-toggler.js' %}"></script>
{% block head %}{% endblock %}
</head>
<body class="d-flex flex-column h-100 justify-content-between {% block background %}{% endblock background %}">
@ -93,7 +92,7 @@
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<li>
<form method="POST" action="{% url 'set_language' %}">
<form method="POST" action="{% url 'save_language' %}">
{% csrf_token %}
<input type="hidden" name="language" value="{{ language.code }}" />
<button class="dropdown-item d-flex align-items-center {% if language.code == LANGUAGE_CODE %} active{% endif %}"
@ -215,5 +214,6 @@
</div>
</div>
</footer>
<script src="{% static 'bootstrap-color-toggler.js' %}"></script>
</body>
</html>