Giter Club home page Giter Club logo

bootstrap-switch's Introduction

Bootstrap-switch

Demo

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

Usage

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

<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8;" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css">
<link rel="stylesheet" href="bootstrapSwitch.css">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="bootstrapSwitch.js"></script>  // master
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/1.3/bootstrapSwitch.min.js">  // from cdnjs.com

Less

If you want to use your bootstrap vars edit bootstrapSwitch.less and then compile the less file

lessc static/less/bootstrapSwitch.less static/stylesheets/bootstrapSwitch.css

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>

Text

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

HTML Text

<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

bootstrap-switch's People

Contributors

andrewmackrodt avatar markmarkoh avatar nostalgiaz avatar owlycode avatar scavenger3 avatar t3chn0r avatar volpino avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.