-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
376 lines (345 loc) · 10.8 KB
/
index.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>jQuery UI: Radiobutton- und Checkbox-Replacement</title>
<link rel="stylesheet" href="css/layout.css" type="text/css" media="screen, projection">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
<script src="js-lib/jquery.ui.widget.js" type="text/javascript"></script>
<!-- optional for High Contrast Mode Support -->
<script src="js/jquery.usermode.js" type="text/javascript"></script>
<script src="js/ui.checkbox.js" type="text/javascript"></script>
<style type="text/css">
/*
* The state classes are a little bit complex, because of the doubble class bug in IE6
* The state class looks like this:
*
* .ui-radio-state[-checked][-disabled][-hover] or .ui-checkbox-state[-checked][-disabled][-hover]
*
* Examples:
*
* .ui-radio-state-checked (simply checked)
* .ui-radio-state-checked-hover (checked and hovered/focused)
* .ui-radio-state-hover (unchecked and hovered/focused)
*
* If you don´t have to deal with the doubble class bug of IE6 you can also use the simple ui-checkbox-checked, ui-checkbox-disabled, ui-checkbox-hover state-classnames (or: ui-radio-checked...)
* and the ui-radio/ui-checkbox role-classnames.
*
*/
.ui-radio-state-disabled,
.ui-radio-state-checked-disabled,
.ui-radio-state-disabled-hover,
.ui-radio-state-checked-disabled-hover {
color: #999;
}
span.ui-checkbox,
span.ui-radio {
display: block;
float: left;
width: 16px;
height: 16px;
background: url(icon_checkbox.png) 0 -40px no-repeat;
}
span.ui-helper-hidden {
display: none;
}
label {
padding: 2px;
}
span.ui-radio-state-hover,
span.ui-checkbox-state-hover {
background-position: 0 -114px;
}
span.ui-checkbox-state-checked {
background-position: 0 -1px;
}
span.ui-checkbox-state-checked-hover {
background-position: 0 -75px;
}
span.ui-radio-state-checked-disabled-hover,
span.ui-radio-state-checked-disabled,
span.ui-radio-state-checked {
background-position: 0 -161px;
}
span.ui-radio-state-checked-hover {
background-position: 0 -200px;
}
.ui-radio-disabled,
.ui-checkbox-disabled {
opacity: 0.7;
}
</style>
<script type="text/javascript">
$(function(){
$('input').checkBox();
$('#toggle-all').click(function(){
$('#example input[type=checkbox]').checkBox('toggle');
return false;
});
$('#check-all').click(function(){
$('#example input[type=checkbox]').checkBox('changeCheckStatus', true);
return false;
});
$('#uncheck-all').click(function(){
$('#example input[type=checkbox]').checkBox('changeCheckStatus', false);
return false;
});
$('#check-2').click(function(){
$('#example input[type=radio]:eq(1)').checkBox('changeCheckStatus', true);
return false;
});
$('#native').click(function(){
//native methods
$('#example input[type=radio]:eq(0)').attr({checked: true, disabled: true})
//reflect the current state
.checkBox('reflectUI');
return false;
});
$('#native-prop').click(function(){
//native methods
$('#example input[type=radio]:eq(2)').prop({checked: true});
return false;
});
});
</script>
<style type="text/css">
form {
overflow: hidden;
height: 1%;
margin: 20px 0;
}
fieldset {
padding: 10px;
color: #fff;
background: #0F1316;
}
.ui-helper-hidden-accessible {
position: absolute;
left: -999em;
}
table {
margin: 10px 0;
border-collapse: collapse;
width: 100%;
}
caption {
text-align: left;
}
th,
td {
border: 1px solid #000;
}
</style>
</head>
<body>
<div id="wrapper">
<h1>jQuery UI: Radiobutton- und Checkbox-Replacement</h1>
<code>
$('input').checkBox();
</code>
<form action="#">
<fieldset>
<div><input id="c1" type="checkbox"/> <label for="c1">CheckBox 1</label></div>
<div><input id="c2" type="checkbox"/> <label for="c2">CheckBox 2</label></div>
<div><input id="c3" type="checkbox"/> <label for="c3">CheckBox 3</label></div>
</fieldset>
<fieldset>
<div><input name="radio" id="c4" type="radio"/> <label for="c4">Radio 1</label></div>
<div><input name="radio" id="c5" type="radio"/> <label for="c5">Radio 2</label></div>
<div><input name="radio" id="c6" type="radio"/> <label for="c6">Radio 3</label></div>
</fieldset>
</form>
<code>
$('#toggle-all').click(function(){
$('#example input[type=checkbox]').checkBox('toggle');
return false;
});
$('#check-all').click(function(){
$('#example input[type=checkbox]').checkBox('changeCheckStatus', true);
return false;
});
$('#uncheck-all').click(function(){
$('#example input[type=checkbox]').checkBox('changeCheckStatus', false);
return false;
});
</code>
<form id="example" action="#">
<fieldset>
<div><input id="c7" type="checkbox"/> <label for="c7">CheckBox 1</label></div>
<div><input id="c8" type="checkbox"/> <label for="c8">CheckBox 2</label></div>
<div><input id="c9" type="checkbox"/> <label for="c9">CheckBox 3</label></div>
</fieldset>
<div>
<button id="toggle-all">toggle all</button> <button id="check-all">check all</button> <button id="uncheck-all">uncheck all</button>
</div>
<code>
$('#check-2').click(function(){
$('#example input[type=radio]:eq(1)').checkBox('changeCheckStatus', true);
return false;
});
$('#native').click(function(){
//native methode
$('#example input[type=radio]:eq(0)').attr({checked: true, disabled: true})
//reflect the current state
.checkBox('reflectUI');
return false;
});
$('#native-prop').click(function(){
//native methode prop (in case of jQuery 1.6 and higher and the prop method you won't need to reflect the state manually)
$('#example input[type=radio]:eq(2)').prop({checked: true});
return false;
});
</code>
<fieldset>
<div><input name="radio" id="c14" type="radio"/> <label for="c14">Radio 1</label></div>
<div><input name="radio" required id="c15" type="radio"/> <label for="c15">Radio 2</label></div>
<div><input name="radio" id="c16" type="radio"/> <label for="c16">Radio 3</label></div>
</fieldset>
<div>
<button id="check-2">check second</button>
<button id="native">native methode + ui-reflection</button>
<button id="native-prop">only prop (check third)</button>
</div>
</form>
<table>
<caption>Configuration</caption>
<tr>
<th>option</th>
<th>description</th>
</tr>
<tr>
<td>replaceInput: [<strong>true</strong>|false]</td>
<td>hide original input-element</td>
</tr>
<tr>
<td>addLabel: [<strong>true</strong>|false]</td>
<td>add checkbox/radiobutton state-classes also to the label-element</td>
</tr>
<tr>
<td>addVisualElement: [<strong>true</strong>|false]</td>
<td>adds a span element as a replacement for the input element (if you turn this to false, you can still style the label-element) (<a href="label-only.html">see label-only demo</a></td>
</tr>
</table>
<code>
$('input').checkbox({
addLabel: false
});
</code>
<table>
<caption>Classes to style label/visual element</caption>
<thead>
<tr>
<th>class</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>ui-radio/ui-checkbox</td>
<td>role style always attached</td>
</tr>
</tbody>
<tbody>
<tr>
<td>ui-radio-hover/ui-checkbox-hover</td>
<td>attached on mouseenter/focus and removed on mouseleave/blur</td>
</tr>
<tr>
<td>ui-radio-checked/ui-checkbox-checked</td>
<td>attached, if checked</td>
</tr>
<tr>
<td>ui-radio-disabled/ui-checkbox-disabled</td>
<td>attached if control is disabled</td>
</tr>
</tbody>
<tbody>
<tr>
<td>radio-focus/checkbox-focus</td>
<td>attached on focus and removed on blur</td>
</tr>
<tr>
<td>radio-invalid/checkbox-invalid</td>
<td>HTML5 validity test (works also in IE with <a href="http://afarkas.github.com/webshim/demos/index.html">webshims lib</a>)</td>
</tr>
<tbody>
</table>
<table>
<caption>events</caption>
<tr>
<th>event</th>
<th>description</th>
</tr>
<tr>
<td>click</td>
<td>click on associated label, checkbox/radiobutton or visual element (last since version 1.3)</td>
</tr>
<tr>
<td>checkboxdisabledchange</td>
<td>change in terms of disabled-state</td>
</tr>
<tr>
<td>checkcoxchange</td>
<td>change in terms of checked/unchecked-state</td>
</tr>
</table>
<code>
$('input')
.checkbox({
'change': function(e, ui){
//checked or unchecked || $(this).is(':checked') === ui.checked
},
'disabledchange': function(e, ui){
//$(this).attr('disabled') === ui.disabled
}
})
;
</code>
<table>
<caption>extra-methods</caption>
<tr>
<th>method</th>
<th>description</th>
</tr>
<tr>
<td>reflectUI</td>
<td>transfer the current states (disabled, checked) of the original input-element to the label and visual replacement-element</td>
</tr>
<tr>
<td>changeCheckStatus [true|false]</td>
<td>true -> check | false -> uncheck</td>
</tr>
<tr>
<td>toggle</td>
<td>toggles checked-state</td>
</tr>
<tr>
<td>enable</td>
<td>enables disabled checkboxes</td>
</tr>
<tr>
<td>disable</td>
<td>disables enabled checkboxes</td>
</tr>
</table>
<code>
//$('input').checkbox(); ...
//...
//check first checkbox
$('input:first').checkbox('changeCheckStatus', true);
</code>
<h2>Download & Bugtracker</h2>
<ul>
<li><a href="https://github.com/aFarkas/accessible--stylable-Radiobuttons-and-Checkboxes/downloads" target="_blank">ui.checkBox-Script (download)</a></li>
<li><a href="https://github.com/aFarkas/accessible--stylable-Radiobuttons-and-Checkboxes/issues" target="_blank">ui.checkBox-Script (bugtracker)</a></li>
<li><a href="http://plugins.jquery.com/project/usermode" target="_blank">jquery.usermode-Script (optional)</a></li>
</ul>
<h2>Licenses</h2>
<ul>
<li><a href="http://jquery.com/dev/svn/trunk/jquery/MIT-LICENSE.txt" target="_blank">MIT License</a></li>
<li><a href="http://jquery.com/dev/svn/trunk/jquery/GPL-LICENSE.txt" target="_blank">GPL License</a></li>
</ul>
<p><a href="/2008/09/06/tutorial-barrierearme-checkbox-und-radio-button-ersetzung-mit-jquery-ui-und-der-ui-reflecting-technik/">Back to the checkbox and radiobutton replacement - tutorial</a>, <a href="/">Back to protofunc</a></p>
</div>
</body>
</html>