Skip to content
Snippets Groups Projects
reveal.js 119 KiB
Newer Older
  • Learn to ignore specific revisions
  • olivierbloch's avatar
    olivierbloch committed
    			dom.wrapper.removeEventListener( 'pointerdown', onPointerDown, false );
    			dom.wrapper.removeEventListener( 'pointermove', onPointerMove, false );
    			dom.wrapper.removeEventListener( 'pointerup', onPointerUp, false );
    		}
    
    		// IE10
    		else if( window.navigator.msPointerEnabled ) {
    			dom.wrapper.removeEventListener( 'MSPointerDown', onPointerDown, false );
    			dom.wrapper.removeEventListener( 'MSPointerMove', onPointerMove, false );
    			dom.wrapper.removeEventListener( 'MSPointerUp', onPointerUp, false );
    		}
    
    		if ( config.progress && dom.progress ) {
    
    			dom.progress.removeEventListener( 'click', onProgressClicked, false );
    
    		[ 'touchstart', 'click' ].forEach( function( eventName ) {
    			dom.controlsLeft.forEach( function( el ) { el.removeEventListener( eventName, onNavigateLeftClicked, false ); } );
    			dom.controlsRight.forEach( function( el ) { el.removeEventListener( eventName, onNavigateRightClicked, false ); } );
    			dom.controlsUp.forEach( function( el ) { el.removeEventListener( eventName, onNavigateUpClicked, false ); } );
    			dom.controlsDown.forEach( function( el ) { el.removeEventListener( eventName, onNavigateDownClicked, false ); } );
    			dom.controlsPrev.forEach( function( el ) { el.removeEventListener( eventName, onNavigatePrevClicked, false ); } );
    			dom.controlsNext.forEach( function( el ) { el.removeEventListener( eventName, onNavigateNextClicked, false ); } );
    		} );
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	}
    
    	 * Extend object a with the properties of object b.
    
    	 * If there's a conflict, object b takes precedence.
    	 */
    	function extend( a, b ) {
    
    		for( var i in b ) {
    			a[ i ] = b[ i ];
    		}
    
    	/**
    	 * Converts the target object to an array.
    	 */
    	function toArray( o ) {
    
    	/**
    	 * Utility for deserializing a value.
    	 */
    	function deserialize( value ) {
    
    		if( typeof value === 'string' ) {
    			if( value === 'null' ) return null;
    			else if( value === 'true' ) return true;
    			else if( value === 'false' ) return false;
    			else if( value.match( /^\d+$/ ) ) return parseFloat( value );
    		}
    
    		return value;
    
    	}
    
    
    	/**
    	 * Measures the distance in pixels between point a
    
    	 * @param {Object} a point with x/y properties
    	 * @param {Object} b point with x/y properties
    	 */
    
    	function distanceBetween( a, b ) {
    
    		var dx = a.x - b.x,
    			dy = a.y - b.y;
    
    		return Math.sqrt( dx*dx + dy*dy );
    
    	/**
    	 * Applies a CSS transform to the target element.
    	 */
    	function transformElement( element, transform ) {
    
    		element.style.WebkitTransform = transform;
    		element.style.MozTransform = transform;
    		element.style.msTransform = transform;
    		element.style.transform = transform;
    
    	}
    
    
    	/**
    	 * Applies CSS transforms to the slides container. The container
    	 * is transformed from two separate sources: layout and the overview
    	 * mode.
    	 */
    	function transformSlides( transforms ) {
    
    		// Pick up new transforms from arguments
    
    		if( typeof transforms.layout === 'string' ) slidesTransform.layout = transforms.layout;
    		if( typeof transforms.overview === 'string' ) slidesTransform.overview = transforms.overview;
    
    
    		// Apply the transforms to the slides container
    		if( slidesTransform.layout ) {
    			transformElement( dom.slides, slidesTransform.layout + ' ' + slidesTransform.overview );
    		}
    		else {
    			transformElement( dom.slides, slidesTransform.overview );
    		}
    
    	/**
    	 * Injects the given CSS styles into the DOM.
    	 */
    	function injectStyleSheet( value ) {
    
    		var tag = document.createElement( 'style' );
    		tag.type = 'text/css';
    		if( tag.styleSheet ) {
    			tag.styleSheet.cssText = value;
    		}
    		else {
    			tag.appendChild( document.createTextNode( value ) );
    		}
    		document.getElementsByTagName( 'head' )[0].appendChild( tag );
    
    	}
    
    
    	/**
    	 * Measures the distance in pixels between point a and point b.
    	 *
    	 * @param {String} color The string representation of a color,
    	 * the following formats are supported:
    	 * - #000
    	 * - #000000
    	 * - rgb(0,0,0)
    	 */
    	function colorToRgb( color ) {
    
    		var hex3 = color.match( /^#([0-9a-f]{3})$/i );
    		if( hex3 && hex3[1] ) {
    			hex3 = hex3[1];
    			return {
    				r: parseInt( hex3.charAt( 0 ), 16 ) * 0x11,
    				g: parseInt( hex3.charAt( 1 ), 16 ) * 0x11,
    				b: parseInt( hex3.charAt( 2 ), 16 ) * 0x11
    			};
    		}
    
    		var hex6 = color.match( /^#([0-9a-f]{6})$/i );
    		if( hex6 && hex6[1] ) {
    			hex6 = hex6[1];
    			return {
    				r: parseInt( hex6.substr( 0, 2 ), 16 ),
    				g: parseInt( hex6.substr( 2, 2 ), 16 ),
    				b: parseInt( hex6.substr( 4, 2 ), 16 )
    			};
    		}
    
    		var rgb = color.match( /^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i );
    		if( rgb ) {
    			return {
    
    				r: parseInt( rgb[1], 10 ),
    				g: parseInt( rgb[2], 10 ),
    				b: parseInt( rgb[3], 10 )
    			};
    		}
    
    		var rgba = color.match( /^rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\,\s*([\d]+|[\d]*.[\d]+)\s*\)$/i );
    		if( rgba ) {
    			return {
    				r: parseInt( rgba[1], 10 ),
    				g: parseInt( rgba[2], 10 ),
    				b: parseInt( rgba[3], 10 ),
    				a: parseFloat( rgba[4] )
    
    			};
    		}
    
    		return null;
    
    	}
    
    	/**
    	 * Calculates brightness on a scale of 0-255.
    	 *
    	 * @param color See colorStringToRgb for supported formats.
    	 */
    	function colorBrightness( color ) {
    
    		if( typeof color === 'string' ) color = colorToRgb( color );
    
    
    		if( color ) {
    			return ( color.r * 299 + color.g * 587 + color.b * 114 ) / 1000;
    		}
    
    		return null;
    
    	/**
    	 * Retrieves the height of the given element by looking
    	 * at the position and height of its immediate children.
    	 */
    	function getAbsoluteHeight( element ) {
    
    		var height = 0;
    
    		if( element ) {
    			var absoluteChildren = 0;
    
    			toArray( element.childNodes ).forEach( function( child ) {
    
    				if( typeof child.offsetTop === 'number' && child.style ) {
    					// Count # of abs children
    
    					if( window.getComputedStyle( child ).position === 'absolute' ) {
    
    						absoluteChildren += 1;
    					}
    
    					height = Math.max( height, child.offsetTop + child.offsetHeight );
    				}
    
    			} );
    
    			// If there are no absolute children, use offsetHeight
    			if( absoluteChildren === 0 ) {
    				height = element.offsetHeight;
    			}
    
    		}
    
    		return height;
    
    	}
    
    
    	 * Returns the remaining height within the parent of the
    
    	 * target element.
    
    	 * remaining height = [ configured parent height ] - [ current parent height ]
    
    	function getRemainingHeight( element, height ) {
    
    			var newHeight, oldHeight = element.style.height;
    
    			// Change the .stretch element height to 0 in order find the height of all
    			// the other elements
    			element.style.height = '0px';
    			newHeight = height - element.parentNode.offsetHeight;
    
    			// Restore the old height, just in case
    			element.style.height = oldHeight + 'px';
    
    			return newHeight;
    
    	/**
    	 * Checks if this instance is being used to print a PDF.
    	 */
    	function isPrintingPDF() {
    
    		return ( /print-pdf/gi ).test( window.location.search );
    
    	}
    
    
    	/**
    	 * Hides the address bar if we're on a mobile device.
    	 */
    	function hideAddressBar() {
    
    
    		if( config.hideAddressBar && isMobileDevice ) {
    
    			// Events that should trigger the address bar to hide
    			window.addEventListener( 'load', removeAddressBar, false );
    			window.addEventListener( 'orientationchange', removeAddressBar, false );
    		}
    
    	}
    
    
    	 * Causes the address bar to hide on mobile devices,
    
    	 * more vertical space ftw.
    	 */
    	function removeAddressBar() {
    
    		setTimeout( function() {
    			window.scrollTo( 0, 1 );
    
    	 * Dispatches an event of the specified type from the
    
    	function dispatchEvent( type, args ) {
    
    		var event = document.createEvent( 'HTMLEvents', 1, 2 );
    
    		event.initEvent( type, true, true );
    
    		dom.wrapper.dispatchEvent( event );
    
    		// If we're in an iframe, post each reveal.js event to the
    		// parent window. Used by the notes plugin
    
    		if( config.postMessageEvents && window.parent !== window.self ) {
    			window.parent.postMessage( JSON.stringify({ namespace: 'reveal', eventName: type, state: getState() }), '*' );
    
    	/**
    	 * Wrap all links in 3D goodness.
    	 */
    	function enableRollingLinks() {
    
    
    		if( features.transforms3d && !( 'msPerspective' in document.body.style ) ) {
    
    			var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a' );
    
    
    			for( var i = 0, len = anchors.length; i < len; i++ ) {
    				var anchor = anchors[i];
    
    				if( anchor.textContent && !anchor.querySelector( '*' ) && ( !anchor.className || !anchor.classList.contains( anchor, 'roll' ) ) ) {
    					var span = document.createElement('span');
    					span.setAttribute('data-title', anchor.text);
    					span.innerHTML = anchor.innerHTML;
    
    					anchor.classList.add( 'roll' );
    					anchor.innerHTML = '';
    					anchor.appendChild(span);
    				}
    			}
    		}
    
    	}
    
    	/**
    	 * Unwrap all 3D links.
    	 */
    	function disableRollingLinks() {
    
    
    		var anchors = dom.wrapper.querySelectorAll( SLIDES_SELECTOR + ' a.roll' );
    
    
    		for( var i = 0, len = anchors.length; i < len; i++ ) {
    			var anchor = anchors[i];
    			var span = anchor.querySelector( 'span' );
    
    			if( span ) {
    				anchor.classList.remove( 'roll' );
    				anchor.innerHTML = span.innerHTML;
    			}
    		}
    
    	}
    
    
    	/**
    	 * Bind preview frame links.
    	 */
    	function enablePreviewLinks( selector ) {
    
    		var anchors = toArray( document.querySelectorAll( selector ? selector : 'a' ) );
    
    		anchors.forEach( function( element ) {
    			if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {
    				element.addEventListener( 'click', onPreviewLinkClicked, false );
    			}
    		} );
    
    	}
    
    	/**
    	 * Unbind preview frame links.
    	 */
    	function disablePreviewLinks() {
    
    		var anchors = toArray( document.querySelectorAll( 'a' ) );
    
    		anchors.forEach( function( element ) {
    			if( /^(http|www)/gi.test( element.getAttribute( 'href' ) ) ) {
    				element.removeEventListener( 'click', onPreviewLinkClicked, false );
    			}
    		} );
    
    	}
    
    	/**
    	 * Opens a preview window for the target URL.
    	 */
    
    	function showPreview( url ) {
    
    		dom.overlay = document.createElement( 'div' );
    		dom.overlay.classList.add( 'overlay' );
    		dom.overlay.classList.add( 'overlay-preview' );
    		dom.wrapper.appendChild( dom.overlay );
    
    		dom.overlay.innerHTML = [
    
    			'<header>',
    				'<a class="close" href="#"><span class="icon"></span></a>',
    				'<a class="external" href="'+ url +'" target="_blank"><span class="icon"></span></a>',
    			'</header>',
    			'<div class="spinner"></div>',
    			'<div class="viewport">',
    				'<iframe src="'+ url +'"></iframe>',
    			'</div>'
    		].join('');
    
    
    		dom.overlay.querySelector( 'iframe' ).addEventListener( 'load', function( event ) {
    			dom.overlay.classList.add( 'loaded' );
    
    		dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
    			closeOverlay();
    
    		dom.overlay.querySelector( '.external' ).addEventListener( 'click', function( event ) {
    			closeOverlay();
    
    			dom.overlay.classList.add( 'visible' );
    
    	 * Opens a overlay window with help material.
    
    	function showHelp() {
    
    		if( config.help ) {
    
    			dom.overlay = document.createElement( 'div' );
    			dom.overlay.classList.add( 'overlay' );
    			dom.overlay.classList.add( 'overlay-help' );
    			dom.wrapper.appendChild( dom.overlay );
    
    			var html = '<p class="title">Keyboard Shortcuts</p><br/>';
    
    			html += '<table><th>KEY</th><th>ACTION</th>';
    			for( var key in keyboardShortcuts ) {
    				html += '<tr><td>' + key + '</td><td>' + keyboardShortcuts[ key ] + '</td></tr>';
    			}
    
    			html += '</table>';
    
    			dom.overlay.innerHTML = [
    				'<header>',
    					'<a class="close" href="#"><span class="icon"></span></a>',
    				'</header>',
    				'<div class="viewport">',
    					'<div class="viewport-inner">'+ html +'</div>',
    				'</div>'
    			].join('');
    
    			dom.overlay.querySelector( '.close' ).addEventListener( 'click', function( event ) {
    				closeOverlay();
    				event.preventDefault();
    			}, false );
    
    			setTimeout( function() {
    				dom.overlay.classList.add( 'visible' );
    			}, 1 );
    
    		}
    
    	/**
    	 * Closes any currently open overlay.
    	 */
    	function closeOverlay() {
    
    		if( dom.overlay ) {
    			dom.overlay.parentNode.removeChild( dom.overlay );
    			dom.overlay = null;
    		}
    
    	}
    
    
    	/**
    	 * Applies JavaScript-controlled layout rules to the
    	 * presentation.
    	 */
    	function layout() {
    
    		if( dom.wrapper && !isPrintingPDF() ) {
    
    			var size = getComputedSlideSize();
    
    			var slidePadding = 20; // TODO Dig this out of DOM
    
    			// Layout the contents of the slides
    			layoutSlideContents( config.width, config.height, slidePadding );
    
    
    			dom.slides.style.width = size.width + 'px';
    			dom.slides.style.height = size.height + 'px';
    
    			// Determine scale of content to fit within available space
    			scale = Math.min( size.presentationWidth / size.width, size.presentationHeight / size.height );
    
    			// Respect max/min scale settings
    			scale = Math.max( scale, config.minScale );
    			scale = Math.min( scale, config.maxScale );
    
    			// Don't apply any scaling styles if scale is 1
    			if( scale === 1 ) {
    				dom.slides.style.zoom = '';
    				dom.slides.style.left = '';
    				dom.slides.style.top = '';
    				dom.slides.style.bottom = '';
    				dom.slides.style.right = '';
    
    				transformSlides( { layout: '' } );
    
    				// Prefer zooming in desktop Chrome so that content remains crisp
    				if( !isMobileDevice && /chrome/i.test( navigator.userAgent ) && typeof dom.slides.style.zoom !== 'undefined' ) {
    					dom.slides.style.zoom = scale;
    
    					transformSlides( { layout: '' } );
    
    				}
    				// Apply scale transform as a fallback
    				else {
    					dom.slides.style.left = '50%';
    					dom.slides.style.top = '50%';
    					dom.slides.style.bottom = 'auto';
    					dom.slides.style.right = 'auto';
    
    					transformSlides( { layout: 'translate(-50%, -50%) scale('+ scale +')' } );
    
    			// Select all slides, vertical and horizontal
    
    			var slides = toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) );
    
    			for( var i = 0, len = slides.length; i < len; i++ ) {
    				var slide = slides[ i ];
    
    				// Don't bother updating invisible slides
    				if( slide.style.display === 'none' ) {
    					continue;
    				}
    
    				if( config.center || slide.classList.contains( 'center' ) ) {
    
    					// Vertical stacks are not centred since their section
    
    					// children will be
    					if( slide.classList.contains( 'stack' ) ) {
    						slide.style.top = 0;
    					}
    					else {
    
    						slide.style.top = Math.max( ( ( size.height - getAbsoluteHeight( slide ) ) / 2 ) - slidePadding, 0 ) + 'px';
    
    			updateProgress();
    
    	/**
    	 * Applies layout logic to the contents of all slides in
    	 * the presentation.
    	 */
    	function layoutSlideContents( width, height, padding ) {
    
    
    		// Handle sizing of elements with the 'stretch' class
    		toArray( dom.slides.querySelectorAll( 'section > .stretch' ) ).forEach( function( element ) {
    
    
    			// Determine how much vertical space we can use
    
    			var remainingHeight = getRemainingHeight( element, height );
    
    
    			// Consider the aspect ratio of media elements
    			if( /(img|video)/gi.test( element.nodeName ) ) {
    
    				var nw = element.naturalWidth || element.videoWidth,
    					nh = element.naturalHeight || element.videoHeight;
    
    
    				var es = Math.min( width / nw, remainingHeight / nh );
    
    				element.style.width = ( nw * es ) + 'px';
    				element.style.height = ( nh * es ) + 'px';
    
    			}
    			else {
    				element.style.width = width + 'px';
    				element.style.height = remainingHeight + 'px';
    			}
    
    		} );
    
    	}
    
    
    	/**
    	 * Calculates the computed pixel size of our slides. These
    	 * values are based on the width and height configuration
    	 * options.
    	 */
    	function getComputedSlideSize( presentationWidth, presentationHeight ) {
    
    		var size = {
    			// Slide size
    			width: config.width,
    			height: config.height,
    
    			// Presentation size
    			presentationWidth: presentationWidth || dom.wrapper.offsetWidth,
    			presentationHeight: presentationHeight || dom.wrapper.offsetHeight
    		};
    
    		// Reduce available space by margin
    		size.presentationWidth -= ( size.presentationHeight * config.margin );
    		size.presentationHeight -= ( size.presentationHeight * config.margin );
    
    		// Slide width may be a percentage of available width
    		if( typeof size.width === 'string' && /%$/.test( size.width ) ) {
    			size.width = parseInt( size.width, 10 ) / 100 * size.presentationWidth;
    		}
    
    		// Slide height may be a percentage of available height
    		if( typeof size.height === 'string' && /%$/.test( size.height ) ) {
    			size.height = parseInt( size.height, 10 ) / 100 * size.presentationHeight;
    		}
    
    		return size;
    
    	}
    
    
    	 * Stores the vertical index of a stack so that the same
    	 * vertical slide can be selected when navigating to and
    
    	 * @param {HTMLElement} stack The vertical stack element
    	 * @param {int} v Index to memorize
    	 */
    	function setPreviousVerticalIndex( stack, v ) {
    
    		if( typeof stack === 'object' && typeof stack.setAttribute === 'function' ) {
    
    			stack.setAttribute( 'data-previous-indexv', v || 0 );
    		}
    
    	 * Retrieves the vertical index which was stored using
    
    	 * #setPreviousVerticalIndex() or 0 if no previous index
    	 * exists.
    	 *
    	 * @param {HTMLElement} stack The vertical stack element
    	 */
    	function getPreviousVerticalIndex( stack ) {
    
    		if( typeof stack === 'object' && typeof stack.setAttribute === 'function' && stack.classList.contains( 'stack' ) ) {
    
    			// Prefer manually defined start-indexv
    			var attributeName = stack.hasAttribute( 'data-start-indexv' ) ? 'data-start-indexv' : 'data-previous-indexv';
    
    			return parseInt( stack.getAttribute( attributeName ) || 0, 10 );
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	 * Displays the overview of slides (quick nav) by scaling
    	 * down and arranging all slide elements.
    
    	 */
    	function activateOverview() {
    
    		// Only proceed if enabled in config
    
    		if( config.overview && !isOverview() ) {
    
    			dom.wrapper.classList.add( 'overview' );
    
    			dom.wrapper.classList.remove( 'overview-deactivating' );
    
    hakimel's avatar
    hakimel committed
    
    
    			if( features.overviewTransitions ) {
    				setTimeout( function() {
    					dom.wrapper.classList.add( 'overview-animated' );
    				}, 1 );
    			}
    
    
    			// Don't auto-slide while in overview mode
    			cancelAutoSlide();
    
    
    			// Move the backgrounds element into the slide container to
    			// that the same scaling is applied
    			dom.slides.appendChild( dom.background );
    
    
    			// Clicking on an overview slide navigates to it
    			toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
    				if( !slide.classList.contains( 'stack' ) ) {
    					slide.addEventListener( 'click', onOverviewSlideClicked, true );
    
    			updateSlidesVisibility();
    
    			layoutOverview();
    
    			// Notify observers of the overview showing
    			dispatchEvent( 'overviewshown', {
    				'indexh': indexh,
    				'indexv': indexv,
    				'currentSlide': currentSlide
    			} );
    
    Hakim El Hattab's avatar
    Hakim El Hattab committed
    	 * Uses CSS transforms to position all slides in a grid for
    	 * display inside of the overview mode.
    
    	 */
    	function layoutOverview() {
    
    		var margin = 70;
    		var slideWidth = config.width + margin,
    			slideHeight = config.height + margin;
    
    		// Reverse in RTL mode
    		if( config.rtl ) {
    			slideWidth = -slideWidth;
    		}
    
    		// Layout slides
    		toArray( dom.wrapper.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) ).forEach( function( hslide, h ) {
    
    			hslide.setAttribute( 'data-index-h', h );
    
    			transformElement( hslide, 'translate3d(' + ( h * slideWidth ) + 'px, 0, 0)' );
    
    
    			if( hslide.classList.contains( 'stack' ) ) {
    
    				toArray( hslide.querySelectorAll( 'section' ) ).forEach( function( vslide, v ) {
    
    					vslide.setAttribute( 'data-index-h', h );
    					vslide.setAttribute( 'data-index-v', v );
    
    
    					transformElement( vslide, 'translate3d(0, ' + ( v * slideHeight ) + 'px, 0)' );
    
    				} );
    
    			}
    		} );
    
    		// Layout slide backgrounds
    		toArray( dom.background.childNodes ).forEach( function( hbackground, h ) {
    
    			transformElement( hbackground, 'translate3d(' + ( h * slideWidth ) + 'px, 0, 0)' );
    
    
    			toArray( hbackground.querySelectorAll( '.slide-background' ) ).forEach( function( vbackground, v ) {
    
    				transformElement( vbackground, 'translate3d(0, ' + ( v * slideHeight ) + 'px, 0)' );
    
    			} );
    		} );
    
    	}
    
    	/**
    	 * Moves the overview viewport to the current slides.
    	 * Called each time the current slide changes.
    	 */
    
    	function updateOverview() {
    
    		var margin = 70;
    		var slideWidth = config.width + margin,
    			slideHeight = config.height + margin;
    
    
    		// Reverse in RTL mode
    		if( config.rtl ) {
    			slideWidth = -slideWidth;
    		}
    
    
    		transformSlides( {
    			overview: [
    				'translateX('+ ( -indexh * slideWidth ) +'px)',
    				'translateY('+ ( -indexv * slideHeight ) +'px)',
    				'translateZ('+ ( window.innerWidth < 400 ? -1000 : -2500 ) +'px)'
    			].join( ' ' )
    		} );
    
    	/**
    	 * Exits the slide overview and enters the currently
    	 * active slide.
    	 */
    
    	function deactivateOverview() {
    
    		// Only proceed if enabled in config
    
    		if( config.overview ) {
    
    			dom.wrapper.classList.remove( 'overview' );
    
    			dom.wrapper.classList.remove( 'overview-animated' );
    
    
    Joel Brandt's avatar
    Joel Brandt committed
    			// Temporarily add a class so that transitions can do different things
    			// depending on whether they are exiting/entering overview, or just
    			// moving from slide to slide
    
    			dom.wrapper.classList.add( 'overview-deactivating' );
    
    hakimel's avatar
    hakimel committed
    
    
    			setTimeout( function () {
    
    				dom.wrapper.classList.remove( 'overview-deactivating' );
    			}, 1 );
    
    			// Move the background element back out
    			dom.wrapper.appendChild( dom.background );
    
    
    			// Clean up changes made to slides
    
    			toArray( dom.wrapper.querySelectorAll( SLIDES_SELECTOR ) ).forEach( function( slide ) {
    
    				transformElement( slide, '' );
    
    				slide.removeEventListener( 'click', onOverviewSlideClicked, true );
    			} );
    
    			// Clean up changes made to backgrounds
    			toArray( dom.background.querySelectorAll( '.slide-background' ) ).forEach( function( background ) {
    				transformElement( background, '' );
    			} );
    
    
    			transformSlides( { overview: '' } );
    
    
    			// Notify observers of the overview hiding
    			dispatchEvent( 'overviewhidden', {
    				'indexh': indexh,
    				'indexv': indexv,
    				'currentSlide': currentSlide
    			} );
    
    
    	 * @param {Boolean} override Optional flag which overrides the
    	 * toggle logic and forcibly sets the desired state. True means
    
    	 * overview is open, false means it's closed.
    	 */
    	function toggleOverview( override ) {
    
    		if( typeof override === 'boolean' ) {
    			override ? activateOverview() : deactivateOverview();
    		}
    		else {
    
    			isOverview() ? deactivateOverview() : activateOverview();
    
    	/**
    	 * Checks if the overview is currently active.
    
    	 * @return {Boolean} true if the overview is active,
    	 * false otherwise
    	 */
    
    	/**
    	 * Checks if the current or specified slide is vertical
    	 * (nested within another slide).
    	 *
    	 * @param {HTMLElement} slide [optional] The slide to check
    	 * orientation of
    	 */
    	function isVerticalSlide( slide ) {
    
    		// Prefer slide argument, otherwise use current slide
    		slide = slide ? slide : currentSlide;
    
    
    		return slide && slide.parentNode && !!slide.parentNode.nodeName.match( /section/i );
    
    	/**
    	 * Handling the fullscreen functionality via the fullscreen API
    
    	 *
    	 * @see http://fullscreen.spec.whatwg.org/
    	 * @see https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
    
    	 */
    	function enterFullscreen() {
    
    		var element = document.body;
    
    		// Check which implementation is available
    		var requestMethod = element.requestFullScreen ||
    
    							element.webkitRequestFullScreen ||
    							element.mozRequestFullScreen ||
    
    							element.msRequestFullscreen;
    
    		if( requestMethod ) {
    			requestMethod.apply( element );
    		}
    
    	 * Enters the paused mode which fades everything on screen to
    
    		if( config.pause ) {
    			var wasPaused = dom.wrapper.classList.contains( 'paused' );
    
    			cancelAutoSlide();
    			dom.wrapper.classList.add( 'paused' );
    
    			if( wasPaused === false ) {
    				dispatchEvent( 'paused' );
    			}
    
    		var wasPaused = dom.wrapper.classList.contains( 'paused' );
    
    		dom.wrapper.classList.remove( 'paused' );
    
    		if( wasPaused ) {
    			dispatchEvent( 'resumed' );
    		}
    
    
    		if( typeof override === 'boolean' ) {
    			override ? pause() : resume();
    
    	}
    
    	/**
    	 * Checks if we are currently in the paused mode.
    	 */
    	function isPaused() {
    
    		return dom.wrapper.classList.contains( 'paused' );
    
    	/**
    	 * Toggles the auto slide mode on and off.
    	 *
    
    	 * @param {Boolean} override Optional flag which sets the desired state.
    
    	 * True means autoplay starts, false means it stops.
    	 */
    
    	function toggleAutoSlide( override ) {
    
    		if( typeof override === 'boolean' ) {
    			override ? resumeAutoSlide() : pauseAutoSlide();
    		}
    
    		else {
    			autoSlidePaused ? resumeAutoSlide() : pauseAutoSlide();
    		}
    
    	}
    
    	/**
    	 * Checks if the auto slide mode is currently on.
    	 */