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.

510 lines
13 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') %>
  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="peek">
  98. <div class="ui vertical pointing secondary menu">
  99. <a class="active item">Usage</a>
  100. <a class="item">Types</a>
  101. <a class="item">Variations</a>
  102. <a class="item">States</a>
  103. <a class="item">Examples</a>
  104. <a class="item">Behavior</a>
  105. <a class="item">Settings</a>
  106. </div>
  107. </div>
  108. <h2 class="ui dividing header">Usage</h2>
  109. <h3 class="ui header">Initializing a modal</h3>
  110. <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>
  111. <div class="ui info message">
  112. <div class="header">Why move modal content?</div>
  113. <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>
  114. </div>
  115. <div class="code" data-type="javascript">
  116. $('.ui.modal')
  117. .modal()
  118. ;
  119. </div>
  120. <div class="code" data-type="html">
  121. <div class="ui modal">
  122. <i class="close icon"></i>
  123. <div class="header">
  124. Modal Title
  125. </div>
  126. <div class="content">
  127. <div class="left">
  128. Content can appear on left
  129. </div>
  130. <div class="right">
  131. Content can appear on right
  132. </div>
  133. </div>
  134. <div class="actions">
  135. <div class="ui button">Cancel</div>
  136. <div class="ui button">OK</div>
  137. </div>
  138. </div>
  139. </div>
  140. <h2 class="ui dividing header">Types</h2>
  141. <div class="no example">
  142. <h4 class="ui header">Standard</h4>
  143. <p>A standard modal</p>
  144. <div class="code" data-demo="true">
  145. $('.test.modal')
  146. .modal('show')
  147. ;
  148. </div>
  149. </div>
  150. <div class="no example">
  151. <h4 class="ui header">Basic</h4>
  152. <p>A modal can reduce its complexity</p>
  153. <div class="code" data-demo="true">
  154. $('.basic.modal')
  155. .modal('show')
  156. ;
  157. </div>
  158. </div>
  159. <h2 class="ui dividing header">Variations</h2>
  160. <div class="no example">
  161. <h4 class="ui header">Size</h4>
  162. <p>A modal can vary in size</p>
  163. <div class="code" data-demo="true">
  164. $('.small.modal')
  165. .modal('show')
  166. ;
  167. </div>
  168. <div class="code" data-demo="true">
  169. $('.large.modal')
  170. .modal('show')
  171. ;
  172. </div>
  173. </div>
  174. <h2 class="ui dividing header">States</h2>
  175. <div class="example">
  176. <h4 class="ui header">Active</h4>
  177. <p>An active modal is visible on the page</p>
  178. <div class="code" data-type="html">
  179. <div class="active ui modal">...</div>
  180. </div>
  181. </div>
  182. <h2 class="ui dividing header">Examples</h2>
  183. <div class="no example">
  184. <h4 class="ui header">Approve / Deny Callbacks</h4>
  185. <p>Modals will automatically tie approve deny callbacks to any positive/approve or negative/deny buttons</p>
  186. <div class="code" data-demo="true">
  187. $('.basic.modal')
  188. .modal('setting', 'onDeny', function(){
  189. window.alert('Denied!');
  190. })
  191. .modal('setting', 'onApprove', function(){
  192. window.alert('Approved!');
  193. })
  194. .modal('show')
  195. ;
  196. </div>
  197. </div>
  198. <div class="no example">
  199. <h4 class="ui header">Forcing a Choice</h4>
  200. <p>You can disable a modal's dimmer from being closed by click to force a user to make a choice</p>
  201. <div class="code" data-demo="true">
  202. $('.basic.modal')
  203. .modal('setting', 'closable', false)
  204. .modal('show')
  205. ;
  206. </div>
  207. </div>
  208. <div class="no example">
  209. <h4 class="ui header">Transitions</h4>
  210. <p>A dimmer can use any named ui transition.</p>
  211. <div class="ui selection dropdown">
  212. <input type="hidden" name="transition">
  213. <i class="dropdown icon"></i>
  214. <div class="default text">Choose transition</div>
  215. <div class="menu">
  216. <div class="item">Horizontal Flip</div>
  217. <div class="item">Vertical Flip</div>
  218. <div class="item">Fade Up</div>
  219. <div class="item">Fade</div>
  220. <div class="item">Scale</div>
  221. </div>
  222. </div>
  223. <div class="ui clearing divider"></div>
  224. <div class="code">
  225. $('.selection')
  226. .dropdown({
  227. onChange: function(value) {
  228. $('.test.modal')
  229. .modal('setting', 'transition', value)
  230. .modal('show')
  231. ;
  232. }
  233. })
  234. ;
  235. </div>
  236. </div>
  237. <h2 class="ui dividing header">Behavior</h2>
  238. <div class="no example">
  239. <h4 class="ui header">Attach events</h4>
  240. <p>A modal can attach events to another element</p>
  241. <div class="code" data-demo="true">
  242. $('.test.modal')
  243. .modal('attach events', '.test.button', 'show')
  244. ;
  245. </div>
  246. <div class="ui primary test button">Launch modal</div>
  247. </div>
  248. <div class="no example">
  249. <h4 class="ui header">Show</h4>
  250. <p>A modal can show itself</p>
  251. <div class="code" data-demo="true">
  252. $('.test.modal')
  253. .modal('show')
  254. ;
  255. </div>
  256. </div>
  257. <div class="no example">
  258. <h4 class="ui header">Hide</h4>
  259. <p>A modal can hide itself</p>
  260. <div class="code">
  261. $('.test.modal')
  262. .modal('hide')
  263. ;
  264. </div>
  265. </div>
  266. <div class="no example">
  267. <h4 class="ui header">Toggle</h4>
  268. <p>A modal can toggle its visibility</p>
  269. <div class="code" data-demo="true">
  270. $('.test.modal')
  271. .modal('toggle')
  272. ;
  273. </div>
  274. </div>
  275. Additionally, all the following behaviors can be called using the syntax <code>$('.foo').modal('behavior name', argumentOne, argumentTwo)</code>
  276. <table class="ui definition celled table segment">
  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. </table>
  310. <h2 class="ui dividing header">Settings</h2>
  311. <h4 class="ui header">Modal Settings</h4>
  312. <p>Modal settings modify the modal's behavior</p>
  313. <table class="ui red celled definition table segment">
  314. <thead>
  315. <th>Setting</th>
  316. <th class="four wide">Default</th>
  317. <th>Description</th>
  318. </thead>
  319. <tbody>
  320. <tr>
  321. <td>offset</td>
  322. <td>0</td>
  323. <td>A vertical offset to allow for content outside of modal, for example a close button, to be centered.</td>
  324. </tr>
  325. <tr>
  326. <td>context</td>
  327. <td>
  328. body
  329. </td>
  330. <td>Selector or jquery object specifying the area to dim</td>
  331. </tr>
  332. <tr>
  333. <td>closable</td>
  334. <td>
  335. true
  336. </td>
  337. <td>Settings to false will not allow you to close the modal by clicking on the dimmer</td>
  338. </tr>
  339. <tr>
  340. <td>transition</td>
  341. <td>
  342. scale
  343. </td>
  344. <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>
  345. </tr>
  346. <tr>
  347. <td>duration</td>
  348. <td>
  349. 400
  350. </td>
  351. <td>Duration of animation</td>
  352. </tr>
  353. <tr>
  354. <td>easing</td>
  355. <td>
  356. easeOutExpo
  357. </td>
  358. <td>Animation easing is only used if javascript animations are used.</td>
  359. </tr>
  360. </tbody>
  361. </table>
  362. <div class="ui horizontal section icon divider"><i class="icon setting"></i></div>
  363. <h4 class="ui header">Callbacks</h4>
  364. <p>Callback settings specify a function to occur after a specific behavior.</p>
  365. <table class="ui green celled definition table segment">
  366. <thead>
  367. <th class="four wide">Setting</th>
  368. <th>Context</th>
  369. <th>Description</th>
  370. </thead>
  371. <tbody>
  372. <tr>
  373. <td>onShow</td>
  374. <td>Modal</td>
  375. <td>Is called after a modal is shown.</td>
  376. </tr>
  377. <tr>
  378. <td>onHide</td>
  379. <td>Modal</td>
  380. <td>Is called after a modal is hidden.</td>
  381. </tr>
  382. <tr>
  383. <td>onApprove</td>
  384. <td>Modal</td>
  385. <td>Is called after a positive or approve button is pressed</td>
  386. </tr>
  387. <tr>
  388. <td>onDeny</td>
  389. <td>Modal</td>
  390. <td>Is called after a negative or cancel button is pressed.</td>
  391. </tr>
  392. </tbody>
  393. </table>
  394. <h4 class="ui header">DOM Settings</h4>
  395. <p>DOM settings specify how this module should interface with the DOM</p>
  396. <table class="ui purple celled definition table segment">
  397. <thead>
  398. <th>Setting</th>
  399. <th class="four wide">Default</th>
  400. <th>Description</th>
  401. </thead>
  402. <tbody>
  403. <tr>
  404. <td>namespace</td>
  405. <td>modal</td>
  406. <td>Event namespace. Makes sure module teardown does not effect other events attached to an element.</td>
  407. </tr>
  408. <tr>
  409. <td>selector</td>
  410. <td colspan="2">
  411. <div class="code">
  412. selector : {
  413. close : '.close, .actions .button',
  414. approve : '.actions .positive, .actions .approve',
  415. deny : '.actions .negative, .actions .cancel'
  416. },
  417. </div>
  418. </td>
  419. </tr>
  420. <tr>
  421. <td>className</td>
  422. <td colspan="2">
  423. <div class="code">
  424. className : {
  425. active : 'active',
  426. scrolling : 'scrolling'
  427. }
  428. </div>
  429. </td>
  430. </tr>
  431. </tbody>
  432. </table>
  433. <h4 class="ui header">Debug Settings</h4>
  434. <p>Debug settings controls debug output to the console</p>
  435. <table class="ui blue celled definition table segment">
  436. <thead>
  437. <th>Setting</th>
  438. <th class="four wide">Default</th>
  439. <th>Description</th>
  440. </thead>
  441. <tbody>
  442. <tr>
  443. <td>name</td>
  444. <td>Modal</td>
  445. <td>Name used in debug logs</td>
  446. </tr>
  447. <tr>
  448. <td>debug</td>
  449. <td>True</td>
  450. <td>Provides standard debug output to console</td>
  451. </tr>
  452. <tr>
  453. <td>performance</td>
  454. <td>True</td>
  455. <td>Provides standard debug output to console</td>
  456. </tr>
  457. <tr>
  458. <td>verbose</td>
  459. <td>True</td>
  460. <td>Provides ancillary debug output to console</td>
  461. </tr>
  462. <tr>
  463. <td>error</td>
  464. <td colspan="2">
  465. <div class="code">
  466. error : {
  467. method : 'The method you called is not defined.''
  468. }
  469. </div>
  470. </td>
  471. </tr>
  472. </tbody>
  473. </table>
  474. </div>
  475. </body>
  476. </html>