Turn checkboxes and radio buttons in toggle switches.
fork from : https://github.com/Bttstrp/bootstrap-switch.git

Mark DiMarco 91ab337152 Return selected elements for chaining 12 years ago
examples e84402b491 add tab+space interaction and update documentation 12 years ago
static 91ab337152 Return selected elements for chaining 12 years ago
.gitignore 40c9d7eb1d welcome 12 years ago
LICENSE 40c9d7eb1d welcome 12 years ago
README.md aaf6329863 add active/disable function 12 years ago

README.md

Bootstrap-switch

Demo

http://www.larentis.eu/switch/

Usage

Just include Twitter Bootstrap, jQuery, Bootstrap Switch CSS and Javascript

<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
<link href="bootstrapSwitch.css" rel="stylesheet">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="bootstrapSwitch.js"></script>

Basic Example

<div class="switch">
    <input type="checkbox">
</div>

Large, small or mini

<div class="switch switch-large">  <!-- switch-large, switch-small or switch-mini -->
    <input type="checkbox">
</div>

Colors

<div class="switch" data-on="danger" data-off="warning">  <!-- primary, info, success, warning and danger -->
    <input type="checkbox">
</div>

Animation

<div class="switch" data-animated="false">
    <input type="checkbox">
</div>

Label

<div class="switch" data-on-label="SI" data-off-label="NO">
    <input type="checkbox">
</div>

HTML Label

<div class="switch" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
    <input type="checkbox">
</div>

Initial values

<div class="switch">
    <input type="checkbox" checked="checked" disabled="disabled">
</div>

Event handler

$('#mySwitch').on('switch-change', function (e, data) {
    var $el = $(data.el)
      , value = data.value;
    console.log(e, $el, value);
});

Methods

$('#mySwitch').bootstrapSwitch('toggleActivation');
$('#mySwitch').bootstrapSwitch('isActive');
$('#mySwitch').bootstrapSwitch('setActive', false);
$('#mySwitch').bootstrapSwitch('setActive', true);
$('#mySwitch').bootstrapSwitch('toggleState');
$('#mySwitch').bootstrapSwitch('setState', true);
$('#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