index.html 27 KB

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