-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
179 lines (164 loc) · 5.08 KB
/
test.html
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="prototype.js">/* */</script>
<script type="text/javascript" src="effects.js">/* */</script>
<script type="text/javascript" src="CheckBoxGroup.js">/* */</script>
<style>
body {
font-family : "Bitstream Vera Sans", "Lucida sans";
font-size : 14px;
}
h2 {
font-style : italic;
margin : 32px 0px 0px 0px;
}
fieldSet#E-group {
border : 1px solid #CC6666;
padding : 0px;
}
fieldSet#E-group legend {
margin : 0px 0px 0px 3px;
padding : 0px 8px;
font-variant : small-caps;
}
</style>
</head>
<body>
<h1>CheckBoxGroup</h1>
<h2>"exclusive" mode</h2>
<p>
<u>Behavior</u>: the master check box will be unchecked as soon as one check box is unchecked.
It will be checked back only if the group is completed.
</p>
<ul>
<li>
<input id="A-masterCheckBox" type="checkbox"/>
<b><label for="A-masterCheckBox">un/check all</label></b>
</li>
<li>
<input id="A-checkBox1" type="checkbox"/>
<label for="A-checkBox1">option #1</label>
</li>
<li>
<input id="A-checkBox2" type="checkbox"/>
<label for="A-checkBox2">option #2</label>
</li>
<li>
<input id="A-checkBox3" type="checkbox"/>
<label for="A-checkBox3">option #3</label>
</li>
</ul>
<h2>"non-exclusive" mode</h2>
<p>
<u>Behavior</u>: the master check box will be unchecked when the selection is empty.
It will be checked back as soon as one check box of the group is checked.
</p>
<ul>
<li>
<input id="B-masterCheckBox" type="checkbox"/>
<b><label for="B-masterCheckBox">un/check all</label></b>
</li>
<li>
<input id="B-checkBox1" type="checkbox"/>
<label for="B-checkBox1">option #1</label>
</li>
<li>
<input id="B-checkBox2" type="checkbox"/>
<label for="B-checkBox2">option #2</label>
</li>
<li>
<input id="B-checkBox3" type="checkbox"/>
<label for="B-checkBox3">option #3</label>
</li>
</ul>
<h2>listener</h2>
<p><u>Activation</u>: unchek all the check boxes</p>
<ul>
<li>
<input id="C-checkBox1" type="checkbox" checked="true"/>
<label for="C-checkBox1">option #1</label>
</li>
<li>
<input id="C-checkBox2" type="checkbox" checked="true"/>
<label for="C-checkBox2">option #2</label>
</li>
<li>
<input id="C-checkBox3" type="checkbox" checked="true"/>
<label for="C-checkBox3">option #3</label>
</li>
</ul>
<h2>virtual event using "click();"</h2>
<ul>
<li>
<input id="D-masterCheckBox" type="checkbox"/>
<b><label for="D-masterCheckBox">un/select all</label></b>
</li>
<li>
<input id="D-checkBox1" type="checkbox"/>
<label for="D-checkBox1">option #1</label>
<button onclick="$('D-checkBox1').click();">click();</button>
</li>
<li>
<input id="D-checkBox2" type="checkbox"/>
<label for="D-checkBox2">option #2</label>
<button onclick="$('D-checkBox2').click();">click();</button>
</li>
<li>
<input id="D-checkBox3" type="checkbox"/>
<label for="D-checkBox3">option #3</label>
<button onclick="$('D-checkBox3').click();">click();</button>
</li>
</ul>
<h2>"getGroup" method</h2>
<p>
Every check box can access its associated group by using the "getGroup" method.
Here, when the user clicks on a check-box, the group (actually the field-set enclosing the group check-boxes) is highlighted.
</p>
<fieldSet id="E-group">
<legend>options</option>
<ul>
<li>
<input id="E-checkBox1" type="checkbox" checked="true"/>
<label for="E-checkBox1">option #1</label>
</li>
<li>
<input id="E-checkBox2" type="checkbox" checked="true"/>
<label for="E-checkBox2">option #2</label>
</li>
<li>
<input id="E-checkBox3" type="checkbox" checked="true"/>
<label for="E-checkBox3">option #3</label>
</li>
</ul>
</fieldSet>
<script type="text/javascript">
var groupA = new CheckBoxGroup(/^A-checkBox([0-9]+)$/, "A-masterCheckBox");
var groupB = new CheckBoxGroup(/^B-checkBox([0-9]+)$/, "B-masterCheckBox");
groupB.setExclusive(false);
var groupC = new CheckBoxGroup(/^C-checkBox([0-9]+)$/);
groupC.addListener({
notifyChange : function(event) {
if(groupC.getSelection().length == 0) {
var checkBox = event.getTarget();
var label = $$("label[for='" + checkBox.id + "']")[0];
if(confirm("You unchecked all options, are you sure you of this choice?")) {
alert("OK then, you've just unchecked '" + label.firstChild.nodeValue + "'.");
}
}
}
});
var groupD = new CheckBoxGroup(/^D-checkBox([0-9]+)$/, "D-masterCheckBox");
var groupE = new CheckBoxGroup(/^E-checkBox([0-9]+)$/);
groupE.addListener({
notifyChange: function(event) {
var checkBox = event.getTarget();
var group = checkBox.getGroup();
if(group) {
new Effect.Highlight($("E-group"), {startcolor : "#FFC0C0"});
}
}
});
</script>
</body>
</html>