Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

test-multiple-instances.html 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.config.testTimeout = 30000;
  35. QUnit.module( 'Multiple reveal.js instances' );
  36. let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {
  37. embedded: true,
  38. keyboard: true,
  39. plugins: [ Zoom ]
  40. } );
  41. r1.initialize();
  42. let r2 = new Reveal( document.querySelector( '.deck2 .reveal' ), {
  43. embedded: true,
  44. keyboard: false
  45. } );
  46. r2.initialize();
  47. QUnit.test( 'Can make independent changes', function( assert ) {
  48. r1.slide(1);
  49. r2.slide(2);
  50. assert.strictEqual( r1.getCurrentSlide().textContent, '1.2' );
  51. assert.strictEqual( r2.getCurrentSlide().textContent, '2.3' );
  52. r2.toggleOverview( true );
  53. assert.strictEqual( r1.isOverview(), false );
  54. assert.strictEqual( r2.isOverview(), true );
  55. r2.toggleOverview( false );
  56. assert.strictEqual( r1.getConfig().keyboard, true );
  57. assert.strictEqual( r2.getConfig().keyboard, false );
  58. });
  59. QUnit.test( 'Can register plugins independently', function( assert ) {
  60. assert.ok( r1.hasPlugin( 'zoom' ) );
  61. assert.notOk( r2.hasPlugin( 'zoom' ) );
  62. });
  63. QUnit.test( 'Slide state is set at the viewport level', function( assert ) {
  64. r1.slide(1);
  65. assert.ok( r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ) );
  66. r1.slide(2);
  67. assert.ok( !r1.getViewportElement().classList.contains( r1.getCurrentSlide().getAttribute( 'data-state' ) ), 'unset' );
  68. });
  69. </script>
  70. <script>
  71. QUnit.test( 'Reveal does not leak to window', function( assert ) {
  72. assert.strictEqual( window.Reveal, undefined );
  73. });
  74. </script>
  75. </body>
  76. </html>