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.

749 lines
24 KiB

11 years ago
  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="male">Male</div>
  57. <div class="item" data-value="female">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 sortabled celled table segment">
  228. <thead>
  229. <th>Behavior</th>
  230. <th>Description</th>
  231. </thead>
  232. <tbody>
  233. <tr>
  234. <td>toggle</td>
  235. <td>Toggles current visibility of dropdown</td>
  236. </tr>
  237. <tr>
  238. <td>show</td>
  239. <td>Shows dropdown</td>
  240. </tr>
  241. <tr>
  242. <td>hide</td>
  243. <td>Hides dropdown</td>
  244. </tr>
  245. <tr>
  246. <td>hide others</td>
  247. <td>Hides all other dropdowns that is not current dropdown</td>
  248. </tr>
  249. <tr>
  250. <td>set selected(value)</td>
  251. <td>Sets selected state to a given value</td>
  252. </tr>
  253. <tr>
  254. <td>set text(text)</td>
  255. <td>Sets dropdown text to a value</td>
  256. </tr>
  257. <tr>
  258. <td>set value(value)</td>
  259. <td>Sets dropdown input to value</td>
  260. </tr>
  261. <tr>
  262. <td>get text</td>
  263. <td>Returns current dropdown text</td>
  264. </tr>
  265. <tr>
  266. <td>get value</td>
  267. <td>Returns current dropdown input value</td>
  268. </tr>
  269. <tr>
  270. <td>get item(value)</td>
  271. <td>Returns DOM element that matches a given input value</td>
  272. </tr>
  273. <tr>
  274. <td>bind touch events</td>
  275. <td>Adds touch events to element</td>
  276. </tr>
  277. <tr>
  278. <td>mouse events</td>
  279. <td>Adds mouse events to element</td>
  280. </tr>
  281. <tr>
  282. <td>bind intent</td>
  283. <td>Binds a click to document to determine if you click away from a dropdown</td>
  284. </tr>
  285. <tr>
  286. <td>unbind intent</td>
  287. <td>Unbinds document intent click</td>
  288. </tr>
  289. <tr>
  290. <td>determine intent</td>
  291. <td>Returns whether event occurred inside dropdown</td>
  292. </tr>
  293. <tr>
  294. <td>determine select action(text, value)</td>
  295. <td>Triggers preset item selection action based on settings passing text/value</td>
  296. </tr>
  297. <tr>
  298. <td>set active</td>
  299. <td>Sets dropdown to active state
  300. <tr>
  301. <td>set visible</td>
  302. <td>Sets dropdown to visible state</td>
  303. </tr>
  304. <tr>
  305. <td>remove active</td>
  306. <td>rRemoves dropdown active state
  307. <tr>
  308. <td>remove visible</td>
  309. <td>Removes dropdown visible state</td>
  310. </tr>
  311. <tr>
  312. <td>is selection</td>
  313. <td>Returns whether dropdown is a selection dropdown</td>
  314. </tr>
  315. <tr>
  316. <td>is animated</td>
  317. <td>Returns whether dropdown is animated</td>
  318. </tr>
  319. <tr>
  320. <td>is visible</td>
  321. <td>Returns whether dropdown is visible</td>
  322. </tr>
  323. <tr>
  324. <td>is hidden</td>
  325. <td>Returns whether dropdown is hidden</td>
  326. </tr>
  327. </tbody>
  328. </table>
  329. </div>
  330. <div class="ui tab" data-tab="examples">
  331. <h2 class="ui dividing header">Examples</h2>
  332. <div class="dropdown example">
  333. <h3 class="ui header">Re-selecting values</h3>
  334. <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>
  335. Current action: <div class="ui inline dropdown">
  336. <div class="text">Hide</div>
  337. <i class="dropdown icon"></i>
  338. <div class="menu">
  339. <div class="item">Edit</div>
  340. <div class="item">Remove</div>
  341. <div class="item">Hide</div>
  342. </div>
  343. </div>
  344. </div>
  345. <div class="dropdown example">
  346. <h3 class="ui header">Button Group</h3>
  347. <p>A <a href="/elements/button.html">button group</a> can be formatted to show additional content as a dropdown</p>
  348. <div class="ui icon buttons">
  349. <div class="ui top left pointing dropdown button">
  350. <i class="user icon"></i>
  351. <div class="menu">
  352. <div class="item"><i class="edit icon"></i>Edit User</div>
  353. <div class="item"><i class="delete icon"></i>Remove User</div>
  354. <div class="item"><i class="hide icon"></i>Make Invisible</div>
  355. </div>
  356. </div>
  357. <div class="ui top left pointing dropdown button">
  358. <i class="users icon"></i>
  359. <div class="menu">
  360. <div class="item"><i class="edit icon"></i>Edit Group</div>
  361. <div class="item"><i class="delete icon"></i>Remove Group</div>
  362. <div class="item"><i class="hide icon"></i>Hide from Group</div>
  363. </div>
  364. </div>
  365. <div class="ui top right pointing dropdown button">
  366. <i class="settings icon"></i>
  367. <div class="menu">
  368. <div class="item"><i class="edit icon"></i>Edit</div>
  369. <div class="item"><i class="delete icon"></i>Remove</div>
  370. <div class="item"><i class="hide icon"></i>Hide</div>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="button example">
  376. <h3 class="ui header">Combo Button</h3>
  377. <p>A <a href="/elements/button.html">button</a> can be formatted with a dropdown</p>
  378. <div class="ui teal buttons">
  379. <div class="ui button">Update Post</div>
  380. <div class="ui teal dropdown icon button">
  381. <i class="dropdown icon"></i>
  382. <div class="menu">
  383. <div class="item"><i class="edit icon"></i>Edit Post</div>
  384. <div class="item"><i class="delete icon"></i>Remove Post</div>
  385. <div class="item"><i class="hide icon"></i>Hide Post</div>
  386. </div>
  387. </div>
  388. </div>
  389. </div>
  390. <div class="dropdown example">
  391. <h3 class="ui header">Multiple Levels</h3>
  392. <p>A dropdown menu can also contain sub menus inside of it</p>
  393. My favorite animal breed is <div class="ui inline dropdown">
  394. <input type="hidden" name="gender">
  395. <div class="text">Shiba Inu</div>
  396. <i class="dropdown icon"></i>
  397. <div class="menu">
  398. <div class="item">
  399. <i class="dropdown icon"></i>
  400. Dogs
  401. <div class="menu">
  402. <div class="item">Shiba Inu</div>
  403. <div class="item">Poodle</div>
  404. <div class="item">Labrador</div>
  405. </div>
  406. </div>
  407. <div class="item">
  408. <i class="dropdown icon"></i>
  409. Cats
  410. <div class="menu">
  411. <div class="item">Aegean</div>
  412. <div class="item">Balinese</div>
  413. <div class="item">Persian</div>
  414. </div>
  415. </div>
  416. </div>
  417. </div>
  418. </div>
  419. <div class="hover example">
  420. <h3 class="ui header">Menu</h3>
  421. <p>A <a href="/collections/menu.html">menu</a> element can contain a dropdown</p>
  422. <div class="ui compact tiered purple inverted menu">
  423. <div class="menu">
  424. <a class="active item">
  425. <i class="icon home"></i> Home
  426. </a>
  427. <a class="ui dropdown item">
  428. <i class="icon mail"></i> Messages <i class="dropdown icon"></i>
  429. <div class="menu">
  430. <div class="item">
  431. <i class="mail icon"></i>Categories
  432. <div class="menu">
  433. <div class="item">Unread</div>
  434. <div class="item">Promotions</div>
  435. <div class="item">Updates</div>
  436. </div>
  437. </div>
  438. <div class="item"><i class="book icon"></i>Archive</div>
  439. </div>
  440. </a>
  441. <a class="item">
  442. <i class="user icon"></i> Browse
  443. </a>
  444. </div>
  445. <div class="sub menu">
  446. <a class="item">Activity Feed</a>
  447. <a class="item">Profile</a>
  448. <a class="item">Events</a>
  449. </div>
  450. </div>
  451. </div>
  452. <div class="dropdown example">
  453. <h3 class="ui header">Form</h3>
  454. <p>A dropdown can be formatted to allow selection inside a <a href="/collections/form.html">form</a></p>
  455. <div class="ui form segment">
  456. <p>Let's go ahead and get you signed up.</p>
  457. <div class="two fields">
  458. <div class="field">
  459. <label>First Name</label>
  460. <input placeholder="First Name" type="text">
  461. </div>
  462. <div class="field">
  463. <label>Last Name</label>
  464. <input placeholder="Last Name" type="text">
  465. </div>
  466. </div>
  467. <div class="field">
  468. <label>Gender</label>
  469. <div class="ui dropdown selection">
  470. <input type="hidden" name="gender">
  471. <div class="default text">...</div>
  472. <i class="dropdown icon"></i>
  473. <div class="menu">
  474. <div class="item" data-value="male">Male</div>
  475. <div class="item" data-value="female">Female</div>
  476. </div>
  477. </div>
  478. </div>
  479. </div>
  480. </div>
  481. <div class="transition example">
  482. <h3 class="ui header">Transitions</h3>
  483. <p>A dropdown can have different <a href="/modules/transition.html">transitions</a>.</p>
  484. <div class="ui teal buttons">
  485. <div class="ui button">Toggle</div>
  486. <div class="ui teal floating dropdown icon button">
  487. <i class="dropdown icon"></i>
  488. <div class="menu">
  489. <div class="item" data-value="horizontal flip">Horizontal Flip</div>
  490. <div class="item" data-value="fade up">Fade Up</div>
  491. <div class="item" data-value="scale">Scale</div>
  492. </div>
  493. </div>
  494. </div>
  495. </div>
  496. </div>
  497. <div class="ui tab" data-tab="settings">
  498. <h3 class="ui header">
  499. Dropdown Settings
  500. <div class="sub header">Dropdown settings modify the dropdown's behavior</div>
  501. </h3>
  502. <table class="ui celled sortable definition table segment">
  503. <thead>
  504. <th>Setting</th>
  505. <th class="four wide">Default</th>
  506. <th>Description</th>
  507. </thead>
  508. <tbody>
  509. <tr>
  510. <td>on</td>
  511. <td>click</td>
  512. <td>Event used to trigger dropdown (Hover, Click)</td>
  513. </tr>
  514. <tr>
  515. <td>delay</td>
  516. <td>
  517. <div class="code">
  518. delay: {
  519. show: 50,
  520. hide: 300
  521. }
  522. </div>
  523. </td>
  524. <td>Time in milliseconds to debounce show or hide behavior when <code>on: hover</code> is used.</td>
  525. </tr>
  526. <tr>
  527. <td>transition</td>
  528. <td>
  529. slide down
  530. </td>
  531. <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>
  532. </tr>
  533. <tr>
  534. <td>duration</td>
  535. <td>
  536. 250
  537. </td>
  538. <td>Duration of animation events</td>
  539. </tr>
  540. <tr>
  541. <td>action</td>
  542. <td>auto</td>
  543. <td>Sets a default action to occur.
  544. <div class="ui vertical divided list">
  545. <div class="item">
  546. <div class="header">activate</div>
  547. <div class="description">Most likely action will be determined by type of dropdown, for example a selection dropdown will automatically use updateForm</div>
  548. </div>
  549. <div class="item">
  550. <div class="header">nothing</div>
  551. <div class="description">no action occurs</div>
  552. </div>
  553. <div class="item">
  554. <div class="header">hide</div>
  555. <div class="description">Dropdown menu is hidden</div>
  556. </div>
  557. <div class="item">
  558. <div class="header">activate</div>
  559. <div class="description">Dropdown menu is hidden, item activated and text is changed</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. <th class="four wide">Setting</th>
  577. <th>Context</th>
  578. <th>Description</th>
  579. </thead>
  580. <tbody>
  581. <tr>
  582. <td>onChange(value, text)</td>
  583. <td>Dropdown</td>
  584. <td>Is called after a dropdown item is selected. Receieves the name and value of selection.</td>
  585. </tr>
  586. <tr>
  587. <td>onShow</td>
  588. <td>Dropdown</td>
  589. <td>Is called after a dropdown is shown.</td>
  590. </tr>
  591. <tr>
  592. <td>onHide</td>
  593. <td>Dropdown</td>
  594. <td>Is called after a dropdown is hidden.</td>
  595. </tr>
  596. </tbody>
  597. </table>
  598. <h3 class="ui header">
  599. DOM Settings
  600. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  601. </h3>
  602. <table class="ui celled sortable definition table segment">
  603. <thead>
  604. <th>Setting</th>
  605. <th class="four wide">Default</th>
  606. <th>Description</th>
  607. </thead>
  608. <tbody>
  609. <tr>
  610. <td>namespace</td>
  611. <td>dropdown</td>
  612. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  613. </tr>
  614. <tr>
  615. <td>selector</td>
  616. <td colspan="2">
  617. <div class="code">
  618. selector : {
  619. input : '> input[type="hidden"]',
  620. item : '.menu > .item',
  621. menu : '.menu',
  622. text : '> .text'
  623. }
  624. </div>
  625. </td>
  626. </tr>
  627. <tr>
  628. <td>metadata</td>
  629. <td colspan="2">
  630. <div class="code">
  631. metadata: {
  632. text : 'text',
  633. value : 'value'
  634. }
  635. </div>
  636. </td>
  637. </tr>
  638. <tr>
  639. <td>className</td>
  640. <td colspan="2">
  641. <div class="code">
  642. className : {
  643. active : 'active',
  644. disabled : 'disabled',
  645. placeholder : 'default',
  646. visible : 'visible'
  647. }
  648. </div>
  649. </td>
  650. </tr>
  651. </tbody>
  652. </table>
  653. <h3 class="ui header">
  654. Debug Settings
  655. <div class="sub header">Debug settings controls debug output to the console</div>
  656. </h3>
  657. <table class="ui celled sortable definition table segment">
  658. <thead>
  659. <th>Setting</th>
  660. <th class="four wide">Default</th>
  661. <th>Description</th>
  662. </thead>
  663. <tbody>
  664. <tr>
  665. <td>name</td>
  666. <td>Dropdown</td>
  667. <td>Name used in debug logs</td>
  668. </tr>
  669. <tr>
  670. <td>debug</td>
  671. <td>True</td>
  672. <td>Provides standard debug output to console</td>
  673. </tr>
  674. <tr>
  675. <td>performance</td>
  676. <td>True</td>
  677. <td>Provides standard debug output to console</td>
  678. </tr>
  679. <tr>
  680. <td>verbose</td>
  681. <td>True</td>
  682. <td>Provides ancillary debug output to console</td>
  683. </tr>
  684. <tr>
  685. <td>error</td>
  686. <td colspan="2">
  687. <div class="code">
  688. error : {
  689. action : 'You called a dropdown action that was not defined',
  690. method : 'The method you called is not defined.',
  691. transition : 'The requested transition was not found'
  692. }
  693. </div>
  694. </td>
  695. </tr>
  696. </tbody>
  697. </table>
  698. </div>
  699. </div>
  700. </body>
  701. </html>