Skip to content
Snippets Groups Projects
Commit 10667a08 authored by Nils Steinger's avatar Nils Steinger Committed by Benjamin Hättasch
Browse files

Extract fullcalendar import as reusable snippet

This removes support for the explicit "locale: '{{ LANGUAGE_CODE }}'" setting,
but that should not be a problem as https://fullcalendar.io/docs/v3/locale
states:
> If you are simply loading one locale, you do not need to specify the locale
> option.
parent 27267e92
Branches
No related tags found
1 merge request!74Improvements to fullcalendar loading
{% load static %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
{% with 'AKPlan/vendor/fullcalendar-scheduler/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
{% if LANGUAGE_CODE != "en" %}
{# Locale 'en' is included in main.js and does not exist separately #}
<script src="{% static locale_file %}"></script>
{% endif %}
{% endwith %}
{% load static %} {% load static %}
{% load tz %} {% load tz %}
{% load i18n %} {% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script> {% include "AKPlan/load_fullcalendar.html" %}
<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
{% with 'AKPlan/vendor/fullcalendar-scheduler/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
{% if LANGUAGE_CODE != "en" %}
{# Locale 'en' is included in main.js and does not exist separately #}
<script src="{% static locale_file %}"></script>
{% endif %}
{% endwith %}
<script> <script>
...@@ -22,8 +13,6 @@ ...@@ -22,8 +13,6 @@
// Adapt to timezone of the connected event // Adapt to timezone of the connected event
timeZone: '{{ ak.event.timezone }}', timeZone: '{{ ak.event.timezone }}',
initialView: 'timeGrid', initialView: 'timeGrid',
// Adapt to user selected locale
locale: '{{ LANGUAGE_CODE }}',
// No header, not buttons // No header, not buttons
headerToolbar: false, headerToolbar: false,
aspectRatio: 2.5, aspectRatio: 2.5,
......
...@@ -10,17 +10,7 @@ ...@@ -10,17 +10,7 @@
{% endblock %} {% endblock %}
{% block imports %} {% block imports %}
{% get_current_language as LANGUAGE_CODE %} {% include "AKPlan/load_fullcalendar.html" %}
<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
{% with 'AKPlan/vendor/fullcalendar-scheduler/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
{% if LANGUAGE_CODE != "en" %}
{# Locale 'en' is included in main.js and does not exist separately #}
<script src="{% static locale_file %}"></script>
{% endif %}
{% endwith %}
{% block fullcalendar %}{% endblock %} {% block fullcalendar %}{% endblock %}
{% endblock imports %} {% endblock imports %}
......
...@@ -19,17 +19,7 @@ ...@@ -19,17 +19,7 @@
<link rel="stylesheet" href="{% static 'common/css/custom.css' %}"> <link rel="stylesheet" href="{% static 'common/css/custom.css' %}">
{% get_current_language as LANGUAGE_CODE %} {% include "AKPlan/load_fullcalendar.html" %}
<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
{% with 'AKPlan/vendor/fullcalendar-scheduler/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
{% if LANGUAGE_CODE != "en" %}
{# Locale 'en' is included in main.js and does not exist separately #}
<script src="{% static locale_file %}"></script>
{% endif %}
{% endwith %}
<script> <script>
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
...@@ -39,8 +29,6 @@ ...@@ -39,8 +29,6 @@
timeZone: '{{ event.timezone }}', timeZone: '{{ event.timezone }}',
headerToolbar: false, headerToolbar: false,
themeSystem: 'bootstrap', themeSystem: 'bootstrap',
// Adapt to user selected locale
locale: '{{ LANGUAGE_CODE }}',
slotDuration: '01:00', slotDuration: '01:00',
initialView: 'resourceTimeline', initialView: 'resourceTimeline',
visibleRange: { visibleRange: {
......
...@@ -11,17 +11,7 @@ ...@@ -11,17 +11,7 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
{% get_current_language as LANGUAGE_CODE %} {% include "AKPlan/load_fullcalendar.html" %}
<script src='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.js' %}'></script>
<link href='{% static 'AKPlan/vendor/fullcalendar-scheduler/main.css' %}' rel='stylesheet'/>
{% with 'AKPlan/vendor/fullcalendar-scheduler/locales/'|add:LANGUAGE_CODE|add:'.js' as locale_file %}
{% if LANGUAGE_CODE != "en" %}
{# Locale 'en' is included in main.js and does not exist separately #}
<script src="{% static locale_file %}"></script>
{% endif %}
{% endwith %}
<style> <style>
.unscheduled-slot { .unscheduled-slot {
...@@ -88,8 +78,6 @@ ...@@ -88,8 +78,6 @@
}, },
//aspectRatio: 2, //aspectRatio: 2,
themeSystem: 'bootstrap', themeSystem: 'bootstrap',
// Adapt to user selected locale
locale: '{{ LANGUAGE_CODE }}',
initialView: 'resourceTimelineEventVert', initialView: 'resourceTimelineEventVert',
views: { views: {
resourceTimelineDayHoriz: { resourceTimelineDayHoriz: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment