From 0fc28f129bd263b51a4b42f640d5a2a5c52e57cc Mon Sep 17 00:00:00 2001 From: Luis Aleixo Date: Fri, 10 Jun 2022 16:08:07 +0200 Subject: [PATCH] Input fields with units (and respective resizing adjustments) --- cara/apps/calculator/static/js/form.js | 25 +++++++-- .../templates/base/calculator.form.html.j2 | 53 +++++++++---------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index e4597acc..dc20b3b4 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -183,7 +183,6 @@ function require_mask(option) { function require_hepa(option) { require_input_field("#hepa_amount", option); - set_disabled_status("#hepa_amount", !option); } function require_input_field(id, option) { @@ -236,6 +235,20 @@ function on_ventilation_type_change() { }); } +function on_hepa_option_change() { + hepa_option = $('input[type=radio][name=hepa_option]') + hepa_option.each(function (index) { + if (this.checked) { + getChildElement($(this)).show(); + require_fields(this); + } + else { + getChildElement($(this)).hide(); + require_fields(this); + } + }) +} + function on_wearing_mask_change() { wearing_mask = $('input[type=radio][name=mask_wearing_option]') wearing_mask.each(function (index) { @@ -711,6 +724,12 @@ $(document).ready(function () { // Call the function now to handle forward/back button presses in the browser. on_ventilation_type_change(); + // When the hepa filtration option changes we want to make its respective + // children show/hide. + $("input[type=radio][name=hepa_option]").change(on_hepa_option_change); + // Call the function now to handle forward/back button presses in the browser. + on_hepa_option_change(); + // When the mask_wearing_option changes we want to make its respective // children show/hide. $("input[type=radio][name=mask_wearing_option]").change(on_wearing_mask_change); @@ -861,8 +880,8 @@ $(document).ready(function () {
-
-

+
+

diff --git a/cara/apps/templates/base/calculator.form.html.j2 b/cara/apps/templates/base/calculator.form.html.j2 index dd43228d..294cda4f 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/cara/apps/templates/base/calculator.form.html.j2 @@ -88,11 +88,11 @@
-
+
- +
-
+
@@ -101,7 +101,7 @@
- +
@@ -109,7 +109,7 @@
- +
@@ -189,21 +189,21 @@
HEPA filtration:
-
-
- - - - -
-
- -
-
+
+ + + + +
+
+
+
+

Face masks: