kadenios/shared/templates/base.html

241 lines
7.9 KiB
HTML
Raw Normal View History

2020-12-19 22:49:50 +01:00
{% load static bulma_utils i18n %}
2020-11-20 19:31:22 +01:00
<!DOCTYPE html>
<html>
2020-12-18 11:48:07 +01:00
<head>
2020-12-20 13:46:25 +01:00
<title>Kadenios</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2020-12-18 11:48:07 +01:00
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
{# CSS #}
2020-12-18 13:53:31 +01:00
<link rel="stylesheet" href="{% static 'css/main.css' %}">
<link rel="stylesheet" href="{% static 'vendor/font-awesome/css/font-awesome.min.css' %}">
<link rel="stylesheet" href="{% static 'vendor/font-awesome/css/solid.min.css' %}">
2020-12-18 11:48:07 +01:00
{# Javascript #}
2020-12-18 13:40:40 +01:00
<script src="{% static 'vendor/jquery/jquery-3.5.1.min.js' %}"></script>
2020-12-18 11:48:07 +01:00
{# <script src="{% static 'elections/js/main.js' %}"></script> #}
<script>
document.addEventListener('DOMContentLoaded', () => {
// Delete notifications
(document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {
var $notification = $delete.parentNode;
$delete.addEventListener('click', () => {
$notification.parentNode.removeChild($notification);
});
});
// Interact with dropdowns
var $dropdowns = document.querySelectorAll('.dropdown:not(.is-hoverable)') || [];
$dropdowns.forEach(($dropdown) => {
$dropdown.addEventListener('click', (event) => {
event.stopPropagation();
$dropdown.classList.toggle('is-active');
});
});
document.addEventListener('click', () => {
$dropdowns.forEach(($dropdown) => {
$dropdown.classList.remove('is-active');
});
});
// Interact with modals
var $modals = document.querySelectorAll('.modal') || [];
var $modalButtons = document.querySelectorAll('.modal-button') || [];
var $modalCloses = document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button-close') || [];
$modalButtons.forEach(function($el) {
$el.addEventListener('click', function() {
var target = $el.dataset.target;
var $target = document.getElementById(target);
document.documentElement.classList.add('is-clipped');
$target.classList.add('is-active');
});
});
$modalCloses.forEach(function($el) {
$el.addEventListener('click', (event) => {
event.stopPropagation();
document.documentElement.classList.remove('is-clipped');
$modals.forEach(function($el) {
$el.classList.remove('is-active');
});
});
});
document.addEventListener('keydown', (event) => {
var e = event || window.event;
if (e.keyCode === 27) {
$dropdowns.forEach(($dropdown) => {
$dropdown.classList.remove('is-active');
});
document.documentElement.classList.remove('is-clipped');
$modals.forEach(function($el) {
$el.classList.remove('is-active');
});
}
});
2021-04-14 03:22:22 +02:00
// Language selection
var $langs = document.querySelectorAll('.dropdown-item.lang-selector') || [];
$langs.forEach($lang => {
$lang.addEventListener('click', () => {
document.getElementById('lang-input').value = $lang.dataset.lang;
document.getElementById('lang-form').submit();
});
});
// Disable button after form submission
var $forms = document.querySelectorAll('form');
$forms.forEach($form => {
const $submit = $form.querySelector('button[type=submit]');
$form.addEventListener('submit', () => {
$submit.classList.add('is-loading');
});
});
});
</script>
2020-12-18 11:48:07 +01:00
{% block extra_head %}{% endblock extra_head %}
</head>
<body>
<nav class="level has-background-primary">
2021-03-20 09:56:25 +01:00
<div class="level-left px-4">
2020-12-19 23:48:18 +01:00
<div class="level-item">
2020-12-21 21:14:52 +01:00
<a href="{% url "kadenios" %}">
<h1 class="has-text-primary-light is-size-1 is-family-secondary">Kadenios</h1>
</a>
2020-12-19 23:48:18 +01:00
</div>
<div class="level-item px-4">
<a href="{% url "election.list" %}">
<h3 class="has-text-primary-light has-text-weight-semibold is-size-3">{% trans "Élections" %}</h3>
</a>
</div>
2020-12-18 11:48:07 +01:00
</div>
2021-03-20 09:56:25 +01:00
<div class="level-right px-5">
2021-04-14 20:51:04 +02:00
{% block auth %}
<div class="level-item">
{% if user.is_authenticated %}
<div class="level is-mobile">
<div class="level-item">
<div class="tag">
{% blocktrans with name=user.base_username connection=user.connection_method %}Connecté·e en tant que {{ name }} par {{ connection }}{% endblocktrans %}
2021-04-14 20:51:04 +02:00
</div>
</div>
<div class="level-item">
<a class="button is-primary" href="{% url 'authens:logout' %}?next={% if view.get_next_url %}{{ view.get_next_url }}{% else %}/{% endif %}">
<span class="icon is-size-1">
<i class="fas fa-sign-out-alt"></i>
</span>
</a>
</div>
</div>
{% else %}
<div class="level-item py-2">
<a class="button" href="{% url 'authens:login' %}?next={{ request.path }}">
<span class="is-size-5">{% trans "Se connecter" %}</span>
<span class="icon is-size-4">
<i class="fas fa-sign-in-alt"></i>
2021-04-14 20:51:04 +02:00
</span>
</a>
</div>
{% endif %}
</div>
{% endblock %}
2021-04-14 03:22:22 +02:00
{# Choix de la langue #}
2021-04-14 20:51:04 +02:00
<div class="level-item">
2021-04-14 03:22:22 +02:00
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as langs %}
<form action="{% url "set_language" %}" method="POST" id="lang-form">
{% csrf_token %}
<input type="hidden" name="language" id="lang-input">
</form>
2021-04-14 20:51:04 +02:00
<div class="dropdown is-hoverable is-right">
2021-04-14 03:22:22 +02:00
<div class="dropdown-trigger">
<a class="button is-primary is-large" aria-haspopup="true" aria-controls="dropdown-menu">
<span class="icon is-size-2">
2021-04-14 03:22:22 +02:00
<i class="fas fa-language"></i>
</span>
</a>
</div>
<div class="dropdown-menu">
<div class="dropdown-content">
{% for lang in langs %}
{% with lang_svg="images/"|add:lang.code|add:".svg" %}
<a class="dropdown-item lang-selector" data-lang="{{ lang.code }}">
<span class="icon-text">
<span class="icon">
<img src="{% static lang_svg %}">
</span>
<span class="ml-1">{{ lang.name_translated }}</span>
</span>
{% endwith %}
</a>
2021-04-14 20:51:04 +02:00
{% if not forloop.last %}
<hr class="dropdown-divider">
{% endif %}
2021-04-14 03:22:22 +02:00
{% endfor %}
</div>
</div>
</div>
</div>
2020-12-18 11:48:07 +01:00
</div>
</nav>
{% block layout %}
<div class="main-content">
<div class="columns is-centered">
2020-12-24 01:10:05 +01:00
<div class="column is-two-thirds-fullhd is-12-desktop is-12-widescreen">
<section class="section pt-3">
{% if messages %}
{% for message in messages %}
<div class="notification is-{{ message.level_tag|bulma_message_tag }} is-light">
{% if 'safe' in message.tags %}
{{ message|safe }}
{% else %}
{{ message }}
{% endif %}
<button class="delete"></button>
</div>
{% endfor %}
2020-11-20 19:31:22 +01:00
{% endif %}
<div class="box">
{% block content %}
{% endblock content %}
</div>
</section>
</div>
2020-11-20 19:31:22 +01:00
</div>
2020-12-18 11:48:07 +01:00
</div>
{% endblock layout %}
<footer class="footer">
<p class="has-text-centered">
2020-12-19 22:49:50 +01:00
{% blocktrans %}Développé par <a class="tag is-light is-danger" href="https://www.eleves.ens.fr/kde">KDEns</a>. En cas de pépin, contacter <span class="tag is-info is-light">klub-dev [at] ens [dot] fr</span>.{% endblocktrans %}
</p>
</footer>
2020-12-18 11:48:07 +01:00
</body>
2020-11-20 19:31:22 +01:00
</html>