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

     1  <!doctype html>
     2  <html lang="en">
     3  
     4  	<head>
     5  		<meta charset="utf-8">
     6  
     7  		<title>reveal.js - Test Iframe Backgrounds</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 data-background-iframe="#1">1</section>
    23  				<section data-background-iframe="#2">2</section>
    24  				<section data-background-iframe="#3" data-preload>3</section>
    25  				<section data-background-iframe="#4">4</section>
    26  				<section data-background-iframe="#5">5</section>
    27  				<section data-background-iframe="#6">6</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  				function getIframe( index ) {
    42  					return document.querySelectorAll( '.slide-background' )[index].querySelector( 'iframe' );
    43  				}
    44  
    45  				QUnit.module( 'Iframe' );
    46  
    47  				QUnit.test( 'Using default settings', function( assert ) {
    48  
    49  					Reveal.slide(0);
    50  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'not preloaded when within viewDistance' );
    51  
    52  					Reveal.slide(1);
    53  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    54  
    55  					Reveal.slide(0);
    56  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'unloaded when slide becomes invisible' );
    57  
    58  				});
    59  
    60  				QUnit.test( 'Using data-preload', function( assert ) {
    61  
    62  					Reveal.slide(1);
    63  					assert.strictEqual( getIframe(2).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    64  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    65  
    66  					Reveal.slide(0);
    67  					assert.strictEqual( getIframe(3).hasAttribute( 'src' ), false, 'unloads outside of viewDistance' );
    68  
    69  				});
    70  
    71  				QUnit.test( 'Using preloadIframes: true', function( assert ) {
    72  
    73  					Reveal.configure({ preloadIframes: true });
    74  
    75  					Reveal.slide(1);
    76  					assert.strictEqual( getIframe(0).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    77  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    78  					assert.strictEqual( getIframe(2).hasAttribute( 'src' ), true, 'preloaded within viewDistance' );
    79  
    80  				});
    81  
    82  				QUnit.test( 'Using preloadIframes: false', function( assert ) {
    83  
    84  					Reveal.configure({ preloadIframes: false });
    85  
    86  					Reveal.slide(0);
    87  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
    88  					assert.strictEqual( getIframe(2).hasAttribute( 'src' ), false, 'not preloaded within viewDistance' );
    89  
    90  					Reveal.slide(1);
    91  					assert.strictEqual( getIframe(1).hasAttribute( 'src' ), true, 'loaded when slide becomes visible' );
    92  
    93  
    94  				});
    95  
    96  			} );
    97  
    98  			Reveal.initialize({
    99  				viewDistance: 3
   100  			});
   101  		</script>
   102  
   103  	</body>
   104  </html>