jq_radio.anubis
3.31 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* Created by PyramIDE.
* User: フランスのトトロ
* Date: 28/06/2015
* Time: 02:22
* © Calexium
*/
transmit xlib/web/making_a_web_site.anubis
transmit xlib/web/jquery.anubis
transmit xlib/web/jQuery/jq_button.anubis
transmit xlib/web/jQuery/jq_icons.anubis
transmit xlib/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
multi_select_script
(
Bool multi_select_with_shift,
String script
) =
if multi_select_with_shift then
"if (!e.shiftKey) {" + script + "} else { window.getSelection().removeAllRanges(); radio.toggleClass('checked').toggleClass('unchecked'); }"
else
script.
define String
radio_onclick_script
(
String radio_id,
RadioGroup radio_group,
Bool multi_select_with_shift,
String on_script
) =
"
var radio = $('#" + radio_id + "');
" +
multi_select_script(multi_select_with_shift,
" 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').addClass('checked');"
) + on_script.
public define HTML
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, multi_select_with_shift, on_script))), orientation))
).
public define HTML
jq_img_radio
(
String radio_id,
RadioGroup radio_group,
Bool initial_state,
String image_url,
String checkbox_label,
String script,
Icon_orientation orientation
) =
jq_img_radio(radio_id, none, initial_state, false, image_url, checkbox_label, script, orientation).
public define HTML
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, false, image_url, checkbox_label, script, orientation).