test-multiple-instances-es5.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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>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 src="../dist/reveal.js"></script>
  32. <script src="../plugin/zoom/zoom.js"></script>
  33. <script>
  34. QUnit.module( 'Multiple reveal.js instances' );
  35. let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {
  36. embedded: true,
  37. keyboard: true,
  38. plugins: [RevealZoom()]
  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. </script>
  63. </body>
  64. </html>