index.html 28 KB

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