summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2016-05-01 14:32:19 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2016-05-01 14:32:19 +0200
commitd66ef2928b913b6eccb0ab05c95996dbea922773 (patch)
treecdc8d752274fdf1e0f2b28303fb4bbb1951ab9d2 /templates
parent78b318d350e404d2fccf174242638bcf4aca2f57 (diff)
downloadkosten-d66ef2928b913b6eccb0ab05c95996dbea922773.tar.gz
kosten-d66ef2928b913b6eccb0ab05c95996dbea922773.tar.bz2
kosten-d66ef2928b913b6eccb0ab05c95996dbea922773.zip
Overhaul js handling
Diffstat (limited to '')
-rw-r--r--templates/expenses/add.jinja6
-rw-r--r--templates/expenses/show.jinja6
-rw-r--r--templates/js.jinja26
-rw-r--r--templates/layout.jinja9
-rw-r--r--templates/stats/show.jinja7
5 files changed, 35 insertions, 19 deletions
diff --git a/templates/expenses/add.jinja b/templates/expenses/add.jinja
index 0941c3a..027c845 100644
--- a/templates/expenses/add.jinja
+++ b/templates/expenses/add.jinja
@@ -6,11 +6,7 @@
{% endblock %}
{% set JSFunction = "addJS" %}
-
-{% block js %}
- {{ super() }}
- <script type="text/javascript" src="{{ "jqueryui/jquery-ui.js" | static_url }}"></script>
-{% endblock %}
+{% set additionalJS = "jqueryui" %}
{% block style %}
{{ super() }}
diff --git a/templates/expenses/show.jinja b/templates/expenses/show.jinja
index e6c40de..59da032 100644
--- a/templates/expenses/show.jinja
+++ b/templates/expenses/show.jinja
@@ -2,11 +2,7 @@
{% from "macros.jinja" import left_arrow, right_arrow, colorize %}
{% set JSFunction = "showJS" %}
-
-{% block js %}
- {{ super() }}
- <script type="text/javascript" src="{{ "js/highstock-2.1.5.js" | static_url }}"></script>
-{% endblock %}
+{% set additionalJS = "highstock" %}
{% block heading %}
{% if exps | length > 1 %}
diff --git a/templates/js.jinja b/templates/js.jinja
new file mode 100644
index 0000000..db26182
--- /dev/null
+++ b/templates/js.jinja
@@ -0,0 +1,26 @@
+{% set js_lib = {
+ "kosten" : "js/kosten.js",
+ "highstock" : "js/highstock-4.2.2.js",
+ "jquery" : "js/jquery-1.11.2.min.js",
+ "jqueryui" : "jqueryui/jquery-ui.js"
+ }
+%}
+
+{% macro script(name) %}
+ {% if name in js_lib %}
+ <script type="text/javascript" src="{{ js_lib[name] | static_url }}"></script>
+ {% endif %}
+{% endmacro %}
+
+{% macro scripts(names) %}
+ {% if names is not string %}
+ {% for name in names %}
+ {{ script(name) }}
+ {% endfor %}
+ {% else %}
+ {{ script(names) }}
+ {% for name in varargs %}
+ {{ script(name) }}
+ {% endfor %}
+ {% endif %}
+{% endmacro %}
diff --git a/templates/layout.jinja b/templates/layout.jinja
index a79785f..e215c3c 100644
--- a/templates/layout.jinja
+++ b/templates/layout.jinja
@@ -1,3 +1,4 @@
+{% from 'js.jinja' import scripts %}
<!doctype html>
<html>
<head>
@@ -69,10 +70,12 @@
</div>
{% if not g.is_mobile %}
{% block js %}
- <script type="text/javascript" src="{{ "js/jquery-1.11.2.min.js" | static_url }}"></script>
- <script type="text/javascript" src="{{ "js/kosten.js" | static_url }}"></script>
+ {{ scripts("jquery", "kosten") }}
{% endblock %}
- {% if JSFunction %}<script type="text/javascript">{{ JSFunction }}()</script> {% endif %}
+ {% if additionalJS %}{{ scripts(additionalJS) }}{% endif %}
+ {% if JSFunction %}
+ <script type="text/javascript">{{ JSFunction }}()</script>
+ {% endif %}
{% endif %}
</body>
</html>
diff --git a/templates/stats/show.jinja b/templates/stats/show.jinja
index 1de1dcc..859a80b 100644
--- a/templates/stats/show.jinja
+++ b/templates/stats/show.jinja
@@ -1,12 +1,7 @@
{% extends "layout.jinja" %}
{% set JSFunction = "statJS" %}
-
-{% block js %}
- {{ super() }}
- <script type="text/javascript" src="{{ "js/highstock-2.1.5.js" | static_url }}"></script>
- <script type="text/javascript" src="{{ "jqueryui/jquery-ui.js" | static_url }}"></script>
-{% endblock %}
+{% set additionalJS = ["highstock", "jqueryui"] %}
{% block style %}
{{ super() }}