-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathindex.html
355 lines (308 loc) · 12.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Switch, by Rawnet</title>
<meta name="description" content="An iOS-inspired slide/toggle switch for jQuery">
<meta name="author" content="Mike Fulcher">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="demo/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link rel="stylesheet" href="demo/bootstrap.css">
<style type="text/css">
body {
padding-top: 60px;
}
select.inline {
display: inline !important;
margin-bottom: 5px;
}
</style>
<!-- Le jquery -->
<script type="text/javascript" src="demo/jquery.js"></script>
<!-- Le syntax highlighting -->
<link href="demo/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="demo/prettify.js"></script>
<script>$(function () { prettyPrint() })</script>
<!-- Le jquery switch-->
<link href="jquery.switch/jquery.switch.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="jquery.switch/jquery.switch.min.js"></script>
<script>
$(function() {
$('select:not(.args, .evented)').switchify();
$('select.args').switchify({ on: '1', off: '0' });
$('.api').click(function(e) {
e.preventDefault();
var self = $(this),
$switch = $('#api-select').data('switch'),
controls = $switch.data('controls');
controls[self.attr('data-action')]();
});
$('select.evented').switchify().data('switch').bind('switch:slide', function(e, type) {
e.preventDefault();
$('.events').append('<li>Preparing to slide to "' + type + '" position</li>');
var answer = confirm('Switch to the "' + type + '" position?'),
$switch = $(this),
controls = $switch.data('controls');
if (answer) {
$('.events').append('<li>Sliding to "' + type + '" position</li>');
setTimeout(function() {
controls[type]({ silent: true });
}, 50);
} else {
$('.events').append('<li>Cancelled slide to "' + type + '" position</li>');
setTimeout(function() {
controls[$switch.hasClass('on') ? 'on' : 'off']({ silent: true });
}, 50);
}
});
$('.focus').click(function(e) {
e.preventDefault();
$(this).focus();
});
});
</script>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-20145-66']);
_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>
<div class="container">
<header>
<div class="page-header">
<h1>
jQuery/Switch <small>awesome slide/toggle switches</small>
<a href="https://github.com/rawnet/jquery-switch/zipball/v0.4.1" class="btn large primary" style="float:right;">download v0.4.1</a>
<a href="http://github.com/rawnet/jquery-switch" target="_blank" class="btn large" style="float:right;margin-right:5px;">github.com/rawnet/jquery-switch</a>
</h1>
</div>
</header>
<section>
<div class="row">
<div class="span16">
<iframe style="width: 100%; height: 600px; border: solid 1px black;" src="http://jsfiddle.net/6twenty/3Uw2s/" frameborder="0"></iframe>
</div>
<div class="span16">
<p><a href="http://jsfiddle.net/6twenty/3Uw2s/" target="_blank">Go to this fiddle</a></p>
</div>
</div><!-- /row -->
<div class="page-header" style="margin-top:50px;">
<h1>Demos <small>cut to the chase</small></h1>
</div>
<div class="row">
<div class="span4">
<h3>The defaults</h3>
<select class="example-1">
<option value="1">On</option>
<option value="0">Off</option>
</select>
</div>
<div class="span12">
<h3>The code <small>the defaults</small></h3>
<pre class="prettyprint linenums"><select>
<option value="1">On</option>
<option value="0">Off</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify();</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Custom values/labels</h3>
<select class="example-2">
<option value="a">True</option>
<option value="b">False</option>
</select>
</div>
<div class="span12">
<h3>The code <small>custom values/labels</small></h3>
<pre class="prettyprint linenums"><select>
<option value="a">True</option>
<option value="b">False</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify();</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Respect initial value</h3>
<select class="example-3">
<option value="1">On</option>
<option value="0" selected="selected">Off</option>
</select>
</div>
<div class="span12">
<h3>The code <small>respect initial value</small></h3>
<pre class="prettyprint linenums"><select>
<option value="1">On</option>
<option value="0" selected="selected">Off</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify();</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Override defaults</h3>
<select class="example-4 args">
<option value="0">Off</option>
<option value="1">On</option>
</select>
</div>
<div class="span12">
<h3>The code <small>override defaults</small></h3>
<pre class="prettyprint linenums"><select>
<option value="0">Off</option>
<option value="1">On</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify({ on: '1', off: '0' });</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Respect initial state</h3>
<select class="example-5" disabled="disabled">
<option value="1">On</option>
<option value="0">Off</option>
</select>
</div>
<div class="span12">
<h3>The code <small>respect initial state</small></h3>
<pre class="prettyprint linenums"><select disabled="disabled">
<option value="1">On</option>
<option value="0">Off</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify();</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Multiple switches</h3>
<select class="example-6">
<option value="1">On</option>
<option value="0">Off</option>
</select>
<select class="example-6">
<option value="1">On</option>
<option value="0">Off</option>
</select>
</div>
<div class="span12">
<h3>The code <small>multiple switches</small></h3>
<pre class="prettyprint linenums"><select>
<option value="1">On</option>
<option value="0">Off</option>
</select>
<select>
<option value="1">On</option>
<option value="0">Off</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify();</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Event driven</h3>
<select class="example-7 inline evented">
<option value="1">On</option>
<option value="0">Off</option>
</select>
<ul class="events"></ul>
</div>
<div class="span12">
<h3>The code <small>event driven</small></h3>
<pre class="prettyprint linenums"><select>
<option value="1">On</option>
<option value="0">Off</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify().data('switch').bind('switch:slide', function(e, type) {
e.preventDefault(); // cancel the default slide action
$('.events').append('<li>Preparing to slide to "' + type + '" position</li>');
var answer = confirm('Switch to the "' + type + '" position?');
if (answer) {
$('.events').append('<li>Sliding to "' + type + '" position</li>');
var controls = $(this).data('controls');
// manually perform the slide action, but without triggering the 'switch:slide' event again
controls[type]({ silent: true });
} else {
$('.events').append('<li>Cancelled slide to "' + type + '" position<li>');
}
});</pre>
<pre class="prettyprint linenums">select { display: inline !important; }</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>API controls</h3>
<select id="api-select" class="example-8">
<option value="1">On</option>
<option value="0">Off</option>
</select>
<p>
<a href="#" class="api" data-action="on">Switch on</a> |
<a href="#" class="api" data-action="off">Switch off</a> |
<a href="#" class="api" data-action="toggle">Toggle</a>
</p>
</div>
<div class="span12">
<h3>The code <small>api controls</small></h3>
<pre class="prettyprint linenums"><select id="api-select">
<option value="1">On</option>
<option value="0">Off</option>
</select>
<p>
<a href="#" class="api" data-action="on">Switch on</a> |
<a href="#" class="api" data-action="off">Switch off</a> |
<a href="#" class="api" data-action="toggle">Toggle</a>
</p></pre>
<pre class="prettyprint linenums">$('select').switchify();
$('.api').click(function(e) {
e.preventDefault();
var self = $(this),
$switch = $('#api-select').data('switch'),
controls = $switch.data('controls');
controls[self.attr('data-action')]();
});</pre>
</div>
</div><!-- /row -->
<div class="row">
<div class="span4">
<h3>Keyboard support</h3>
<p><a href="#" class="focus">Click here, press <code>tab</code> to focus on the switch, then hit <code>enter</code> to toggle</a></p>
<select class="example-9">
<option value="1">On</option>
<option value="0">Off</option>
</select>
</div>
<div class="span12">
<h3>The code <small>keyboard support</small></h3>
<pre class="prettyprint linenums"><p><a href="#" class="focus">Click here, press <code>tab</code> to focus on the switch, then hit <code>enter</code> to toggle</a></p>
<select>
<option value="1">On</option>
<option value="0">Off</option>
</select></pre>
<pre class="prettyprint linenums">$('select').switchify();
$('.api-keyboard-focus').click(function(e) {
e.preventDefault();
$(this).focus();
});</pre>
</div>
</div><!-- /row -->
</section>
<footer class="footer">
<div class="container">
<p class="pull-right"><a href="#">Back to top</a></p>
<p>© 2011 <a href="http://www.rawnet.com/">Rawnet</a> - written by the <a href="http://rawnet.github.com/">Rawnet Engineering team</a></p>
</div>
</footer>
</div> <!-- /container -->
</body>
</html>