CXM_jq_radio.anubis
2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Created by PyramIDE.
* User: フランスのトトロ
* Date: 28/06/2015
* Time: 02:22
* © Calexium
*/
transmit calexium_lib/web/CXM_making_a_web_site.anubis
transmit calexium_lib/web/CXM_jquery.anubis
transmit calexium_lib/web/jQuery/CXM_jquery_button.anubis
transmit calexium_lib/web/jQuery/CXM_jquery_icons.anubis
transmit calexium_lib/web/js_tools.anubis
transmit tools/basis.anubis
transmit system/string.anubis
transmit tools/random.anubis
public type RadioGroup:
group(String name),
none.
define String
radio_init_script
(
String radio_id,
RadioGroup radio_group,
Bool initial_state
) =
"var radio = $('#" + radio_id + "');" +
if radio_group is
{
group(name) then
"radio.addClass('radio-group-" + name + "');",
none then
""
} +
if initial_state then
"radio.addClass('checked');"
else
"radio.addClass('unchecked');".
define String
radio_onclick_script
(
String radio_id,
RadioGroup radio_group,
String on_script
) =
"
var radio = $('#" + radio_id + "');
if (radio.hasClass('checked')) return;
" +
if radio_group is
{
group(name) then
with jq_selector = "$('.radio-group-" + name + ":not(#" + radio_id + ")')",
jq_selector + ".addClass('unchecked').removeClass('checked');",
none then
""
} +
"radio.removeClass('unchecked');
radio.addClass('checked');" + on_script.
public define HTML_Partial_Content
jq_img_radio
(
String radio_id,
RadioGroup radio_group,
Bool initial_state,
//Bool multi_select_with_shift,
String image_url,
String checkbox_label,
String on_script,
Icon_orientation orientation
) =
partial_content(
[
js_inline(jquery_ready(radio_init_script(radio_id, radio_group, initial_state)))
],
jquery_button(jquery_img_button(image_url, checkbox_label, radio_id, jQuery_actioner(same, jqscript, radio_onclick_script(radio_id, radio_group, on_script)), orientation))
).
public define HTML_Partial_Content
jq_img_radio
(
String radio_id,
Bool initial_state,
String image_url,
String checkbox_label,
String script,
Icon_orientation orientation
) =
jq_img_radio(radio_id, none, initial_state, image_url, checkbox_label, script, orientation).