demo.html 19 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <html>
  2. <head>
  3. <title>jQuery Switchbutton</title>
  4. <link type="text/css" rel="stylesheet" href="../ui.switchbutton.min.css" />
  5. <link type="text/css" rel="stylesheet" href="./demo.css" />
  6. <script type="text/javascript" src="./jquery-1.6.2.min.js"></script>
  7. <script type="text/javascript" src="./jquery.tmpl.min.js"></script>
  8. <script type="text/javascript" src="./jquery-ui-1.8.16.custom.min.js"></script>
  9. <script type="text/javascript" src="../jquery.switchbutton.min.js"></script>
  10. <script type="text/javascript" src="./demo.js"></script>
  11. </head>
  12. <body>
  13. <div id="page">
  14. <h3>jQuery Switchbutton</h3>
  15. <p class="listTitle">Checked by default</p>
  16. <input type="checkbox" class="common" id="switch1" checked="checked" />
  17. <p class="listTitle">Unchecked by default</p>
  18. <input type="checkbox" class="common" id="switch2" />
  19. <p class="listTitle">Disabled by default</p>
  20. <input type="checkbox" class="common" id="switch3" disabled="disabled" />
  21. <p class="listTitle">With a label</p>
  22. <input type="checkbox" class="common" id="switch4" checked="checked" />
  23. <label for="switch4">Click the label</label>
  24. <p class="listTitle">With some actions</p>
  25. <input type="checkbox" id="switch5" checked="checked" /><br />
  26. <span class="lightgrey actions" id="uncheck5">Uncheck -</span>
  27. <span class="lightgrey actions" id="check5">Check -</span>
  28. <span class="lightgrey actions" id="disable5">Disable -</span>
  29. <span class="lightgrey actions" id="enable5">Enable</span>
  30. <p class="listTitle">With custom labels and callbacks</p>
  31. <input type="checkbox" id="switch6" checked="checked" />
  32. <p class="listTitle">With custom options</p>
  33. <input type="checkbox" id="switch7" checked="checked" /><br />
  34. <span class="lightgrey">With &laquo; thin &raquo; class and labels set to false</span>
  35. <br /><br />
  36. <input type="checkbox" id="switch8" checked="checked" /><br />
  37. <span class="lightgrey">With &laquo; ios5 &raquo; class</span>
  38. <p class="listTitle" id="showCode">Show code</p>
  39. <div id="pageCode"><div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009966; font-style: italic;">/* Simple ones */</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.common:checkbox&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">switchbutton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #006600; font-style: italic;">/* Switch 5: with check/enable actions */</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">switchbutton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#uncheck5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prop</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;checked&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#check5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prop</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;checked&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#disable5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">switchbutton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;disable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#enable5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch5&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">switchbutton</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;enable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009966; font-style: italic;">/* Switch 6: with custom labels and callbacks */</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch6&quot;</span><span style="color: #009900;">&#41;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> .<span style="color: #660066;">switchbutton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> checkedLabel<span style="color: #339933;">:</span> <span style="color: #3366CC;">'YES'</span><span style="color: #339933;">,</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> uncheckedLabel<span style="color: #339933;">:</span> <span style="color: #3366CC;">'NO'</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> .<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Switch 6 changed to &quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prop</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;checked&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">&quot;checked&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;unchecked&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009966; font-style: italic;">/* Switch 7: with custom options */</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;">&nbsp;</pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#switch7&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">switchbutton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> classes<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ui-switchbutton-thin'</span><span style="color: #339933;">,</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> labels<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span></pre></li><li style="font-weight: bold; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li><li style="font-weight: normal; vertical-align:top;"><pre style="font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></li></ol></div></div>
  40. </div>
  41. <div id="footer">
  42. <h3>jQuery Switchbutton</h3>
  43. <p class="lightGrey">
  44. Based on work by tdreyno on iphone-style-checkboxes for events management<br />
  45. (<a href="https://github.com/tdreyno/iphone-style-checkboxes" target="_blank">https://github.com/tdreyno/iphone-style-checkboxes)</a>
  46. </p>
  47. <p class="lightGrey">
  48. Copyright 2011, L.STEVENIN for <a href="http://www.naeka.fr/" target="_blank">Naeka</a><br />
  49. Released under the MIT license.
  50. </p>
  51. <br /><br />
  52. <p class="lightGrey">
  53. <h4>Requirements</h4>
  54. <a href="http://jquery.com/" target="_blank">jQuery 1.6+</a><br />
  55. <a href="http://api.jquery.com/category/plugins/templates/" target="_blank">jQuery Templates</a><br />
  56. <a href="http://jqueryui.com/download" target="_blank">jQuery UI Widget</a>
  57. </p>
  58. </div>
  59. </body>
  60. </html>