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.

657 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 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>action</td>
  451. <td>auto</td>
  452. <td>Sets a default action to occur.
  453. <div class="ui vertical divided list">
  454. <div class="item">
  455. <div class="header">activate</div>
  456. <div class="description">Most likely action will be determined by type of dropdown, for example a selection dropdown will automatically use updateForm</div>
  457. </div>
  458. <div class="item">
  459. <div class="header">nothing</div>
  460. <div class="description">no action occurs</div>
  461. </div>
  462. <div class="item">
  463. <div class="header">hide</div>
  464. <div class="description">Dropdown menu is hidden</div>
  465. </div>
  466. <div class="item">
  467. <div class="header">activate</div>
  468. <div class="description">Dropdown menu is hidden, item activated and text is changed</div>
  469. </div>
  470. <div class="item">
  471. <div class="header">function(){}</div>
  472. <div class="description">custom function is executed</div>
  473. </div>
  474. </div>
  475. </tr>
  476. </tbody>
  477. </table>
  478. <div class="ui horizontal section divider"><i class="icon setting"></i></div>
  479. <h4 class="ui header">Callbacks</h4>
  480. <p>Callback settings specify a function to occur after a specific behavior.</p>
  481. <table class="ui celled definition table segment">
  482. <thead>
  483. <th class="four wide">Setting</th>
  484. <th>Context</th>
  485. <th>Description</th>
  486. </thead>
  487. <tbody>
  488. <tr>
  489. <td>onChange(value, text)</td>
  490. <td>Dropdown</td>
  491. <td>Is called after a dropdown item is selected. Receieves the name and value of selection.</td>
  492. </tr>
  493. <tr>
  494. <td>onShow</td>
  495. <td>Dropdown</td>
  496. <td>Is called after a dropdown is shown.</td>
  497. </tr>
  498. <tr>
  499. <td>onHide</td>
  500. <td>Dropdown</td>
  501. <td>Is called after a dropdown is hidden.</td>
  502. </tr>
  503. </tbody>
  504. </table>
  505. </div>
  506. <div class="no example">
  507. <h4 class="ui header">DOM Settings</h4>
  508. <p>DOM settings specify how this module should interface with the DOM</p>
  509. <table class="ui celled definition table segment">
  510. <thead>
  511. <th>Setting</th>
  512. <th class="four wide">Default</th>
  513. <th>Description</th>
  514. </thead>
  515. <tbody>
  516. <tr>
  517. <td>namespace</td>
  518. <td>dropdown</td>
  519. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  520. </tr>
  521. <tr>
  522. <td>selector</td>
  523. <td colspan="2">
  524. <div class="code">
  525. selector : {
  526. menu : '.menu',
  527. item : '.menu > .item',
  528. text : '> .text',
  529. input : '> input[type="hidden"]'
  530. },
  531. </div>
  532. </td>
  533. </tr>
  534. <tr>
  535. <td>metadata</td>
  536. <td colspan="2">
  537. <div class="code">
  538. metadata: {
  539. text : 'text',
  540. value : 'value'
  541. },
  542. </div>
  543. </td>
  544. </tr>
  545. <tr>
  546. <td>className</td>
  547. <td colspan="2">
  548. <div class="code">
  549. className : {
  550. active : 'active',
  551. placeholder : 'default',
  552. disabled : 'disabled',
  553. visible : 'visible'
  554. }
  555. </div>
  556. </td>
  557. </tr>
  558. </tbody>
  559. </table>
  560. </div>
  561. <div class="no example">
  562. <h4 class="ui header">Debug Settings</h4>
  563. <p>Debug settings controls debug output to the console</p>
  564. <table class="ui celled definition table segment">
  565. <thead>
  566. <th>Setting</th>
  567. <th class="four wide">Default</th>
  568. <th>Description</th>
  569. </thead>
  570. <tbody>
  571. <tr>
  572. <td>name</td>
  573. <td>Dropdown</td>
  574. <td>Name used in debug logs</td>
  575. </tr>
  576. <tr>
  577. <td>debug</td>
  578. <td>True</td>
  579. <td>Provides standard debug output to console</td>
  580. </tr>
  581. <tr>
  582. <td>performance</td>
  583. <td>True</td>
  584. <td>Provides standard debug output to console</td>
  585. </tr>
  586. <tr>
  587. <td>verbose</td>
  588. <td>True</td>
  589. <td>Provides ancillary debug output to console</td>
  590. </tr>
  591. <tr>
  592. <td>error</td>
  593. <td colspan="2">
  594. <div class="code">
  595. error : {
  596. action : 'You called a dropdown action that was not defined',
  597. method : 'The method you called is not defined.',
  598. transition : 'The requested transition was not found'
  599. }
  600. </div>
  601. </td>
  602. </tr>
  603. </tbody>
  604. </table>
  605. </div>
  606. </div>
  607. </body>
  608. </html>