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.

520 lines
16 KiB

10 years ago
  1. ---
  2. layout : 'default'
  3. css : ''
  4. element : 'dimmer'
  5. elementType : 'module'
  6. title : 'Dimmer'
  7. description : "A dimmer hides distractions to focus attention on particular content"
  8. type : 'UI Module'
  9. themes : ['Default']
  10. ---
  11. <link rel="stylesheet/less" type="text/css" href="/build/less/definitions/modules/dimmer.less" />
  12. <script src="/javascript/dimmer.js"></script>
  13. <div class="ui page dimmer">
  14. <div class="content">
  15. <div class="center">
  16. <h2 class="ui inverted icon header">
  17. <i class="icon circular inverted emphasized green mail"></i>
  18. You're all signed up for the weekly dog tips newsletter!
  19. <div class="sub header">Your first edition will be sent on January 22</div>
  20. </h2>
  21. </div>
  22. </div>
  23. </div>
  24. <%- @partial('header', { tabs: 'module' }) %>
  25. <div class="main container">
  26. <div class="active ui tab" data-tab="definition">
  27. <h2 class="ui dividing header">Types</h2>
  28. <div class="example">
  29. <h4 class="ui header">Content Dimmer</h4>
  30. <p>A dimmer can display content</p>
  31. <div class="ui ignored info message">Content must be included inside <code>.content .center</code> to display centered correctly in the modal.</div>
  32. <div class="ui segment">
  33. <h4 class="ui dividing header">
  34. <i class="photo icon"></i>Dog Photos
  35. </h4>
  36. <img src="/images/demo/item1.jpg">
  37. <img src="/images/demo/item2.jpg">
  38. <div class="ui dimmer">
  39. <div class="content">
  40. <div class="center">
  41. <h2 class="ui inverted icon header">
  42. <i class="icon circular inverted emphasized red heart"></i>
  43. Your poodle photo uploaded successfully!
  44. </h2>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="ui icon buttons">
  50. <div class="ui show button"><i class="plus icon"></i></div>
  51. <div class="ui hide button"><i class="minus icon"></i></div>
  52. </div>
  53. <div class="existing code">
  54. <div class="ui dimmer">
  55. <div class="content">
  56. <div class="center">
  57. <h2 class="ui inverted icon header">
  58. <i class="icon circular inverted emphasized red heart"></i>
  59. Your poodle photo uploaded successfully!
  60. </h2>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. <div class="example">
  67. <h4 class="ui header">Page Dimmer</h4>
  68. <p>A dimmer can be formatted to be fixed to the page</p>
  69. <div class="existing code">
  70. <div class="ui page dimmer">
  71. <div class="content">
  72. <div class="center">Hello</div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="ui page button"><i class="plus icon"></i> Show</div>
  77. </div>
  78. <h2 class="ui dividing header">States</h2>
  79. <div class="example">
  80. <h4 class="ui header">Active</h4>
  81. <p>An active dimmer will dim its parent container</p>
  82. <div class="ui segment">
  83. <div class="ui active dimmer"></div>
  84. </div>
  85. </div>
  86. <div class="example">
  87. <h4 class="ui header">Disabled</h4>
  88. <p>A disabled dimmer cannot be activated</p>
  89. <div class="ui segment">
  90. <div class="ui disabled dimmer"></div>
  91. </div>
  92. </div>
  93. <h2 class="ui dividing header">Variations</h2>
  94. <h3>Dimmer</h3>
  95. <div class="example">
  96. <h4 class="ui header">Simple Dimmer</h4>
  97. <p>A dimmer can be controlled without javascript</p>
  98. <div class="ignored ui info message">Having any parent element receive the class <code>ui dimmable dimmed</code> will trigger the dimmer to display.</div>
  99. <div class="ui dimmable dimmed segment">
  100. <div class="ui simple dimmer"></div>
  101. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  102. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  103. </div>
  104. </div>
  105. <div class="example">
  106. <h4 class="ui header">Inverted Dimmer</h4>
  107. <p>A dimmer can be formatted to have its colors inverted</p>
  108. <div class="ui segment">
  109. <div class="ui inverted dimmer"></div>
  110. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  111. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  112. </div>
  113. <div class="ignore ui icon buttons">
  114. <div class="ui show button"><i class="plus icon"></i></div>
  115. <div class="ui hide button"><i class="minus icon"></i></div>
  116. </div>
  117. </div>
  118. </div>
  119. <div class="ui tab" data-tab="examples">
  120. <div class="event example">
  121. <h4 class="ui header">Dimmer Events</h4>
  122. <p>A dimmer can trigger a visibility change on an event</p>
  123. <div class="evaluated code">
  124. $('.event.example .image')
  125. .dimmer({
  126. on: 'hover'
  127. })
  128. ;
  129. </div>
  130. <div class="ui medium image">
  131. <div class="ui dimmer">
  132. <div class="content">
  133. <div class="center">
  134. <h2 class="ui inverted header">Puppy</h2>
  135. <div class="ui green button">Vote</div>
  136. <a class="ui button">View</a>
  137. </div>
  138. </div>
  139. </div>
  140. <img src="/images/demo/highres.jpg">
  141. </div>
  142. <div class="ui circular image">
  143. <div class="ui dimmer">
  144. <div class="content">
  145. <div class="center">
  146. <div class="ui mini green button">Vote</div>
  147. <a class="ui mini button">View</a>
  148. </div>
  149. </div>
  150. </div>
  151. <img src="/images/demo/photo2.jpg">
  152. </div>
  153. </div>
  154. <div class="example">
  155. <h4 class="ui header">Loaders inside Dimmers</h4>
  156. <p>Any loader inside a dimmer will automatically use an appropriate color to match</p>
  157. <div class="ui segment">
  158. <div class="ui inverted dimmer">
  159. <div class="ui text loader">Loading</div>
  160. </div>
  161. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  162. <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p>
  163. </div>
  164. <div class="ignore ui icon buttons">
  165. <div class="ui show button"><i class="plus icon"></i></div>
  166. <div class="ui hide button"><i class="minus icon"></i></div>
  167. </div>
  168. </div>
  169. </div>
  170. <div class="ui tab" data-tab="usage">
  171. <h2 class="ui dividing header">Usage</h2>
  172. <h3 class="ui header">Display</h3>
  173. <p>You can display a dimmer by either invoking .dimmer('show') on a section or a dimmer itself. If you choose to dim a dimmable section, a dimmer will automatically be created.</p>
  174. <div class="ignore code">
  175. // these two are the same
  176. $('.ui.dimmable)
  177. .dimmer('show')
  178. ;
  179. $('.ui.dimmable .dimmer')
  180. .dimmer('show')
  181. ;
  182. </div>
  183. <h3 class="ui header">Creating Dimmers</h3>
  184. <p>If a dimmer does not exist inside the element it will be created on first use.</p>
  185. <div class="code" data-demo="true">
  186. $('h3')
  187. .dimmer('toggle')
  188. ;
  189. </div>
  190. <h3 class="ui header">Showing a specific dimmer</h3>
  191. <p>If a dimmer is already inside an element, you can call behavior on the dimmable section or the dimmer itself.</p>
  192. <div class="code" data-demo="true">
  193. // If a dimmer exists on a page, you can make it appear by calling it directly
  194. $('.page.dimmer:first')
  195. .dimmer('toggle')
  196. ;
  197. </div>
  198. <h2 class="ui dividing header">Behavior</h2>
  199. <p>All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax:</p>
  200. <div class="code">
  201. $('.your.element')
  202. .dimmer('behavior name', argumentOne, argumentTwo)
  203. ;
  204. </div>
  205. <table class="ui definition celled sortable table segment">
  206. <thead>
  207. <th>Behavior</th>
  208. <th>Description</th>
  209. </thead>
  210. <tbody>
  211. <tr>
  212. <td>add content (element)</td>
  213. <td>Detaches a given element from DOM and reattaches element inside dimmer</td>
  214. </tr>
  215. <tr>
  216. <td>show</td>
  217. <td>Shows dimmer</td>
  218. </tr>
  219. <tr>
  220. <td>hide</td>
  221. <td>Hides dimmer</td>
  222. </tr>
  223. <tr>
  224. <td>toggle</td>
  225. <td>Toggles current dimmer visibility</td>
  226. </tr>
  227. <tr>
  228. <td>get duration</td>
  229. <td>Returns current duration for show or hide event depending on current visibility</td>
  230. </tr>
  231. <tr>
  232. <td>get dimmer</td>
  233. <td>Returns DOM element for dimmer</td>
  234. </tr>
  235. <tr>
  236. <td>has dimmer</td>
  237. <td>Returns whether current dimmable has a dimmer</td>
  238. </tr>
  239. <tr>
  240. <td>is dimmer</td>
  241. <td>Whether current element is a dimmer</td>
  242. </tr>
  243. <tr>
  244. <td>is dimmable</td>
  245. <td>Whether current element is a dimmable section</td>
  246. </tr>
  247. <tr>
  248. <td>is active</td>
  249. <td>Whether section's dimmer is active</td>
  250. </tr>
  251. <tr>
  252. <td>is animating</td>
  253. <td>Whether dimmer is animating</td>
  254. </tr>
  255. <tr>
  256. <td>is page</td>
  257. <td>Whether dimmable section is <code>body</code></td>
  258. </tr>
  259. <tr>
  260. <td>is enabled</td>
  261. <td>Whether dimmer is not disabled</td>
  262. </tr>
  263. <tr>
  264. <td>is disabled</td>
  265. <td>Whether dimmer is disabled</td>
  266. </tr>
  267. <tr>
  268. <td>is page dimmer</td>
  269. <td>Whether dimmer is a page dimmer</td>
  270. </tr>
  271. <tr>
  272. <td>set active</td>
  273. <td>Sets page dimmer to active</td>
  274. </tr>
  275. <tr>
  276. <td>set dimmable</td>
  277. <td>Sets an element as a dimmable section</td>
  278. </tr>
  279. <tr>
  280. <td>set dimmed</td>
  281. <td>Sets a dimmable section as dimmed</td>
  282. </tr>
  283. <tr>
  284. <td>set page dimmer</td>
  285. <td>Sets current dimmer as a page dimmer</td>
  286. </tr>
  287. <tr>
  288. <td>set disabled</td>
  289. <td>Sets a dimmer as disabled</td>
  290. </tr>
  291. </tbody>
  292. </table>
  293. </div>
  294. <div class="ui tab" data-tab="settings">
  295. <h3 class="ui header">
  296. Dimmer Settings
  297. <div class="sub header">Dimmer settings modify its behavior</div>
  298. </h3>
  299. <table class="ui sortable celled definition table segment">
  300. <thead>
  301. <th>Setting</th>
  302. <th class="four wide">Default</th>
  303. <th>Description</th>
  304. </thead>
  305. <tbody>
  306. <tr>
  307. <td>closable</td>
  308. <td class="six wide">true</td>
  309. <td>Whether clicking on the dimmer should close it automatically</td>
  310. </tr>
  311. <tr>
  312. <td>on</td>
  313. <td class="six wide">false</td>
  314. <td>Can be set to <code>hover</code> or <code>click</code> to show/hide dimmer on dimmable event</td>
  315. </tr>
  316. <tr>
  317. <td>duration</td>
  318. <td>
  319. <div class="code">
  320. duration : {
  321. show : 500,
  322. hide : 500
  323. }
  324. </div>
  325. </td>
  326. <td>Animation duration of dimming. If an integer is used, that value will apply to both show and hide animations.</td>
  327. </tr>
  328. <tr>
  329. <td>transition</td>
  330. <td>
  331. Fade
  332. </td>
  333. <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>
  334. </tr>
  335. </tbody>
  336. </tbody>
  337. </table>
  338. <h3 class="ui header">
  339. Callbacks
  340. <div class="sub header">Callbacks specify a function to occur after a specific behavior.</div>
  341. </h3>
  342. <table class="ui sortable celled definition table segment">
  343. <thead>
  344. <th class="four wide">Setting</th>
  345. <th>Context</th>
  346. <th>Description</th>
  347. </thead>
  348. <tbody>
  349. <tr>
  350. <td>onShow</td>
  351. <td>dimmable</td>
  352. <td>Callback on element show</td>
  353. </tr>
  354. <tr>
  355. <td>onHide</td>
  356. <td>dimmable</td>
  357. <td>Callback on element hide</td>
  358. </tr>
  359. <tr>
  360. <td>onChange</td>
  361. <td>dimmable</td>
  362. <td>Callback on element show or hide</td>
  363. </tr>
  364. </tbody>
  365. </table>
  366. <h3 class="ui header">
  367. Templates
  368. <div class="sub header">Templates are used to generate DOM elements</div>
  369. </h3>
  370. <table class="ui sortable celled definition table segment">
  371. <thead>
  372. <th class="three wide">Generates</th>
  373. <th>Default</th>
  374. </thead>
  375. <tbody>
  376. <tr>
  377. <td>dimmer</td>
  378. <td>
  379. <div class="code" data-type="javascript">
  380. function() {
  381. return $('<div />').attr('class', 'ui dimmer');
  382. }
  383. </div>
  384. </td>
  385. </tr>
  386. </tbody>
  387. </table>
  388. <h3 class="ui header">
  389. DOM Settings
  390. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  391. </h3>
  392. <table class="ui sortable celled definition table segment">
  393. <thead>
  394. <th>Setting</th>
  395. <th class="six wide">Default</th>
  396. <th>Description</th>
  397. </thead>
  398. <tbody>
  399. <tr>
  400. <td>namespace</td>
  401. <td>dimmer</td>
  402. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  403. </tr>
  404. <tr>
  405. <td>selector</td>
  406. <td>
  407. <div class="code" data-type="css">
  408. selector: {
  409. dimmable : '.ui.dimmable',
  410. dimmer : '.ui.dimmer',
  411. content : '.ui.dimmer > .content, .ui.dimmer > .content > .center'
  412. }
  413. </div>
  414. </td>
  415. <td>Object containing selectors used by module.</td>
  416. </tr>
  417. <tr>
  418. <td>className</td>
  419. <td>
  420. <div class="code">
  421. className : {
  422. active : 'active',
  423. dimmable : 'ui dimmable',
  424. dimmed : 'dimmed',
  425. disabled : 'disabled',
  426. pageDimmer : 'page',
  427. hide : 'hide',
  428. show : 'show',
  429. transition : 'transition'
  430. }
  431. </div>
  432. </td>
  433. <td>Class names used to attach style to state</td>
  434. </tr>
  435. </tbody>
  436. </table>
  437. <h3 class="ui header">
  438. Debug Settings
  439. <div class="sub header">Debug settings controls debug output to the console</div>
  440. </h3>
  441. <table class="ui sortable celled definition table segment">
  442. <thead>
  443. <th>Setting</th>
  444. <th class="four wide">Default</th>
  445. <th>Description</th>
  446. </thead>
  447. <tbody>
  448. <tr>
  449. <td>name</td>
  450. <td>Dimmer</td>
  451. <td>Name used in debug logs</td>
  452. </tr>
  453. <tr>
  454. <td>debug</td>
  455. <td>True</td>
  456. <td>Provides standard debug output to console</td>
  457. </tr>
  458. <tr>
  459. <td>performance</td>
  460. <td>True</td>
  461. <td>Provides standard debug output to console</td>
  462. </tr>
  463. <tr>
  464. <td>verbose</td>
  465. <td>True</td>
  466. <td>Provides ancillary debug output to console</td>
  467. </tr>
  468. <tr>
  469. <td>errors</td>
  470. <td colspan="2">
  471. <div class="code">
  472. error : {
  473. method : 'The method you called is not defined.'
  474. }
  475. </div>
  476. </td>
  477. </tr>
  478. </tbody>
  479. </table>
  480. </div>
  481. </div>