index.html 28 KB

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