diff --git a/cara/apps/calculator/static/js/form.js b/cara/apps/calculator/static/js/form.js index 26e72eea..568f2c45 100644 --- a/cara/apps/calculator/static/js/form.js +++ b/cara/apps/calculator/static/js/form.js @@ -287,6 +287,22 @@ function on_short_range_option_change() { }) } +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 +759,13 @@ $(document).ready(function () { // Call the function now to handle forward/back button presses in the browser. on_short_range_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..78d0114f 100644 --- a/cara/apps/templates/base/calculator.form.html.j2 +++ b/cara/apps/templates/base/calculator.form.html.j2 @@ -476,25 +476,27 @@
- - + + - +

- Duration (minutes): -
+
@@ -525,17 +527,18 @@
- + - +

+