Browse Source

DIV-640: Only hide the fact sheet if none is selected otherwise show it if any of the other check boxes are selected

* introduced the data-reveal_control_group data attribute which allows user to associate a group of checkbox items that should be treated as a single reveal group
pull/160/head
Benard Ebinu 8 years ago
parent
commit
9a3e38e1ed
2 changed files with 20 additions and 9 deletions
  1. +16
    -5
      edivorce/apps/core/static/js/functions.js
  2. +4
    -4
      edivorce/apps/core/templates/question/06_children_income_expenses.html

+ 16
- 5
edivorce/apps/core/static/js/functions.js View File

@ -3,12 +3,16 @@
// data-target_id: id of information section
// data-reveal_target: reveal target_id section if true
// data-related_id: id of information section which needed to be hide when target_id section is shown or vice versa
// data-reveal_control_group: the selector for checkbox items that all behave as one group. As long as one of them
// is checked, the target_id or target_class will be shown. Otherwise
// if they are all unchecked, the target_id will be hidden.
var reveal = function(el) {
var id = '#' + el.data("target_id");
var css_class = el.data("target_class");
var related_id = el.data("related_id");
var reveal_condition = el.data("reveal_condition");
var invert_target = el.data("invert_target");
var reveal_control_group = el.data("reveal_control_group");
var should_reveal = true;
@ -54,7 +58,7 @@ var reveal = function(el) {
}
if (should_reveal) {
showHideTargetId(el, id, related_id);
showHideTargetId(el, id, related_id, reveal_control_group);
showHideRevealClass(el, css_class);
if (el.prop('name') === "provide_certificate_later" || el.prop('name') === "original_marriage_certificate") {
@ -69,20 +73,27 @@ var reveal = function(el) {
};
// hide or show based on target id
var showHideTargetId = function(el, id, related_id) {
var showHideTargetId = function(el, id, related_id, reveal_control_group) {
if (el.data("reveal_target") === true && el.prop('checked')) {
$(id).show();
if (related_id !== undefined){
if (related_id !== undefined) {
$('#' + related_id).hide();
}
if (id === "#has_children"){
if (id === "#has_children") {
reveal($("input[name=number_children_over_19]"));
}
// reveal nested question as well
if (id ==="#marriage_certificate"){
if (id === "#marriage_certificate") {
reveal($("input[name=provide_certificate_later]:checked"));
}
} else if (reveal_control_group !== undefined) {
if ($(reveal_control_group).is(':checked').length === 0) {
$(id).hide();
if (related_id !== undefined){
$('#' + related_id).show();
}
}
} else {
$(id).hide();
if (related_id !== undefined){


+ 4
- 4
edivorce/apps/core/templates/question/06_children_income_expenses.html View File

@ -874,12 +874,12 @@
</label>
</div>
<div class="checkbox">
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Children's Child Care" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" %}
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Children's Child Care" class="positive-reveal" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" data_reveal_control_group=".positive-reveal" %}
<b>Children's Child Care</b>
</label>
</div>
<div class="checkbox">
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Medical" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" %}
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Medical" class="positive-reveal" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" data_reveal_control_group=".positive-reveal"%}
<b>Medical</b>
</label>
</div>
@ -891,7 +891,7 @@
drugs, hearing aids, glasses, and contact lenses
</p>
<div class="checkbox">
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Education" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" %}
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Education" class="positive-reveal" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" data_reveal_control_group=".positive-reveal"%}
<b>Education</b>
</label>
</div>
@ -901,7 +901,7 @@
before the separation and the parents can afford the expense
</p>
<div class="checkbox">
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Extraordinary extracurricular activity expenses" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" %}
<label>{% input_field type="checkbox" name="special_extraordinary_expenses" value="Extraordinary extracurricular activity expenses" class="positive-reveal" data_checkbox_radio="true" data_checkbox_radio_state_set="true" data_target_id="fact_sheet_a" data_reveal_target="true" data_reveal_control_group=".positive-reveal"%}
<b>Extraordinary extracurricular activity expenses</b>
</label>
</div>


Loading…
Cancel
Save