Modal Samples - InkJS

Open the modal on page load

  1. <div class="ink-shade fade">
  2. <div id="displayOnStart" class="ink-modal fade" data-width="80%" data-height="60%" role="dialog" aria-hidden="true" aria-labelled-by="modal-title">
  3. <div class="modal-header">
  4. <button class="modal-close ink-dismiss"></button>
  5. <h5 id="modal-title">This Modal is dislayed as soon as the page is fully available</h5>
  6. </div>
  7. <div class="modal-body">
  8. <h3>Please confirm your previous choice</h3>
  9. <p>"No," said Peleg, "and he hasn't been baptized right either, or it would have washed some of that devil's blue off his face."</p>
  10. <p>
  11. <img src="http://placehold.it/800x400" style="width: 100%;" alt="">
  12. </p>
  13. <p>"Do tell, now," cried Bildad, "is this Philistine a regular member of Deacon Deuteronomy's meeting? I never saw him going there, and I pass it every Lord's day."</p>
  14. <p>"I don't know anything about Deacon Deuteronomy or his meeting," said I; "all I know is, that Queequeg here is a born member of the First Congregational Church. He is a deacon himself, Queequeg is."</p>
  15. </div>
  16. <div class="modal-footer">
  17. <div class="push-right">
  18. <button class="ink-button blue">Confirm</button>
  19. <button class="ink-button red ink-dismiss">Cancel</button>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24.  
  25. <script type="text/javascript">
  26. // Unnecessary with autoload.js
  27. Ink.requireModules(['Ink.UI.Modal_1'],function(Modal){
  28. var myFirstModal = new Modal('#displayOnStart');
  29. });
  30. </script>

A modal and a button to trigger it

  1. <div class="ink-shade fade">
  2. <div id="displayOnBtnClick" class="ink-modal fade" data-trigger="#myTrigger" data-width="800px" data-height="400px" role="dialog" aria-hidden="true" aria-labelled-by="modal-title">
  3. <div class="modal-header">
  4. <button class="modal-close ink-dismiss"></button>
  5. <h5 id="modal-title">This is a different modal</h5>
  6. </div>
  7. <div class="modal-body">
  8. Different!!! Opened by a button and filled dynamically!
  9. </div>
  10. </div>
  11. </div>
  12. <script type="text/javascript">
  13. Ink.requireModules(['Ink.UI.Modal_1'], function(Modal){
  14. var mySecondModal = new Modal('#displayOnBtnClick');
  15. });
  16. </script>

Construct a modal with HTML through JavaScript

  1. <script type="text/javascript">
  2. Ink.requireModules(['Ink.Dom.Event_1','Ink.UI.Modal_1'],function(InkEvent,Modal){
  3. var mySecondModal = new Modal('#displayOnBtnClick');
  4.  
  5. InkEvent.observe( Ink.s('#codeTrigger'), 'click', function( event ){
  6. InkEvent.stopDefault(event);
  7.  
  8. var myThirdModal = new Modal(null,{
  9. width: '600px',
  10. height: '400px',
  11. shadeClass: 'myShadeClass myOtherShadeClass',
  12. modalClass: 'myModalClass myOtherModalClass',
  13. markup: '<div class="modal-header"><button class="modal-close ink-dismiss"></button></div><div class="modal-body">Stuff</div>'
  14. });
  15. });
  16. });
  17. </script>

Open a modal manually through JavaScript

  1. <div class="ink-shade fade">
  2. <div id="displayLater" class="ink-modal fade" data-width="800px" data-height="400px" role="dialog" aria-hidden="true" aria-labelled-by="modal-title">
  3. <div class="modal-header">
  4. <button class="modal-close ink-dismiss"></button>
  5. <h5 id="modal-title">Created after constructing the <code>Modal</code> object</h5>
  6. </div>
  7. <div class="modal-body">
  8. <p>Opened using the <code>open()</code> method. Add the <code>autoDisplay:false</code> option to avoid opening when the page loads.</p>
  9. </div>
  10. </div>
  11. </div>
  12. <script type="text/javascript">
  13. Ink.requireModules(['Ink.UI.Modal_1', 'Ink.Dom.Event_1'], function (Modal, InkEvent) {
  14. var openLater = new Modal('#displayLater', { autoDisplay: false });
  15.  
  16. InkEvent.observe( Ink.s('#openDisplayLaterModal'), 'click', function ( event ) {
  17. // Opening the modal when we damn well please
  18. setTimeout(function () {
  19. openLater.open();
  20. }, 1000);
  21. });
  22. });
  23. </script>

Stuff you can put in your modal

  1. <div class="ink-shade fade">
  2. <div id="modalWithStuff" class="ink-modal fade" data-width="80%" data-height="80%" data-trigger="#openModalWithStuffs" role="dialog" aria-hidden="true" aria-labelled-by="modal-title">
  3. <div class="modal-header">
  4. <button class="modal-close ink-dismiss"></button>
  5. <h5 id="modal-title>This Modal is dislayed as soon as the page is fully available</h5>
  6. </div>
  7. <div class="modal-body">
  8. <h1>A tooltip</h1>
  9.  
  10. <span class="ink-tooltip" data-tip-text="A tooltip!!!!1">A tooltip!</span>
  11.  
  12. <hr>
  13.  
  14. <h1>A video</h1>
  15. <iframe src="http://rd3.videos.sapo.pt/playhtml?file=http://rd3.videos.sapo.pt/hhl0qEyhOad0aNrZYGvQ/mov/1&quality=sd" frameborder="0" scrolling="no" width="640" height="360"></iframe>
  16. <hr>
  17.  
  18. <h1>A datepicker</h1>
  19.  
  20. <input class="ink-datepicker" type="text">
  21.  
  22. <hr>
  23. </div>
  24. <div class="modal-footer">
  25. <div class="push-right">
  26. <button class="ink-button blue">Confirm</button>
  27. <button class="ink-button red ink-dismiss">Cancel</button>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32.  
  33. <button id="openModalWithStuffs">Open Modal</button>
  34.  
  35. <script>
  36. Ink.requireModules(['Ink.UI.Modal_1'], function (Modal) {
  37. new Modal('#modalWithStuff');
  38. });
  39. </script>