index.html 35 KB

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