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.

309 lines
8.5 KiB

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