index.html 28 KB

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