index.html 28 KB

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