aboutsummaryrefslogtreecommitdiff
path: root/js/reveal.js
diff options
context:
space:
mode:
authorHakim El Hattab <hakim@squarespace.com>2013-06-04 19:42:33 +0200
committerHakim El Hattab <hakim@squarespace.com>2013-06-04 19:42:33 +0200
commitf3f5d7780afda0e419a55e16cda522321b0e2c3e (patch)
tree6f4d31fab2747f978495ba3077555606b1fdd07e /js/reveal.js
parentb67889049af3f5e66f2a8bfc5c7f9dea85b10932 (diff)
downloadfosdem-2018-presentation-f3f5d7780afda0e419a55e16cda522321b0e2c3e.tar
fosdem-2018-presentation-f3f5d7780afda0e419a55e16cda522321b0e2c3e.tar.gz
started the new per-slide background implementation (#453)
Diffstat (limited to 'js/reveal.js')
-rw-r--r--js/reveal.js87
1 files changed, 83 insertions, 4 deletions
diff --git a/js/reveal.js b/js/reveal.js
index 4ff34c9..7d8020f 100644
--- a/js/reveal.js
+++ b/js/reveal.js
@@ -186,6 +186,13 @@ var Reveal = (function(){
dom.wrapper = document.querySelector( '.reveal' );
dom.slides = document.querySelector( '.reveal .slides' );
+ // Background element
+ if( !document.querySelector( '.reveal .background' ) ) {
+ dom.background = document.createElement( 'div' );
+ dom.background.classList.add( 'background' );
+ dom.wrapper.appendChild( dom.background );
+ }
+
// Progress bar
if( !dom.wrapper.querySelector( '.progress' ) ) {
var progressElement = document.createElement( 'div' );
@@ -205,11 +212,11 @@ var Reveal = (function(){
dom.wrapper.appendChild( controlsElement );
}
- // Presentation background element
+ // State background element [DEPRECATED]
if( !dom.wrapper.querySelector( '.state-background' ) ) {
- var backgroundElement = document.createElement( 'div' );
- backgroundElement.classList.add( 'state-background' );
- dom.wrapper.appendChild( backgroundElement );
+ var stateBackgroundElement = document.createElement( 'div' );
+ stateBackgroundElement.classList.add( 'state-background' );
+ dom.wrapper.appendChild( stateBackgroundElement );
}
// Overlay graphic which is displayed during the paused mode
@@ -238,6 +245,54 @@ var Reveal = (function(){
}
/**
+ * Creates the slide background elements and appends them
+ * to the background container.
+ */
+ function createBackgrounds() {
+
+ // Clear prior backgrounds
+ dom.background.innerHTML = '';
+
+ // Helper method for creating a background element for the
+ // given slide
+ function _createBackground( slide, container ) {
+
+ var background = slide.getAttribute( 'data-background' );
+ var element = document.createElement( 'div' );
+
+ if( background ) {
+ // Auto-wrap image urls in url(...)
+ if( /\.(png|jpg|jpeg|gif|bmp|)$/gi.test( background ) ) {
+ element.style.backgroundImage = 'url('+ background +')';
+ }
+ else {
+ element.style.background = background;
+ }
+ }
+
+ container.appendChild( element );
+
+ return element;
+
+ }
+
+ // Iterate over all horizontal slides
+ toArray( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( slideh ) {
+
+ var backgroundStack = _createBackground( slideh, dom.background );
+
+ // Iterate over all vertical slides
+ toArray( slideh.querySelectorAll( 'section' ) ).forEach( function( slidev ) {
+
+ _createBackground( slidev, backgroundStack );
+
+ } );
+
+ } );
+
+ }
+
+ /**
* Hides the address bar if we're on a mobile device.
*/
function hideAddressBar() {
@@ -1173,6 +1228,7 @@ var Reveal = (function(){
updateControls();
updateProgress();
+ updateBackground();
}
@@ -1196,8 +1252,12 @@ var Reveal = (function(){
// Start auto-sliding if it's enabled
cueAutoSlide();
+ // Re-create the slide backgrounds
+ createBackgrounds();
+
updateControls();
updateProgress();
+ updateBackground();
}
@@ -1403,6 +1463,25 @@ var Reveal = (function(){
}
/**
+ *
+ */
+ function updateBackground() {
+
+ toArray( dom.background.childNodes ).forEach( function( backgroundh, h ) {
+
+ backgroundh.className = ( h < indexh ? 'past' : h > indexh ? 'future' : 'present' );
+
+ toArray( backgroundh.childNodes ).forEach( function( backgroundv, v ) {
+
+ backgroundv.className = ( v < indexv ? 'past' : v > indexv ? 'future' : 'present' );
+
+ } );
+
+ } );
+
+ }
+
+ /**
* Determine what available routes there are for navigation.
*
* @return {Object} containing four booleans: left/right/up/down