-
Benjamin Hättasch authored
Ask user if they really want to change the language as it will clear the form as soon as the main form on the page was edited at least once. Fixes #80
Benjamin Hättasch authoredAsk user if they really want to change the language as it will clear the form as soon as the main form on the page was edited at least once. Fixes #80
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
base.html 3.59 KiB
{% load static %}
{% load i18n %}
{% load bootstrap4 %}
{% load fontawesome_5 %}
{% load tags_AKModel %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
{% block meta %}{% endblock%}
<title>{% block title %}AK Planning{% endblock %}</title>
{# Load Bootstrap CSS and JavaScript as well as font awesome #}
{% bootstrap_css %}
{% bootstrap_javascript jquery='slim' %}
{% fontawesome_5_static %}
<link rel="stylesheet" href="{% static 'common/css/custom.css' %}">
<script type='text/javascript'>
var changed_form = false;
$(document).ready(function() {
// Ask before changing language if user changed main form on page
$("#language-switcher").submit(function(e){
if(changed_form) {
if(!confirm("{% trans 'Are you sure you want to change the language now? This will clear the form!' %}"))
e.preventDefault(e);
}
});
// Remember any main form edits/changes
$("form.post-form :input").change(function(){
if($(this).val() != '')
changed_form = true;
});
});
</script>
{% block imports %}{% endblock %}
</head>
<body>
{% block language-switcher %}
<!-- language switcher -->
<div class="container" style="margin-top:20px">
<form action="{% url 'set_language' %}"
method="post"
class="form-inline"
name="language-form"
id="language-switcher"
style="flex-direction: column;">
{% csrf_token %}
<input name="next" type="hidden" value="{{ request.path }}" />
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
<div style="align-self: end;">
{% for language in languages %}
<button type="submit"
class="btn {% if language.code == LANGUAGE_CODE %}btn-info{% else %}btn-outline-info{% endif %}"
name="language"
value="{{ language.code }}"
style="align-self: end;">
{{ language.code | upper }}