index.html 21 KB

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