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.

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