index.html 35 KB

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