From 095492203f500e1173416e934c2f5377b2b980dd Mon Sep 17 00:00:00 2001 From: Oliver Date: Sat, 28 Apr 2018 12:45:12 +1000 Subject: [PATCH] Simplified javascript templating - Load js modules in block js_load - Write $(document).ready script in block js_ready - Write any other js in block_js --- InvenTree/build/templates/build/detail.html | 14 ++++---------- InvenTree/build/templates/build/index.html | 11 +++-------- InvenTree/company/templates/company/detail.html | 13 ++++--------- .../company/templates/company/detail_part.html | 14 +++----------- InvenTree/company/templates/company/index.html | 11 +++-------- .../company/templates/company/partdetail.html | 12 +++--------- InvenTree/part/templates/part/bom.html | 11 +++-------- InvenTree/part/templates/part/build.html | 11 +++-------- .../part/templates/part/category_detail.html | 10 +++------- InvenTree/part/templates/part/detail.html | 9 +++------ InvenTree/part/templates/part/index.html | 15 ++++++++------- InvenTree/part/templates/part/stock.html | 11 +++-------- InvenTree/part/templates/part/supplier.html | 13 +++---------- InvenTree/stock/templates/stock/index.html | 13 +++---------- InvenTree/stock/templates/stock/item.html | 11 +++-------- InvenTree/stock/templates/stock/location.html | 12 +++--------- InvenTree/templates/InvenTree/index.html | 2 +- InvenTree/templates/base.html | 13 ++++++++++++- 18 files changed, 68 insertions(+), 138 deletions(-) diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 8573fb062c..2f1de7d6fb 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -64,14 +64,12 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} +{% endblock %} - - -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/InvenTree/build/templates/build/index.html b/InvenTree/build/templates/build/index.html index 329c2591af..eba368b601 100644 --- a/InvenTree/build/templates/build/index.html +++ b/InvenTree/build/templates/build/index.html @@ -22,15 +22,10 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/detail.html b/InvenTree/company/templates/company/detail.html index f95482e3c6..b8fb3deea4 100644 --- a/InvenTree/company/templates/company/detail.html +++ b/InvenTree/company/templates/company/detail.html @@ -33,11 +33,10 @@ {% endblock %} -{% block javascript %} +{% block js_load %} - - - - + }); {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/detail_part.html b/InvenTree/company/templates/company/detail_part.html index c9de89ceda..8d9181707b 100644 --- a/InvenTree/company/templates/company/detail_part.html +++ b/InvenTree/company/templates/company/detail_part.html @@ -39,15 +39,11 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/index.html b/InvenTree/company/templates/company/index.html index 42180722b7..16072b3b7f 100644 --- a/InvenTree/company/templates/company/index.html +++ b/InvenTree/company/templates/company/index.html @@ -36,13 +36,11 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/company/templates/company/partdetail.html b/InvenTree/company/templates/company/partdetail.html index 18fd806a9c..5afc9e8a6a 100644 --- a/InvenTree/company/templates/company/partdetail.html +++ b/InvenTree/company/templates/company/partdetail.html @@ -38,13 +38,10 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/bom.html b/InvenTree/part/templates/part/bom.html index 1157279312..dc12ffccb5 100644 --- a/InvenTree/part/templates/part/bom.html +++ b/InvenTree/part/templates/part/bom.html @@ -47,13 +47,11 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/build.html b/InvenTree/part/templates/part/build.html index 6b7b74d624..28432cadb0 100644 --- a/InvenTree/part/templates/part/build.html +++ b/InvenTree/part/templates/part/build.html @@ -39,12 +39,10 @@ {% endblock %} -{% block javascript %} - +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/category_detail.html b/InvenTree/part/templates/part/category_detail.html index 1eff2e013a..030c40a935 100644 --- a/InvenTree/part/templates/part/category_detail.html +++ b/InvenTree/part/templates/part/category_detail.html @@ -35,12 +35,11 @@ {% endblock %} -{% block javascript %} +{% block js_load %} `` - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html index 33d2ec573f..d73fa5f503 100644 --- a/InvenTree/part/templates/part/detail.html +++ b/InvenTree/part/templates/part/detail.html @@ -88,12 +88,12 @@ {% endblock %} -{% block javascript %} +{% block js_load %} +{% endblock %} +{% block js_ready %} - - {% endblock %} diff --git a/InvenTree/part/templates/part/index.html b/InvenTree/part/templates/part/index.html index 73cc9f5eba..27d169bcce 100644 --- a/InvenTree/part/templates/part/index.html +++ b/InvenTree/part/templates/part/index.html @@ -1,6 +1,10 @@ {% extends "base.html" %} {% load static %} +{% block css %} + +{% endblock %} + {% block content %} {% include "part/cat_link.html" with category=category %} @@ -23,13 +27,13 @@ {% endblock %} -{% block javascript %} +{% block js_load %} - - +{% endblock %} +{% block js_ready %} $('#part-list').footable(); $("#create-cat").click(function() { @@ -43,7 +47,4 @@ $(document).ready(function () { $("#create-part").click(function() { launchModalForm("#modal-form", "{% url 'part-create' %}"); }); -}); - - {% endblock %} diff --git a/InvenTree/part/templates/part/stock.html b/InvenTree/part/templates/part/stock.html index d07f8cf2b6..9dbc1e6c9e 100644 --- a/InvenTree/part/templates/part/stock.html +++ b/InvenTree/part/templates/part/stock.html @@ -49,14 +49,12 @@ {% endblock %} -{% block javascript %} +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/supplier.html b/InvenTree/part/templates/part/supplier.html index 5265ea14f1..a6a5153a20 100644 --- a/InvenTree/part/templates/part/supplier.html +++ b/InvenTree/part/templates/part/supplier.html @@ -39,14 +39,12 @@ {% endblock %} -{% block javascript %} +{% block js_load %} `` - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/index.html b/InvenTree/stock/templates/stock/index.html index 08bc715f70..6c63af81d7 100644 --- a/InvenTree/stock/templates/stock/index.html +++ b/InvenTree/stock/templates/stock/index.html @@ -48,14 +48,12 @@ {% endblock %} -{% block javascript %} +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html index cfc5708297..27fff0ef23 100644 --- a/InvenTree/stock/templates/stock/item.html +++ b/InvenTree/stock/templates/stock/item.html @@ -102,13 +102,12 @@ {% endblock %} -{% block javascript %} +{% block js_load %} - - - {% endblock %} \ No newline at end of file diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html index b9716164b5..c0dbbabe12 100644 --- a/InvenTree/stock/templates/stock/location.html +++ b/InvenTree/stock/templates/stock/location.html @@ -27,14 +27,12 @@ {% endblock %} -{% block javascript %} +{% block js_load %} - - - {% endblock %} diff --git a/InvenTree/templates/InvenTree/index.html b/InvenTree/templates/InvenTree/index.html index 79f5e50a5d..ff7d214cf2 100644 --- a/InvenTree/templates/InvenTree/index.html +++ b/InvenTree/templates/InvenTree/index.html @@ -5,6 +5,6 @@ {% endblock %} -{% block javascript %} +{% block js_load %} {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index 6b2ed951f2..4c56e599d4 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -41,9 +41,20 @@ InvenTree +{% block js_load %} +{% endblock %} -{% block javascript %} + + +{% block js %} {% endblock %}