index.html 33 KB

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