-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
222 lines (214 loc) · 7.2 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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>ui.checkSwitch</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="styles/style.css">
<link rel="stylesheet" href="styles/ui.checkswitch.css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-4011945-9']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<header>
<h1>ui.checkSwitch</h1>
</header>
<div class="contents">
<section>
<h2>What's this?</h2>
<p>"ui.checkswitch" is a javascript library and you can implement ios style switching checkbox by using this.</p>
</section>
<section>
<h2>iOS style switching checkbox</h2>
<fieldset>
<div>
<label>Basic</label>
<input type="checkbox" id="basic" name="basic" value="1">
</div>
<div>
<label>Events</label>
<input type="checkbox" id="events" name="events" value="1" checked>
</div>
<div>
<label>Custom Label</label>
<input type="checkbox" id="label" name="label" value="1" checked>
</div>
</fieldset>
</section>
<section>
<h2>Download</h2>
<ul>
<li class="icon_download"><a href="https://github.com/5509/ui.checkSwitch/zipball/master">Download ui.checkSwitch.js</a></li>
</ul>
</section>
<section>
<h2>Implementation</h2>
<p>Here is a checkbox, and this is to be base.</p>
<pre><input type="checkbox" id="checkbox" name="checkbox" value="1"></pre>
<p>Then, reading "ui.checkswitch.css", "ui.checkswitch.js" and run ChechSwitch func.</p>
<pre class="html"><link rel="stylesheet" href="styles/ui.checkswitch.css">
<script src="scripts/ui.checkswitch.js"></script>
<script>
CheckSwitch('#checkbox');
// a 1st argument is set a target checkbox id
</script></pre>
<p>A checkbox targeted is replaced by HTML following. Text labels and classes are custmizable by using options.</p>
<pre class="html"><span class="ui_check_switch">
<span class="ui_check_switch_inner">
<span class="ui_check_switch_slider">
<span class="ui_check_on ui_check_text">ON</span>
<span class="ui_check_knob"></span>
<span class="ui_check_off ui_check_text">OFF</span>
</span>
</span>
</span></pre>
</section>
<section>
<h2>Options</h2>
<p>Custom text label and classes</p>
<table>
<thead>
<tr><th>key</th><td>default</td></tr>
</thead>
<tbody>
<tr><th>checkOnText</th><td>'ON'</td></tr>
<tr><th>checkOffText</th><td>'OFF'</td></tr>
<tr><th>uiClass</th><td>'ui_check_switch'</td></tr>
<tr><th>uiOnClass</th><td>'ui_check_switch_on'</td></tr>
<tr><th>uiOffClass</th><td>'ui_check_switch_off'</td></tr>
<tr><th>uiInnerClass</th><td>'ui_check_switch_inner'</td></tr>
<tr><th>uiSliderClass</th><td>'ui_check_switch_slider'</td></tr>
<tr><th>uiTextClass</th><td>'ui_check_text'</td></tr>
<tr><th>uiKnobClass</th><td>'ui_check_knob'</td></tr>
<tr><th>uiCheckOffClass</th><td>'ui_check_off'</td></tr>
<tr><th>uiCheckOnClass </th><td>'ui_check_on</td></tr>
</tbody>
</table>
<h3>source code</h3>
<pre class="javascript">CheckSwitch('#checkbox', {
checkOnText: 'ON',
checkOffText: 'OFF'
});</pre>
</section>
<section>
<h2>APIs</h2>
<table>
<thead>
<tr><th>method</th><td>description</td></tr>
</thead>
<tbody>
<tr><th>on</th><td>make the checkSwitch state on</td></tr>
<tr><th>off</th><td>make the checkSwitch state off</td></tr>
<tr><th>getState</th><td>get checked or not from the checkbox</td></tr>
<tr><th>bind</th><td>bind events to the checkSwitch</td></tr>
<tr><th>destroy</th><td>destroy all events and APIs from the checkSwitch</td></tr>
</tbody>
</table>
<h3>source code</h3>
<pre class="javascript">var chk = CheckSwitch('#checkbox');
chk.on();</pre>
</section>
<section>
<h2>Events</h2>
<table>
<thead>
<tr><th>events</th><td>description</td></tr>
</thead>
<tbody>
<tr><th>checkSwitch:on</th><td>Fire when the checkSwitch is on</td></tr>
<tr><th>checkSwitch:off</th><td>Fire when the checkSwitch is off</td></tr>
</tbody>
</table>
<h3>source code</h3>
<pre class="javascript">var chk = CheckSwitch('#checkbox');
chk.bind({
'checkSwitch:on': function(ev) {
var cs = ev.checkSwitch;
console.log(cs.name);
},
'checkSwitch:off': function(ev) {
var cs = ev.checkSwitch;
console.log(cs.name);
}
});</pre>
</section>
<section>
<h2>Capable browsers</h2>
<ul>
<li class="icon_capable">Mobile Safari iOS 3+ (*1)</li>
<li class="icon_capable">Android 2.2+ (*2)</li>
<li class="icon_capable">IE 6+ (*3)</li>
<li class="icon_capable">and modern browsers</li>
</ul>
<div class="note">
<p>*1) Default styles does not support iOS3 or less, operation check has.</p>
<p>*2) There are ugly border radiuses in default styles.</p>
<p>*3) If you want to use in IEs, you would write new styles.</p>
</div>
</section>
<section>
<h2>About</h2>
<ul>
<li class="icon_license">Licensed under the MIT</li>
<li class="icon_author">Kazunori Tokuda, <a href="http://5509.me">5509</a></li>
<li class="icon_repository">Repository on <a href="https://github.com/5509/ui.checkSwitch">github</a></li>
<li class="icon_like">
<g:plusone size="medium"></g:plusone><script>(function(){var po=document.createElement("script");po.type="text/javascript";po.async=true;po.src="https://apis.google.com/js/plusone.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(po,s);})();</script>
<iframe src="http://www.facebook.com/plugins/like.php?href=&layout=button_count&show_faces=false&width=90&action=like&colorscheme=light&height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:20px;" allowTransparency="true"></iframe>
</li>
</ul>
</section>
</div>
<footer>
<p>Some icons by <a href="http://blog.twg.ca/">The Working Group</a></p>
</footer>
<script src="scripts/ui.checkswitch.js"></script>
<script>
(function() {
var chk = CheckSwitch('#basic');
}());
(function() {
var chk = CheckSwitch('#events');
chk.bind({
'checkSwitch:on': function(ev) {
console.log(
'state:', chk.getState(),
'\nid:', ev.checkSwitch.id,
'\nname:', ev.checkSwitch.name
);
},
'checkSwitch:off': function(ev) {
console.log(
'state:', chk.getState(),
'\nid:', ev.checkSwitch.id,
'\nname:', ev.checkSwitch.name
);
}
});
}());
(function() {
var chk = CheckSwitch('#label', {
checkOnText: 'オン',
checkOffText: 'オフ'
});
}());
</script>
<script src="scripts/lib/highlight.min.js"></script>
<script>
(function() {
var pre = document.getElementsByTagName('pre');
for ( var i = 0, l = pre.length; i < l; i++ ) {
hljs.highlightBlock(pre[i]);
}
}());
</script>
</body>
</html>