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.

516 lines
14 KiB

  1. ---
  2. layout : 'default'
  3. css : 'modal-demo'
  4. title : 'Modal'
  5. description : 'A modal displays content that temporarily blocks interactions with a web site'
  6. type : 'UI Module'
  7. ---
  8. <script src="/javascript/modal.js"></script>
  9. <%- @partial('header', { tabs: 'module' }) %>
  10. <div class="main container">
  11. <div class="ui basic modal">
  12. <div class="header">
  13. Change Your Homepage
  14. </div>
  15. <div class="content">
  16. <div class="left">
  17. <i class="home icon"></i>
  18. </div>
  19. <div class="right">
  20. <p>Are you sure you want to change your homepage to <b>Poodle.com</b>?</p>
  21. </div>
  22. </div>
  23. <div class="actions">
  24. <div class="two fluid ui buttons">
  25. <div class="ui negative labeled icon button">
  26. <i class="remove icon"></i>
  27. No
  28. </div>
  29. <div class="ui positive right labeled icon button">
  30. Yes
  31. <i class="checkmark icon"></i>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. <div class="ui small modal">
  37. <i class="close icon"></i>
  38. <div class="header">
  39. Changing Your Thing
  40. </div>
  41. <div class="content">
  42. <p>Do you want to change that thing to something else?</p>
  43. </div>
  44. <div class="actions">
  45. <div class="ui negative button">
  46. No
  47. </div>
  48. <div class="ui positive right labeled icon button">
  49. Yes
  50. <i class="checkmark icon"></i>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="ui large modal">
  55. <i class="close icon"></i>
  56. <div class="header">
  57. Changing Your Thing
  58. </div>
  59. <div class="content">
  60. <p>Do you want to change that thing to something else?</p>
  61. </div>
  62. <div class="actions">
  63. <div class="ui negative button">
  64. No
  65. </div>
  66. <div class="ui positive right labeled icon button">
  67. Yes
  68. <i class="checkmark icon"></i>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="ui test modal">
  73. <i class="close icon"></i>
  74. <div class="header">
  75. Profile Picture
  76. </div>
  77. <div class="content">
  78. <div class="left">
  79. <img class="ui medium image" src="/images/demo/avatar2.jpg">
  80. </div>
  81. <div class="right">
  82. <div class="ui header">Are you sure you want to upload that?</div>
  83. <p>I mean it's not really the best profile photo.</p>
  84. <p>It's resampled to like two times the size it's suppose to be. Our image detection software also says it might even be inappropriate.</p>
  85. </div>
  86. </div>
  87. <div class="actions">
  88. <div class="ui black button">
  89. Cancel
  90. </div>
  91. <div class="ui positive right labeled icon button">
  92. Add Photo
  93. <i class="checkmark icon"></i>
  94. </div>
  95. </div>
  96. </div>
  97. <div class="ui active tab" data-tab="definition">
  98. <div class="peek">
  99. <div class="ui vertical pointing secondary menu">
  100. <a class="item">Types</a>
  101. <a class="item">Variations</a>
  102. <a class="item">States</a>
  103. </div>
  104. </div>
  105. <h2 class="ui dividing header">Types</h2>
  106. <div class="no example">
  107. <h4 class="ui header">Standard</h4>
  108. <p>A standard modal</p>
  109. <div class="code" data-demo="true">
  110. $('.test.modal')
  111. .modal('show')
  112. ;
  113. </div>
  114. </div>
  115. <div class="no example">
  116. <h4 class="ui header">Basic</h4>
  117. <p>A modal can reduce its complexity</p>
  118. <div class="code" data-demo="true">
  119. $('.basic.modal')
  120. .modal('show')
  121. ;
  122. </div>
  123. </div>
  124. <h2 class="ui dividing header">Variations</h2>
  125. <div class="no example">
  126. <h4 class="ui header">Size</h4>
  127. <p>A modal can vary in size</p>
  128. <div class="code" data-demo="true">
  129. $('.small.modal')
  130. .modal('show')
  131. ;
  132. </div>
  133. <div class="code" data-demo="true">
  134. $('.large.modal')
  135. .modal('show')
  136. ;
  137. </div>
  138. </div>
  139. <h2 class="ui dividing header">States</h2>
  140. <div class="example">
  141. <h4 class="ui header">Active</h4>
  142. <p>An active modal is visible on the page</p>
  143. <div class="code" data-type="html">
  144. <div class="active ui modal">...</div>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="ui tab" data-tab="examples">
  149. <h2 class="ui dividing header">Examples</h2>
  150. <div class="no example">
  151. <h4 class="ui header">Approve / Deny Callbacks</h4>
  152. <p>Modals will automatically tie approve deny callbacks to any positive/approve or negative/deny buttons. If a callback returns false it will prevent the modal from closing</p>
  153. <div class="code" data-demo="true">
  154. $('.basic.modal')
  155. .modal('setting', {
  156. closable : false,
  157. onDeny : function(){
  158. window.alert('Wait not yet!');
  159. return false;
  160. },
  161. onApprove : function() {
  162. window.alert('Approved!');
  163. }
  164. })
  165. .modal('show')
  166. ;
  167. </div>
  168. </div>
  169. <div class="no example">
  170. <h4 class="ui header">Forcing a Choice</h4>
  171. <p>You can disable a modal's dimmer from being closed by click to force a user to make a choice</p>
  172. <div class="code" data-demo="true">
  173. $('.basic.modal')
  174. .modal('setting', 'closable', false)
  175. .modal('show')
  176. ;
  177. </div>
  178. </div>
  179. <div class="no example">
  180. <h4 class="ui header">Transitions</h4>
  181. <p>A modal can use any named ui transition.</p>
  182. <div class="ui selection dropdown">
  183. <input type="hidden" name="transition">
  184. <i class="dropdown icon"></i>
  185. <div class="default text">Choose transition</div>
  186. <div class="menu">
  187. <div class="item">Horizontal Flip</div>
  188. <div class="item">Vertical Flip</div>
  189. <div class="item">Fade Up</div>
  190. <div class="item">Fade</div>
  191. <div class="item">Scale</div>
  192. </div>
  193. </div>
  194. <div class="ui clearing divider"></div>
  195. <div class="code">
  196. $('.selection')
  197. .dropdown({
  198. onChange: function(value) {
  199. $('.test.modal')
  200. .modal('setting', 'transition', value)
  201. .modal('show')
  202. ;
  203. }
  204. })
  205. ;
  206. </div>
  207. </div>
  208. <div class="no example">
  209. <h4 class="ui header">Attach events</h4>
  210. <p>A modal can attach events to another element</p>
  211. <div class="code" data-demo="true">
  212. $('.test.modal')
  213. .modal('attach events', '.test.button', 'show')
  214. ;
  215. </div>
  216. <div class="ui primary test button">Launch modal</div>
  217. </div>
  218. </div>
  219. <div class="ui tab" data-tab="usage">
  220. <h2 class="ui dividing header">Usage</h2>
  221. <h3 class="ui header">Initializing a modal</h3>
  222. <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>
  223. <div class="ui info message">
  224. <div class="header">Why move modal content?</div>
  225. <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>
  226. </div>
  227. <div class="code" data-type="javascript">
  228. $('.ui.modal')
  229. .modal()
  230. ;
  231. </div>
  232. <div class="code" data-type="html">
  233. <div class="ui modal">
  234. <i class="close icon"></i>
  235. <div class="header">
  236. Modal Title
  237. </div>
  238. <div class="content">
  239. <div class="left">
  240. Content can appear on left
  241. </div>
  242. <div class="right">
  243. Content can appear on right
  244. </div>
  245. </div>
  246. <div class="actions">
  247. <div class="ui button">Cancel</div>
  248. <div class="ui button">OK</div>
  249. </div>
  250. </div>
  251. </div>
  252. <h2 class="ui dividing header">Behavior</h2>
  253. <p>All the following <a href="/module.html#/behavior">behaviors</a> can be called using the syntax:</p>
  254. <div class="code">
  255. $('.ui.modal')
  256. .modal('behavior name', argumentOne, argumentTwo)
  257. ;
  258. </div>
  259. <table class="ui definition celled sortable table segment">
  260. <thead>
  261. <th>Behavior</th>
  262. <th>Description</th>
  263. </thead>
  264. <tbody>
  265. <tr>
  266. <td>show</td>
  267. <td>Shows the modal</td>
  268. </tr>
  269. <tr>
  270. <td>hide</td>
  271. <td>Hides the modal</td>
  272. </tr>
  273. <tr>
  274. <td>toggle</td>
  275. <td>Toggles the modal</td>
  276. </tr>
  277. <tr>
  278. <td>refresh</td>
  279. <td>Refreshes centering of modal on page</td>
  280. </tr>
  281. <tr>
  282. <td>show dimmer</td>
  283. <td>Shows associated page dimmer</td>
  284. </tr>
  285. <tr>
  286. <td>hide dimmer</td>
  287. <td>Hides associated page dimmer</td>
  288. </tr>
  289. <tr>
  290. <td>hide all</td>
  291. <td>Hides all visible modals initialized at the same time</td>
  292. </tr>
  293. <tr>
  294. <td>cache sizes</td>
  295. <td>Caches current modal size</td>
  296. </tr>
  297. <tr>
  298. <td>can fit</td>
  299. <td>Returns whether the modal can fit on the page</td>
  300. </tr>
  301. <tr>
  302. <td>is active</td>
  303. <td>Returns whether the modal is active</td>
  304. </tr>
  305. <tr>
  306. <td>set active</td>
  307. <td>Sets modal to active</td>
  308. </tr>
  309. </tbody>
  310. </table>
  311. </div>
  312. <div class="ui tab" data-tab="settings">
  313. <h2 class="ui dividing header">Settings</h2>
  314. <h4 class="ui header">Modal Settings</h4>
  315. <p>Modal settings modify the modal's behavior</p>
  316. <table class="ui red celled sortable definition table segment">
  317. <thead>
  318. <th>Setting</th>
  319. <th class="four wide">Default</th>
  320. <th>Description</th>
  321. </thead>
  322. <tbody>
  323. <tr>
  324. <td>offset</td>
  325. <td>0</td>
  326. <td>A vertical offset to allow for content outside of modal, for example a close button, to be centered.</td>
  327. </tr>
  328. <tr>
  329. <td>context</td>
  330. <td>
  331. body
  332. </td>
  333. <td>Selector or jquery object specifying the area to dim</td>
  334. </tr>
  335. <tr>
  336. <td>closable</td>
  337. <td>
  338. true
  339. </td>
  340. <td>Settings to false will not allow you to close the modal by clicking on the dimmer</td>
  341. </tr>
  342. <tr>
  343. <td>transition</td>
  344. <td>
  345. scale
  346. </td>
  347. <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>
  348. </tr>
  349. <tr>
  350. <td>duration</td>
  351. <td>
  352. 400
  353. </td>
  354. <td>Duration of animation</td>
  355. </tr>
  356. <tr>
  357. <td>easing</td>
  358. <td>
  359. easeOutExpo
  360. </td>
  361. <td>Animation easing is only used if javascript animations are used.</td>
  362. </tr>
  363. </tbody>
  364. </table>
  365. <div class="ui horizontal section icon divider"><i class="icon setting"></i></div>
  366. <h4 class="ui header">Callbacks</h4>
  367. <p>Callbacks specify a function to occur after a specific behavior.</p>
  368. <table class="ui celled sortable definition table segment">
  369. <thead>
  370. <th class="four wide">Setting</th>
  371. <th>Context</th>
  372. <th>Description</th>
  373. </thead>
  374. <tbody>
  375. <tr>
  376. <td>onShow</td>
  377. <td>Modal</td>
  378. <td>Is called after a modal is shown.</td>
  379. </tr>
  380. <tr>
  381. <td>onHide</td>
  382. <td>Modal</td>
  383. <td>Is called after a modal is hidden.</td>
  384. </tr>
  385. <tr>
  386. <td>onApprove</td>
  387. <td>Modal</td>
  388. <td>Is called after a positive or approve button is pressed</td>
  389. </tr>
  390. <tr>
  391. <td>onDeny</td>
  392. <td>Modal</td>
  393. <td>Is called after a negative or cancel button is pressed.</td>
  394. </tr>
  395. </tbody>
  396. </table>
  397. <h4 class="ui header">DOM Settings</h4>
  398. <p>DOM settings specify how this module should interface with the DOM</p>
  399. <table class="ui celled sortable definition table segment">
  400. <thead>
  401. <th>Setting</th>
  402. <th class="four wide">Default</th>
  403. <th>Description</th>
  404. </thead>
  405. <tbody>
  406. <tr>
  407. <td>namespace</td>
  408. <td>modal</td>
  409. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  410. </tr>
  411. <tr>
  412. <td>selector</td>
  413. <td colspan="2">
  414. <div class="code">
  415. selector : {
  416. close : '.close, .actions .button',
  417. approve : '.actions .positive, .actions .approve',
  418. deny : '.actions .negative, .actions .cancel'
  419. },
  420. </div>
  421. </td>
  422. </tr>
  423. <tr>
  424. <td>className</td>
  425. <td colspan="2">
  426. <div class="code">
  427. className : {
  428. active : 'active',
  429. scrolling : 'scrolling'
  430. }
  431. </div>
  432. </td>
  433. </tr>
  434. </tbody>
  435. </table>
  436. <h4 class="ui header">Debug Settings</h4>
  437. <p>Debug settings controls debug output to the console</p>
  438. <table class="ui celled sortable definition table segment">
  439. <thead>
  440. <th>Setting</th>
  441. <th class="four wide">Default</th>
  442. <th>Description</th>
  443. </thead>
  444. <tbody>
  445. <tr>
  446. <td>name</td>
  447. <td>Modal</td>
  448. <td>Name used in debug logs</td>
  449. </tr>
  450. <tr>
  451. <td>debug</td>
  452. <td>True</td>
  453. <td>Provides standard debug output to console</td>
  454. </tr>
  455. <tr>
  456. <td>performance</td>
  457. <td>True</td>
  458. <td>Provides standard debug output to console</td>
  459. </tr>
  460. <tr>
  461. <td>verbose</td>
  462. <td>True</td>
  463. <td>Provides ancillary debug output to console</td>
  464. </tr>
  465. <tr>
  466. <td>error</td>
  467. <td colspan="2">
  468. <div class="code">
  469. error : {
  470. method : 'The method you called is not defined.''
  471. }
  472. </div>
  473. </td>
  474. </tr>
  475. </tbody>
  476. </table>
  477. </div>
  478. </div>
  479. </body>
  480. </html>