Bootstrap Switch
================
Turn radio and checkbox form input in switches.
**Bootstrap 3 ready** thanks to [nabil1337](https://github.com/nabil1337)
Demo
----
http://www.bootstrap-switch.org
Usage
-----
Just include jQuery, Bootstrap and Bootstrap Switch CSS + Javascript
``` html
```
Less
----
If you want to use your bootstrap variables, edit bootstrap-switch.less and compile it:
``` bash
lessc src/less/bootstrap3/bootstrap-switch.less bootstrap-switch.css
```
Or if you are using Bootstrap 2.3.2:
``` bash
lessc src/less/bootstrap2/bootstrap-switch.less bootstrap-switch.css
```
Supported browsers
------------------
IE8+ and all the other modern browsers.
Basic Example
-------------
checkboxes:
``` html
```
radioboxes:
``` html
```
Large, small or mini
--------------------
checkboxes:
``` html
```
radioboxes:
``` html
```
Colors
------
checkboxes:
``` html
```
radioboxes:
``` html
```
Animation
---------
checkboxes:
``` html
```
radioboxes:
``` html
```
Text
-----
checkboxes:
``` html
```
radioboxes:
``` html
```
Text Label
----------
checkboxes:
``` html
```
radioboxes:
``` html
```
HTML Text
----------
checkboxes:
``` html
```
radioboxes:
``` html
```
Initial values
--------------
checkboxes:
``` html
```
radioboxes:
``` html
```
Event handler
-------------
``` javascript
$('#mySwitch').on('switch-change', function (e, data) {
var $el = $(data.el)
, value = data.value;
console.log(e, $el, value);
});
```
Methods
-------
``` javascript
$('#mySwitch').bootstrapSwitch('toggleActivation');
$('#mySwitch').bootstrapSwitch('isActive');
$('#mySwitch').bootstrapSwitch('setActive', false);
$('#mySwitch').bootstrapSwitch('setActive', true);
$('#mySwitch').bootstrapSwitch('toggleState');
$('.mySwitch').bootstrapSwitch('toggleRadioState'); // the radiobuttons need a class not a ID, don't allow uncheck radio switch
$('.mySwitch').bootstrapSwitch('toggleRadioStateAllowUncheck'); // don't allow uncheck radio switch
$('.mySwitch').bootstrapSwitch('toggleRadioStateAllowUncheck', false); // don't allow uncheck radio switch
$('.mySwitch').bootstrapSwitch('toggleRadioStateAllowUncheck', true); // allow uncheck radio switch
$('#mySwitch').bootstrapSwitch('setState', true);
$('#mySwitch').bootstrapSwitch('setState', true || false, true); // sets the state without getting the switch-change event
$('#mySwitch').bootstrapSwitch('setOnLabel', onValue); // sets the text of the "on" label
$('#mySwitch').bootstrapSwitch('setOffLabel', offValue); // sets the text of the "off" label
$('#mySwitch').bootstrapSwitch('setTextLabel', labelValue); // sets the text of the middle label
$('#mySwitch').bootstrapSwitch('setIconLabel', iconValue); // sets the icon of the middle label
$('#mySwitch').bootstrapSwitch('setOnClass', onClass); // sets the left color class
$('#mySwitch').bootstrapSwitch('setOffClass', offClass); // sets the right color class
$('#mySwitch').bootstrapSwitch('setAnimated', animated); // sets true or false for animation
$('#mySwitch').bootstrapSwitch('setSizeClass', size); // sets 'switch-mini', 'switch-small' or 'switch-large'
$('#mySwitch').bootstrapSwitch('status'); // returns true or false
$('#mySwitch').bootstrapSwitch('destroy');
```
License
-------
Licensed under the Apache License, Version 2.0
http://www.apache.org/licenses/LICENSE-2.0