You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

329 lines
9.0 KiB

  1. ---
  2. layout : 'default'
  3. css : 'checkbox'
  4. title : 'Checkbox'
  5. description : "A checkbox visually indicates the status of a user's selection"
  6. type : 'UI Module'
  7. ---
  8. <script src="/javascript/checkbox.js"></script>
  9. <%- @partial('header', { tabs: 'module' }) %>
  10. <div class="main container">
  11. <div class="ui tab" data-tab="definition">
  12. <div class="peek">
  13. <div class="ui vertical pointing secondary menu">
  14. <a class="active item">Types</a>
  15. <a class="item">Variations</a>
  16. </div>
  17. </div>
  18. <h2 class="ui dividing header">Types</h2>
  19. <div class="example">
  20. <h4 class="ui header">Checkbox</h4>
  21. <p>A standard checkbox</p>
  22. <div class="ui checkbox">
  23. <input type="checkbox" name="fun" />
  24. <label>I enjoy having fun</label>
  25. </div>
  26. </div>
  27. <div class="example">
  28. <h4 class="ui header">Slider</h4>
  29. <p>A checkbox can be formatted to show user selection as a slider</p>
  30. <div class="ui slider checkbox">
  31. <input type="checkbox" name="walk" />
  32. <label>Allow others to see when your dog is on a walk</label>
  33. </div>
  34. </div>
  35. <div class="example">
  36. <h4 class="ui header">Toggle</h4>
  37. <p>A checkbox can be formatted to show user selection as a toggle</p>
  38. <div class="ui toggle checkbox">
  39. <input type="checkbox" name="pet" />
  40. <label>Allow other people to pet my dog</label>
  41. </div>
  42. </div>
  43. <div class="example">
  44. <h4 class="ui header">Radio Box</h4>
  45. <p>A checkbox can be formatted as a radio element. This means it is an exclusive option.</p>
  46. <div class="ui form">
  47. <div class="grouped inline fields">
  48. <div class="field">
  49. <div class="ui radio checkbox">
  50. <input type="radio" name="fruit" checked="checked" />
  51. <label>Apples</label>
  52. </div>
  53. </div>
  54. <div class="field">
  55. <div class="ui radio checkbox">
  56. <input type="radio" name="fruit" />
  57. <label>Oranges</label>
  58. </div>
  59. </div>
  60. <div class="field">
  61. <div class="ui radio checkbox">
  62. <input type="radio" name="fruit" />
  63. <label>Pears</label>
  64. </div>
  65. </div>
  66. <div class="field">
  67. <div class="ui radio checkbox">
  68. <input type="radio" name="fruit" />
  69. <label>Grapefruit</label>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. <h2 class="ui dividing header">Variations</h2>
  76. <div class="example">
  77. <h4 class="ui header">Size</h4>
  78. <p>A checkbox can be a different size.</p>
  79. <div class="ui large checkbox">
  80. <input type="checkbox" />
  81. <label>Add a pro membership</label>
  82. </div>
  83. </div>
  84. <div class="another example">
  85. <div class="ui huge checkbox">
  86. <input type="checkbox" />
  87. <label>Signup for our mailing list</label>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="ui tab" data-tab="usage">
  92. <h3 class="ui header">Check Box</h3>
  93. <p>A checkbox can be initialized with javascript for increase programmatic control</p>
  94. <div class="code">
  95. $('.ui.checkbox')
  96. .checkbox()
  97. ;
  98. </div>
  99. <div class="code" data-type="html">
  100. <div class="ui checkbox">
  101. <input type="checkbox">
  102. <label>Poodle</label>
  103. </div>
  104. </div>
  105. <h3 class="ui header">Check Box without Javascript</h3>
  106. <p>A checkbox can also be used without using javascript by matching the <code>id</code> attribute of the input field to the <code>for</code> attribute of the accompanying label</p>
  107. <div class="code" data-type="html">
  108. <div class="ui checkbox">
  109. <input type="checkbox" id="unique-id" />
  110. <label for="unique-id">Poodle</label>
  111. </div>
  112. </div>
  113. <h2 class="ui dividing header">Behavior</h2>
  114. <table class="ui definition celled table segment">
  115. <tr>
  116. <td>enable</td>
  117. <td>A checkbox can change to show a user has selected it</td>
  118. </tr>
  119. <tr>
  120. <td>disable</td>
  121. <td>A checkbox can change to show a user has deselected it</td>
  122. </tr>
  123. <tr>
  124. <td>toggle</td>
  125. <td>A checkbox can toggle its current selection state</td>
  126. </tr>
  127. </table>
  128. </div>
  129. <div class="ui tab" data-tab="examples">
  130. <h2>Examples</h2>
  131. <div class="example">
  132. <p>Example of using checkbox states to alter multiple checkboxes</p>
  133. <div class="evaluated code">
  134. $('.enable.button')
  135. .on('click', function() {
  136. $(this)
  137. .nextAll('.checkbox')
  138. .checkbox('enable')
  139. ;
  140. })
  141. ;
  142. $('.disable.button')
  143. .on('click', function() {
  144. $(this)
  145. .nextAll('.checkbox')
  146. .checkbox('disable')
  147. ;
  148. })
  149. ;
  150. $('.toggle.button')
  151. .on('click', function() {
  152. $(this)
  153. .nextAll('.checkbox')
  154. .checkbox('toggle')
  155. ;
  156. })
  157. ;
  158. </div>
  159. <div class="ui toggle button">Toggle</div>
  160. <div class="ui positive enable button">Enable</div>
  161. <div class="ui negative disable button">Disable</div>
  162. <br><br>
  163. <div class="ui slider checkbox">
  164. <input type="checkbox" />
  165. <div class="box"></div>
  166. </div>
  167. <div class="ui slider checkbox">
  168. <input type="checkbox" checked="checked" />
  169. <div class="box"></div>
  170. </div>
  171. <div class="ui slider checkbox">
  172. <input type="checkbox" />
  173. <div class="box"></div>
  174. </div>
  175. <div class="ui slider checkbox">
  176. <input type="checkbox" checked="checked" />
  177. <div class="box"></div>
  178. </div>
  179. <div class="ui slider checkbox">
  180. <input type="checkbox" />
  181. <div class="box"></div>
  182. </div>
  183. <div class="ui slider checkbox">
  184. <input type="checkbox" />
  185. <div class="box"></div>
  186. </div>
  187. <div class="ui slider checkbox">
  188. <input type="checkbox" checked="checked" />
  189. <div class="box"></div>
  190. </div>
  191. <div class="ui slider checkbox">
  192. <input type="checkbox" />
  193. <div class="box"></div>
  194. </div>
  195. <div class="ui slider checkbox">
  196. <input type="checkbox" checked="checked" />
  197. <div class="box"></div>
  198. </div>
  199. <div class="ui slider checkbox">
  200. <input type="checkbox" />
  201. <div class="box"></div>
  202. </div>
  203. </div>
  204. </div>
  205. <div class="ui tab" data-tab="settings">
  206. <h3 class="ui header">
  207. Checkbox Settings
  208. <div class="sub header">Checkbox settings modify its behavior</div>
  209. </h3>
  210. <table class="ui celled sortable definition table segment">
  211. <thead>
  212. <th>Setting</th>
  213. <th class="four wide">Default</th>
  214. <th>Description</th>
  215. </thead>
  216. <tbody>
  217. <tr>
  218. <td>required</td>
  219. <td>auto</td>
  220. <td>Setting to true/false will determine whether an input will allow no selection. Auto will set disallow this behavior only for radio boxes</td>
  221. </tr>
  222. <tr>
  223. <td>context</td>
  224. <td>false</td>
  225. <td>A selector or jQuery object to use as a delegated event context</td>
  226. </tr>
  227. </tbody>
  228. </table>
  229. <h3 class="ui header">
  230. Callbacks
  231. <div class="sub header">Callbacks specify a function to occur after a specific behavior.</div>
  232. </h3>
  233. <table class="ui celled sortable definition table segment">
  234. <thead>
  235. <th class="four wide">Setting</th>
  236. <th>Context</th>
  237. <th>Description</th>
  238. </thead>
  239. <tbody>
  240. <tr>
  241. <td>onChange</td>
  242. <td>Checkbox</td>
  243. <td>Callback after a checkbox is either disabled or enabled.</td>
  244. </tr>
  245. <tr>
  246. <td>onEnable</td>
  247. <td>Checkbox</td>
  248. <td>Callback after a checkbox is enabled.</td>
  249. </tr>
  250. <tr>
  251. <td>onDisable</td>
  252. <td>Checkbox</td>
  253. <td>Callback after a checkbox is disabled.</td>
  254. </tr>
  255. </tbody>
  256. </table>
  257. <h3 class="ui header">DOM Settings
  258. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  259. </h3>
  260. <table class="ui celled sortable definition table segment">
  261. <thead>
  262. <th>Setting</th>
  263. <th class="four wide">Default</th>
  264. <th>Description</th>
  265. </thead>
  266. <tbody>
  267. <tr>
  268. <td>namespace</td>
  269. <td>checkbox</td>
  270. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  271. </tr>
  272. <tr>
  273. <td>selector</td>
  274. <td colspan="2">
  275. <div class="code">
  276. selector : {
  277. input : 'input',
  278. label : 'label'
  279. }
  280. </div>
  281. </td>
  282. </tr>
  283. <tr>
  284. <td>className</td>
  285. <td colspan="2">
  286. <div class="code">
  287. className : {
  288. radio : 'radio'
  289. }
  290. </div>
  291. </td>
  292. </tr>
  293. </tbody>
  294. </table>
  295. </div>
  296. </div>
  297. </body>
  298. </html>