diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index 26e72eea..655ff5ac 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -160,8 +160,6 @@ function require_lunch(id, option) { require_input_field(startID, option); require_input_field(finishID, option); - set_disabled_status(startID, !option); - set_disabled_status(finishID, !option); if (!option) { $(finishID).removeClass("red_border finish_time_error lunch_break_error"); @@ -287,6 +285,33 @@ function on_short_range_option_change() { }) } +function on_lunch_break_option_change() { + all_lunch_breaks = [$('input[type=radio][name=exposed_lunch_option]'), $('input[type=radio][name=infected_lunch_option]')]; + for (lunch_break of all_lunch_breaks) { + lunch_break.each(function() { + children = getChildElement($(this)); + this.checked ? children.show() : children.hide(); + require_fields(this); + }) + } +} + +function on_coffee_break_option_change() { + all_coffee_breaks = [$('input[type=radio][name=exposed_coffee_break_option]'), $('input[type=radio][name=infected_coffee_break_option]')]; + for (coffee_breaks of all_coffee_breaks) { + coffee_breaks.each(function() { + children = getChildElement($(this)); + if (this.checked && children.length) { + children.show(); + return false; + } + else { + children.hide(); + } + }) + } +} + /* -------UI------- */ function show_disclaimer() { @@ -743,6 +768,20 @@ $(document).ready(function () { // Call the function now to handle forward/back button presses in the browser. on_short_range_option_change(); + // When a lunch_option changes we want to make its respective children + // to show/hide + $("input[type=radio][name=exposed_lunch_option]").change(on_lunch_break_option_change); + $("input[type=radio][name=infected_lunch_option]").change(on_lunch_break_option_change); + // Call the function now to handle forward/back button presses in the browser. + on_lunch_break_option_change(); + + // When the coffee_break_option changes we want to make its respective + // children show/hide + $("input[type=radio][name=exposed_coffee_break_option]").change(on_coffee_break_option_change); + $("input[type=radio][name=infected_coffee_break_option]").change(on_coffee_break_option_change); + // Call the function now to handle forward/back button presses in the browser. + on_coffee_break_option_change(); + // Setup the maximum number of people at page load (to handle back/forward), // and update it when total people is changed. setMaxInfectedPeople(); diff --git a/cara/apps/templates/base/calculator.form.html.j2 b/cara/apps/templates/base/calculator.form.html.j2 index 3b494d0f..0329d845 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/cara/apps/templates/base/calculator.form.html.j2 @@ -455,46 +455,52 @@
- Lunch break: - - - -
-
- Start: -
-
- Finish:
+
Lunch break:
+
+ + + +
+
+
+
+ Start: +
+
+ Finish:
+
-
- Coffee Breaks: +
Coffee Breaks:
+
+ + + + + +
+
-
- - - - - -
-
-
-
- - Duration (minutes): -
+

@@ -502,47 +508,54 @@
Infected person(s) breaks:
- Lunch break: - - - -
-
+
Lunch break:
+
+ + + +
+
+
+
- Start: + Start:
- Finish:
+ Finish:
-
- Coffee Breaks: -
-
- - - - - -
-
+
Coffee Breaks:
+
+ + + + + +
+

- Duration (minutes): -
+