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.

752 lines
24 KiB

  1. ---
  2. layout : 'default'
  3. css : 'dropdown'
  4. title : 'Dropdown'
  5. description : 'A dropdown is a hidden list of selections that a user can choose to have appear'
  6. type : 'UI Module'
  7. ---
  8. <script src="/javascript/dropdown.js"></script>
  9. <%- @partial('header', { tabs: 'module' }) %>
  10. <div class="main container">
  11. <div class="ui active 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. <a class="item">States</a>
  17. </div>
  18. </div>
  19. <h2 class="ui dividing header">Types</h2>
  20. <div class="visible dropdown example">
  21. <h4 class="ui header">Dropdown</h4>
  22. <p>A basic dropdown has no special formatting of its own</p>
  23. <div class="ui dropdown">
  24. <div class="text">Select</div>
  25. <i class="dropdown icon"></i>
  26. <div class="menu">
  27. <div class="item">Edit</div>
  28. <div class="item">Remove</div>
  29. <div class="item">Hide</div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="dropdown example">
  34. <h4 class="ui header">Inline</h4>
  35. <p>A dropdown can be formatted to appear inline in other content</p>
  36. <div>Show me posts trending
  37. <div class="ui inline dropdown">
  38. <div class="text">today</div>
  39. <i class="dropdown icon"></i>
  40. <div class="menu">
  41. <div class="item" data-text="today">Today</div>
  42. <div class="item" data-text="this week">This Week</div>
  43. <div class="item" data-text="this month">This Month</div>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="dropdown example">
  49. <h4 class="ui header">Selection</h4>
  50. <p>A dropdown can be formatted to allow selection of a menu choice.</p>
  51. <div class="ui selection dropdown">
  52. <input type="hidden" name="gender">
  53. <div class="default text">Gender</div>
  54. <i class="dropdown icon"></i>
  55. <div class="menu">
  56. <div class="item" data-value="1">Male</div>
  57. <div class="item" data-value="0">Female</div>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="button example">
  62. <h4 class="ui header">Floating</h4>
  63. <p>A dropdown menu can appear to be floating below an element.</p>
  64. <div class="ui teal buttons">
  65. <div class="ui button">Save</div>
  66. <div class="ui teal floating dropdown icon button">
  67. <i class="dropdown icon"></i>
  68. <div class="menu">
  69. <div class="item"><i class="edit icon"></i>Edit Post</div>
  70. <div class="item"><i class="delete icon"></i>Remove Post</div>
  71. <div class="item"><i class="hide icon"></i>Hide Post</div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="hover example">
  77. <h4 class="ui header">Pointing</h4>
  78. <p>A dropdown can be formatted so that its menu is pointing</p>
  79. <div class="ui compact menu">
  80. <div class="menu">
  81. <a class="active item">
  82. <i class="home icon"></i> Home
  83. </a>
  84. <div class="ui pointing dropdown link item">
  85. <i class="icon mail"></i> Messages <i class="dropdown icon"></i>
  86. <div class="menu">
  87. <a class="item"><i class="mail icon"></i>Inbox</a>
  88. <a class="item"><i class="book icon"></i>Archive</a>
  89. </div>
  90. </div>
  91. <a class="item">
  92. <i class="user icon"></i> Browse
  93. </a>
  94. <a class="item">
  95. <i class="question icon"></i> Help
  96. </a>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="another button example">
  101. <div class="ui blue labeled icon top left pointing dropdown button">
  102. <i class="settings icon"></i>
  103. <span class="text">Settings</span>
  104. <div class="menu">
  105. <div class="item"><i class="edit icon"></i>Edit</div>
  106. <div class="item"><i class="delete icon"></i>Remove</div>
  107. <div class="item"><i class="hide icon"></i>Hide</div>
  108. </div>
  109. </div>
  110. <div class="ui red labeled icon top right pointing dropdown button">
  111. <i class="settings icon"></i>
  112. <span class="text">Settings</span>
  113. <div class="menu">
  114. <div class="item"><i class="edit icon"></i>Edit</div>
  115. <div class="item"><i class="delete icon"></i>Remove</div>
  116. <div class="item"><i class="hide icon"></i>Hide</div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="another button example">
  121. <div class="ui right pointing dropdown icon button">
  122. <i class="settings icon"></i>
  123. <div class="menu">
  124. <div class="item"><i class="edit icon"></i>Edit</div>
  125. <div class="item"><i class="delete icon"></i>Remove</div>
  126. <div class="item"><i class="hide icon"></i>Hide</div>
  127. </div>
  128. </div>
  129. <div class="ui left pointing dropdown icon button">
  130. <i class="settings icon"></i>
  131. <div class="menu">
  132. <div class="item"><i class="edit icon"></i>Edit</div>
  133. <div class="item"><i class="delete icon"></i>Remove</div>
  134. <div class="item"><i class="hide icon"></i>Hide</div>
  135. </div>
  136. </div>
  137. </div>
  138. <div class="example">
  139. <h4 class="ui header">Simple</h4>
  140. <p>A simple dropdown can open without javascript</p>
  141. <div class="ui compact menu">
  142. <div class="ui simple dropdown item">
  143. Dropdown <i class="dropdown icon"></i>
  144. <div class="menu">
  145. <div class="item">Choice 1</div>
  146. <div class="item">Choice 2</div>
  147. <div class="item">Choice 3</div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <h2 class="ui dividing header">Variations</h2>
  153. <div class="dropdown example">
  154. <h4 class="ui header">Fluid</h4>
  155. <p>A dropdown can take the full width of its parent</p>
  156. <div class="ui vertical menu">
  157. <a class="item">Link 1</a>
  158. <a class="item">Link 2</a>
  159. <div class="header item">All Sections</div>
  160. <div class="ui item">
  161. <div class="ui fluid selection dropdown">
  162. <div class="text">More</div>
  163. <i class="dropdown icon"></i>
  164. <div class="menu">
  165. <div class="item">Choice 1</div>
  166. <div class="item">Choice 2</div>
  167. <div class="item">Choice 3</div>
  168. </div>
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. <h2 class="ui dividing header">States</h2>
  174. <div class="example">
  175. <h4 class="ui header">Active</h4>
  176. <p>An active dropdown menu has its menu open</p>
  177. <div class="ui compact menu">
  178. <div class="ui simple active dropdown item">
  179. Dropdown <i class="dropdown icon"></i>
  180. <div class="menu">
  181. <div class="item">Choice 1</div>
  182. <div class="item">Choice 2</div>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. <div class="example">
  188. <h4 class="ui header">Disabled</h4>
  189. <p>A disabled dropdown menu will not open or close</p>
  190. <div class="ui menu">
  191. <div class="ui simple disabled dropdown item">
  192. Dropdown <i class="dropdown icon"></i>
  193. <div class="menu">
  194. <div class="item">Choice 1</div>
  195. <div class="item">Choice 2</div>
  196. <div class="item">Choice 3</div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <div class="ui tab" data-tab="usage">
  203. <h2 class="ui dividing header">Initializing</h2>
  204. <h3 class="ui header">Initializing a dropdown</h3>
  205. <div class="code" data-label="HTML" data-type="html">
  206. <div class="ui dropdown">
  207. <div class="text">Select</div>
  208. <i class="dropdown icon"></i>
  209. <div class="menu">
  210. <div class="item" data-value="option1">Option 1</div>
  211. <div class="item" data-value="option2">Option 2</div>
  212. </div>
  213. </div>
  214. </div>
  215. <div class="code" data-label="Javascript" data-type="javascript">
  216. $('.ui.dropdown')
  217. .dropdown()
  218. ;
  219. </div>
  220. <h2 class="ui dividing header">Behavior</h2>
  221. <p>All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax:</p>
  222. <div class="code">
  223. $('.your.element')
  224. .dropdown('behavior name', argumentOne, argumentTwo)
  225. ;
  226. </div>
  227. <table class="ui definition sortable celled table segment">
  228. <thead>
  229. <tr>
  230. <th>Behavior</th>
  231. <th>Description</th>
  232. </tr>
  233. </thead>
  234. <tbody>
  235. <tr>
  236. <td>toggle</td>
  237. <td>Toggles current visibility of dropdown</td>
  238. </tr>
  239. <tr>
  240. <td>show</td>
  241. <td>Shows dropdown</td>
  242. </tr>
  243. <tr>
  244. <td>hide</td>
  245. <td>Hides dropdown</td>
  246. </tr>
  247. <tr>
  248. <td>hide others</td>
  249. <td>Hides all other dropdowns that is not current dropdown</td>
  250. </tr>
  251. <tr>
  252. <td>set selected(value)</td>
  253. <td>Sets selected state to a given value</td>
  254. </tr>
  255. <tr>
  256. <td>set text(text)</td>
  257. <td>Sets dropdown text to a value</td>
  258. </tr>
  259. <tr>
  260. <td>set value(value)</td>
  261. <td>Sets dropdown input to value</td>
  262. </tr>
  263. <tr>
  264. <td>get text</td>
  265. <td>Returns current dropdown text</td>
  266. </tr>
  267. <tr>
  268. <td>get value</td>
  269. <td>Returns current dropdown input value</td>
  270. </tr>
  271. <tr>
  272. <td>get item(value)</td>
  273. <td>Returns DOM element that matches a given input value</td>
  274. </tr>
  275. <tr>
  276. <td>bind touch events</td>
  277. <td>Adds touch events to element</td>
  278. </tr>
  279. <tr>
  280. <td>mouse events</td>
  281. <td>Adds mouse events to element</td>
  282. </tr>
  283. <tr>
  284. <td>bind intent</td>
  285. <td>Binds a click to document to determine if you click away from a dropdown</td>
  286. </tr>
  287. <tr>
  288. <td>unbind intent</td>
  289. <td>Unbinds document intent click</td>
  290. </tr>
  291. <tr>
  292. <td>determine intent</td>
  293. <td>Returns whether event occurred inside dropdown</td>
  294. </tr>
  295. <tr>
  296. <td>determine select action(text, value)</td>
  297. <td>Triggers preset item selection action based on settings passing text/value</td>
  298. </tr>
  299. <tr>
  300. <td>set active</td>
  301. <td>Sets dropdown to active state
  302. <tr>
  303. <td>set visible</td>
  304. <td>Sets dropdown to visible state</td>
  305. </tr>
  306. <tr>
  307. <td>remove active</td>
  308. <td>rRemoves dropdown active state
  309. <tr>
  310. <td>remove visible</td>
  311. <td>Removes dropdown visible state</td>
  312. </tr>
  313. <tr>
  314. <td>is selection</td>
  315. <td>Returns whether dropdown is a selection dropdown</td>
  316. </tr>
  317. <tr>
  318. <td>is animated</td>
  319. <td>Returns whether dropdown is animated</td>
  320. </tr>
  321. <tr>
  322. <td>is visible</td>
  323. <td>Returns whether dropdown is visible</td>
  324. </tr>
  325. <tr>
  326. <td>is hidden</td>
  327. <td>Returns whether dropdown is hidden</td>
  328. </tr>
  329. </tbody>
  330. </table>
  331. </div>
  332. <div class="ui tab" data-tab="examples">
  333. <h2 class="ui dividing header">Examples</h2>
  334. <div class="dropdown example">
  335. <h3 class="ui header">Re-selecting values</h3>
  336. <p>A dropdown will automatically select on page load any menu item that includes the currently value of <code>text</code> or your dropdown's hidden input value. This is used to preserve a user's selection on page navigation and will automatically remove and default text placeholder formatting.</p>
  337. Current action: <div class="ui inline dropdown">
  338. <div class="text">Hide</div>
  339. <i class="dropdown icon"></i>
  340. <div class="menu">
  341. <div class="item">Edit</div>
  342. <div class="item">Remove</div>
  343. <div class="item">Hide</div>
  344. </div>
  345. </div>
  346. </div>
  347. <div class="dropdown example">
  348. <h3 class="ui header">Button Group</h3>
  349. <p>A <a href="/elements/button.html">button group</a> can be formatted to show additional content as a dropdown</p>
  350. <div class="ui icon buttons">
  351. <div class="ui top left pointing dropdown button">
  352. <i class="user icon"></i>
  353. <div class="menu">
  354. <div class="item"><i class="edit icon"></i>Edit User</div>
  355. <div class="item"><i class="delete icon"></i>Remove User</div>
  356. <div class="item"><i class="hide icon"></i>Make Invisible</div>
  357. </div>
  358. </div>
  359. <div class="ui top left pointing dropdown button">
  360. <i class="users icon"></i>
  361. <div class="menu">
  362. <div class="item"><i class="edit icon"></i>Edit Group</div>
  363. <div class="item"><i class="delete icon"></i>Remove Group</div>
  364. <div class="item"><i class="hide icon"></i>Hide from Group</div>
  365. </div>
  366. </div>
  367. <div class="ui top right pointing dropdown button">
  368. <i class="settings icon"></i>
  369. <div class="menu">
  370. <div class="item"><i class="edit icon"></i>Edit</div>
  371. <div class="item"><i class="delete icon"></i>Remove</div>
  372. <div class="item"><i class="hide icon"></i>Hide</div>
  373. </div>
  374. </div>
  375. </div>
  376. </div>
  377. <div class="button example">
  378. <h3 class="ui header">Combo Button</h3>
  379. <p>A <a href="/elements/button.html">button</a> can be formatted with a dropdown</p>
  380. <div class="ui teal buttons">
  381. <div class="ui button">Update Post</div>
  382. <div class="ui teal dropdown icon button">
  383. <i class="dropdown icon"></i>
  384. <div class="menu">
  385. <div class="item"><i class="edit icon"></i>Edit Post</div>
  386. <div class="item"><i class="delete icon"></i>Remove Post</div>
  387. <div class="item"><i class="hide icon"></i>Hide Post</div>
  388. </div>
  389. </div>
  390. </div>
  391. </div>
  392. <div class="dropdown example">
  393. <h3 class="ui header">Multiple Levels</h3>
  394. <p>A dropdown menu can also contain sub menus inside of it</p>
  395. My favorite animal breed is <div class="ui inline dropdown">
  396. <input type="hidden" name="gender">
  397. <div class="text">Shiba Inu</div>
  398. <i class="dropdown icon"></i>
  399. <div class="menu">
  400. <div class="item">
  401. <i class="dropdown icon"></i>
  402. Dogs
  403. <div class="menu">
  404. <div class="item">Shiba Inu</div>
  405. <div class="item">Poodle</div>
  406. <div class="item">Labrador</div>
  407. </div>
  408. </div>
  409. <div class="item">
  410. <i class="dropdown icon"></i>
  411. Cats
  412. <div class="menu">
  413. <div class="item">Aegean</div>
  414. <div class="item">Balinese</div>
  415. <div class="item">Persian</div>
  416. </div>
  417. </div>
  418. </div>
  419. </div>
  420. </div>
  421. <div class="hover example">
  422. <h3 class="ui header">Menu</h3>
  423. <p>A <a href="/collections/menu.html">menu</a> element can contain a dropdown</p>
  424. <div class="ui compact tiered purple inverted menu">
  425. <div class="menu">
  426. <a class="active item">
  427. <i class="icon home"></i> Home
  428. </a>
  429. <a class="ui dropdown item">
  430. <i class="icon mail"></i> Messages <i class="dropdown icon"></i>
  431. <div class="menu">
  432. <div class="item">
  433. <i class="mail icon"></i>Categories
  434. <div class="menu">
  435. <div class="item">Unread</div>
  436. <div class="item">Promotions</div>
  437. <div class="item">Updates</div>
  438. </div>
  439. </div>
  440. <div class="item"><i class="book icon"></i>Archive</div>
  441. </div>
  442. </a>
  443. <a class="item">
  444. <i class="user icon"></i> Browse
  445. </a>
  446. </div>
  447. <div class="sub menu">
  448. <a class="item">Activity Feed</a>
  449. <a class="item">Profile</a>
  450. <a class="item">Events</a>
  451. </div>
  452. </div>
  453. </div>
  454. <div class="dropdown example">
  455. <h3 class="ui header">Form</h3>
  456. <p>A dropdown can be formatted to allow selection inside a <a href="/collections/form.html">form</a></p>
  457. <div class="ui form segment">
  458. <p>Let's go ahead and get you signed up.</p>
  459. <div class="two fields">
  460. <div class="field">
  461. <label>First Name</label>
  462. <input placeholder="First Name" type="text">
  463. </div>
  464. <div class="field">
  465. <label>Last Name</label>
  466. <input placeholder="Last Name" type="text">
  467. </div>
  468. </div>
  469. <div class="field">
  470. <label>Gender</label>
  471. <div class="ui dropdown selection">
  472. <input type="hidden" name="gender">
  473. <div class="default text">...</div>
  474. <i class="dropdown icon"></i>
  475. <div class="menu">
  476. <div class="item" data-value="male">Male</div>
  477. <div class="item" data-value="female">Female</div>
  478. </div>
  479. </div>
  480. </div>
  481. </div>
  482. </div>
  483. <div class="transition example">
  484. <h3 class="ui header">Transitions</h3>
  485. <p>A dropdown can have different <a href="/modules/transition.html">transitions</a>.</p>
  486. <div class="ui teal buttons">
  487. <div class="ui button">Toggle</div>
  488. <div class="ui teal floating dropdown icon button">
  489. <i class="dropdown icon"></i>
  490. <div class="menu">
  491. <div class="item" data-value="horizontal flip">Horizontal Flip</div>
  492. <div class="item" data-value="fade up">Fade Up</div>
  493. <div class="item" data-value="scale">Scale</div>
  494. </div>
  495. </div>
  496. </div>
  497. </div>
  498. </div>
  499. <div class="ui tab" data-tab="settings">
  500. <h3 class="ui header">
  501. Dropdown Settings
  502. <div class="sub header">Dropdown settings modify the dropdown's behavior</div>
  503. </h3>
  504. <table class="ui celled sortable definition table segment">
  505. <thead>
  506. <tr>
  507. <th>Setting</th>
  508. <th class="four wide">Default</th>
  509. <th>Description</th>
  510. </tr>
  511. </thead>
  512. <tbody>
  513. <tr>
  514. <td>on</td>
  515. <td>click</td>
  516. <td>Event used to trigger dropdown (Hover, Click)</td>
  517. </tr>
  518. <tr>
  519. <td>delay</td>
  520. <td>
  521. <div class="code">
  522. delay: {
  523. show: 50,
  524. hide: 300
  525. }
  526. </div>
  527. </td>
  528. <td>Time in milliseconds to debounce show or hide behavior when <code>on: hover</code> is used.</td>
  529. </tr>
  530. <tr>
  531. <td>transition</td>
  532. <td>
  533. slide down
  534. </td>
  535. <td>Named transition to use when animating menu in and out. Fade and slide down are available without including <a href="/modules/transition.html">ui transitions</a></td>
  536. </tr>
  537. <tr>
  538. <td>duration</td>
  539. <td>
  540. 250
  541. </td>
  542. <td>Duration of animation events</td>
  543. </tr>
  544. <tr>
  545. <td>action</td>
  546. <td>auto</td>
  547. <td>Sets a default action to occur.
  548. <div class="ui vertical divided list">
  549. <div class="item">
  550. <div class="header">activate</div>
  551. <div class="description">Most likely action will be determined by type of dropdown, for example a selection dropdown will automatically use updateForm</div>
  552. </div>
  553. <div class="item">
  554. <div class="header">nothing</div>
  555. <div class="description">no action occurs</div>
  556. </div>
  557. <div class="item">
  558. <div class="header">hide</div>
  559. <div class="description">Dropdown menu is hidden</div>
  560. </div>
  561. <div class="item">
  562. <div class="header">function(){}</div>
  563. <div class="description">custom function is executed</div>
  564. </div>
  565. </div>
  566. </tr>
  567. </tbody>
  568. </table>
  569. <div class="ui horizontal section divider"><i class="icon setting"></i></div>
  570. <h3 class="ui header">
  571. Callbacks
  572. <div class="sub header">Callbacks specify a function to occur after a specific behavior.</div>
  573. </h3>
  574. <table class="ui celled sortable definition table segment">
  575. <thead>
  576. <tr>
  577. <th class="four wide">Setting</th>
  578. <th>Context</th>
  579. <th>Description</th>
  580. </tr>
  581. </thead>
  582. <tbody>
  583. <tr>
  584. <td>onChange(value, text)</td>
  585. <td>Dropdown</td>
  586. <td>Is called after a dropdown item is selected. receives the name and value of selection.</td>
  587. </tr>
  588. <tr>
  589. <td>onShow</td>
  590. <td>Dropdown</td>
  591. <td>Is called after a dropdown is shown.</td>
  592. </tr>
  593. <tr>
  594. <td>onHide</td>
  595. <td>Dropdown</td>
  596. <td>Is called after a dropdown is hidden.</td>
  597. </tr>
  598. </tbody>
  599. </table>
  600. <h3 class="ui header">
  601. DOM Settings
  602. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  603. </h3>
  604. <table class="ui celled sortable definition table segment">
  605. <thead>
  606. <tr>
  607. <th>Setting</th>
  608. <th class="four wide">Default</th>
  609. <th>Description</th>
  610. </tr>
  611. </thead>
  612. <tbody>
  613. <tr>
  614. <td>namespace</td>
  615. <td>dropdown</td>
  616. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  617. </tr>
  618. <tr>
  619. <td>selector</td>
  620. <td colspan="2">
  621. <div class="code">
  622. selector : {
  623. input : '> input[type="hidden"]',
  624. item : '.menu > .item',
  625. menu : '.menu',
  626. text : '> .text'
  627. }
  628. </div>
  629. </td>
  630. </tr>
  631. <tr>
  632. <td>metadata</td>
  633. <td colspan="2">
  634. <div class="code">
  635. metadata: {
  636. text : 'text',
  637. value : 'value'
  638. }
  639. </div>
  640. </td>
  641. </tr>
  642. <tr>
  643. <td>className</td>
  644. <td colspan="2">
  645. <div class="code">
  646. className : {
  647. active : 'active',
  648. disabled : 'disabled',
  649. placeholder : 'default',
  650. visible : 'visible'
  651. }
  652. </div>
  653. </td>
  654. </tr>
  655. </tbody>
  656. </table>
  657. <h3 class="ui header">
  658. Debug Settings
  659. <div class="sub header">Debug settings controls debug output to the console</div>
  660. </h3>
  661. <table class="ui celled sortable definition table segment">
  662. <thead>
  663. <tr>
  664. <th>Setting</th>
  665. <th class="four wide">Default</th>
  666. <th>Description</th>
  667. </tr>
  668. </thead>
  669. <tbody>
  670. <tr>
  671. <td>name</td>
  672. <td>Dropdown</td>
  673. <td>Name used in debug logs</td>
  674. </tr>
  675. <tr>
  676. <td>debug</td>
  677. <td>True</td>
  678. <td>Provides standard debug output to console</td>
  679. </tr>
  680. <tr>
  681. <td>performance</td>
  682. <td>True</td>
  683. <td>Provides standard debug output to console</td>
  684. </tr>
  685. <tr>
  686. <td>verbose</td>
  687. <td>True</td>
  688. <td>Provides ancillary debug output to console</td>
  689. </tr>
  690. <tr>
  691. <td>error</td>
  692. <td colspan="2">
  693. <div class="code">
  694. error : {
  695. action : 'You called a dropdown action that was not defined',
  696. method : 'The method you called is not defined.',
  697. transition : 'The requested transition was not found'
  698. }
  699. </div>
  700. </td>
  701. </tr>
  702. </tbody>
  703. </table>
  704. </div>
  705. </div>