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.

654 lines
19 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. ---
  2. layout : 'default'
  3. css : 'modal-page'
  4. element : 'modal'
  5. elementType : 'module'
  6. title : 'Modal'
  7. description : 'A modal displays content that temporarily blocks interactions with the main view of a site'
  8. type : 'UI Module'
  9. themes : ['Default', 'Fixed-width']
  10. ---
  11. <link rel="stylesheet/less" type="text/css" href="/build/less/definitions/modules/modal.less" />
  12. <script src="/javascript/modal.js"></script>
  13. <%- @partial('header', { tabs: 'module' }) %>
  14. <div class="main container">
  15. <div class="ui basic test modal">
  16. <i class="close icon"></i>
  17. <div class="header">
  18. Archive Old Messages
  19. </div>
  20. <div class="content">
  21. <div class="image">
  22. <i class="archive icon"></i>
  23. </div>
  24. <div class="description">
  25. <p>Your inbox is getting full, would you like us to enable automatic archiving of old messages?</p>
  26. </div>
  27. </div>
  28. <div class="actions">
  29. <div class="two fluid ui inverted buttons">
  30. <div class="ui red basic inverted button">
  31. <i class="remove icon"></i>
  32. No
  33. </div>
  34. <div class="ui green basic inverted button">
  35. <i class="checkmark icon"></i>
  36. Yes
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="ui small modal">
  42. <i class="close icon"></i>
  43. <div class="header">
  44. Delete Your Account
  45. </div>
  46. <div class="content">
  47. <p>Are you sure you want to delete your account</p>
  48. </div>
  49. <div class="actions">
  50. <div class="ui negative button">
  51. No
  52. </div>
  53. <div class="ui positive right labeled icon button">
  54. Yes
  55. <i class="checkmark icon"></i>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="ui fullscreen modal">
  60. <i class="close icon"></i>
  61. <div class="header">
  62. Update Your Account Settings
  63. </div>
  64. <div class="content">
  65. <div class="ui form">
  66. <h4 class="ui dividing header">Give us your feedback</h4>
  67. <div class="field">
  68. <label>Feedback</label>
  69. <textarea></textarea>
  70. </div>
  71. <div class="field">
  72. <div class="ui checkbox">
  73. <input type="checkbox" checked="checked" name="contact-me">
  74. <label>It's okay to contact me.</label>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <div class="actions">
  80. <div class="ui button">Cancel</div>
  81. <div class="ui green button">Send</div>
  82. </div>
  83. </div>
  84. <div class="ui large modal">
  85. <i class="close icon"></i>
  86. <div class="header">
  87. Changing Your Thing
  88. </div>
  89. <div class="content">
  90. <p>Do you want to change that thing to something else?</p>
  91. </div>
  92. <div class="actions">
  93. <div class="ui negative button">
  94. No
  95. </div>
  96. <div class="ui positive right labeled icon button">
  97. Yes
  98. <i class="checkmark icon"></i>
  99. </div>
  100. </div>
  101. </div>
  102. <div class="ui standard test modal">
  103. <i class="close icon"></i>
  104. <div class="header">
  105. Profile Picture
  106. </div>
  107. <div class="content">
  108. <div class="ui medium image">
  109. <img src="/images/avatar/large/chris.jpg">
  110. </div>
  111. <div class="description">
  112. <div class="ui header">We've auto-chosen a profile image for you.</div>
  113. <p>We've grabbed the following image from the <a href="https://www.gravatar.com" target="_blank">gravatar</a> image associated with your registered e-mail address.</p>
  114. <p>Is it okay to use this photo?</p>
  115. </div>
  116. </div>
  117. <div class="actions">
  118. <div class="ui black button">
  119. Nope
  120. </div>
  121. <div class="ui positive right labeled icon button">
  122. Yep, that's me
  123. <i class="checkmark icon"></i>
  124. </div>
  125. </div>
  126. </div>
  127. <div class="ui active tab" data-tab="definition">
  128. <h2 class="ui dividing header">Types</h2>
  129. <div class="example">
  130. <h4 class="ui header">Standard</h4>
  131. <p>A standard modal</p>
  132. <div class="code" data-demo="true">
  133. $('.standard.test.modal')
  134. .modal('show')
  135. ;
  136. </div>
  137. <div class="existing code" data-type="html">
  138. <div class="ui modal">
  139. <i class="close icon"></i>
  140. <div class="header">
  141. Profile Picture
  142. </div>
  143. <div class="content">
  144. <div class="ui medium image">
  145. <img src="/images/avatar/large/chris.jpg">
  146. </div>
  147. <div class="description">
  148. <div class="ui header">We've auto-chosen a profile image for you.</div>
  149. <p>We've grabbed the following image from the <a href="https://www.gravatar.com" target="_blank">gravatar</a> image associated with your registered e-mail address.</p>
  150. <p>Is it okay to use this photo?</p>
  151. </div>
  152. </div>
  153. <div class="actions">
  154. <div class="ui black button">
  155. Nope
  156. </div>
  157. <div class="ui positive right labeled icon button">
  158. Yep, that's me
  159. <i class="checkmark icon"></i>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. <div class="example">
  166. <h4 class="ui header">Basic</h4>
  167. <p>A modal can reduce its complexity</p>
  168. <div class="code" data-demo="true">
  169. $('.basic.test.modal')
  170. .modal('show')
  171. ;
  172. </div>
  173. <div class="existing code">
  174. <div class="ui basic modal">
  175. <i class="close icon"></i>
  176. <div class="header">
  177. Archive Old Messages
  178. </div>
  179. <div class="content">
  180. <div class="image">
  181. <i class="archive icon"></i>
  182. </div>
  183. <div class="description">
  184. <p>Your inbox is getting full, would you like us to enable automatic archiving of old messages?</p>
  185. </div>
  186. </div>
  187. <div class="actions">
  188. <div class="two fluid ui inverted buttons">
  189. <div class="ui red basic inverted button">
  190. <i class="remove icon"></i>
  191. No
  192. </div>
  193. <div class="ui green basic inverted button">
  194. <i class="checkmark icon"></i>
  195. Yes
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. </div>
  202. <h2 class="ui dividing header">Variations</h2>
  203. <div class="no example">
  204. <h4 class="ui header">Full Screen</h4>
  205. <p>A modal can use the entire size of the screen</p>
  206. <div class="code" data-demo="true">
  207. $('.fullscreen.modal')
  208. .modal('show')
  209. ;
  210. </div>
  211. </div>
  212. <div class="no example">
  213. <h4 class="ui header">Size</h4>
  214. <p>A modal can vary in size</p>
  215. <div class="code" data-demo="true">
  216. $('.small.modal')
  217. .modal('show')
  218. ;
  219. </div>
  220. <div class="code" data-demo="true">
  221. $('.large.modal')
  222. .modal('show')
  223. ;
  224. </div>
  225. </div>
  226. <h2 class="ui dividing header">States</h2>
  227. <div class="example">
  228. <h4 class="ui header">Active</h4>
  229. <p>An active modal is visible on the page</p>
  230. <div class="code" data-type="html">
  231. <div class="ui active modal"></div>
  232. </div>
  233. </div>
  234. </div>
  235. <div class="ui tab" data-tab="examples">
  236. <h2 class="ui dividing header">Examples</h2>
  237. <div class="no example">
  238. <h4 class="ui header">Forcing a Choice</h4>
  239. <p>You can disable a modal's dimmer from being closed by click to force a user to make a choice</p>
  240. <div class="code" data-demo="true">
  241. $('.basic.test.modal')
  242. .modal('setting', 'closable', false)
  243. .modal('show')
  244. ;
  245. </div>
  246. </div>
  247. <div class="no example">
  248. <h4 class="ui header">Approve / Deny Callbacks</h4>
  249. <p>Modals will automatically tie approve deny callbacks to any positive/approve, negative/deny or ok/cancel buttons. If a callback returns false it will prevent the modal from closing</p>
  250. <div class="code" data-demo="true">
  251. $('.basic.test.modal')
  252. .modal('setting', {
  253. closable : false,
  254. onDeny : function(){
  255. window.alert('Wait not yet!');
  256. return false;
  257. },
  258. onApprove : function() {
  259. window.alert('Approved!');
  260. }
  261. })
  262. .modal('show')
  263. ;
  264. </div>
  265. </div>
  266. <div class="no example">
  267. <h4 class="ui header">Transitions</h4>
  268. <p>A modal can use any named ui transition.</p>
  269. <div class="ui selection dropdown">
  270. <input type="hidden" name="transition">
  271. <div class="default text">Choose transition</div>
  272. <i class="dropdown icon"></i>
  273. <div class="menu">
  274. <div class="item">Horizontal Flip</div>
  275. <div class="item">Vertical Flip</div>
  276. <div class="item">Fade Up</div>
  277. <div class="item">Fade</div>
  278. <div class="item">Scale</div>
  279. </div>
  280. </div>
  281. <div class="ui clearing divider"></div>
  282. <div class="code">
  283. $('.selection.dropdown')
  284. .dropdown({
  285. onChange: function(value) {
  286. alert($('.standard.test.modal').size());
  287. $('.standard.test.modal')
  288. .modal('setting', 'transition', value)
  289. .modal('show')
  290. ;
  291. }
  292. })
  293. ;
  294. </div>
  295. </div>
  296. <div class="no example">
  297. <h4 class="ui header">Attach events</h4>
  298. <p>A modal can attach events to another element</p>
  299. <div class="code" data-demo="true">
  300. $('.standard.test.modal')
  301. .modal('attach events', '.test.button', 'show')
  302. ;
  303. </div>
  304. <div class="ui primary test button">Launch modal</div>
  305. </div>
  306. </div>
  307. <div class="ui tab" data-tab="usage">
  308. <h2 class="ui dividing header">Usage</h2>
  309. <h3 class="ui header">Initializing a modal</h3>
  310. <p>A modal can be included anywhere on the page. On initialization a modal's current size will be cached, and the element will be detached from the dom and moved inside a dimmer.</p>
  311. <div class="ui info message">
  312. <div class="header">Why move modal content?</div>
  313. <p>Having a modal inside the page dimmer allows for 3D animations without having the 3D perspective settings alter the rest of the page content. Additionally, content outside the dimmer can be blurred or altered without affecting the modal's content.</p>
  314. <p>If you need to have your modal stay in its current location you can preserve its position using the setting <code>detachable: false</code></p>
  315. </div>
  316. <div class="code" data-type="javascript">
  317. $('.ui.modal')
  318. .modal()
  319. ;
  320. </div>
  321. <div class="code" data-type="html">
  322. <div class="ui modal">
  323. <i class="close icon"></i>
  324. <div class="header">
  325. Modal Title
  326. </div>
  327. <div class="content">
  328. <div class="image">
  329. An image can appear on left or an icon
  330. </div>
  331. <div class="description">
  332. A description can appear on the right
  333. </div>
  334. </div>
  335. <div class="actions">
  336. <div class="ui button">Cancel</div>
  337. <div class="ui button">OK</div>
  338. </div>
  339. </div>
  340. </div>
  341. <h2 class="ui dividing header">Behavior</h2>
  342. <p>All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax:</p>
  343. <div class="code">
  344. $('.ui.modal')
  345. .modal('behavior name', argumentOne, argumentTwo)
  346. ;
  347. </div>
  348. <table class="ui definition celled sortable table segment">
  349. <thead>
  350. <tr>
  351. <th>Behavior</th>
  352. <th>Description</th>
  353. </tr>
  354. </thead>
  355. <tbody>
  356. <tr>
  357. <td>show</td>
  358. <td>Shows the modal</td>
  359. </tr>
  360. <tr>
  361. <td>hide</td>
  362. <td>Hides the modal</td>
  363. </tr>
  364. <tr>
  365. <td>toggle</td>
  366. <td>Toggles the modal</td>
  367. </tr>
  368. <tr>
  369. <td>refresh</td>
  370. <td>Refreshes centering of modal on page</td>
  371. </tr>
  372. <tr>
  373. <td>show dimmer</td>
  374. <td>Shows associated page dimmer</td>
  375. </tr>
  376. <tr>
  377. <td>hide dimmer</td>
  378. <td>Hides associated page dimmer</td>
  379. </tr>
  380. <tr>
  381. <td>hide others</td>
  382. <td>Hides all modals not selected modal in a dimmer</td>
  383. </tr>
  384. <tr>
  385. <td>hide all</td>
  386. <td>Hides all visible modals in the same dimmer</td>
  387. </tr>
  388. <tr>
  389. <td>cache sizes</td>
  390. <td>Caches current modal size</td>
  391. </tr>
  392. <tr>
  393. <td>can fit</td>
  394. <td>Returns whether the modal can fit on the page</td>
  395. </tr>
  396. <tr>
  397. <td>is active</td>
  398. <td>Returns whether the modal is active</td>
  399. </tr>
  400. <tr>
  401. <td>set active</td>
  402. <td>Sets modal to active</td>
  403. </tr>
  404. </tbody>
  405. </table>
  406. </div>
  407. <div class="ui tab" data-tab="settings">
  408. <h2 class="ui dividing header">Settings</h2>
  409. <h3 class="ui header">Modal Settings
  410. <div class="sub header">Modal settings modify the modal's behavior</div>
  411. </h3>
  412. <table class="ui red celled sortable definition table segment">
  413. <thead>
  414. <tr>
  415. <th>Setting</th>
  416. <th class="four wide">Default</th>
  417. <th>Description</th>
  418. </tr>
  419. </thead>
  420. <tbody>
  421. <tr>
  422. <td>detachable</td>
  423. <td>true</td>
  424. <td>If set to false will prevent the modal from being moved to inside the dimmer</td>
  425. </tr>
  426. <tr>
  427. <td>allowMultiple</td>
  428. <td>false</td>
  429. <td>If set to true will not close other visible modals when opening a new one</td>
  430. </tr>
  431. <tr>
  432. <td>offset</td>
  433. <td>0</td>
  434. <td>A vertical offset to allow for content outside of modal, for example a close button, to be centered.</td>
  435. </tr>
  436. <tr>
  437. <td>context</td>
  438. <td>
  439. body
  440. </td>
  441. <td>Selector or jquery object specifying the area to dim</td>
  442. </tr>
  443. <tr>
  444. <td>closable</td>
  445. <td>
  446. true
  447. </td>
  448. <td>Settings to false will not allow you to close the modal by clicking on the dimmer</td>
  449. </tr>
  450. <tr>
  451. <td>useCSS</td>
  452. <td>
  453. true
  454. </td>
  455. <td>Whether to use CSS animations instead of fallback javascript animations</td>
  456. </tr>
  457. <tr>
  458. <td>transition</td>
  459. <td>
  460. scale
  461. </td>
  462. <td>Named transition to use when animating menu in and out. <code>Fade</code> is available without including <a href="/modules/transition.html">ui transitions</a></td>
  463. </tr>
  464. <tr>
  465. <td>duration</td>
  466. <td>
  467. 400
  468. </td>
  469. <td>Duration of animation</td>
  470. </tr>
  471. <tr>
  472. <td>easing</td>
  473. <td>
  474. easeOutExpo
  475. </td>
  476. <td>Animation easing is only used if javascript animations are used.</td>
  477. </tr>
  478. </tbody>
  479. </table>
  480. <div class="ui horizontal section icon divider"><i class="icon setting"></i></div>
  481. <h3 class="ui header">Callbacks
  482. <div class="sub header">Callbacks specify a function to occur after a specific behavior.</div>
  483. </h3>
  484. <table class="ui celled sortable definition table segment">
  485. <thead>
  486. <tr>
  487. <th class="four wide">Setting</th>
  488. <th>Context</th>
  489. <th>Description</th>
  490. </tr>
  491. </thead>
  492. <tbody>
  493. <tr>
  494. <td>onShow</td>
  495. <td>Modal</td>
  496. <td>Is called when a modal starts to show.</td>
  497. </tr>
  498. <tr>
  499. <td>onVisible</td>
  500. <td>Modal</td>
  501. <td>Is called after a modal has finished showing animating.</td>
  502. </tr>
  503. <tr>
  504. <td>onHide</td>
  505. <td>Modal</td>
  506. <td>Is called after a modal starts to hide.</td>
  507. </tr>
  508. <tr>
  509. <td>onHidden</td>
  510. <td>Modal</td>
  511. <td>Is called after a modal has finished hiding animation.</td>
  512. </tr>
  513. <tr>
  514. <td>onApprove</td>
  515. <td>Modal</td>
  516. <td>Is called after a positive, approve or ok button is pressed</td>
  517. </tr>
  518. <tr>
  519. <td>onDeny</td>
  520. <td>Modal</td>
  521. <td>Is called after a negative, deny or cancel button is pressed.</td>
  522. </tr>
  523. </tbody>
  524. </table>
  525. <h3 class="ui header">DOM Settings
  526. <div class="sub header">DOM settings specify how this module should interface with the DOM</div>
  527. </h3>
  528. <table class="ui celled sortable definition table segment">
  529. <thead>
  530. <tr>
  531. <th>Setting</th>
  532. <th class="four wide">Default</th>
  533. <th>Description</th>
  534. </thead>
  535. <tbody>
  536. <tr>
  537. <td>namespace</td>
  538. <td>modal</td>
  539. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  540. </tr>
  541. <tr>
  542. <td>selector</td>
  543. <td colspan="2">
  544. <div class="code">
  545. selector : {
  546. close : '.close, .actions .button',
  547. approve : '.actions .positive, .actions .approve, .actions .ok',
  548. deny : '.actions .negative, .actions .deny, .actions .cancel'
  549. },
  550. </div>
  551. </td>
  552. </tr>
  553. <tr>
  554. <td>className</td>
  555. <td colspan="2">
  556. <div class="code">
  557. className : {
  558. active : 'active',
  559. scrolling : 'scrolling'
  560. }
  561. </div>
  562. </td>
  563. </tr>
  564. </tbody>
  565. </table>
  566. <h3 class="ui header">Debug Settings
  567. <div class="sub header">Debug settings controls debug output to the console</div>
  568. </h3>
  569. <table class="ui celled sortable definition table segment">
  570. <thead>
  571. <tr>
  572. <th>Setting</th>
  573. <th class="four wide">Default</th>
  574. <th>Description</th>
  575. </tr>
  576. </thead>
  577. <tbody>
  578. <tr>
  579. <td>name</td>
  580. <td>Modal</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. method : 'The method you called is not defined.''
  604. }
  605. </div>
  606. </td>
  607. </tr>
  608. </tbody>
  609. </table>
  610. </div>
  611. </div>
  612. <link rel="stylesheet/less" type="text/css" href="/build/less/definitions/modules/modal.less" />