github.com/mweagle/Sparta@v1.15.0/docs_source/static/presentations/reveal.js-3.9.2/test/test-iframes.html (about)

     1  <!doctype html>
     2  <html lang="en">
     3  
     4  	<head>
     5  		<meta charset="utf-8">
     6  
     7  		<title>reveal.js - Test Iframes</title>
     8  
     9  		<link rel="stylesheet" href="../css/reveal.css">
    10  		<link rel="stylesheet" href="qunit-2.5.0.css">
    11  	</head>
    12  
    13  	<body style="overflow: auto;">
    14  
    15  		<div id="qunit"></div>
    16  		<div id="qunit-fixture"></div>
    17  
    18  		<div class="reveal" style="display: none;">
    19  
    20  			<div class="slides">
    21  
    22  				<section>1</section>
    23  				<section>2</section>
    24  				<section>
    25  					<iframe class="default-iframe" data-src="#"></iframe>
    26  					<iframe class="preload-iframe" data-src="#" data-preload></iframe>
    27  				</section>
    28  
    29  			</div>
    30  
    31  		</div>
    32  
    33  		<script src="../js/reveal.js"></script>
    34  		<script src="qunit-2.5.0.js"></script>
    35  
    36  		<script>
    37  
    38  
    39  			Reveal.addEventListener( 'ready', function() {
    40  
    41  				var defaultIframe = document.querySelector( '.default-iframe' ),
    42  					preloadIframe = document.querySelector( '.preload-iframe' );
    43  
    44  				QUnit.module( 'Iframe' );
    45  
    46  				QUnit.test( 'Using default settings', function( assert ) {
    47  
    48  					Reveal.slide(1);
    49  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' );
    50  
    51  					Reveal.slide(2);
    52  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    53  
    54  					Reveal.slide(1);
    55  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' );
    56  
    57  				});
    58  
    59  				QUnit.test( 'Using data-preload', function( assert ) {
    60  
    61  					Reveal.slide(1);
    62  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    63  
    64  					Reveal.slide(2);
    65  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becoems visible' );
    66  
    67  					Reveal.slide(0);
    68  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'unloads outside of viewDistance' );
    69  
    70  				});
    71  
    72  				QUnit.test( 'Using preloadIframes: true', function( assert ) {
    73  
    74  					Reveal.configure({ preloadIframes: true });
    75  
    76  					Reveal.slide(1);
    77  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    78  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    79  
    80  					Reveal.slide(2);
    81  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    82  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    83  
    84  				});
    85  
    86  				QUnit.test( 'Using preloadIframes: false', function( assert ) {
    87  
    88  					Reveal.configure({ preloadIframes: false });
    89  
    90  					Reveal.slide(0);
    91  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
    92  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
    93  
    94  					Reveal.slide(2);
    95  					assert.strictEqual( defaultIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    96  					assert.strictEqual( preloadIframe.hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    97  
    98  				});
    99  
   100  			} );
   101  
   102  			Reveal.initialize({
   103  				viewDistance: 2
   104  			});
   105  		</script>
   106  
   107  	</body>
   108  </html>