test-multiple-instances.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>reveal.js - Test Iframes</title>
  6. <link rel="stylesheet" href="../dist/reveal.css">
  7. <link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
  8. <script src="../node_modules/qunit/qunit/qunit.js"></script>
  9. </head>
  10. <body style="overflow: auto;">
  11. <div id="qunit"></div>
  12. <div id="qunit-fixture"></div>
  13. <div class="deck1">
  14. <div class="reveal" style="display: none;">
  15. <div class="slides">
  16. <section>1.1</section>
  17. <section data-state="deck1slide2">1.2</section>
  18. <section>1.3</section>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="deck2">
  23. <div class="reveal" style="display: none;">
  24. <div class="slides">
  25. <section>2.1</section>
  26. <section>2.2</section>
  27. <section>2.3</section>
  28. </div>
  29. </div>
  30. </div>
  31. <script type="module">
  32. import Reveal from '../dist/reveal.esm.js';
  33. import Zoom from '../plugin/zoom/zoom.esm.js';
  34. QUnit.module( 'Multiple reveal.js instances' );
  35. let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {
  36. embedded: true,
  37. keyboard: true,
  38. plugins: [ Zoom ]
  39. } );
  40. r1.initialize();
  41. let r2 = new Reveal( document.querySelector( '.deck2 .reveal' ), {
  42. embedded: true,
  43. keyboard: false
  44. } );
  45. r2.initialize();
  46. QUnit.test( 'Can make independent changes', function( assert ) {
  47. r1.slide(1);
  48. r2.slide(2);
  49. assert.strictEqual( r1.getCurrentSlide().textContent, '1.2' );
  50. assert.strictEqual( r2.getCurrentSlide().textContent, '2.3' );
  51. r2.toggleOverview( true );
  52. assert.strictEqual( r1.isOverview(), false );
  53. assert.strictEqual( r2.isOverview(), true );
  54. r2.toggleOverview( false );
  55. assert.strictEqual( r1.getConfig().keyboard, true );
  56. assert.strictEqual( r2.getConfig().keyboard, false );
  57. });
  58. QUnit.test( 'Can register plugins independently', function( assert ) {
  59. assert.ok( r1.hasPlugin( 'zoom' ) );
  60. assert.notOk( r2.hasPlugin( 'zoom' ) );
  61. });
  62. QUnit.test( 'Slide state is set at the viewport level', function( assert ) {
  63. r1.slide(1);
  64. assert.ok( r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ) );
  65. r1.slide(2);
  66. assert.ok( !r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ), 'unset' );
  67. });
  68. </script>
  69. <script>
  70. QUnit.test( 'Reveal does not leak to window', function( assert ) {
  71. assert.strictEqual( window.Reveal, undefined );
  72. });
  73. </script>
  74. </body>
  75. </html>