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.

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