From 3aaca471b193cf2ff4bb54432e59798b6c688a43 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sun, 6 Apr 2014 10:09:25 +0200 Subject: stop tracking minified files #783 --- test/test.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/test.html') diff --git a/test/test.html b/test/test.html index 094f3c7..aa233c8 100644 --- a/test/test.html +++ b/test/test.html @@ -6,7 +6,7 @@ reveal.js - Tests - + @@ -72,7 +72,7 @@ - + -- cgit v1.2.3 From 3ad0d6adc026c620af1b2eaadabd2ce2c338e2f1 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Tue, 22 Apr 2014 15:58:21 +0200 Subject: tests for lazy loading --- test/test.html | 5 +++++ test/test.js | 12 ++++++++++++ 2 files changed, 17 insertions(+) (limited to 'test/test.html') diff --git a/test/test.html b/test/test.html index aa233c8..31c31dd 100644 --- a/test/test.html +++ b/test/test.html @@ -21,6 +21,11 @@

1

+ +
diff --git a/test/test.js b/test/test.js index 90a002a..367373e 100644 --- a/test/test.js +++ b/test/test.js @@ -449,6 +449,18 @@ Reveal.addEventListener( 'ready', function() { }); + // --------------------------------------------------------------- + // LAZY-LOADING TESTS + + QUnit.module( 'Lazy-Loading' ); + + test( 'img with data-src', function() { + strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' ); + + strictEqual( document.querySelectorAll( '.reveal section video source[src]' ).length, 2, 'Video sources have been set' ); + }); + + // --------------------------------------------------------------- // EVENT TESTS -- cgit v1.2.3 From 73f96f1d284bca6e01c36c888c2620b376c06598 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Tue, 22 Apr 2014 16:10:08 +0200 Subject: lazy-load support for audio #793 --- js/reveal.js | 14 +++++++------- test/test.html | 4 ---- test/test.js | 2 -- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'test/test.html') diff --git a/js/reveal.js b/js/reveal.js index e910682..42edf90 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2173,25 +2173,25 @@ var Reveal = (function(){ function loadSlide( slide ) { // Media elements with data-src attributes - toArray( slide.querySelectorAll( 'img[data-src], video[data-src]' ) ).forEach( function( element ) { + toArray( slide.querySelectorAll( 'img[data-src], video[data-src], audio[data-src]' ) ).forEach( function( element ) { element.setAttribute( 'src', element.getAttribute( 'data-src' ) ); element.removeAttribute( 'data-src' ); } ); - // Video elements with multiple s - toArray( slide.querySelectorAll( 'video' ) ).forEach( function( video ) { + // Media elements with multiple s + toArray( slide.querySelectorAll( 'video, audio' ) ).forEach( function( media ) { var sources = 0; - toArray( slide.querySelectorAll( 'source[data-src]' ) ).forEach( function( source ) { + toArray( media.querySelectorAll( 'source[data-src]' ) ).forEach( function( source ) { source.setAttribute( 'src', source.getAttribute( 'data-src' ) ); source.removeAttribute( 'data-src' ); sources += 1; } ); - // If we rewrote sources for this video, we need to manually - // tell it to load from its new origin + // If we rewrote sources for this video/audio element, we need + // to manually tell it to load from its new origin if( sources > 0 ) { - video.load(); + media.load(); } } ); diff --git a/test/test.html b/test/test.html index 31c31dd..edb1623 100644 --- a/test/test.html +++ b/test/test.html @@ -22,10 +22,6 @@

1

-
diff --git a/test/test.js b/test/test.js index 367373e..93a3d61 100644 --- a/test/test.js +++ b/test/test.js @@ -456,8 +456,6 @@ Reveal.addEventListener( 'ready', function() { test( 'img with data-src', function() { strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' ); - - strictEqual( document.querySelectorAll( '.reveal section video source[src]' ).length, 2, 'Video sources have been set' ); }); -- cgit v1.2.3 From 635e51f8f54ba519c7b865b7b4f62cb65a927d2f Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 28 Apr 2014 11:51:35 +0200 Subject: addition background image and getSlideBackground tests --- test/test.html | 4 ++-- test/test.js | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'test/test.html') diff --git a/test/test.html b/test/test.html index edb1623..29d02a9 100644 --- a/test/test.html +++ b/test/test.html @@ -19,13 +19,13 @@
-
+

1

-
+

2.1

diff --git a/test/test.js b/test/test.js index 3bc934f..c0c25fb 100644 --- a/test/test.js +++ b/test/test.js @@ -114,11 +114,13 @@ Reveal.addEventListener( 'ready', function() { }); test( 'Reveal.getSlideBackground', function() { - var firstBackground = document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ); + equal( Reveal.getSlideBackground( 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:first-child' ), 'gets correct first background' ); + equal( Reveal.getSlideBackground( 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2)' ), 'no v index returns stack' ); + equal( Reveal.getSlideBackground( 1, 0 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(1)' ), 'v index 0 returns first vertical child' ); + equal( Reveal.getSlideBackground( 1, 1 ), document.querySelector( '.reveal .backgrounds>.slide-background:nth-child(2) .slide-background:nth-child(2)' ), 'v index 1 returns second vertical child' ); - equal( Reveal.getSlideBackground( 0 ), firstBackground, 'gets correct first background' ); - - strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'returns undefined when background can\'t be found' ); + strictEqual( Reveal.getSlideBackground( 100 ), undefined, 'undefined when out of horizontal bounds' ); + strictEqual( Reveal.getSlideBackground( 1, 100 ), undefined, 'undefined when out of vertical bounds' ); }); test( 'Reveal.getPreviousSlide/getCurrentSlide', function() { @@ -470,6 +472,15 @@ Reveal.addEventListener( 'ready', function() { strictEqual( document.querySelectorAll( '.reveal section img[src]' ).length, 1, 'Image source has been set' ); }); + test( 'background images', function() { + var imageSource1 = Reveal.getSlide( 0 ).getAttribute( 'data-background-image' ); + var imageSource2 = Reveal.getSlide( 1, 0 ).getAttribute( 'data-background' ); + + // check that the images are applied to the background elements + ok( Reveal.getSlideBackground( 0 ).style.backgroundImage.indexOf( imageSource1 ) !== -1, 'data-background-image worked' ); + ok( Reveal.getSlideBackground( 1, 0 ).style.backgroundImage.indexOf( imageSource2 ) !== -1, 'data-background worked' ); + }); + // --------------------------------------------------------------- // EVENT TESTS -- cgit v1.2.3