index.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Bootstrap switch - by Mattia Larentis, enhanced by Peter Stein aka BdMdesigN</title>
  6. <meta name="description" content="Switches for radio buttons and checkboxes">
  7. <meta name="author" content="Mattia Larentis">
  8. <meta name="subauthor" content="Peter Stein">
  9. <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8;" />
  10. <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" />
  11. <link rel="stylesheet" href="static/stylesheets/bootstrap-switch.css" />
  12. <link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/js/google-code-prettify/prettify.css" />
  13. <link rel="stylesheet" href="http://getbootstrap.com/2.3.2/assets/css/docs.css" />
  14. <link rel="stylesheet" href="static/stylesheets/styles.css" />
  15. <style type="text/css">
  16. body {
  17. padding-top: 60px;
  18. padding-bottom: 40px;
  19. }
  20. .span4, h1 {
  21. text-align: center;
  22. }
  23. h1 {
  24. margin-bottom: 20px;
  25. }
  26. h3 {
  27. margin-top: 20px;
  28. }
  29. </style>
  30. <!-- TODO: make sure bootstrap-responsive.min.css points to BootTheme
  31. generated file -->
  32. <link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-responsive.min.css"
  33. rel="stylesheet">
  34. <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
  35. <!--[if lt IE 9]>
  36. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  37. <![endif]-->
  38. <!-- Fav and touch icons -->
  39. </head>
  40. <body>
  41. <div class="navbar navbar-fixed-top">
  42. <div class="navbar-inner">
  43. <a href="https://github.com/nostalgiaz/bootstrap-switch"><img
  44. style="position: absolute; top: 0; right: 0; border: 0;"
  45. src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"
  46. alt="Fork me on GitHub"></a>
  47. <div class="row-fluid" style="margin-top:10px;">
  48. <div class="span12">
  49. <h1>Bootstrap switch<small> - by <a href="http://larentis.eu">Mattia Larentis</a> <a href="https://twitter.com/spiritualguru">(@SpiritualGuru)</a></small></h1>
  50. </div>
  51. </div>
  52. <div class="row-fluid">
  53. <div class="span8 offset2" style="text-align: center;">
  54. <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&repo=bootstrap-switch&type=watch&count=true"
  55. allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
  56. <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&repo=bootstrap-switch&type=fork&count=true"
  57. allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
  58. <iframe src="http://ghbtns.com/github-btn.html?user=nostalgiaz&type=follow&count=true"
  59. allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
  60. </div>
  61. </div>
  62. <div class="container-fluid">
  63. <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span>
  64. <span class="icon-bar"></span>
  65. <span class="icon-bar"></span>
  66. </a>
  67. <div class="nav-collapse collapse">
  68. <p class="navbar-text pull-right" style="padding-right:15px;">Downloads:
  69. <a href="https://github.com/nostalgiaz/bootstrap-switch/zipball/master" class="navbar-link">ZIP</a>
  70. <a href="https://github.com/nostalgiaz/bootstrap-switch/tarball/master" class="navbar-link">TAR</a>
  71. </p>
  72. <ul class="nav nav-links">
  73. <li>
  74. <a href="./index.html">Home</a>
  75. </li>
  76. <li class="active">
  77. <a href="./examples.html">Demos</a>
  78. </li>
  79. </ul>
  80. </div>
  81. <!--/.nav-collapse -->
  82. </div>
  83. </div>
  84. </div>
  85. <div id="nav-content-container">
  86. <div class="container">
  87. <div class="wrapper">
  88. <nav>
  89. <ul></ul>
  90. </nav>
  91. <section>
  92. <h2><a name="size" class="anchor" href="#size"><span class="octicon octicon-link"></span></a>Size</h2>
  93. <!-- SIZE -->
  94. <div class="row-fluid">
  95. <div class="span12">
  96. <div class="bs-docs-example">
  97. <div class="make-switch switch-large">
  98. <input type="checkbox" checked />
  99. </div>
  100. <div class="make-switch">
  101. <input type="checkbox" checked />
  102. </div>
  103. <div class="make-switch switch-small">
  104. <input type="checkbox" checked />
  105. </div>
  106. <div class="make-switch switch-mini">
  107. <input type="checkbox" checked />
  108. </div>
  109. <br />
  110. <br />
  111. <label>Dimensions can be changed too:</label>
  112. <div id="dimension-switch" class="make-switch">
  113. <input type="checkbox" checked />
  114. </div>
  115. <br />
  116. <br />
  117. <button id="btn-size-large-switch" class="btn">Large</button>
  118. <button id="btn-size-regular-switch" class="btn">Regular</button>
  119. <button id="btn-size-small-switch" class="btn">Small</button>
  120. <button id="btn-size-mini-switch" class="btn">Mini</button>
  121. </div>
  122. <pre class="prettyprint linenums">
  123. &lt;div class="make-switch switch-large">
  124. &lt;input type="checkbox" checked />
  125. &lt;/div>
  126. &lt;div class="make-switch">
  127. &lt;input type="checkbox" checked />
  128. &lt;/div>
  129. &lt;div class="make-switch switch-small">
  130. &lt;input type="checkbox" checked />
  131. &lt;/div>
  132. &lt;div class="make-switch switch-mini">
  133. &lt;input type="checkbox" checked />
  134. &lt;/div>
  135. &lt;div id="dimension-switch" class="make-switch">
  136. &lt;input type="checkbox" checked />
  137. &lt;/div>
  138. </pre>
  139. <pre class="prettyprint linenums">
  140. $('#dimension-switch').bootstrapSwitch('setSizeClass', ''); // Resets to the regular style
  141. $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-mini'); // Sets a mini switch
  142. $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-small'); // Sets a small switch
  143. $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-large'); // Sets a large switch
  144. </pre>
  145. </div>
  146. </div>
  147. <h2><a name="colors" class="anchor" href="#colors"><span class="octicon octicon-link"></span></a>Colors</h2>
  148. <!-- COLORS -->
  149. <div class="row-fluid">
  150. <div class="span12">
  151. <div class="bs-docs-example">
  152. <div class="make-switch" data-on="primary" data-off="info">
  153. <input type="checkbox" checked />
  154. </div>
  155. <div class="make-switch" data-on="info" data-off="success">
  156. <input type="checkbox" checked />
  157. </div>
  158. <div class="make-switch" data-on="success" data-off="warning">
  159. <input type="checkbox" checked />
  160. </div>
  161. <div class="make-switch" data-on="warning" data-off="danger">
  162. <input type="checkbox" checked />
  163. </div>
  164. <div class="make-switch" data-on="danger" data-off="default">
  165. <input type="checkbox" checked />
  166. </div>
  167. <div class="make-switch" data-on="default" data-off="primary">
  168. <input type="checkbox" checked />
  169. </div>
  170. <br />
  171. <br />
  172. <label for="change-color-switch">Colors can be changed too</label>
  173. <div id="change-color-switch" class="make-switch" data-on="default" data-off="primary">
  174. <input type="checkbox" checked />
  175. </div>
  176. <br />
  177. <br />
  178. <button id="btn-color-on-switch" class="btn">
  179. Change "On" color
  180. </button>
  181. <button id="btn-color-off-switch" class="btn">
  182. Change "Off" color
  183. </button>
  184. </div>
  185. <pre class="prettyprint linenums">
  186. &lt;div class="make-switch" data-on="primary" data-off="info">
  187. &lt;input type="checkbox" checked />
  188. &lt;/div>
  189. &lt;div class="make-switch" data-on="info" data-off="success">
  190. &lt;input type="checkbox" checked />
  191. &lt;/div>
  192. &lt;div class="make-switch" data-on="success" data-off="warning">
  193. &lt;input type="checkbox" checked />
  194. &lt;/div>
  195. &lt;div class="make-switch" data-on="warning" data-off="danger">
  196. &lt;input type="checkbox" checked />
  197. &lt;/div>
  198. &lt;div class="make-switch" data-on="danger" data-off="default">
  199. &lt;input type="checkbox" checked />
  200. &lt;/div>
  201. &lt;div class="make-switch" data-on="default" data-off="primary">
  202. &lt;input type="checkbox" checked />
  203. &lt;/div>
  204. &lt;div id="change-color-switch" class="make-switch" data-on="default" data-off="primary">
  205. &lt;input type="checkbox" checked />
  206. &lt;/div>
  207. </pre>
  208. <pre class="prettyprint linenums">
  209. $('#change-color-switch').bootstrapSwitch('setOnClass', 'success');
  210. $('#change-color-switch').bootstrapSwitch('setOffClass', 'danger');
  211. </pre>
  212. </div>
  213. </div>
  214. <h2><a name="animation" class="anchor" href="#animation"><span class="octicon octicon-link"></span></a>Animation <small>javascript</small></h2>
  215. <!-- ANIMATION -->
  216. <div class="row-fluid">
  217. <div class="span12">
  218. <div class="bs-docs-example">
  219. <div id="animated-switch" class="make-switch" data-animated="false">
  220. <input type="checkbox" checked />
  221. </div>
  222. <br />
  223. <br />
  224. <button id="btn-animate-switch" class="btn">
  225. Animate
  226. </button>
  227. <button id="btn-dont-animate-switch" class="btn">
  228. Don't animate
  229. </button>
  230. </div>
  231. <pre class="prettyprint linenums">
  232. &lt;div id="animated-switch" class="make-switch" data-animated="false">
  233. &lt;input type="checkbox" checked />
  234. &lt;/div>
  235. </pre>
  236. <pre class="prettyprint linenums">
  237. $('#animated-switch').bootstrapSwitch('setAnimated', true); // Enables animation for the selected item
  238. $('#animated-switch').bootstrapSwitch('setAnimated', false); // Disables animation for the selected item
  239. </pre>
  240. </div>
  241. </div>
  242. <h2><a name="disabled" class="anchor" href="#disabled"><span class="octicon octicon-link"></span></a>Disabled</h2>
  243. <!-- DISABLED -->
  244. <div class="row-fluid">
  245. <div class="span12">
  246. <div class="bs-docs-example">
  247. <div class="make-switch">
  248. <input type="checkbox" checked disabled />
  249. </div>
  250. </div>
  251. <pre class="prettyprint linenums">
  252. &lt;div class="make-switch">
  253. &lt;input type="checkbox" checked disabled />
  254. &lt;/div>
  255. </pre>
  256. </div>
  257. </div>
  258. <h2><a name="text" class="anchor" href="#text"><span class="octicon octicon-link"></span></a>Text</h2>
  259. <!-- TEXT -->
  260. <div class="row-fluid">
  261. <div class="span12">
  262. <div class="bs-docs-example">
  263. <div id="label-switch" class="make-switch" data-on-label="SI" data-off-label="NO">
  264. <input type="checkbox" checked />
  265. </div>
  266. <br />
  267. <br />
  268. <button id="btn-label-on-switch" class="btn">
  269. Change "On" label
  270. </button>
  271. <button id="btn-label-off-switch" class="btn">
  272. Change "Off" label
  273. </button>
  274. </div>
  275. <pre class="prettyprint linenums">
  276. &lt;div id="label-switch" class="make-switch" data-on-label="SI" data-off-label="NO">
  277. &lt;input type="checkbox" checked />
  278. &lt;/div>
  279. </pre>
  280. <pre class="prettyprint linenums">
  281. $('#label-switch').bootstrapSwitch('setOnLabel', 'I');
  282. $('#label-switch').bootstrapSwitch('setOffLabel', 'O');
  283. </pre>
  284. </div>
  285. </div>
  286. <h2><a name="html-text" class="anchor" href="#html-text"><span class="octicon octicon-link"></span></a>HTML text</h2>
  287. <!-- HTML TEXT -->
  288. <div class="row-fluid">
  289. <div class="span12">
  290. <div class="bs-docs-example">
  291. <div class="make-switch" data-on-label="<i class='icon-ok icon-white'></i>" data-off-label="<i class='icon-remove'></i>">
  292. <input type="checkbox" checked />
  293. </div>
  294. </div>
  295. <pre class="prettyprint linenums">
  296. &lt;div class="make-switch" data-on-label="&lt;i class='icon-ok icon-white'>&lt;/i>" data-off-label="&lt;i class='icon-remove'>&lt;/i>">
  297. &lt;input type="checkbox" checked />
  298. &lt;/div>
  299. </pre>
  300. </div>
  301. </div>
  302. <h2><a name="html-text-mini-switch" class="anchor" href="#html-text-mini-switch"><span class="octicon octicon-link"></span></a>HTML text (mini-switch)</h2>
  303. <!-- HTML TEXT MINI SWITCH -->
  304. <div class="row-fluid">
  305. <div class="span12">
  306. <div class="bs-docs-example">
  307. <div class="make-switch switch-mini" data-on-label="<i class='switch-mini-icons icon-ok icon-white'></i>" data-off-label="<i class='switch-mini-icons icon-remove'></i>">
  308. <input type="checkbox" checked />
  309. </div>
  310. </div>
  311. <pre class="prettyprint linenums">
  312. &lt;div class="make-switch switch-mini" data-on-label="&lt;i class='switch-mini-icons icon-ok icon-white'>&lt;/i>" data-off-label="&lt;i class='switch-mini-icons icon-remove'>&lt;/i>">
  313. &lt;input type="checkbox" checked />
  314. &lt;/div>
  315. </pre>
  316. </div>
  317. </div>
  318. <h2><a name="event-handler" class="anchor" href="#event-handler"><span class="octicon octicon-link"></span></a>Event handler <small>javascript</small></h2>
  319. <!-- EVENT HANDLER -->
  320. <div class="row-fluid">
  321. <div class="span12">
  322. <div class="bs-docs-example">
  323. <div id="mySwitch" class="make-switch">
  324. <input type="checkbox" checked />
  325. </div>
  326. </div>
  327. <pre class="prettyprint linenums">
  328. $('#mySwitch').on('switch-change', function (e, data) {
  329. var $el = $(data.el)
  330. , value = data.value;
  331. console.log(e, $el, value);
  332. });
  333. </pre>
  334. </div>
  335. </div>
  336. <h2><a name="toggle-state " class="anchor" href="#toggle-state"><span class="octicon octicon-link"></span></a>Toggle State <small>javascript</small></h2>
  337. <!-- TOGGLE -->
  338. <div class="row-fluid">
  339. <div class="span12">
  340. <div class="bs-docs-example">
  341. <div id="toggle-state-switch" class="make-switch">
  342. <input type="checkbox" checked />
  343. </div>
  344. <br />
  345. <br />
  346. <div id="toggle-state-switch-button-status" class="btn btn-primary">Status!</div>
  347. <div id="toggle-state-switch-button-on" class="btn btn-primary">ON!</div>
  348. <div id="toggle-state-switch-button" class="btn btn-primary">Toggle me!</div>
  349. <div id="toggle-state-switch-button-off" class="btn btn-primary">OFF!</div>
  350. </div>
  351. <pre class="prettyprint linenums">
  352. $('#toggle-state-switch').bootstrapSwitch('status'); // true || false
  353. $('#toggle-state-switch').bootstrapSwitch('toggleState');
  354. $('#toggle-state-switch').bootstrapSwitch('setState', false); // true || false
  355. </pre>
  356. </div>
  357. </div>
  358. <h2><a name="destroy" class="anchor" href="#destroy"><span class="octicon octicon-link"></span></a>Destroy <small>javascript</small></h2>
  359. <!-- DESTROY -->
  360. <div class="row-fluid">
  361. <div class="span12">
  362. <div class="bs-docs-example">
  363. <div id="destroy-switch" class="make-switch">
  364. <input type="checkbox" checked />
  365. </div>
  366. <br />
  367. <br />
  368. <button id="btn-destroy-switch" class="btn btn-danger">
  369. Destroy me!
  370. </button>
  371. </div>
  372. <pre class="prettyprint linenums">
  373. $('#destroy-switch').bootstrapSwitch('destroy');
  374. </pre>
  375. </div>
  376. </div>
  377. <h2><a name="create" class="anchor" href="#create"><span class="octicon octicon-link"></span></a>Create <small>javascript</small></h2>
  378. <!-- CREATE -->
  379. <div class="row-fluid">
  380. <div class="span12">
  381. <div class="bs-docs-example">
  382. <input id="create-switch" type="checkbox" checked />
  383. <br />
  384. <br />
  385. <div id="btn-create" class="btn">Create</div>
  386. </div>
  387. <pre class="prettyprint linenums">
  388. $('#create-switch').wrap('&lt;div class="make-switch" />').parent().bootstrapSwitch();
  389. </pre>
  390. </div>
  391. </div>
  392. <h2><a name="disabled-javascript" class="anchor" href="#disabled-javascript"><span class="octicon octicon-link"></span></a>Disabled <small>javascript</small></h2>
  393. <!-- DISABLED -->
  394. <div class="row-fluid">
  395. <div class="span12">
  396. <div class="bs-docs-example">
  397. <label for="disable-switch-input">amazing label</label>
  398. <div id="disable-switch" class="make-switch">
  399. <input id="disable-switch-input" type="checkbox" checked />
  400. </div>
  401. <br />
  402. <br />
  403. <button id="btn-is-active-switch" class="btn">
  404. Is active?
  405. </button>
  406. <button id="btn-toggle-activation-switch" class="btn">
  407. Toggle activation!
  408. </button>
  409. <button id="btn-disable-switch" class="btn">
  410. Disable!
  411. </button>
  412. <button id="btn-activate-switch" class="btn">
  413. Activate!
  414. </button>
  415. </div>
  416. <pre class="prettyprint linenums">
  417. $('#disable-switch').bootstrapSwitch('isActive');
  418. $('#disable-switch').bootstrapSwitch('toggleActivation');
  419. $('#disable-switch').bootstrapSwitch('setActive', false); // true || false
  420. </pre>
  421. </div>
  422. </div>
  423. <h2><a name="radio-javascript" class="anchor" href="#radio-javascript"><span class="octicon octicon-link"></span></a>Radio <small>javascript</small></h2>
  424. <!-- RADIO -->
  425. <div class="row-fluid">
  426. <div class="span12">
  427. <div class="bs-docs-example">
  428. <div class="control-group">
  429. <div class="controls">
  430. <label class="control-label" for="option1">Option 1</label>
  431. <div id="option1" class="make-switch radio1 radio-no-uncheck">
  432. <input type="radio" name="radio1" value="option1" />
  433. </div>
  434. <label class="control-label" for="option2">Option 2</label>
  435. <div id="option2" class="make-switch radio1 radio-no-uncheck">
  436. <input type="radio" name="radio1" value="option2" />
  437. </div>
  438. <label class="control-label" for="option3">Option 3</label>
  439. <div id="option3" class="make-switch radio1 radio-no-uncheck">
  440. <input type="radio" name="radio1" value="option3" />
  441. </div>
  442. </div>
  443. </div>
  444. </div>
  445. <pre class="prettyprint linenums">
  446. &lt;div class="control-group">
  447. &lt;div class="controls">
  448. &lt;label class="control-label" for="option1">Option 1&lt;/label>
  449. &lt;div id="option1" class="make-switch radio1 radio-no-uncheck">
  450. &lt;input type="radio" name="radio1" value="option1" />
  451. &lt;/div>
  452. &lt;label class="control-label" for="option2">Option 2&lt;/label>
  453. &lt;div id="option2" class="make-switch radio1 radio-no-uncheck">
  454. &lt;input type="radio" name="radio1" value="option2" />
  455. &lt;/div>
  456. &lt;label class="control-label" for="option3">Option 3&lt;/label>
  457. &lt;div id="option3" class="make-switch radio1 radio-no-uncheck">
  458. &lt;input type="radio" name="radio1" value="option3" />
  459. &lt;/div>
  460. &lt;/div>
  461. &lt;/div>
  462. &lt;script>
  463. $(document).ready(function() {
  464. $('.radio1').on('switch-change', function () {
  465. $('.radio1').bootstrapSwitch('toggleRadioState');
  466. });
  467. // or
  468. $('.radio1').on('switch-change', function () {
  469. $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck');
  470. });
  471. // or
  472. $('.radio1').on('switch-change', function () {
  473. $('.radio1').bootstrapSwitch('toggleRadioStateAllowUncheck', false);
  474. });
  475. });
  476. &lt;/script>
  477. </pre>
  478. </div>
  479. </div>
  480. <h2><a name="radio-javascript-allow-uncheck" class="anchor" href="#radio-javascript-allow-uncheck"><span class="octicon octicon-link"></span></a>Radio <small>javascript (allow radios uncheck)</small></h2>
  481. <!-- RADIO ALLOW UNCHECK -->
  482. <div class="row-fluid">
  483. <div class="span12">
  484. <div class="bs-docs-example">
  485. <div class="control-group">
  486. <div class="controls">
  487. <label class="control-label" for="option1">Option 1</label>
  488. <div id="option1" class="make-switch radio2">
  489. <input type="radio" name="radio2" value="option1" />
  490. </div>
  491. <label class="control-label" for="option2">Option 2</label>
  492. <div id="option2" class="make-switch radio2">
  493. <input type="radio" name="radio2" value="option2" checked="checked" />
  494. </div>
  495. <label class="control-label" for="option3">Option 3</label>
  496. <div id="option3" class="make-switch radio2">
  497. <input type="radio" name="radio2" value="option3" />
  498. </div>
  499. </div>
  500. </div>
  501. </div>
  502. <pre class="prettyprint linenums">
  503. &lt;div class="control-group">
  504. &lt;div class="controls">
  505. &lt;label class="control-label" for="option1">Option 1&lt;/label>
  506. &lt;div id="option1" class="make-switch radio2">
  507. &lt;input type="radio" name="radio2" value="option1" />
  508. &lt;/div>
  509. &lt;label class="control-label" for="option2">Option 2&lt;/label>
  510. &lt;div id="option2" class="make-switch radio2">
  511. &lt;input type="radio" name="radio2" value="option2" checked="checked" />
  512. &lt;/div>
  513. &lt;label class="control-label" for="option3">Option 3&lt;/label>
  514. &lt;div id="option3" class="make-switch radio2">
  515. &lt;input type="radio" name="radio2" value="option3" />
  516. &lt;/div>
  517. &lt;/div>
  518. &lt;/div>
  519. &lt;script>
  520. $(document).ready(function() {
  521. $('.radio2').on('switch-change', function () {
  522. $('.radio2').bootstrapSwitch('toggleRadioStateAllowUncheck', true);
  523. });
  524. });
  525. &lt;/script>
  526. </pre>
  527. </div>
  528. </div>
  529. <h2><a name="form" class="anchor" href="#form"><span class="octicon octicon-link"></span></a>Form <small>- try to use tab, space and reset button</small></h2>
  530. <!-- FORM -->
  531. <div class="row-fluid">
  532. <div class="span12">
  533. <div class="bs-docs-example">
  534. <form class="form-horizontal span8 offset2">
  535. <div class="control-group">
  536. <label class="control-label" for="inputEmail">Email</label>
  537. <div class="controls">
  538. <input type="text" id="inputEmail" placeholder="Email">
  539. </div>
  540. </div>
  541. <div class="control-group">
  542. <label class="control-label" for="notification1">Notification 1</label>
  543. <div class="controls">
  544. <div class="make-switch" tabindex="0">
  545. <input id="notification1" type="checkbox" />
  546. </div>
  547. </div>
  548. </div>
  549. <div class="control-group">
  550. <label class="control-label" for="notification2">Notification 2</label>
  551. <div class="controls">
  552. <div class="make-switch" tabindex="0">
  553. <input id="notification2" type="checkbox" />
  554. </div>
  555. </div>
  556. </div>
  557. <div class="form-actions">
  558. <button type="reset" class="btn btn-inverse">Reset</button>
  559. </div>
  560. </form>
  561. <div class="clearfix"></div>
  562. </div>
  563. <pre class="prettyprint linenums">
  564. &lt;form class="form-horizontal">
  565. &lt;div class="control-group">
  566. &lt;label class="control-label" for="inputEmail">Email&lt;/label>
  567. &lt;div class="controls">
  568. &lt;input type="text" id="inputEmail" placeholder="Email">
  569. &lt;/div>
  570. &lt;/div>
  571. &lt;div class="control-group">
  572. &lt;label class="control-label" for="notification1">Notification 1&lt;/label>
  573. &lt;div class="controls">
  574. &lt;div class="make-switch" tabindex="0">
  575. &lt;input id="notification1" type="checkbox" />
  576. &lt;/div>
  577. &lt;/div>
  578. &lt;/div>
  579. &lt;div class="control-group">
  580. &lt;label class="control-label" for="notification2">Notification 2&lt;/label>
  581. &lt;div class="controls">
  582. &lt;div class="make-switch" tabindex="0">
  583. &lt;input id="notification2" type="checkbox" />
  584. &lt;/div>
  585. &lt;/div>
  586. &lt;/div>
  587. &lt;div class="form-actions">
  588. &lt;button type="reset" class="btn btn-inverse">Reset&lt;/button>
  589. &lt;/div>
  590. &lt;/form>
  591. </pre>
  592. </div>
  593. </div>
  594. <h2><a name="modal" class="anchor" href="#modal"><span class="octicon octicon-link"></span></a>Modal</h2>
  595. <!-- MODAL -->
  596. <div class="row-fluid">
  597. <div class="span12">
  598. <div class="bs-docs-example">
  599. <a href="#myModal" role="button" class="btn" data-toggle="modal">Modal</a>
  600. </div>
  601. <pre class="prettyprint linenums">
  602. &lt;a href="#myModal" role="button" class="btn" data-toggle="modal">Modal&lt;/a>
  603. -----
  604. &lt;div class="modal-body">
  605. &lt;div class="make-switch">
  606. &lt;input type="checkbox" checked />
  607. &lt;/div>
  608. &lt;/div></pre>
  609. </div>
  610. </div>
  611. </div>
  612. <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  613. <div class="modal-header">
  614. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  615. <h3>Modal</h3>
  616. </div>
  617. <div class="modal-body">
  618. <div class="make-switch">
  619. <input type="checkbox" checked />
  620. </div>
  621. </div>
  622. <div class="modal-footer">
  623. <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
  624. </div>
  625. </div>
  626. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  627. <script>
  628. $(document).ready(function() {
  629. window.prettyPrint && prettyPrint();
  630. $('#mySwitch').on('switch-change', function (e, data) {
  631. var $el = $(data.el)
  632. , value = data.value;
  633. console.log(e, $el, value);
  634. });
  635. // DIMENSION
  636. $('#btn-size-regular-switch').on('click', function () {
  637. $('#dimension-switch').bootstrapSwitch('setSizeClass', '');
  638. });
  639. $('#btn-size-mini-switch').on('click', function () {
  640. $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-mini');
  641. });
  642. $('#btn-size-small-switch').on('click', function () {
  643. $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-small');
  644. });
  645. $('#btn-size-large-switch').on('click', function () {
  646. $('#dimension-switch').bootstrapSwitch('setSizeClass', 'switch-large');
  647. });
  648. // STATE
  649. $('#toggle-state-switch-button').on('click', function () {
  650. $('#toggle-state-switch').bootstrapSwitch('toggleState');
  651. });
  652. $('#toggle-state-switch-button-on').on('click', function () {
  653. $('#toggle-state-switch').bootstrapSwitch('setState', true);
  654. });
  655. $('#toggle-state-switch-button-off').on('click', function () {
  656. $('#toggle-state-switch').bootstrapSwitch('setState', false);
  657. });
  658. $('#toggle-state-switch-button-status').on('click', function () {
  659. alert($('#toggle-state-switch').bootstrapSwitch('status'));
  660. });
  661. // DESTROY
  662. $('#btn-destroy-switch').on('click', function () {
  663. $('#destroy-switch').bootstrapSwitch('destroy');
  664. $(this).remove();
  665. });
  666. // CREATE
  667. $('#btn-create').on('click', function () {
  668. $('#create-switch').wrap('<div class="make-switch" />').parent().bootstrapSwitch();
  669. $(this).remove()
  670. });
  671. // ACTIVATION
  672. $('#btn-is-active-switch').on('click', function () {
  673. alert($('#disable-switch').bootstrapSwitch('isActive'));
  674. });
  675. $('#btn-toggle-activation-switch').on('click', function () {
  676. $('#disable-switch').bootstrapSwitch('toggleActivation');
  677. });
  678. $('#btn-disable-switch').on('click', function () {
  679. $('#disable-switch').bootstrapSwitch('setActive', false);
  680. });
  681. $('#btn-activate-switch').on('click', function () {
  682. $('#disable-switch').bootstrapSwitch('setActive', true);
  683. });
  684. // LABEL
  685. $('#btn-label-on-switch').on('click', function() {
  686. $('#label-switch').bootstrapSwitch('setOnLabel', 'I');
  687. });
  688. $('#btn-label-off-switch').on('click', function() {
  689. $('#label-switch').bootstrapSwitch('setOffLabel', 'O');
  690. });
  691. // COLOR
  692. $('#btn-color-on-switch').on('click', function() {
  693. $('#change-color-switch').bootstrapSwitch('setOnClass', 'success');
  694. });
  695. $('#btn-color-off-switch').on('click', function() {
  696. $('#change-color-switch').bootstrapSwitch('setOffClass', 'danger');
  697. });
  698. // ANIMATION
  699. $('#btn-animate-switch').on('click', function() {
  700. $('#animated-switch').bootstrapSwitch('setAnimated', true);
  701. });
  702. $('#btn-dont-animate-switch').on('click', function() {
  703. $('#animated-switch').bootstrapSwitch('setAnimated', false);
  704. });
  705. // RADIO
  706. $('.radio1').on('switch-change', function () {
  707. $('.radio1').bootstrapSwitch('toggleRadioState');
  708. });
  709. $('.radio2').on('switch-change', function () {
  710. $('.radio2').bootstrapSwitch('toggleRadioStateAllowUncheck', true);
  711. });
  712. });
  713. </script>
  714. </section>
  715. </div>
  716. </div>
  717. </div>
  718. <footer>
  719. <div class="navbar navbar-fixed-bottom" style="height:30px;">
  720. <div class="navbar-inner">
  721. <div class="container-fluid">
  722. <p style="float:left; padding-top: 5px;">
  723. &copy; by
  724. Mattia Larentis 2012 - 2013, enhanced by Peter Stein (BdMdesigN)
  725. <i class="icon-asterisk"> </i> design by BdMdesigN
  726. </p>
  727. <p class="pull-right" style="padding-top: 5px;">
  728. <a href="https://twitter.com/SpiritualGuru">follow me</a> -
  729. <a href="http://www.larentis.eu">my site</a>
  730. </p>
  731. </div>
  732. </div>
  733. </div>
  734. </footer>
  735. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  736. <script src="http://getbootstrap.com/2.3.2/assets/js/google-code-prettify/prettify.js"></script>
  737. <script src="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
  738. <script src="static/js/bootstrap-switch.js"></script>
  739. <script src="static/js/main.js"></script>
  740. </body>
  741. </html>