mirror of
https://github.com/wger-project/wger.git
synced 2026-02-18 00:17:51 +01:00
refactor: remove the script tag JS and use the new submitLanguageForm function instead
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{% load i18n static %}
|
||||
|
||||
<li>
|
||||
<button class="dropdown-item" type="button" data-language="{{ code }}">
|
||||
<button class="dropdown-item" type="button" onclick="submitLanguageForm('{{ code }}')">
|
||||
<img src="{% static path %}"
|
||||
width="20"
|
||||
alt="{% translate name %}"
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
</script>
|
||||
<script src="{% static 'node/masonry-layout/dist/masonry.pkgd.min.js' %}"></script>
|
||||
<script src="{% static 'js/nutrition.js' %}"></script>
|
||||
<script src="{% static 'js/language.js' %}"></script>
|
||||
{% endcompress %}
|
||||
|
||||
{# this needs to be outside of the compress block! #}
|
||||
@@ -218,23 +219,6 @@
|
||||
{% language_select language %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
<script>
|
||||
document.querySelectorAll('[data-language]').forEach(item => {
|
||||
item.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
const langCode = this.dataset.language;
|
||||
|
||||
if (langCode === '') {
|
||||
// Delete cookie and reload
|
||||
document.cookie = 'django_language=; path=/; max-age=0';
|
||||
window.location.reload();
|
||||
} else {
|
||||
document.getElementById('language-input').value = langCode;
|
||||
document.getElementById('language-form').submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<li>
|
||||
<hr class="dropdown-divider"></hr>
|
||||
|
||||
Reference in New Issue
Block a user