From 860580d4d0d10646b59a9b3663c0c1cc504bc1c2 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sun, 27 Apr 2014 17:31:50 +0200 Subject: [PATCH] getSlideBackground now works in pdf mode, add pdf tests --- css/print/pdf.css | 1 + js/reveal.js | 11 ++++-- test/test-pdf.html | 83 ++++++++++++++++++++++++++++++++++++++++++++++ test/test-pdf.js | 15 +++++++++ 4 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 test/test-pdf.html create mode 100644 test/test-pdf.js diff --git a/css/print/pdf.css b/css/print/pdf.css index bc09a70..e43d05c 100644 --- a/css/print/pdf.css +++ b/css/print/pdf.css @@ -152,6 +152,7 @@ ul, ol, div, p { /* Slide backgrounds are placed inside of their slide when exporting to PDF */ .reveal section .slide-background { + display: block !important; position: absolute; top: 0; left: 0; diff --git a/js/reveal.js b/js/reveal.js index a4dba10..d1f2fb0 100644 --- a/js/reveal.js +++ b/js/reveal.js @@ -2693,11 +2693,18 @@ var Reveal = (function(){ /** * Returns the background element for the given slide. * All slides, even the ones with no background properties - * defined, have a background element so this never returns - * null. + * defined, have a background element so as long as the + * index is valid an element will be returned. */ function getSlideBackground( x, y ) { + // When printing to PDF the slide backgrounds are nested + // inside of the slides + if( isPrintingPDF() ) { + var slide = getSlide( x, y ); + return slide ? slide.querySelector( '.slide-background' ) : undefined; + } + var horizontalBackground = document.querySelectorAll( '.backgrounds>.slide-background' )[ x ]; var verticalBackgrounds = horizontalBackground && horizontalBackground.querySelectorAll( '.slide-background' ); diff --git a/test/test-pdf.html b/test/test-pdf.html new file mode 100644 index 0000000..751ed26 --- /dev/null +++ b/test/test-pdf.html @@ -0,0 +1,83 @@ + + + + + + + reveal.js - Test PDF exports + + + + + + + + +
+
+ + + + + + + + + + + diff --git a/test/test-pdf.js b/test/test-pdf.js new file mode 100644 index 0000000..8ec34fd --- /dev/null +++ b/test/test-pdf.js @@ -0,0 +1,15 @@ + +Reveal.addEventListener( 'ready', function() { + + // Only one test for now, we're mainly ensuring that there + // are no execution errors when running PDF mode + + test( 'Reveal.isReady', function() { + strictEqual( Reveal.isReady(), true, 'returns true' ); + }); + + +} ); + +Reveal.initialize({ pdf: true }); +