index.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Bootstrap Switch · Turn checkboxes and radio buttons in toggle switches.</title>
  6. <meta name="description" content="Turn checkboxes and radio buttons in toggle switches.">
  7. <meta name="author" content="Mattia Larentis">
  8. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  9. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  10. <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
  11. <link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css">
  12. <link rel="stylesheet" href="http://bdmdesign.github.io/bootstrap-switch/static/stylesheets/flat-ui-fonts.css">
  13. <link rel="stylesheet" href="build/css/bootstrap3/bootstrap-switch.css" />
  14. <link rel="stylesheet" href="docs/vendor/prism.css">
  15. <link rel="stylesheet" href="docs/index.css">
  16. <script>
  17. var _gaq = _gaq || [];
  18. _gaq.push(['_setAccount', 'UA-43092768-1']);
  19. _gaq.push(['_trackPageview']);
  20. (function () {
  21. var ga = document.createElement('script');
  22. ga.type = 'text/javascript';
  23. ga.async = true;
  24. ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  25. var s = document.getElementsByTagName('script')[0];
  26. s.parentNode.insertBefore(ga, s);
  27. })();
  28. </script>
  29. </head>
  30. <body>
  31. <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">
  32. </a>
  33. <header class="header">
  34. <div class="container">
  35. <h1>Bootstrap Switch <span class="small">2.0.1</span></h1>
  36. <h2>Turn checkboxes and radio buttons in toggle switches.</h2>
  37. <br>
  38. <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&amp;repo=bootstrap-switch&amp;type=watch&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="120" height="30"></iframe>
  39. <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&amp;repo=bootstrap-switch&amp;type=fork&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="110" height="30"></iframe>
  40. <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&amp;type=follow&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="190" height="30"></iframe>
  41. <iframe src="http://ghbtns.com/github-btn.html?user=LostCrew&amp;type=follow&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
  42. <iframe src="http://ghbtns.com/github-btn.html?user=BdMdesigN&amp;type=follow&amp;count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
  43. <br>
  44. <br>
  45. <p class="people">
  46. <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>
  47. </p>
  48. </div>
  49. </header>
  50. <hr>
  51. <div class="container">
  52. <div class="row">
  53. <div class="col-sm-10 col-sm-offset-1">
  54. <section id="sizes">
  55. <div class="page-header">
  56. <h2><a href="#sizes">Sizes</a></h2>
  57. </div>
  58. <input type="checkbox" checked data-size="large">
  59. <input type="checkbox" checked>
  60. <input type="checkbox" checked data-size="small">
  61. <input type="checkbox" checked data-size="mini">
  62. <br>
  63. <br>
  64. <p>Change the size programmatically:</p>
  65. <input type="checkbox" id="dimension-switch" checked>
  66. <br>
  67. <br>
  68. <button id="btn-size-large-switch" class="btn btn-default">Large</button>
  69. <button id="btn-size-regular-switch" class="btn btn-default">Regular</button>
  70. <button id="btn-size-small-switch" class="btn btn-default">Small</button>
  71. <button id="btn-size-mini-switch" class="btn btn-default">Mini</button>
  72. <br>
  73. <pre class="language-markup"><code>&lt;input type="checkbox" checked data-size="large">
  74. &lt;input type="checkbox" checked>
  75. &lt;input type="checkbox" checked data-size="small">
  76. &lt;input type="checkbox" checked data-size="mini">
  77. &lt;input id="dimension-switch" type="checkbox" checked></code></pre>
  78. <pre class="language-javascript"><code>// Resets to the regular style
  79. $('#dimension-switch').bootstrapSwitch('size', '');
  80. // Sets a mini switch
  81. $('#dimension-switch').bootstrapSwitch('size', 'mini');
  82. // Sets a small switch
  83. $('#dimension-switch').bootstrapSwitch('size', 'small');
  84. // Sets a large switch
  85. $('#dimension-switch').bootstrapSwitch('size', 'large');</code></pre>
  86. </section>
  87. <section id="colors">
  88. <div class="page-header">
  89. <h2><a href="#colors">Colors</a></h2>
  90. </div>
  91. <input type="checkbox" checked data-on-color="primary" data-off-color="info">
  92. <input type="checkbox" checked data-on-color="info" data-off-color="success">
  93. <input type="checkbox" checked data-on-color="success" data-off-color="warning">
  94. <input type="checkbox" checked data-on-color="warning" data-off-color="danger">
  95. <input type="checkbox" checked data-on-color="danger" data-off-color="default">
  96. <input type="checkbox" checked data-on-color="default" data-off-color="primary">
  97. <br>
  98. <br>
  99. <span>Change the colors programmatically:</span>
  100. <input type="checkbox" id="change-color-switch" checked data-on-color="default" data-off-color="primary">
  101. <br>
  102. <br>
  103. <button id="btn-color-on-switch" class="btn btn-success">Change ON color</button>
  104. <button id="btn-color-off-switch" class="btn btn-danger">Change OFF color</button>
  105. <pre class="language-markup"><code>&lt;input type="checkbox" checked data-on-color="primary" data-off-color="info">
  106. &lt;input type="checkbox" checked data-on-color="info" data-off-color="success">
  107. &lt;input type="checkbox" checked data-on-color="success" data-off-color="warning">
  108. &lt;input type="checkbox" checked data-on-color="warning" data-off-color="danger">
  109. &lt;input type="checkbox" checked data-on-color="danger" data-off-color="default">
  110. &lt;input type="checkbox" checked data-on-color="default" data-off-color="primary">
  111. &lt;input type="checkbox" id="change-color-switch" checked data-on-color="default" data-off-color="primary"></code></pre>
  112. <pre class="language-javascript"><code>$('#change-color-switch').bootstrapSwitch('onColor', 'success');
  113. $('#change-color-switch').bootstrapSwitch('offColor', 'danger');</code></pre>
  114. </section>
  115. <section id="animation">
  116. <div class="page-header">
  117. <h2><a name="animation" class="anchor" href="#animation">Animation <small>JavaScript</small></a></h2>
  118. </div>
  119. <input type="checkbox" id="animated-switch" checked data-animated="false">
  120. <br>
  121. <br>
  122. <button id="btn-animate-switch" class="btn btn-default">Animate</button>
  123. <button id="btn-dont-animate-switch" class="btn btn-default">Don't animate</button>
  124. <pre class="language-markup"><code>&lt;input type="checkbox" checked data-animate="false"></code></pre>
  125. <pre class="language-javascript"><code>// Enables animation for the selected item
  126. $('#animated-switch').bootstrapSwitch('animate', true);
  127. // Disables animation for the selected item
  128. $('#animated-switch').bootstrapSwitch('animate', false);</code></pre>
  129. </section>
  130. <section id="disabled">
  131. <div class="page-header">
  132. <h2><a name="disabled" class="anchor" href="#disabled">Disabled / Readonly</a></h2>
  133. </div>
  134. <input type="checkbox" checked disabled>
  135. <input type="checkbox" checked readonly>
  136. <pre class="language-markup"><code>&lt;input type="checkbox" checked disabled>
  137. &lt;input type="checkbox" checked readonly></code></pre>
  138. </section>
  139. <section id="text">
  140. <div class="page-header">
  141. <h2><a name="text" class="anchor" href="#text">Text</a></h2>
  142. </div>
  143. <input type="checkbox" id="label-switch" checked data-on-text="SI" data-off-text="NO">
  144. <br>
  145. <br>
  146. <button id="btn-label-on-switch" class="btn btn-default">Change "On" label</button>
  147. <button id="btn-label-off-switch" class="btn btn-default">Change "Off" label</button>
  148. <pre class="language-markup"><code>&lt;input type="checkbox" checked data-on-text="SI" data-off-text="NO"></code></pre>
  149. <pre class="language-javascript"><code>$('#label-switch').bootstrapSwitch('onText', 'I');
  150. $('#label-switch').bootstrapSwitch('offText', 'O');</code></pre>
  151. </section>
  152. <section id="label-text">
  153. <div class="page-header">
  154. <h2><a href="#label-text">Label Text</a></h2>
  155. </div>
  156. <input type="checkbox" checked data-label-text="TV">
  157. <pre class="language-markup"><code>&lt;input type="checkbox" checked data-label-text="TV"></code></pre>
  158. </section>
  159. <section id="icon-label-text">
  160. <div class="page-header">
  161. <h2><a name="icon-label-text" class="anchor" href="#html-text-label-icon">Icon Label Text</a></h2>
  162. </div>
  163. Standard <input type="checkbox" checked data-size="large" data-label-text="<span class='glyphicon glyphicon-fullscreen'></span>" data-on-text="<span class='glyphicon glyphicon-ok'></span>" data-off-text="<span class='glyphicon glyphicon-remove'></span>"> &nbsp;&nbsp;
  164. Font Awesome <input type="checkbox" checked data-size="large" data-label-text="<span class='fa fa-youtube fa-lg'></span>" data-on-text="<span class='fa fa-thumbs-up fa-lg'></span>" data-off-text="<span class='fa fa-thumbs-down fa-lg'></span>"> &nbsp;&nbsp;
  165. Flat UI <input type="checkbox" data-size="large" checked data-label-text="<span class='fui-video'></span>" data-on-text="<span class='fui-check'></span>" data-off-text="<span class='fui-cross'></span>">
  166. <pre class="language-markup"><code>&lt;input type="checkbox" checked data-size="large" data-label-text="&lt;span class='glyphicon glyphicon-fullscreen'>&lt;/span>" data-on-text="&lt;span class='glyphicon glyphicon-ok'>&lt;/span>" data-off-text="&lt;span class='glyphicon glyphicon-remove'>&lt;/span>">
  167. &lt;input type="checkbox" checked data-size="large" data-label-text="&lt;span class='fa fa-youtube fa-lg'>&lt;/span>" data-on-text="&lt;span class='fa fa-thumbs-up fa-lg'>&lt;/span>" data-off-text="&lt;span class='fa fa-thumbs-down fa-lg'>&lt;/span>">
  168. &lt;input type="checkbox" data-size="large" checked data-label-text="&lt;span class='fui-video'>&lt;/span>" data-on-text="&lt;span class='fui-check'>&lt;/span>" data-off-text="&lt;span class='fui-cross'>&lt;/span>"></code></pre>
  169. </section>
  170. <div class="page-header">
  171. <h2><a name="event-handler-javascript" class="anchor" href="#event-handler-javascript">Event Handler <small>JavaScript</small></a></h2>
  172. </div>
  173. <div class="bs-docs-example">
  174. <input type="checkbox" id="switch-change" checked>
  175. </div>
  176. <pre class="language-javascript"><code>$('#switch-change').on('switchChange', function (e, data) {
  177. var $element = $(data.el),
  178. value = data.value;
  179. console.log(e, $element, value);
  180. });</code></pre>
  181. <div class="page-header">
  182. <h2><a name="label-event-handler-javascript" class="anchor" href="#label-event-handler-javascript">Label Event Handler <small>JavaScript</small></a></h2>
  183. </div>
  184. <div class="bs-docs-example">
  185. <label id="label-toggle-switch">Click on this Text to change the switch state</label>
  186. <input type="checkbox" checked class="label-toggle-switch">
  187. </div>
  188. <pre class="language-markup"><code>&lt;label id="label-toggle-switch">Click on this Text to change the switch state&lt;/label>
  189. &lt;input type="checkbox" checked></code></pre>
  190. <pre class="language-javascript"><code>$('#label-toggle-switch').on('click', function(e, data) {
  191. $('.label-toggle-switch').bootstrapSwitch('toggleState');
  192. });
  193. $('.label-toggle-switch').on('switch-change', function (e, data) {
  194. alert(data.value);
  195. });</code></pre>
  196. <div class="page-header">
  197. <h2><a name="toggle-state" class="anchor" href="#toggle-state">Toggle State <small>JavaScript</small></a></h2>
  198. </div>
  199. <div class="bs-docs-example">
  200. <input type="checkbox" id="toggle-state-switch" checked>
  201. <br>
  202. <br>
  203. <div id="toggle-state-switch-button-state" class="btn btn-default">State!</div>
  204. <div id="toggle-state-switch-button-on" class="btn btn-default">On</div>
  205. <div id="toggle-state-switch-button" class="btn btn-default">Toggle</div>
  206. <div id="toggle-state-switch-button-off" class="btn btn-default">Off</div>
  207. </div>
  208. <pre class="language-javascript"><code>$('#toggle-state-switch').bootstrapSwitch('state'); // true || false
  209. $('#toggle-state-switch').bootstrapSwitch('toggleState');
  210. $('#toggle-state-switch').bootstrapSwitch('state', false); // true || false</code></pre>
  211. <div class="page-header">
  212. <h2><a name="destroy" class="anchor" href="#destroy">Destroy <small>JavaScript</small></a></h2>
  213. </div>
  214. <div class="bs-docs-example">
  215. <input type="checkbox" id="destroy-switch" checked >
  216. <br>
  217. <br>
  218. <button id="btn-destroy-switch" class="btn btn-default">Destroy me!</button>
  219. </div>
  220. <pre class="language-javascript"><code>$('#destroy-switch').bootstrapSwitch('destroy');</code></pre>
  221. <div class="page-header">
  222. <h2><a name="disabled-javascript" class="anchor" href="#disabled-javascript">Disable / Readonly <small>JavaScript</small></a></h2>
  223. </div>
  224. <div class="bs-docs-example">
  225. <label for="disable-switch">Disable controls</label>
  226. <input type="checkbox" id="disable-switch" checked>
  227. <br>
  228. <br>
  229. <button id="btn-disable-is" class="btn btn-default">Is disabled?</button>
  230. <button id="btn-disable-toggle" class="btn btn-default">Toggle Disable</button>
  231. <button id="btn-disable-set" class="btn btn-default">Set Disable</button>
  232. <button id="btn-disable-remove" class="btn btn-default">Remove Disable</button>
  233. <br>
  234. <br>
  235. <label for="readonly-switch">Readonly controls</label>
  236. <input type="checkbox" id="readonly-switch" checked>
  237. <br>
  238. <br>
  239. <button id="btn-readonly-is" class="btn btn-default">Is readonly?</button>
  240. <button id="btn-readonly-toggle" class="btn btn-default">Toggle readonly</button>
  241. <button id="btn-readonly-set" class="btn btn-default">Set readonly</button>
  242. <button id="btn-readonly-remove" class="btn btn-default">Remove readonly</button>
  243. </div>
  244. <pre class="language-javascript"><code>$('#disable-switch').bootstrapSwitch('disabled');
  245. $('#disable-switch').bootstrapSwitch('toggleDisabled');
  246. $('#disable-switch').bootstrapSwitch('disabled', true); // true || false
  247. $('#readonly-switch').bootstrapSwitch('readonly');
  248. $('#readonly-switch').bootstrapSwitch('toggleReadonly');
  249. $('#readonly-switch').bootstrapSwitch('readonly', true); // true || false</code></pre>
  250. <div class="page-header">
  251. <h2><a name="radio-javascript" class="anchor" href="#radio-javascript">Radio <small>JavaScript</small></a></h2>
  252. </div>
  253. <div class="bs-docs-example">
  254. <div class="form-group">
  255. <label for="option1">Option 1</label>
  256. <input id="option1" type="radio" name="radio1" value="option1" class="radio1 radio-no-uncheck"> &nbsp;&nbsp;
  257. <label for="option2">Option 2</label>
  258. <input id="option2" type="radio" name="radio1" value="option2" class="radio1 radio-no-uncheck"> &nbsp;&nbsp;
  259. <label for="option3">Option 3</label>
  260. <input id="option3" type="radio" name="radio1" value="option3" class="radio1 radio-no-uncheck">
  261. </div>
  262. </div>
  263. <pre class="language-markup"><code>&lt;div class="form-group">
  264. &lt;label for="option1">Option 1&lt;/label>
  265. &lt;input id="option1" type="radio" name="radio1" value="option1">
  266. &lt;label for="option2">Option 2&lt;/label>
  267. &lt;input id="option2" type="radio" name="radio1" value="option2">
  268. &lt;label for="option3">Option 3&lt;/label>
  269. &lt;input id="option3" type="radio" name="radio1" value="option3">
  270. &lt;/div></code></pre>
  271. <div class="page-header">
  272. <h2><a name="radio-javascript-allow-uncheck" class="anchor" href="#radio-javascript-allow-uncheck">Radio + uncheck <small>JavaScript</small></a></h2>
  273. </div>
  274. <div class="bs-docs-example">
  275. <div class="form-group">
  276. <label for="option11">Option 1</label>
  277. <input id="option11" type="radio" name="radio2" value="option11" class="radio2">
  278. <label for="option12">Option 2</label>
  279. <input id="option12" type="radio" name="radio2" value="option12" checked="checked" class="radio2">
  280. <label for="option13">Option 3</label>
  281. <input id="option13" type="radio" name="radio2" value="option13" class="radio2">
  282. </div>
  283. </div>
  284. <pre class="language-markup"><code>&lt;div class="form-group">
  285. &lt;label for="option11">Option 1&lt;/label>
  286. &lt;input id="option11" type="radio" name="radio2" value="option1">
  287. &lt;label for="option12">Option 2&lt;/label>
  288. &lt;input id="option12" type="radio" name="radio2" value="option2" checked="checked">
  289. &lt;label for="option13">Option 3&lt;/label>
  290. &lt;input id="option13" type="radio" name="radio2" value="option3">
  291. &lt;/div></code></pre>
  292. <div class="page-header">
  293. <h2><a name="form" class="anchor" href="#form">Form</a></h2>
  294. </div>
  295. <div class="bs-docs-example">
  296. <form class="clearfix" role="form">
  297. <div class="form-group">
  298. <label class="control-label" for="inputEmail">Email</label>
  299. <input type="text" id="inputEmail" placeholder="Email" class="form-control">
  300. </div>
  301. <div class="form-group">
  302. <label class="control-label" for="notification1">Notification 1</label>
  303. <input id="notification1" type="checkbox">
  304. </div>
  305. <div class="form-group">
  306. <label class="control-label" for="notification2">Notification 2</label>
  307. <input id="notification2" type="checkbox">
  308. </div>
  309. <div class="form-actions">
  310. <button type="reset" class="btn btn-default btn-warning">Reset</button>
  311. </div>
  312. </form>
  313. <div ></div>
  314. </div>
  315. <pre class="language-markup"><code>&lt;form class="form-horizontal">
  316. &lt;div class="form-group">
  317. &lt;label class="control-label" for="inputEmail">Email&lt;/label>
  318. &lt;input type="text" id="inputEmail" placeholder="Email">
  319. &lt;/div>
  320. &lt;div class="form-group">
  321. &lt;label class="control-label" for="notification1">Notification 1&lt;/label>
  322. &lt;input id="notification1" type="checkbox">
  323. &lt;/div>
  324. &lt;div class="form-group">
  325. &lt;label class="control-label" for="notification2">Notification 2&lt;/label>
  326. &lt;input id="notification2" type="checkbox">
  327. &lt;/div>
  328. &lt;div class="form-actions">
  329. &lt;button type="reset" class="btn btn-inverse">Reset&lt;/button>
  330. &lt;/div>
  331. &lt;/form></code></pre>
  332. <div class="page-header">
  333. <h2><a name="modal" class="anchor" href="#modal">Modal</a></h2>
  334. </div>
  335. <div class="bs-docs-example">
  336. <a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal</a>
  337. </div>
  338. <pre class="language-markup"><code>&lt;a href="#myModal" role="button" class="btn btn-default" data-toggle="modal">Modal&lt;/a>
  339. &lt;div class="modal-body">
  340. &lt;input type="checkbox" checked>
  341. &lt;/div></code></pre>
  342. <footer class="footer">
  343. <p>&copy; 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>
  344. </footer>
  345. </div>
  346. </div>
  347. </div>
  348. <div id="myModal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
  349. <div class="modal-dialog">
  350. <div class="modal-content">
  351. <div class="modal-header">
  352. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
  353. <h3>Modal</h3>
  354. </div>
  355. <div class="modal-body">
  356. <input type="checkbox" checked>
  357. </div>
  358. <div class="modal-footer">
  359. <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button>
  360. </div>
  361. </div>
  362. </div>
  363. </div>
  364. <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
  365. <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
  366. <script src="build/js/bootstrap-switch.js"></script>
  367. <script src="docs/vendor/prism.js"></script>
  368. <script src="docs/index.js"></script>
  369. </body>
  370. </html>