From 31541417083cacdda36f86367f5090e43c135bf4 Mon Sep 17 00:00:00 2001 From: totoro Date: Mon, 14 Mar 2016 22:39:43 +0100 Subject: [PATCH] add radio_button hide show. This allow to show or hide some fields when the radio button is selected or not --- web/CXM_form.anubis | 19 +++++++++++++++++-- web/widgets/button.anubis | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/web/CXM_form.anubis b/web/CXM_form.anubis index 6d24ed2..27ddaee 100644 --- a/web/CXM_form.anubis +++ b/web/CXM_form.anubis @@ -142,6 +142,14 @@ public type CXM_Form_Field: WebArgValue web_arg_value, Bool checked, Mandatory mandatory), + //radio_button_hide_show + radio_button_hide_show( + List(InputAttrs) options, + String label, + WebArgName web_arg_name, + WebArgValue web_arg_value, + Bool checked, + List(CXM_Form_Field) fields), // the same one, but with the tag on the right of the radio_button radio_buttonr (List(InputAttrs) options, String label, @@ -408,12 +416,19 @@ public define HTML_In_Form checkbox_hide_show(options, label, wan, val, checked, fields) then with div_id = generate_random_string(15), sequence([ - check_box([event(onclick, "checkbox_hide_show_element('"+div_id+"', this);")], label, htmlId(""), wan, val, get_Bool(lwa, wan.name, checked)), + check_box([class("in"), event(onclick, "checked_hide_show_element('"+div_id+"', this);")], label, htmlId(""), wan, val, get_Bool(lwa, wan.name, checked)), div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], cxm_format_form_field(ff2, lwa)),fields))) ]), radio_button(options, label, id, wan, val, checked, mand) then - radio_button([class("in") . options], label + star(mand), id, wan, val, get_Bool(lwa, wan.name, checked)), + radio_button([class("in"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);") . options], label + star(mand), id, wan, val, get_Bool(lwa, wan.name, checked)), + + radio_button_hide_show(options, label, wan, val, checked, fields) then + with div_id = generate_random_string(15), + sequence([ + radio_button([data("show_id", div_id), class("in"), event(onclick, "radio_hide_show_group('"+wan.name+"', this);")], label, htmlId(""), wan, val, get_Bool(lwa, wan.name, checked)), + div([id(div_id), style("display:"+if checked then "block" else "none")], sequence(map((CXM_Form_Field ff2) |-> div([class("form_field")], cxm_format_form_field(ff2, lwa)),fields))) + ]), radio_buttonr(options, label, id, wan, val, checked, mand) then radio_button_r([class("in") . options], label + star(mand), id, wan, val, get_Bool(lwa, wan.name, checked)), diff --git a/web/widgets/button.anubis b/web/widgets/button.anubis index 9fdf3a0..987d1fa 100644 --- a/web/widgets/button.anubis +++ b/web/widgets/button.anubis @@ -7,7 +7,7 @@ */ read calexium_lib/web/CXM_making_a_web_site.anubis -read calexium_lib/web/CXM_jquery.anubis +transmit calexium_lib/web/CXM_jquery.anubis read calexium_lib/web/CXM_json.anubis read calexium_lib/web/js_tools.anubis transmit calexium_lib/web/widgets/icons_set.anubis -- libgit2 0.21.4