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.

524 lines
18 KiB

11 years ago
  1. ---
  2. layout : 'default'
  3. css : 'accordion'
  4. element : 'accordion'
  5. elementType : 'module'
  6. title : 'Accordion'
  7. description : 'An accordion allows users to toggle the display of sections of content'
  8. type : 'UI Module'
  9. themes : ['Default', 'Chubby']
  10. ---
  11. <link rel="stylesheet/less" type="text/css" href="/build/less/definitions/modules/accordion.less" />
  12. <script src="/javascript/accordion.js"></script>
  13. <%- @partial('header', { tabs: 'module' }) %>
  14. <div class="main container">
  15. <div class="ui active tab" data-tab="definition">
  16. <h2 class="ui dividing header">Types</h2>
  17. <div class="example">
  18. <h4 class="ui header">Accordion</h4>
  19. <p>A standard accordion</p>
  20. <div class="ui accordion">
  21. <div class="active title">
  22. <i class="dropdown icon"></i>
  23. What is a dog?
  24. </div>
  25. <div class="active content">
  26. <p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
  27. </div>
  28. <div class="title">
  29. <i class="dropdown icon"></i>
  30. What kinds of dogs are there?
  31. </div>
  32. <div class="content">
  33. <p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
  34. </div>
  35. <div class="title">
  36. <i class="dropdown icon"></i>
  37. How do you acquire a dog?
  38. </div>
  39. <div class="content">
  40. <p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
  41. <p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="example">
  46. <h4 class="ui header">Styled</h4>
  47. <p>A styled accordion adds basic formatting</p>
  48. <div class="ui styled accordion">
  49. <div class="active title">
  50. <i class="dropdown icon"></i>
  51. What is a dog?
  52. </div>
  53. <div class="active content">
  54. <p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
  55. </div>
  56. <div class="title">
  57. <i class="dropdown icon"></i>
  58. What kinds of dogs are there?
  59. </div>
  60. <div class="content">
  61. <p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
  62. </div>
  63. <div class="title">
  64. <i class="dropdown icon"></i>
  65. How do you acquire a dog?
  66. </div>
  67. <div class="content">
  68. <p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
  69. <p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
  70. </div>
  71. </div>
  72. </div>
  73. <h2 class="ui dividing header">Variations</h2>
  74. <div class="example">
  75. <h4 class="ui header">Fluid</h4>
  76. <p>An accordion can take up the width of its container</p>
  77. <div class="ui styled fluid accordion">
  78. <div class="active title">
  79. <i class="dropdown icon"></i>
  80. What is a dog?
  81. </div>
  82. <div class="active content">
  83. <p>A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.</p>
  84. </div>
  85. <div class="title">
  86. <i class="dropdown icon"></i>
  87. What kinds of dogs are there?
  88. </div>
  89. <div class="content">
  90. <p>There are many breeds of dogs. Each breed varies in size and temperament. Owners often select a breed of dog that they find to be compatible with their own lifestyle and desires from a companion.</p>
  91. </div>
  92. <div class="title">
  93. <i class="dropdown icon"></i>
  94. How do you acquire a dog?
  95. </div>
  96. <div class="content">
  97. <p>Three common ways for a prospective owner to acquire a dog is from pet shops, private owners, or shelters.</p>
  98. <p>A pet shop may be the most convenient way to buy a dog. Buying a dog from a private owner allows you to assess the pedigree and upbringing of your dog before choosing to take it home. Lastly, finding your dog from a shelter, helps give a good home to a dog who may not find one so readily.</p>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="ui tab" data-tab="examples">
  104. <h2 class="ui dividing header">Examples</h2>
  105. <div class="example">
  106. <h4 class="ui header">Nested</h4>
  107. <p>An accordion can have multiple levels of nested content. This content can either be in a nested <code>accordion</code> or simply another level of <code>title</code> and <code>content</code></p>
  108. <div class="ui styled accordion">
  109. <div class="active title">
  110. <i class="dropdown icon"></i>
  111. Level 1
  112. </div>
  113. <div class="active content">
  114. Welcome to level 1
  115. <div class="accordion">
  116. <div class="active title">
  117. <i class="dropdown icon"></i>
  118. Level 1A
  119. </div>
  120. <div class="active content">
  121. <p>Level 1A Contents</p>
  122. <div class="accordion">
  123. <div class="title">
  124. <i class="dropdown icon"></i>
  125. Level 1A-A
  126. </div>
  127. <div class="content">
  128. Level 1A-A Contents
  129. </div>
  130. <div class="title">
  131. <i class="dropdown icon"></i>
  132. Level 1A-B
  133. </div>
  134. <div class="content">
  135. Level 1A-B Contents
  136. </div>
  137. </div>
  138. </div>
  139. <div class="title">
  140. <i class="dropdown icon"></i>
  141. Level 1B
  142. </div>
  143. <div class="content">
  144. Level 1B Contents
  145. </div>
  146. <div class="title">
  147. <i class="dropdown icon"></i>
  148. Level 1C
  149. </div>
  150. <div class="content">
  151. Level 1C Contents
  152. </div>
  153. </div>
  154. </div>
  155. <div class="title">
  156. <i class="dropdown icon"></i>
  157. Level 2
  158. </div>
  159. <div class="content">
  160. <p>Welcome to level 2</p>
  161. <div class="accordion">
  162. <div class="active title">
  163. <i class="dropdown icon"></i>
  164. Level 2A
  165. </div>
  166. <div class="active content">
  167. <p>Level 2A Contents</p>
  168. <div class="accordion">
  169. <div class="title">
  170. <i class="dropdown icon"></i>
  171. Level 2A-A
  172. </div>
  173. <div class="content">
  174. Level 2A-A Contents
  175. </div>
  176. <div class="title">
  177. <i class="dropdown icon"></i>
  178. Level 2A-B
  179. </div>
  180. <div class="content">
  181. Level 2A-B Contents
  182. </div>
  183. </div>
  184. </div>
  185. <div class="title">
  186. <i class="dropdown icon"></i>
  187. Level 2B
  188. </div>
  189. <div class="content">
  190. Level 2B Contents
  191. </div>
  192. <div class="title">
  193. <i class="dropdown icon"></i>
  194. Level 2C
  195. </div>
  196. <div class="content">
  197. Level 2C Contents
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <div class="example">
  204. <h4 class="ui header">Form</h4>
  205. <p>An accordion can be used anywhere where content can be shown or hidden. For example, to show optional form fields.</p>
  206. <div class="ui segment">
  207. <div class="ui fluid form">
  208. <div class="two fields">
  209. <div class="field">
  210. <label>First Name</label>
  211. <input placeholder="First Name" type="text">
  212. </div>
  213. <div class="field">
  214. <label>Last Name</label>
  215. <input placeholder="Last Name" type="text">
  216. </div>
  217. </div>
  218. <div class="ui accordion field">
  219. <div class="title">
  220. <i class="icon dropdown"></i>
  221. Optional Details
  222. </div>
  223. <div class="content field">
  224. <label>Maiden Name</label>
  225. <input placeholder="Maiden Name" type="text">
  226. </div>
  227. </div>
  228. <div class="ui secondary submit button">Sign Up</div>
  229. </div>
  230. </div>
  231. </div>
  232. <div class="example">
  233. <h4 class="ui header">Menu</h4>
  234. <p>An accordion can be used to create content drawers inside a menu</p>
  235. <div class="ui vertical accordion menu">
  236. <div class="item">
  237. <a class="active title">
  238. <i class="dropdown icon"></i>
  239. Size
  240. </a>
  241. <div class="active content">
  242. <div class="ui form">
  243. <div class="grouped fields">
  244. <div class="field">
  245. <div class="ui radio checkbox">
  246. <input type="radio" name="size" value="small" />
  247. <label>Small</label>
  248. </div>
  249. </div>
  250. <div class="field">
  251. <div class="ui radio checkbox">
  252. <input type="radio" name="size" value="medium" />
  253. <label>Medium</label>
  254. </div>
  255. </div>
  256. <div class="field">
  257. <div class="ui radio checkbox">
  258. <input type="radio" name="size" value="large" />
  259. <label>Large</label>
  260. </div>
  261. </div>
  262. <div class="field">
  263. <div class="ui radio checkbox">
  264. <input type="radio" name="size" value="x-large" />
  265. <label>X-Large</label>
  266. </div>
  267. </div>
  268. </div>
  269. </div>
  270. </div>
  271. </div>
  272. <div class="item">
  273. <a class="title">
  274. <i class="dropdown icon"></i>
  275. Colors
  276. </a>
  277. <div class="content">
  278. <div class="ui form">
  279. <div class="grouped fields">
  280. <div class="field">
  281. <div class="ui checkbox">
  282. <input type="checkbox" name="small" />
  283. <label>Red</label>
  284. </div>
  285. </div>
  286. <div class="field">
  287. <div class="ui checkbox">
  288. <input type="checkbox" name="medium" />
  289. <label>Orange</label>
  290. </div>
  291. </div>
  292. <div class="field">
  293. <div class="ui checkbox">
  294. <input type="checkbox" name="large" />
  295. <label>Green</label>
  296. </div>
  297. </div>
  298. <div class="field">
  299. <div class="ui checkbox">
  300. <input type="checkbox" name="x-large" />
  301. <label>Blue</label>
  302. </div>
  303. </div>
  304. </div>
  305. </div>
  306. </div>
  307. </div>
  308. </div>
  309. </div>
  310. </div>
  311. <div class="ui tab" data-tab="usage">
  312. <h2 class="ui dividing header">Initializing</h2>
  313. <div class="no example">
  314. <h4 class="ui header">Initializing an accordion</h4>
  315. <p>Accordion is initialized on pre-existing markup</p>
  316. <div class="test code">
  317. $('.ui.accordion')
  318. .accordion()
  319. ;
  320. </div>
  321. </div>
  322. <div class="no example">
  323. <h4 class="ui header">AJAX Content</h4>
  324. <p>Accordions use <a href="https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver" target="_blank">DOM Mutation Observers</a> and delegated events to allow for easy compataibility with AJAX content, or content added after initialization.</p>
  325. <p>If the DOM tree changes the module will automatically call <code>module.refresh</code> and update the selector cache. Because events are bound on the parent module using delegated events, events will automatically fire on content added after initialization.</p>
  326. <p>If you change other attributes of the module without DOM insertion and need to update the cache you can do so by calling this module's <code>refresh</code> behavior.
  327. <div class="code" data-type="javascript">
  328. $('.ui.accordion').accordion('refresh');
  329. </div>
  330. </div>
  331. <h2 class="ui dividing header">Behaviors</h2>
  332. <p>Behaviors are short english phrases used for accessing specific functionality in
  333. <p>Behaviors are accessible with javascript using the syntax:<p>
  334. <div class="code">
  335. $('.ui.accordion').accordion('behavior', argumentOne, argumentTwo...);
  336. </div>
  337. <table class="ui definition celled table">
  338. <tr>
  339. <td>open (index)</td>
  340. <td>Opens accordion content at index</td>
  341. </tr>
  342. <tr>
  343. <td>close others</td>
  344. <td>Closes accordion content that are not active</td>
  345. </tr>
  346. <tr>
  347. <td>close (index)</td>
  348. <td>Closes accordion content at index</td>
  349. </tr>
  350. <tr>
  351. <td>toggle (index)</td>
  352. <td>Toggles accordion content at index</td>
  353. </tr>
  354. </table>
  355. </div>
  356. <div class="ui tab" data-tab="settings">
  357. <h2 class="ui dividing header">
  358. Accordion
  359. </h2>
  360. <h4 class="ui header">
  361. Behavior
  362. </h4>
  363. <table class="ui sortable celled definition table">
  364. <thead>
  365. <th class="three wide"></th>
  366. <th class="three wide">Default</th>
  367. <th>Description</th>
  368. </thead>
  369. <tbody>
  370. <tr>
  371. <td>exclusive</td>
  372. <td>true</td>
  373. <td>Only allow one section open at a time</td>
  374. </tr>
  375. <tr>
  376. <td>close nested</td>
  377. <td>true</td>
  378. <td>Allow active sections to collapse</td>
  379. </tr>
  380. <tr>
  381. <td>collapsible</td>
  382. <td>true</td>
  383. <td>Allow active sections to collapse</td>
  384. </tr>
  385. <tr>
  386. <td>duration</td>
  387. <td>500</td>
  388. <td>Duration in ms of opening animation</td>
  389. </tr>
  390. <tr>
  391. <td>easing</td>
  392. <td>easeInOutQuint</td>
  393. <td>Easing of opening animation. EaseInOutQuint is included with accordion, for additional options you must include <a href="http://gsgd.co.uk/sandbox/jquery/easing/">easing equations</a>.</td>
  394. </tr>
  395. </tbody>
  396. </table>
  397. <h4 class="ui header">
  398. Callbacks
  399. </h4>
  400. <table class="ui sortable celled definition table">
  401. <thead>
  402. <th class="three wide"></th>
  403. <th class="three wide">Context</th>
  404. <th>Description</th>
  405. </thead>
  406. <tbody>
  407. <tr>
  408. <td>onOpen</td>
  409. <td>active content</td>
  410. <td>Callback on element open</td>
  411. </tr>
  412. <tr>
  413. <td>onClose</td>
  414. <td>active content</td>
  415. <td>Callback on element close</td>
  416. </tr>
  417. <tr>
  418. <td>onChange</td>
  419. <td>active content</td>
  420. <td>Callback on element open or close</td>
  421. </tr>
  422. </tbody>
  423. </table>
  424. <h2 class="ui dividing header">
  425. Module
  426. </h2>
  427. <p>These settings are native to all modules, and define how the component ties content to DOM attributes, and debugging settings for the module.</p>
  428. <table class="ui sortable celled definition table">
  429. <thead>
  430. <th></th>
  431. <th class="six wide">Default</th>
  432. <th>Description</th>
  433. </thead>
  434. <tbody>
  435. <tr>
  436. <td>name</td>
  437. <td>Accordion</td>
  438. <td>Name used in log statements</td>
  439. </tr>
  440. <tr>
  441. <td>namespace</td>
  442. <td>accordion</td>
  443. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  444. </tr>
  445. <tr>
  446. <td>selector</td>
  447. <td>
  448. <div class="code" data-type="css">
  449. selector : {
  450. accordion : '.accordion',
  451. title : '.title',
  452. content : '.content'
  453. }
  454. </div>
  455. </td>
  456. <td>Selectors used to find parts of a module</td>
  457. </tr>
  458. <tr>
  459. <td>className</td>
  460. <td>
  461. <div class="code">
  462. className : {
  463. active : 'active'
  464. }
  465. </div>
  466. </td>
  467. <td>Class names used to determine element state</td>
  468. </tr>
  469. <tr>
  470. <td>debug</td>
  471. <td>false</td>
  472. <td>Debug output to console</td>
  473. </tr>
  474. <tr>
  475. <td>performance</td>
  476. <td>false</td>
  477. <td>Show <code>console.table</code> output with performance metrics</td>
  478. </tr>
  479. <tr>
  480. <td>verbose</td>
  481. <td>false</td>
  482. <td>Debug output includes all internal behaviors</td>
  483. </tr>
  484. <tr>
  485. <td>errors</td>
  486. <td colspan="2">
  487. <div class="code">
  488. error : {
  489. method : 'The method you called is not defined.'
  490. }
  491. </div>
  492. </td>
  493. </tr>
  494. </tbody>
  495. </table>
  496. </div>
  497. </div>