返回 reveal.js
test-multiple-instances-es5.html
根目录 / test / test-multiple-instances-es5.html
1 <!doctype html>
2 <html lang="en">
3
4 <head>
5 <meta charset="utf-8">
6
7 <title>reveal.js - Test Iframes</title>
8 </head>
9
10 <body style="overflow: auto;">
11
12 <div id="qunit"></div>
13 <div id="qunit-fixture"></div>
14
15 <div class="deck1">
16 <div class="reveal" style="display: none;">
17 <div class="slides">
18 <section>1.1</section>
19 <section>1.2</section>
20 <section>1.3</section>
21 </div>
22 </div>
23 </div>
24
25 <div class="deck2">
26 <div class="reveal" style="display: none;">
27 <div class="slides">
28 <section>2.1</section>
29 <section>2.2</section>
30 <section>2.3</section>
31 </div>
32 </div>
33 </div>
34
35 <script type="module">
36 import 'reveal.css';
37 import 'qunit/qunit/qunit.css';
38 import QUnit from 'qunit';
39 import Reveal from 'reveal.js';
40 import RevealZoom from 'reveal.js/plugin/zoom';
41
42 QUnit.config.testTimeout = 30000;
43 QUnit.module( 'Multiple reveal.js instances' );
44
45 let r1 = new Reveal( document.querySelector( '.deck1 .reveal' ), {
46 embedded: true,
47 keyboard: true,
48 plugins: [RevealZoom()]
49 } );
50 r1.initialize();
51
52 let r2 = new Reveal( document.querySelector( '.deck2 .reveal' ), {
53 embedded: true,
54 keyboard: false
55 } );
56 r2.initialize();
57
58 QUnit.test( 'Can make independent changes', function( assert ) {
59
60 r1.slide(1);
61 r2.slide(2);
62 assert.strictEqual( r1.getCurrentSlide().textContent, '1.2' );
63 assert.strictEqual( r2.getCurrentSlide().textContent, '2.3' );
64
65 r2.toggleOverview( true );
66 assert.strictEqual( r1.isOverview(), false );
67 assert.strictEqual( r2.isOverview(), true );
68 r2.toggleOverview( false );
69
70 assert.strictEqual( r1.getConfig().keyboard, true );
71 assert.strictEqual( r2.getConfig().keyboard, false );
72
73 });
74
75 QUnit.test( 'Can register plugins independently', function( assert ) {
76
77 assert.ok( r1.hasPlugin( 'zoom' ) );
78 assert.notOk( r2.hasPlugin( 'zoom' ) );
79
80 });
81
82 </script>
83
84 </body>
85 </html>
86
86 lines HTML