forked from Bttstrp/bootstrap-switch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
410 lines (401 loc) · 22.6 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bootstrap Switch · Turn checkboxes and radio buttons in toggle switches.</title>
<meta name="description" content="Turn checkboxes and radio buttons in toggle switches.">
<meta name="author" content="Mattia Larentis">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="docs/vendor/bootstrap.min.css" />
<!-- <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css"> -->
<!-- <link rel="stylesheet" href="http://bdmdesign.github.io/bootstrap-switch/static/stylesheets/flat-ui-fonts.css"> -->
<link rel="stylesheet" href="docs/vendor/prism.css">
<link rel="stylesheet" href="build/css/bootstrap3/bootstrap-switch.min.css" />
<link rel="stylesheet" href="docs/index.css">
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-43092768-1']);
_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>
<a href="https://github.com/nostalgiaz/bootstrap-switch" id="github"><img src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub">
</a>
<header class="header">
<div class="container">
<h1>Bootstrap Switch <span class="small">2.0.1</span></h1>
<h2>Turn checkboxes and radio buttons in toggle switches.</h2>
<br>
<iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&repo=bootstrap-switch&type=watch&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="120" height="30"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&repo=bootstrap-switch&type=fork&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="30"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&type=follow&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="190" height="30"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=LostCrew&type=follow&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
<iframe src="http://ghbtns.com/github-btn.html?user=BdMdesigN&type=follow&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
<br>
<br>
<p class="people">
<a href="http://larentis.eu" target="_blank">Mattia Larentis</a> · <a href="http://www.bdmdesign.org/" target="_blank">Peter Stein</a> · <a href="http://www.lostcrew.it" target="_blank">Emanuele Marchi</a>
</p>
</div>
</header>
<hr>
<div class="container">
<div class="row">
<div class="col-sm-10 col-sm-offset-1">
<section name="size">
<div class="page-header">
<h2>Sizes</h2>
</div>
<input type="checkbox" checked class="switch-large">
<input type="checkbox" checked>
<input type="checkbox" checked class="switch-small">
<input type="checkbox" checked class="switch-mini">
<br>
<br>
<p>Change the size programmatically:</p>
<input type="checkbox" id="dimension-switch" checked>
<br>
<br>
<button id="btn-size-large-switch" class="btn btn-default">Large</button>
<button id="btn-size-regular-switch" class="btn btn-default">Regular</button>
<button id="btn-size-small-switch" class="btn btn-default">Small</button>
<button id="btn-size-mini-switch" class="btn btn-default">Mini</button>
<br>
<pre class="language-markup"><code><input type="checkbox" checked class="switch-large">
<input type="checkbox" checked>
<input type="checkbox" checked class="switch-small">
<input type="checkbox" checked class="switch-mini">
<input id="dimension-switch" type="checkbox" checked></code></pre>
<pre class="language-javascript"><code>// Resets to the regular style
$('#dimension-switch').bootstrapSwitch('setSizeClass', '');
// Sets a mini switch
$('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-mini');
// Sets a small switch
$('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-small');
// Sets a large switch
$('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-large');</code></pre>
</section>
<section name="colors">
<div class="page-header">
<h2><a href="#colors">Colors</a></h2>
</div>
<input type="checkbox" checked data-on="primary" data-off="info">
<input type="checkbox" checked data-on="info" data-off="success">
<input type="checkbox" checked data-on="success" data-off="warning">
<input type="checkbox" checked data-on="warning" data-off="danger">
<input type="checkbox" checked data-on="danger" data-off="default">
<input type="checkbox" checked data-on="default" data-off="primary">
<br>
<br>
<span>Change the colors programmatically:</span>
<input type="checkbox" id="change-color-switch" checked data-on="default" data-off="primary">
<br>
<br>
<button id="btn-color-on-switch" class="btn btn-success">Change ON color</button>
<button id="btn-color-off-switch" class="btn btn-danger">Change OFF color</button>
<pre class="language-markup"><code><input type="checkbox" checked data-on="primary" data-off="info">
<input type="checkbox" checked data-on="info" data-off="success">
<input type="checkbox" checked data-on="success" data-off="warning">
<input type="checkbox" checked data-on="warning" data-off="danger">
<input type="checkbox" checked data-on="danger" data-off="default">
<input type="checkbox" checked data-on="default" data-off="primary">
<input type="checkbox" id="change-color-switch" checked data-on="default" data-off="primary"></code></pre>
<pre class="language-javascript"><code>$('#change-color-switch').bootstrapSwitch('setOnClass', 'success');
$('#change-color-switch').bootstrapSwitch('setOffClass', 'danger');</code></pre>
</section>
<section name="animation">
<div class="page-header">
<h2><a name="animation" class="anchor" href="#animation">Animation <small>JavaScript</small></a></h2>
</div>
<input type="checkbox" id="animated-switch" checked data-animated="false">
<br>
<br>
<button id="btn-animate-switch" class="btn btn-default">Animate</button>
<button id="btn-dont-animate-switch" class="btn btn-default">Don't animate</button>
<pre class="language-markup"><code><input type="checkbox" checked data-animated="false"></code></pre>
<pre class="language-javascript"><code>// Enables animation for the selected item
$('#animated-switch').bootstrapSwitch('setAnimated', true);
// Disables animation for the selected item
$('#animated-switch').bootstrapSwitch('setAnimated', false);</code></pre>
</section>
<section name="disabled">
<div class="page-header">
<h2><a name="disabled" class="anchor" href="#disabled">Disabled / Readonly</a></h2>
</div>
<input type="checkbox" checked disabled>
<input type="checkbox" checked readonly>
<pre class="language-markup"><code><input type="checkbox" checked disabled>
<input type="checkbox" checked readonly></code></pre>
</section>
<section name="text">
<div class="page-header">
<h2><a name="text" class="anchor" href="#text">Text</a></h2>
</div>
<input type="checkbox" id="label-switch" checked data-on-label="SI" data-off-label="NO">
<br>
<br>
<button id="btn-label-on-switch" class="btn btn-default">Change "On" label</button>
<button id="btn-label-off-switch" class="btn btn-default">Change "Off" label</button>
<pre class="language-markup"><code><input type="checkbox" checked data-on-label="SI" data-off-label="NO"></code></pre>
<pre class="language-javascript"><code>$('#label-switch').bootstrapSwitch('setOnLabel', 'I');
$('#label-switch').bootstrapSwitch('setOffLabel', 'O');</code></pre>
</section>
<div class="page-header">
<h2><a name="label-text" class="anchor" href="#label-text">Label Text</a></h2>
</div>
<div class="bs-docs-example">
<input type="checkbox" checked data-text-label="TV">
</div>
<pre class="language-markup"><code><input type="checkbox" checked data-text-label="TV"></code></pre>
<div class="page-header">
<h2><a name="html-text" class="anchor" href="#html-text">HTML Text</a></h2>
</div>
<div class="bs-docs-example">
<input type="checkbox" checked data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
</div>
<pre class="language-markup"><code><input type="checkbox" checked data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>"></code></pre>
<div class="page-header">
<h2><a name="html-text-label-icon" class="anchor" href="#html-text-label-icon">HTML Text Label Icon</a></h2>
</div>
<div class="bs-docs-example">
Standard <input type="checkbox" checked class="switch-large" data-label-icon="icon-fullscreen" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
Font Awesome <input type="checkbox" checked class="switch-large" data-label-icon="icon-youtube icon-large" data-on-label="<i class='icon-thumbs-up icon-white'></i>" data-off-label="<i class='icon-thumbs-down'></i>">
Flat UI <input type="checkbox" class="switch-large" checked data-label-icon="fui-video" data-on-label="<i class='fui-check icon-white'></i>" data-off-label="<i class='fui-cross'></i>">
</div>
<pre class="language-markup"><code><input type="checkbox" checked class="switch-large" data-label-icon="icon-fullscreen" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
<input type="checkbox" checked class="switch-large" data-label-icon="icon-youtube icon-large" data-on-label="<i class='icon-thumbs-up icon-white'></i>" data-off-label="<i class='icon-thumbs-down'></i>">
<input type="checkbox" class="switch-large" checked data-label-icon="fui-video" data-on-label="<i class='fui-check icon-white'></i>" data-off-label="<i class='fui-cross'></i>"></code></pre>
<div class="page-header">
<h2><a name="event-handler-javascript" class="anchor" href="#event-handler-javascript">Event Handler <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<input type="checkbox" id="switch-change" checked>
</div>
<pre class="language-javascript"><code>$('#switch-change').on('switch-change', function (e, data) {
var $element = $(data.el),
value = data.value;
console.log(e, $element, value);
});</code></pre>
<div class="page-header">
<h2><a name="label-event-handler-javascript" class="anchor" href="#label-event-handler-javascript">Label Event Handler <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<label id="label-toggle-switch">Click on this Text to change the switch state</label>
<input type="checkbox" checked class="label-toggle-switch">
</div>
<pre class="language-markup"><code><label id="label-toggle-switch">Click on this Text to change the switch state</label>
<input type="checkbox" checked></code></pre>
<pre class="language-javascript"><code>$('#label-toggle-switch').on('click', function(e, data) {
$('.label-toggle-switch').bootstrapSwitch('toggleState');
});
$('.label-toggle-switch').on('switch-change', function (e, data) {
alert(data.value);
});</code></pre>
<div class="page-header">
<h2><a name="toggle-state" class="anchor" href="#toggle-state">Toggle State <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<input type="checkbox" id="toggle-state-switch" checked>
<br>
<br>
<div id="toggle-state-switch-button-state" class="btn btn-default">State!</div>
<div id="toggle-state-switch-button-on" class="btn btn-default">On</div>
<div id="toggle-state-switch-button" class="btn btn-default">Toggle</div>
<div id="toggle-state-switch-button-off" class="btn btn-default">Off</div>
</div>
<pre class="language-javascript"><code>$('#toggle-state-switch').bootstrapSwitch('state'); // true || false
$('#toggle-state-switch').bootstrapSwitch('toggleState');
$('#toggle-state-switch').bootstrapSwitch('setState', false); // true || false</code></pre>
<div class="page-header">
<h2><a name="destroy" class="anchor" href="#destroy">Destroy <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<input type="checkbox" id="destroy-switch" checked >
<br>
<br>
<button id="btn-destroy-switch" class="btn btn-default">Destroy me!</button>
</div>
<pre class="language-javascript"><code>$('#destroy-switch').bootstrapSwitch('destroy');</code></pre>
<div class="page-header">
<h2><a name="create" class="anchor" href="#create">Create <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<input id="create-switch" type="checkbox" checked>
<br>
<br>
<div id="btn-create" class="btn btn-default">Create</div>
</div>
<pre class="language-javascript"><code>$('#create-switch').bootstrapSwitch();</code></pre>
<div class="page-header">
<h2><a name="disabled-javascript" class="anchor" href="#disabled-javascript">Disable / Readonly <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<label for="disable-switch">Disable controls</label>
<input type="checkbox" id="disable-switch" checked>
<br>
<br>
<button id="btn-disable-is" class="btn btn-default">Is disabled?</button>
<button id="btn-disable-toggle" class="btn btn-default">Toggle Disable</button>
<button id="btn-disable-set" class="btn btn-default">Set Disable</button>
<button id="btn-disable-remove" class="btn btn-default">Remove Disable</button>
<br>
<br>
<label for="readonly-switch">Readonly controls</label>
<input type="checkbox" id="readonly-switch" checked>
<br>
<br>
<button id="btn-readonly-is" class="btn btn-default">Is readonly?</button>
<button id="btn-readonly-toggle" class="btn btn-default">Toggle readonly</button>
<button id="btn-readonly-set" class="btn btn-default">Set readonly</button>
<button id="btn-readonly-remove" class="btn btn-default">Remove readonly</button>
</div>
<pre class="language-javascript"><code>$('#disable-switch').bootstrapSwitch('isDisabled');
$('#disable-switch').bootstrapSwitch('toggleDisabled');
$('#disable-switch').bootstrapSwitch('setDisabled', true); // true || false
$('#readonly-switch').bootstrapSwitch('isReadOnly');
$('#readonly-switch').bootstrapSwitch('toggleReadOnly');
$('#readonly-switch').bootstrapSwitch('setReadOnly', true); // true || false</code></pre>
<div class="page-header">
<h2><a name="radio-javascript" class="anchor" href="#radio-javascript">Radio <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<div class="form-group">
<label for="option1">Option 1</label>
<input id="option1" type="radio" name="radio1" value="option1" class="radio1 radio-no-uncheck">
<label for="option2">Option 2</label>
<input id="option2" type="radio" name="radio1" value="option2" class="radio1 radio-no-uncheck">
<label for="option3">Option 3</label>
<input id="option3" type="radio" name="radio1" value="option3" class="radio1 radio-no-uncheck">
</div>
</div>
<pre class="language-markup"><code><div class="form-group">
<label for="option1">Option 1</label>
<input id="option1" type="radio" name="radio1" value="option1">
<label for="option2">Option 2</label>
<input id="option2" type="radio" name="radio1" value="option2">
<label for="option3">Option 3</label>
<input id="option3" type="radio" name="radio1" value="option3">
</div></code></pre>
<pre class="language-javascript"><code>$('.radio1').on('switch-change', function () {
$('.radio1').bootstrapSwitch('toggleRadioState');
});
// or
$('.radio1').on('switch-change', function () {
$('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck');
});
// or
$('.radio1').on('switch-change', function () {
$('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck', false);
});</code></pre>
<div class="page-header">
<h2><a name="radio-javascript-allow-uncheck" class="anchor" href="#radio-javascript-allow-uncheck">Radio + uncheck <small>JavaScript</small></a></h2>
</div>
<div class="bs-docs-example">
<div class="form-group">
<label for="option11">Option 1</label>
<input id="option11" type="radio" name="radio2" value="option11" class="radio2">
<label for="option12">Option 2</label>
<input id="option12" type="radio" name="radio2" value="option12" checked="checked" class="radio2">
<label for="option13">Option 3</label>
<input id="option13" type="radio" name="radio2" value="option13" class="radio2">
</div>
</div>
<pre class="language-markup"><code><div class="form-group">
<label for="option11">Option 1</label>
<input id="option11" type="radio" name="radio2" value="option1">
<label for="option12">Option 2</label>
<input id="option12" type="radio" name="radio2" value="option2" checked="checked">
<label for="option13">Option 3</label>
<input id="option13" type="radio" name="radio2" value="option3">
</div></code></pre>
<pre class="language-javascript"><code>$('.radio2').on('switch-change', function () {
$('.radio2').bootstrapSwitch('toggleRadioStateAllowUncheck', true);
});</code></pre>
<div class="page-header">
<h2><a name="form" class="anchor" href="#form">Form</a></h2>
</div>
<div class="bs-docs-example">
<form class="clearfix" role="form">
<div class="form-group">
<label class="control-label" for="inputEmail">Email</label>
<input type="text" id="inputEmail" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<label class="control-label" for="notification1">Notification 1</label>
<input id="notification1" type="checkbox">
</div>
<div class="form-group">
<label class="control-label" for="notification2">Notification 2</label>
<input id="notification2" type="checkbox">
</div>
<div class="form-actions">
<button type="reset" class="btn btn-default btn-warning">Reset</button>
</div>
</form>
<div ></div>
</div>
<pre class="language-markup"><code><form class="form-horizontal">
<div class="form-group">
<label class="control-label" for="inputEmail">Email</label>
<input type="text" id="inputEmail" placeholder="Email">
</div>
<div class="form-group">
<label class="control-label" for="notification1">Notification 1</label>
<input id="notification1" type="checkbox">
</div>
<div class="form-group">
<label class="control-label" for="notification2">Notification 2</label>
<input id="notification2" type="checkbox">
</div>
<div class="form-actions">
<button type="reset" class="btn btn-inverse">Reset</button>
</div>
</form></code></pre>
<div class="page-header">
<h2><a name="modal" class="anchor" href="#modal">Modal</a></h2>
</div>
<div class="bs-docs-example">
<a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal</a>
</div>
<pre class="language-markup"><code><a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal</a>
<div class="modal-body">
<input type="checkbox" checked>
</div></code></pre>
<footer class="footer">
<p>© by <a href="http://larentis.eu" target="_blank">Mattia Larentis</a> (<a href="https://twitter.com/SpiritualGuru">@SpiritualGuru</a>), <a href="http://www.bdmdesign.org/" target="_blank">Peter Stein</a> and <a href="http://www.lostcrew.it/" target="_blank">Emanuele Marchi</a></p>
</footer>
</div>
</div>
</div>
<div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3>Modal</h3>
</div>
<div class="modal-body">
<input type="checkbox" checked>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
</div>
</div>
<script src="docs/vendor/jquery.js"></script>
<script src="docs/vendor/bootstrap.min.js"></script>
<script src="build/js/bootstrap-switch.min.js"></script>
<script src="docs/vendor/prism.js"></script>
<script src="docs/index.js"></script>
</body>
</html>